Jump to content
Sign in to follow this  
JavaCupiX

DllCall and EnumDisplayMonitors (call back functions)

Recommended Posts

JavaCupiX

Hi,

I'm struggling to use the "EnumDisplayMonitors" function available in the "user32.dll" (http://msdn.microsoft.com/en-us/library/ms534809(VS.85).aspx), the problem is related to the use of callback functions, I just don't get how all of this can be used in autoit.

I've started with that but can't get more further... any idea?

$handle = DLLCallbackRegister ("_MonitorEnumProc", "long", "long;long;long;str")

;~ ; Call EnumDisplayMonitors

DllCall("user32.dll", "bool", "EnumDisplayMonitors", "long", 0, "long", 0, "ptr", DllCallbackGetPtr($handle), "lparam", 10)

;~ ; Delete callback function

DllCallbackFree($handle)

Share this post


Link to post
Share on other sites
monoceres

Hi!

You have got some errors, here's how you should do it :P

$callback=DllCallbackRegister("MonitorEnumProc","int","ptr;ptr;ptr;lparam")

DllCall("user32.dll","int","EnumDisplayMonitors","ptr",0,"ptr",0,"ptr",DllCallbackGetPtr($callback),"lparam",10)


Func MonitorEnumProc($hMonitor,$hdcMonitor,$lprect,$lparam)
    
    MsgBox(0,"Monitor","Monitor handle: "&$hMonitor&@CRLF&"LPARAM: "&$lparam)
    
EndFunc
Edited by monoceres

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites
JavaCupiX

Hi!

You have got some errors, here's how you should do it :P

$callback=DllCallbackRegister("MonitorEnumProc","int","ptr;ptr;ptr;lparam")

DllCall("user32.dll","int","EnumDisplayMonitors","ptr",0,"ptr",0,"ptr",DllCallbackGetPtr($callback),"lparam",10)


Func MonitorEnumProc($hMonitor,$hdcMonitor,$lprect,$lparam)
    
    MsgBox(0,"Monitor","Monitor handle: "&$hMonitor&@CRLF&"LPARAM: "&$lparam)
    
EndFunc
Thanks a lot!

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.