Jump to content

  • Log In with Google      Sign In   
  • Create Account


making a window move itself


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 graeme   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 January 2002 - 03:11 PM

Ok, as a first project in C++ i am trying to make a desktop toy so far i have a window with no borders bliting an image from the desktop into itself. i want to be able to let the window find out where it is on the screen in order to move itself. so far i''ve been making it hop about here and there with this code: /*SetWindowPos (hwnd, 0, rand()%(GetSystemMetrics(SM_CXSCREEN)-60), rand()%(GetSystemMetrics(SM_CYSCREEN)-60), 0,0, SWP_NOSIZE | SWP_NOZORDER);*/ instead of those random positions how could i replace them with a ''my windows x pos +1 and my window y pos +1 sort of thing, obviously i wouldn''t introduce the increment within the actual moving of the window, i''d be setting a variable earlier. i think, in essence my question is ''how do interogate an hwnd in terms of x and y coords on the screen''? with MSDN i have got as far as the operation GetWindowRect, is the one to use? and how do i interrogate the structure that it returns (is it a structure?) ? do i use bracket access? like to get the x coord i''d say theThingThatWasTheResultOfGetWindowRect [1] for the x coord and [3] for the x width? or am i completely wrong??

Sponsor:

#2 Oluseyi   Staff Emeritus   -  Reputation: 1670

Like
Likes
Like

Posted 22 January 2002 - 03:26 PM

Why interrogate the window if you have its previous position already (you set it, didn''t you)?

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!


#3 myme15   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 January 2002 - 03:29 PM

Am I missing something, or couldn''t you just keep track of the window''s location in a couple of variables?

------------------------------
bah
------------------------------

#4 graeme   Members   -  Reputation: 122

Like
Likes
Like

Posted 23 January 2002 - 02:00 AM

of course you are quite right of course. i should learn not to post (or program) after pub. i vow not to in the future.
But for the sake of argument, how do you access the properties of a window? hwnd._X or something?




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS