Jump to content

DllCall and EnumDisplayMonitors (call back functions)


Recommended Posts

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)

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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!
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...