Skip to main content
gamedev.net
🔒 Locked

SetWindowPos weird behaviour.

Started by ANSI2000 1 reply 600+ views
Original Post
ANSI2000
ANSI2000
I have created base Object class for creating Windows object, windows, command buttons etc... I have the following 2 methods for Set the object Pos and Size, but SetWidnowPos behave weird as in my Window disapears. I can see ti in the task bar and the only way I can size it is by right clicking on the taskbar and clicking on maximize. I think SetWindowPos is probably shrinking the window or something... Am I callint the SetWindowPos function correctly? void move(const int pX, const int pY) { x += pX; y += pY; SetWindowPos(getHandle(), HWND_TOP, getX(), getY(), width, height, SWP_NOSIZE); } void size(const int pWidth, const int pHeight) { width += pWidth; height += pHeight; SetWindowPos(getHandle(), HWND_TOP, 0, 0, getWidth(), getHeight(), SWP_NOMOVE); }
a person
a person
you are passing the wrong things to SetWindowPosition. simply put there is a bug in your code that figures out the x,y coordinates and the width height stuff. also you may consider looking up the flags for SetWindowPosition since you can force not changifn the zorder (SWP_NOZORDER i think). also you pasing the right handle? you probally need to work on yoru functions a bit more. also why call getX()/getY()/etc. when the move() member function obviously has access to the x/y/width/height varibles. it better not be because the get functions handle bounds checking (set functions do that).
ANSI2000
ANSI2000
I manged to gigure it out.

When I first instanciate my object the default constructor sets the values of x, y, widt, height to CW_DEFAULT. This can be any
value...

Also notice I was doing += to the x,y, width, height values. What that was doing is to move the window from the position it is currently. So I removed the += so now I set the window to it''s absolute position, instead of moving it x amount of pixels from it''s current position. Like this I overide the original values of CW_DEFAULT.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.