Jump to content
  • Advertisement
Sign in to follow this  
Strewya

Client area of my window

This topic is 2609 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi there! ^^

after searching on this topic a bit, and trying everything that i found, i have failed to solve my problem.

my problem is my client area's Y coordinate is shorter by a little under 30 pixels than my target size, and the X coordinate by 4 pixels, which is very apparent when i try to rotate my test sprite around it's exact position. i have come to the conclusion that the problem is around getting the client area dimensions, and setting them to be as i want them.
i have tried using AdjustWindowRect(Ex) but the problem persists.
i've provided the code on how i create my window, and how i get the mouse coords. i added comments about the values my debugger gives my for the rect.
i'm not using the precise coords just yet, but it's in my interest to have it as precise as possible.
code is C++.
any idea how i might solve this?
thank you!


DWORD style;
if(st.IsFullscreen())
style = WS_EX_TOPMOST | WS_VISIBLE | WS_POPUP;
else
style = WS_OVERLAPPEDWINDOW;

//width and height is gotten by using GetSystemMetrics(SM_CXSCREEN) and SM_CYSCREEN
RECT rc = {0,0,st.GetWidth(), st.GetHeight()}; //rc = {top=0, bottom=1080, left=0 , right=1920}
AdjustWindowRect(&rc, style, false); //rc = {top=-30, bottom=1088, left=-8 , right=1928}

//create a new window
_hwnd = CreateWindow(
st.GetTitle().c_str(),
st.GetTitle().c_str(),
style,
CW_USEDEFAULT,
CW_USEDEFAULT,
rc.right-rc.left,
rc.bottom-rc.top,
NULL,
NULL,
hInst,
NULL);

if(_hwnd == NULL)
return false;

GetClientRect(_hwnd, &rc); //rc = {top=0, bottom=1054, left=0 , right=1916}
GetWindowRect(_hwnd, &rc); //rc = {top=0, bottom=1092, left=0 , right=1932}


and this is how i get the mouse coords

RECT rc;
GetClientRect(_hwnd, &rc);
GetWindowRect(_hwnd, &rc);
POINT cursor;
GetCursorPos(&cursor);
ScreenToClient(_hwnd, &cursor);

Share this post


Link to post
Share on other sites
Advertisement
MSDN states "Note that you cannot specify the WS_OVERLAPPED style.", could that be the problem? Does this problem occur in both st.IsFullscreen() and !st.IsFullscreen()?

Share this post


Link to post
Share on other sites

MSDN states "Note that you cannot specify the WS_OVERLAPPED style.", could that be the problem? Does this problem occur in both st.IsFullscreen() and !st.IsFullscreen()?


MSDN says WS_OVERLAPPED, and i'm using WS_OVERLAPPEDWINDOW. in this topic Evil Steve says in should work with WS_OVERLAPPEDWINDOW.
as far as st.IsFullscreen() goes, it returns a bool variable saying whether the screen is fullscreen or not, and when the window is fullscreen it works fine (my sprite rotates when moving the cursor exactly around it's position), while in windowed it doesn't (rotates when cursor is about 20ish pixels beneath the sprite).

Share this post


Link to post
Share on other sites
Well WS_OVERLAPPEDWINDOW = (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX), I'm not sure if the inclusion of the WS_OVERLAPPED flag might cause incorrect values. I've used this in the past myself:
[source]Style = WS_OVERLAPPEDWINDOW;
ExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;[/source]
I can't remember having any issues with it, you could try it with those flags.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!