Sign in to follow this  
PaganX

GetWindowRect, works in compiler but not exe

Recommended Posts

Window styles Used: WS_MAXIMIZEBOX WS_MINIMIZEBOX WS_SYSMENU WS_CLIPCHILDREN WS_CLIPSIBLINGS WS_MAXIMIZE Method used to find and store screen resolution: GetWindowRect(Window.hWnd, &Window.Rect) rFullScreen = Window.Rect I figure, if I make the window maximized I should be able to get and store the window rect after the window is created. When I run the program without debugging, it works perfectly. Createing a full screen window and storing it as an RECT. BUT... When I run it as an exe, the window is minimized in the top left corner of the screen and doesnt capture the RECT correctly.

Share this post


Link to post
Share on other sites
could you provide the some surrounding code or maybe your class declaration etc? i think a little more information would help, but what im guessing is its a variable initialization problem...

Share this post


Link to post
Share on other sites
There isn't much to the code that would effect it. My real confusion lies with why it works in the compiler and when the exe is run.

this is the run at the top of the Main just outside the main loop with other initialization code.
SetupCameraWindow(hInstance);
Window.Window.Create(true, false);
GetWindowRect(Window.Window.hWnd, &Window.Window.Rect);
rFullScreen = Window.Window.Rect;

SetupCameraWindow goes through and fills out the windowclass. Pretty basic but sloppy when cut and pasted : )

void SetupCameraWindow(HINSTANCE hInstance)
{
CameraWindow.Window.WC.cbClsExtra = 0;
CameraWindow.Window.WC.cbWndExtra = 0;
CameraWindow.Window.WC.hbrBackground = (HBRUSH)GetStockObject(DKGRAY_BRUSH);
CameraWindow.Window.WC.hCursor = LoadCursor(NULL, IDC_ARROW);
CameraWindow.Window.WC.hIcon = LoadIcon (NULL, IDI_APPLICATION);
CameraWindow.Window.WC.hInstance = hInstance;
CameraWindow.Window.WC.lpfnWndProc = MainProc;
CameraWindow.Window.WC.lpszClassName = "CameraWindow";
CameraWindow.Window.WC.lpszMenuName = NULL;
CameraWindow.Window.WC.style = CS_OWNDC|CS_HREDRAW|CS_VREDRAW;
CameraWindow.Window.style = WS_MAXIMIZEBOX|WS_MINIMIZEBOX|WS_SYSMENU|WS_CLIPCHILDREN|WS_CLIPSIBLINGS|WS_MAXIMIZE;
//CameraWindow.Window.Parent = Menu.Window.hWnd;
CameraWindow.Window.WindowName = "Camera Window";
}

void Create(bool bShow, bool bLoadMenu)
{
if(!RegisterClass(&WC))
{
MessageBox(hWnd, "Error Registering Class", "ERROR!", MB_OK);
}

hWnd = CreateWindow(WC.lpszClassName, WindowName,
style,
Rect.left, Rect.top, Rect.right, Rect.bottom,
Parent, NULL, WC.hInstance, NULL);

if(bShow)
{ShowWindow(hWnd, SW_SHOW);}
if(bLoadMenu)
{SetMenu (hWnd, Menu);}
}

hopefuly this clears up a few things, I removed the pixformat code the simplify things. It contains no code that would change the window RECT.

Share this post


Link to post
Share on other sites
Quote:
Original post by PaganX
Method used to find and store screen resolution: (..)

Easier way to obtain the same info:

::GetSystemMetrics( SM_CXSCREEN ); // width
::GetSystemMetrics( SM_CYSCREEN ); // height

Share this post


Link to post
Share on other sites
Worked great. Even when I ran the exe. I guess GetWindowRect after creating a maximized window fills the rect array with the correct info when tested. But NULL when the exe was run.

Once again, thanks for the help

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this