Jump to content

Recommended Posts

Posted

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.

  Reveal hidden contents

 

Posted

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.

  Reveal hidden contents

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

Posted

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

  Reveal hidden contents

 

Posted

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!

  Reveal hidden contents

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

Posted

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.

  Reveal hidden contents

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

Posted (edited)
  On 2/16/2016 at 6:27 PM, 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.

Expand  

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.

Posted

@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 ?

  Reveal hidden contents

 

Posted

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:

  On 2/17/2016 at 4:57 AM, 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 ?

Expand  

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.

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
  • Recently Browsing   0 members

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