Yes you are right I was half sleeping! MONITORINFOEX seems to work just fine by the way.D.J.Peters wrote:With lpmi_ = new LPMONITORINFOEX you create a pointer that points to a pointer that points to nothing !!!
I'm trying to get a step further right here with the system metrics call that returns directly the monitor count. I hope I'll find how to loop over the monitors without moving the mouse next.
Code: Select all
#include "fbgfx.bi"
#include "windows.bi"
dim as HWND hwnd_
dim as LPMONITORINFOEX lpmi_
dim as HMONITOR hMonitor_
lpmi_ = new MONITORINFOEX
lpmi_->cbSize = sizeOf(MONITORINFOEX)
screenRes 800, 600, 32
dim as fb.IMAGE ptr shot
shot = imageCreate(800,600)
screenControl fb.GET_WINDOW_HANDLE, _
cast(integer, hwnd_)
dim as string monitorNameArray(1 to GetSystemMetrics(SM_CMONITORS))
for arrayIndex as integer = lBound(monitorNameArray) to uBound(monitorNameArray)
monitorNameArray(arrayIndex) = "name not discovered - move the app window"
next arrayIndex
GetMonitorInfo(MonitorFromWindow(hwnd_, MONITOR_DEFAULTTONEAREST), lpmi_)
monitorNameArray(lBound(monitorNameArray)) = lpmi_->szDevice
do
screenLock
cls
color rgb(255,0,255)
? "number of avaiable monitors = "; GetSystemMetrics(SM_CMONITORS)
GetMonitorInfo(MonitorFromWindow(hwnd_, MONITOR_DEFAULTTONEAREST), lpmi_)
var currentMonitorName = lpmi_->szDevice
for arrayIndex as integer = lBound(monitorNameArray) to uBound(monitorNameArray)
if "name not discovered - move the app window"=monitorNameArray(arrayIndex) then
var nameAlreadyExists = FALSE
for subArrayIndex as integer = arrayIndex to lBound(monitorNameArray) step -1
if monitorNameArray(subArrayIndex)=currentMonitorName then
nameAlreadyExists = TRUE
exit for
end if
next subArrayIndex
if not nameAlreadyExists then
monitorNameArray(arrayIndex) = currentMonitorName
end if
end if
? arrayIndex, monitorNameArray(arrayIndex)
next arrayIndex
'text display -> dirty zoom feature
get (0,0)-(800 - 1,600 - 1), shot
var n = 2
for x as integer = 0 to 400
for y as integer = 0 to 300
if point(x, y, shot)=rgb(255,0,255) then
circle (x*n, y*n + 100), n/2
end if
next y
next x
screenUnlock
sleep 25
loop until inkey()=chr(27)
delete lpmi_
imageDestroy shot
getKey()
'(eof)