Moveable Window or Dialog

Just starting out? Need help? Post your questions and find answers here.
TeddyLM
Enthusiast
Enthusiast
Posts: 133
Joined: Wed Apr 30, 2003 2:04 pm
Location: Germany (French expat)

Moveable Window or Dialog

Post by TeddyLM »

Hello there

I'm actually working on some application and i'd like my main window to be moveable on the screen but not outside the borders. Do somebody know how i can do this ? :?:

Thanks in advance !

May the force be with you :wink:
Searhin
User
User
Posts: 41
Joined: Mon May 26, 2003 10:53 am
Location: Germany

Post by Searhin »

a simple way would be to check in the beginning of the event loop (before actually processing events)

IF WindowX < 0 OR WindowX > ScreenWidth - WindowWidth
(and likewise for the Y coordinate)

if this is true you can relocate the window so that it is positioned exactly on the border of your Screen

i admit that's not a very sophisticated method :wink: but it works fine nonetheless.
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

A trick/tip about this:
viewtopic.php?t=5576

This tip though only works if 'show window when dragging' is enabled! i found out what was wrong though :), i was checking #WM_MOVE (catches event after move) instead of #WM_MOVING (catches event while moving, which is missing from PB) this next link shows how to check for both.

A little app i coded that does this:
http://www.garyw.uklinux.net/PB/PureMonitor.zip

have fun :twisted:
--Kale

Image
TeddyLM
Enthusiast
Enthusiast
Posts: 133
Joined: Wed Apr 30, 2003 2:04 pm
Location: Germany (French expat)

Post by TeddyLM »

Thanks Kale....

it works fine now !

(what would i do without you pals !!! :wink: )
Post Reply