Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: EnumDisplayMonitors udfEnumDisplayMonitors Enumerate List Display Dual Monitor Multi-Monitor Device DllCallbackCreate DllCallbackDestroy IntControl 32 Pointer Binary Buffer
; DllCall with Callback example. ; Requires WinBatch 2011B or newer #DefineFunction udfMonitorEnumProc(hMonitor,hdcMonitor,lprcMonitor,dwData) ;-------------------------------------------------------------------------------- ; udfMonitorEnumProc : Callback function that is called by the ; udfEnumDisplayMonitors function. ; ;-------------------------------------------------------------------------------- ; parm1 : hMonitor ; parm2 : hdcMonitor ; parm3 : lprcMonitor ; parm4 : dwData ;-------------------------------------------------------------------------------- ; returns : @TRUE/@FALSE. This callback will run until: Callback returns FALSE ; ;-------------------------------------------------------------------------------- ; Deana Falk ; 2011.11.30 Initial Release ;-------------------------------------------------------------------------------- ;BOOL CALLBACK MonitorEnumProc( ; __in HMONITOR hMonitor, ; __in HDC hdcMonitor, ; __in LPRECT lprcMonitor, ; __in LPARAM dwData ;); left = IntControl(32,lprcMonitor ,"LONG",0,0) top = IntControl(32,lprcMonitor+4 ,"LONG",0,0) right = IntControl(32,lprcMonitor+8 ,"LONG",0,0) bottom = IntControl(32,lprcMonitor+12,"LONG",0,0) Pause('LPRECT: left,top,right,bottom', left:@CR:top:@CR:right:@CR:bottom) GetMonitorInfo() Return @TRUE #EndFunction #DefineFunction udfEnumDisplayMonitors(cbhandle) ;-------------------------------------------------------------------------------- ; EnumDisplayMonitors : enumerates display monitors (including invisible ; pseudo-monitors associated with the mirroring drivers) ; that intersect a region formed by the intersection of ; a specified clipping rectangle and the visible region ; of a device context. ; ;-------------------------------------------------------------------------------- ; parm1 : NA ;-------------------------------------------------------------------------------- ; returns : ; ;-------------------------------------------------------------------------------- ; Deana Falk ; 2011.11.30 Initial Release ;-------------------------------------------------------------------------------- ; BOOL EnumDisplayMonitors( ; __in HDC hdc, ; __in LPCRECT lprcClip, ; __in MONITORENUMPROC lpfnEnum, ; __in LPARAM dwData ;) ; EnumDisplayMonitors calls an application-defined MonitorEnumProc callback function once ; for each monitor that is enumerated. Note that GetSystemMetrics (SM_CMONITORS) counts ; only the display monitors. userdll = StrCat(DirWindows(1),"USER32.DLL") returnvalue = DllCall(userdll,long:"EnumDisplayMonitors",lpnull,lpnull,callback:cbhandle,long:0) If returnvalue == 0 Pause('EnumDisplayMonitors Failed',DllLastError()) Return 0 EndIf Return 1 #EndFunction cbhandle = DllCallbackCreate('udfMonitorEnumProc','LONG','LONG LONG LONG LONG') udfEnumDisplayMonitors(cbhandle) DllCallbackDestroy(cbhandle) Exit
Article ID: W18419
Filename: udfEnumDisplayMonitors.txt
File Created: 2011:12:01:12:23:24
Last Updated: 2011:12:01:12:23:24