Jump to content

DllCallBackRegister + DllCallBackGetPtr = AddressOf in Vb.net ?


kcvinu
 Share

Recommended Posts

Hi all,

I am reading subclassing and hooking in vb.net. When i read the lesson about subclass a window, this thought came to my mind. So i am asking this for a clarification.

Using DllCallBackRegister + DllCallBackGetPtr is equal to use AddressOf in Vb.net ? If so i think, i need to make a new function to club the both autoit functions in order to make something equal to AddressOf.

Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

This is not Developer Chat, this is General Chat, where we don't discuss the intricacies of programming. ;)

I suggest you report your topic and ask a MOD to move it to Developer General Discussion. :D

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

@TheSaint Oh, i am so sorry TheSaint. By report, you mean i am commenting a mod's name here and tell the matter ?. 

Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

No, he means click the Report Post link

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

No worries.

At the top of each post, it says Report Post.

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

1 hour ago, kcvinu said:

Using DllCallBackRegister + DllCallBackGetPtr is equal to use AddressOf in Vb.net ? If so i think, i need to make a new function to club the both autoit functions in order to make something equal to AddressOf.

Uhm, could you rephrase that? This is a very weird sentence.

A few hints though:

AddressOf

This .NET operator creates a delegate. One example of this is to provide other methods with handlers to digest events (eg. clicking a button).

Pointers

DllCallbackGetPtr get's a real pointer to an AutoIt callback method. Native code (not .NET) can use this pointer to call functions in your AutoIt script. This is not at all comparable to AddressOf, since the Dllxxx function use actual pointers. The last version of VB to support real pointers (and pointer arithmetic) is VB6. VB14's AddressOf has nothing to do with this. What you are looking for is

Function References

This (relatively) new feature in AutoIt allows you to pass references to functions as values in AutoIt. This can be used for the same purpose as AddressOf, here's an example:

; Actual code
ProvokeError()                ; will do nothing
ProvokeError(True)            ; will show error in console
ProvokeError(True, UIHandler) ; will show error MessageBox


; Examples of handlers for different purposes
Func ConsoleHandler($msg)
    ConsoleWrite("!> Error. Message: " & $msg & @LF)
EndFunc

Func UIHandler($msg)
    If MsgBox(4, "Error", "Message: " & $msg & @CRLF & "Do you want to exit?") = 6 Then Exit
EndFunc

; This will do something
Func ProvokeError($bFail = False, $hErrorHandler = ConsoleHandler)
    If $bFail Then $hErrorHandler("$bFail was true.")
EndFunc

 

Edited by minxomat

I will answer every single PM, and you are free to ask anything anytime.

Link to comment
Share on other sites

@minxomat , 

I think i need to read more about AddressOf. Any how, the book i read was related to vb6. So i think the AdderssOf in vb.net and AddressOf in vb6 are equal. The book says that in vb6 they used AddressOf as a function pointer. Then i have searched this forum and got some good examples of DllCallBackRegister function. And in your example, i can see that you use just a function name as a parameter in another function. So i am assuming that using function name is enough as using function pointer. Am i right ?

Spoiler

My Contributions

Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language.

UDF Link Viewer   --- A tool to visit the links of some most important UDFs 

 Includer_2  ----- A tool to type the #include statement automatically 

 Digits To Date  ----- date from 3 integer values

PrintList ----- prints arrays into console for testing.

 Alert  ------ An alternative for MsgBox 

 MousePosition ------- A simple tooltip display of mouse position

GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function

Access_UDF  -------- An UDF for working with access database files. (.*accdb only)

 

Link to comment
Share on other sites

VB6 is a completely different, no longer sold (but still supported) language from VB.NET (which the current version of is VB14). Pointers in VB6 are native pointers. What you need is exactly this:

4 hours ago, kcvinu said:

And in your example, i can see that you use just a function name as a parameter in another function. So i am assuming that using function name is enough as using function pointer. Am i right ?

Yes. I suggest you read the AutoIt Helpfile on that topic, which should make this clearer.

I will answer every single PM, and you are free to ask anything anytime.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...