making a window move itself
3 replies to this topic
Members - Reputation: 122
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  for the x coord and  for the x width? or am i completely wrong??