VS 2008 - What Is Different From A Delegate To A Pointer
Feb 2, 2010
I have been looking into delegates today, have come across them a few times but haven't understood them. I started thinking today that a Delegate is like a Pointer (for those who don't know a pointer is a reference to a location used in C++ and other languages than VB) So how much of a pointer is a delegate? what can a delegate do that a pointer/pointers cant?
Similarly does anyone else agree with me that all .NET languages should be able to do the same things, why cant i use pointers or logical shift operators in VB.NET? Would you guys think that being able to use code from any .net language within your code would be advantageous?
View 16 Replies
ADVERTISEMENT
Jul 15, 2010
I have an open source project I converted to vb.net. I solved all the errors, except for one. This is the C# line
[Code]....
View 4 Replies
Jan 30, 2010
from the documentation we have this: Multicast Delegate: Represents a multicast delegate; that is, a delegate that can have more than one element in its invocation list.
so am i right to say that Multicast delegate is no different from a normal delegate other than the fact that it has arguments. so System.Action is a 'normal' delegate whereas System.Action(T)(Byval obj as T) is a multicast delegate?
View 5 Replies
Feb 9, 2010
I've created a Delegate that I intend to call Async.
[Code]...
View 2 Replies
Jun 1, 2010
Code:
Public Class SendPings
Shared Sub New()
AddHandler Post.Saved, AddressOf Post_Saved[code].....
I get a error" Method 'Private Shared Sub Ping(item As BlogEngine.Core.IPublishable, itemUrl As System.Uri)' does not have a signature compatible with delegate 'Delegate Sub WaitCallback(state As Object)'.
View 4 Replies
Aug 28, 2010
I'm calling an API that returns a string pointer but I can't find anyway to return the string it points to.
Is it possible in VB.Net, I see VB6 had a STRPTR function but I can see a .net alternative.
View 3 Replies
Feb 3, 2009
I have just started to try to duplicate what I have done in Autohotkeys language.
What I need to do is point to a string variable - I will explain.
I'm reading from my own asci font files that contain big letters made up of characters, used for chat forums: EG.
[a_ch]
___oo___
__o__o__
_oooooo_
[Code]....
What I then want to say is a_ch=letter. But it is in a loop, so I can't do it directly. I want to point to lettername which contains the string of the variable name.
How can I point to the address of lettername?
In autohotkey language, it would be easy:
%lettername%:=letter
View 23 Replies
Dec 29, 2010
How can I declare pointer to pointer in ATL. Actually I have a handle which I want to pass by address to function. As shown below
STDMETHODIMP Function(HANDLE* hHC) //HANDLE declared as void * so actual type is void **
OR
STDMETHODIMP Function(LONG **hHC)
And want to access this function from the VB client.
View 1 Replies
Aug 31, 2010
What I want to do is either trivial, or likely impossible in the .NET framework.
I have a number of forms, with various pictureboxes, labels, etc. in each. Same names for the same items on each form. Only one form is visible at a time. What I need is some way to assign to a variable in the code which form is currently in use, such that I can reference the control on that form in a single statement.
That is, I have set up (already) references to the individual forms (call them frmForm1, frmForm2, etc.). So I can write to a textbox as:
frmForm1.textbox1.text="Hi there."
frmForm2.textbox1.text="Hello world."
What I need to be able to do is something like:
currentform = frmForm2
currentform.textbox1.text="Display on visible box"
Is such a thing even possible? Obviously, the way .Net normally wants to work is to verify everything at compile, and there is (of course) no way for it to know if whatever "currentform" points to even has a "textbox1" control.
save me a LOT of long-winded IF-THEN-ELSE to see which form is currently displayed for each and every time I want to display something. [FWIW, I *could* right everything out to every form, but I feel that would waste to much CPU time.]
View 6 Replies
Jul 21, 2009
Is there a code in which the software scans the screen and point a specified color out of that scan and mark it.
View 1 Replies
Jan 31, 2011
I have a main form "Parent" and another "child" form. When I am filling a textbox in the child form the mouse pointer disappears. Then I hit the tab key to jump to a combobox. At this time when I move the mouse, the pointer doesn't come up until I click the mouse button. This is annoying and the user of my program doesn't like it. How can I keep the mouse pointer always on top. NOte: although the main form has the parent property as true, the other child form are not defined as child forms.
View 2 Replies
Aug 6, 2009
I want to make a small application for my web designing needs that will display the color of the current pixel under the mouse pointer. I need this to work on the entire screen (no matter what form/application is in focus) and it needs to update in real time.
I'm not worried about the math or working with coordinates, but I don't know (and can't find) anything that might get the color of the pixel under the cursor on any form. I've found a small number of VB6 examples, but I'm with .NET 2008. Does anyone know of a method or anything (DLL even >.<)
View 1 Replies
Jan 13, 2010
I have a Dialog Box that creates a Link Label for each item in a list.When one of those LinkLabels is clicked the DialogBox raises a LinkClicked event.Before, I was using code like this in the Form that was instantiating the Dialog:[code]But I don't like that for several reasons.What I want to do, and what I thought would be straight forward, was to pass the AddressOf the UserClicked PoLink Method into the ShowClickableLinksDialog Constructor and do an AddHandler within the constructor and also assign the Delegate to a Property on the Dialog so as to RemoveHandler when the Dialog is Disposed.[code]But I get a squiggly on the tempLinkClickedEventHandler after the AddressOf Operator saying: "AddressOf operand must be the name of a method (without parenthesis)"I don't get it.I've played around with a number of permutations and can't get what I feel ought to work, to work.
View 3 Replies
Mar 23, 2010
I am trying to write a VB.NET alternative to a C# anonymous function.I wish to call Threading.SynchronizationContext.Current.Send which expects a delegate of type Threading.SendOrPostCallback to be passed to it. The background is here, but because I wish to both pass in a string to MessageBox.Show and also capture the DialogResult I need to define another delegate within. I am struggling with the VB.NET syntax, both from the traditional delegate style, and lambda functions.My go at the traditional syntax is below, but I have gut feeling it should be much simpler than this:
Private Sub CollectMesssageBoxResultFromUserAsDelegate(ByVal messageToShow As String, ByRef wasCanceled As Boolean)
wasCanceled = False
[code].....
View 2 Replies
Mar 28, 2009
I'm using vb2008 Is that possible to change the pointer from left to right to right to left in the TextBox.
View 4 Replies
May 1, 2010
I understand there are no pointers in VB.Net. I need to use something similar.The issue is that I have a structure that represent a deck of cards, with elements showing how many of each type of card there is. So I have my_deck.ace, my_deck.two, and so on.What I want to do is set a pointer called current_element that refers to any element in the structure. It may one time point to my_deck.three, and another time to my_deck.nine, and so on. It could point to any element.What I want to do is, for instance to set current_element to point to my_deck.ace, then decrementing current_element would reduce the count of aces by one.[code]that would work, but it's inelegant, I have about 30 different operations to perform, some of them using several lines of code. I'd like to avoid this if at all possible. I could tolerate doing it 2 or 3 times, but not 30.
View 8 Replies
Oct 11, 2009
I need to change the default windows pointer to this: not generally, just in my program. (Form1) There's a Pointer Control But I Dont Know What That Does.
View 7 Replies
Dec 10, 2009
I've got a 3rd party C application that's compiled to a non-.NET non-COM DLL. It has one simple function declared like so: Declare Function CapiTaxRoutine Lib "taxcommono.dll" (ByVal sInData As String, ByVal OutputData As String, ByVal intINPutLength As Long) As Integer
If I place the taxcommono.dll in my path (C:WindowsSystem32 is what I'm using because it's what the vendor recommends),I can wire up a call to the function and it works just fine.It returns a 1 or 0 for success/failure, but it also sets the value of the OutputData string parameter (using some C pointer magic I'm not familiar with) to a huge fixed width format return record that has the data I need.When I call it from a .NET .exe application, it works just fine.When I try to call it from an ASP.NET application via a referenced compiled .NET wrapper DLL, it runs but can't set that string.In order to get it to run, I can't have taxcommono.dll in my path, but rather have to place it in my Bin directory of the web project.Does anyone know of a reason it can set the pointer when called from an .exe application but not when called from a web app?The .NET wrapper DLL I'm using works when called from our ERP software, which is not web based. But when I add a reference to that same DLL in the web app, it won't give me that output value.am used to just getting a return value instead of a function setting the value of one of my input parameters.
View 1 Replies
Feb 10, 2010
In VB6 I have several child forms that have Subs and Controls with the same names.I need to access these Subs and Controls from public subs (in a module) that have a reference to the Active Form.[code]...
View 1 Replies
Nov 12, 2010
I'm by no means a good programmer and I'm just trying to wrap my head around some of this stuff, so please forgive me if this is a dumb question.I want the following to produce a message box that says "2", not "5":
Public Class SomeClass
Private SomeInt As Integer = 5
Private SomeListOfInts As New List(Of Integer)
[code].....
View 1 Replies
Mar 30, 2009
im in a project using drag and drop events and.. , when i drag a label image, i need to change te cursor pointer from an image that is on a labelike the SO windows when you drag a file appears like a mirror with alfa minimun so its like the image but more transparent when i drag i need to change the cursor pointer from an image that i'm dragging by the way im, using visual studio .net and im programming in visual basic
View 6 Replies
Nov 5, 2011
Public Class Form1 Public Declare Function GetModuleHandle Lib "kernel32" Alias "GetModuleHandleA" (ByVal lpModuleName As String) As IntPtr Public Declare Function GetProcAddress Lib "kernel32" Alias "GetProcAddress" (ByVal hModule As IntPtr, ByVal lpProcName As String) As IntPtr
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim hmod As IntPtr = GetModuleHandle(Nothing) 'Work Dim addrs As IntPtr = GetProcAddress(hmod , "TestFunction") 'Not work, always NULL why??
View 3 Replies
Feb 20, 2012
How do I change my mouse cursor/icon to use a image or icon. I want to make a simple "wack a mole" type game but I dont know how to change the pointer to a icon or at least get a image to follow the pointer.
View 7 Replies
Feb 23, 2010
I have a form that has 100 text boxes with 100 coinciding labels. I want them hidden until another function populates the text boxes with data gathered elsewhere. The data could be between 1 and 100.
I would like one loop where I can assign the data to the correct text box, set it visible and set the label visible. I can not figure out how to do this in VB, or know if it is even possible.
Here is an example of what I would like to do
Dim i As Long = 1
Dim textbox As String = "textbox"
[code]....
I would also like to do this to hide all the items on the form in the on load event.
View 16 Replies
Sep 28, 2010
Private Declare Function src_simple Lib "libsamplerate.dll" (ByVal data As IntPtr, ByVal converter_type As Integer, ByVal channels As Integer) As Integer<br/>
Private Declare Function src_strerror Lib "libsamplerate.dll" (ByVal err As Integer) As IntPtr<br/>
<br/>
<StructLayout(LayoutKind.Sequential, Pack:=1)> _
[code]....
View 1 Replies
Jan 4, 2012
I'm trying to rewrite a C++ library. But I have an issue. I'm not extremely pointer-savvy. In the C++ class there is a std::vector that holds unsigned int pointers (vector<unsigned int*>), and the int pointer just points to an array of integer data.
Here is the C++ code I'm a bit unsure about:
unsigned int* relocation = m_relocations.front();
m_relocations.pop();
unsigned int* reloc = *(unsigned int **)relocation;
View 3 Replies
May 3, 2011
I am trying to use VirtualQueryEx to read the memory of a process (first instance of notepad in this case). This function returns a pointer to the MEMORY_BASIC_INFORMATION structure. I am trying to read this structure.But everytime I try to access a member of the structure, I get a zero, which indicates I am messing something up.I am copying my code here.
-Coder_in_distress
Imports System.Runtime.InteropServices
Module Module1[code].....
View 4 Replies
Sep 17, 2009
I am using a DLL written in C#, and one of its API's wants to be used as such, (this is the sample useage they give, but it is also written in C#)[code]...
View 18 Replies
Apr 23, 2009
I have three TextBoxes, how can I let the pointer show in the TextBox2 when I load the Form I treid this but didn't succeed
Me.TextBox2.Focus()
View 15 Replies
Feb 23, 2011
This small snippet of code is to increment a count value (integer) which is stored in a dictionary using my referenced object as a key. When the dictionary is small, multiple lookups aren't a big deal but this particular dictionary can get quite large.
Private RefCount As IDictionary(Of ILifeTimeManaged, Integer)
......... CODE HERE.....
Private Sub IncrementRefCount(ByVal entity As ILifeTimeManaged)
Dim prevCount As Integer
''# if we have no reference entry, add one and set its count to 1
[Code] .....
I find a corresponding dictionary entry then increment the int stored in the value, or add a new dictionary entry. Is it a bad idea to use a pointer to the dictionary value? Then I can avoid the second key lookup when I already have gotten the value. How would you implement it? Is this even possible in .NET4? Can I do it using IntPtr do you think? [URL]
RefCount.Item(entity) = prevCount + 1
View 2 Replies