... to return the x,y coordinates of the origin of a desktop (ie. screen / monitor)
(Think I've asked this one before, the reason it pops up again is I'm rewriting some old programs, and I was trying to remove as much winapi as possible, but I have no alternative for this one...)
DesktopX() DesktopY()
DesktopX() DesktopY()
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
I think he means the X Position of another connected screen. If you have two monitors connected to your GFX Card you are able to expand your desktop to the right or left side. (Maybe even uppon your actual desktop, did not tried this). In this cases you will have coordinates beyond your actual primary desktop display.Mistrel wrote:I'm not sure I understand this request. Can you explain how DesktopX() and DesktopY() would function?
Tranquil
i want this too
ya, i'm gonna have to figure out how to do this with WinAPI. those would be great functions.
i want to keep a particular hindi/sanskrit dictionary program fully visible on one monitor (either monitor) depending on where the user clicks (on a word in another program):
the problem is, on the second monitor (currently to the left of the primary), the x range is from [-1280 to 0] and the y range is from [-224 to 800], so i can't easily decide when my window will go off the bottom of the screen (which has a DesktopHeight of 1024 but a max y value of 800).
so DesktopX(0) and DesktopY(0) will always = 0
but in my case, DesktopX(1) will return -1280 and DesktopY(1) will return -224. had it been on the right side DesktopX(1) would return 1280 (my primary is 1280x800, so the secondary starts on its right edge).
when (if) i find the WinAPI for this i'll post it.
i want to keep a particular hindi/sanskrit dictionary program fully visible on one monitor (either monitor) depending on where the user clicks (on a word in another program):
Code: Select all
x=DesktopMouseX()
y=DesktopMouseY()+20
numDesks=ExamineDesktops()
DW=DesktopWidth(0)
DH=DesktopHeight(0)
If numDesks>1
If x>DW
DW=DW+DesktopWidth(1)
DH=DesktopHeight(1)
ElseIf x<0
DW=0
DH=DesktopHeight(1)
EndIf
EndIf
If x+800>DW: x=DW-800: EndIf
If y+231>DH: y=y-231-40: EndIf
ResizeWindow(#mainWindow, x, y, 600, 231)
ResizeWindow(#defViewer, x+600, y, 200, 231)
so DesktopX(0) and DesktopY(0) will always = 0
but in my case, DesktopX(1) will return -1280 and DesktopY(1) will return -224. had it been on the right side DesktopX(1) would return 1280 (my primary is 1280x800, so the secondary starts on its right edge).
when (if) i find the WinAPI for this i'll post it.
http://www.purebasic.fr/english/viewtop ... 2&start=21
That's the solution you actually need in this case and which is a very popular behavior in one of my programs. (the users love it)
Ideally every GUI program out there should do this but alas they do not.
That's the solution you actually need in this case and which is a very popular behavior in one of my programs. (the users love it)
Ideally every GUI program out there should do this but alas they do not.
what poshu has made available (http://www.purebasic.fr/english/viewtop ... n&start=19) is the really really good way to do it. the following method is far less robust.
GetSystemMetrics_(#SM_XVIRTUALSCREEN) is the originX of the entire work-area, of all connected monitors... use Y for originY.
and
GetSystemMetrics_(#SM_CXVIRTUALSCREEN) is the width of the entire work-area... use Y for height
so if you expect more than 2 monitors, and want proper info about them, use poshu's. if you just want a clean way to get the x&y origin and you know there are only 2 monitors (and it is pretty rare to have more than 2), then use this method.
here's an example:
hare krsna!
GetSystemMetrics_(#SM_XVIRTUALSCREEN) is the originX of the entire work-area, of all connected monitors... use Y for originY.
and
GetSystemMetrics_(#SM_CXVIRTUALSCREEN) is the width of the entire work-area... use Y for height
so if you expect more than 2 monitors, and want proper info about them, use poshu's. if you just want a clean way to get the x&y origin and you know there are only 2 monitors (and it is pretty rare to have more than 2), then use this method.
here's an example:
Code: Select all
;This will work only if there are exactly two monitors
numDesks=ExamineDesktops()
If numDesks=2
Debug "Desktop #0:"
Debug "OriginX = 0"
Debug "OriginY = 0"
Debug "WidthX = "+Str(DesktopWidth(0))
Debug "WidthY = "+Str(DesktopHeight(0))
Debug ""
Debug "Desktop #1:"
Debug "OriginX = "+Str(GetSystemMetrics_(#SM_XVIRTUALSCREEN))
Debug "OriginY = "+Str(GetSystemMetrics_(#SM_YVIRTUALSCREEN))
Debug "WidthX = "+Str(DesktopWidth(1))
Debug "WidthY = "+Str(DesktopHeight(1))
Else
Debug "Desktop #0:"
Debug "OriginX = 0"
Debug "OriginY = 0"
Debug "WidthX = "+Str(DesktopWidth(0))
Debug "WidthY = "+Str(DesktopHeight(0))
EndIf
no i didnt realize that
i have 4.10
--------------
edit: now i have 4.30... low and behold: DesktopX/Y(). that's really useful
the PB developers are one of the few remaining good things about this world.

i have 4.10
--------------
edit: now i have 4.30... low and behold: DesktopX/Y(). that's really useful
the PB developers are one of the few remaining good things about this world.
Repeat this sequence out loud:
*say hare krishna twice
*then say krishna twice
*then say hare twice
*then do the whole thing with rama instead of krishna
if you do this correctly, a representative will appear with further instructions
*say hare krishna twice
*then say krishna twice
*then say hare twice
*then do the whole thing with rama instead of krishna
if you do this correctly, a representative will appear with further instructions