Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi. :)

I made a DLL in CodeBlocks / GCC MinGW compiler, that can be called to change the border style of the active window. One of those functions I created can change the window from being fixed, to resizeable, with the maximize (and minimize) button enabled.

C++
#include "main.h"
#include <cstdlib>
#define DLL extern "C" _declspec(dllexport)

DLL double Resizeable()
{
    SetWindowLongPtr(GetActiveWindow(),GWL_STYLE, WS_VISIBLE|WS_SYSMENU|
                                                  WS_BORDER|WS_CAPTION|
                                                  WS_SIZEBOX|WS_MINIMIZEBOX|
                                                  WS_MAXIMIZEBOX|WS_CLIPCHILDREN
                     );
    return 0;
}


The window initially is a size smaller than the screen resolution, to be exact it's 640x480 and my screen display is 1280x1024. So when I maximize the window, it fills the entire display area above the task bar, just as all maximized applications should.

The problem is, when I try to "un-maximize", (or press the maximize button when already maximized), it doesn't do anything. Instead of returning to its original size/pos and automatically remembering that original size/pos, it just stays maximized and filling the screen.

A little help or code snippet anyone?
Thanks.
Samuel
Posted
Updated 10-Sep-14 20:44pm
v3
Comments
Richard MacCutchan 10-Sep-14 5:43am    
Flags needed for sizeable window
Wouldn't it be more useful to show us the actual flags that you are using?
time-killer-games 10-Sep-14 18:38pm    
I did that because it doesn't fit on one line. CodeProjects code tag is retarded that way.
WS_VISIBLE|WS_SYSMENU|WS_BORDER|WS_CAPTION|WS_SIZEBOX|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_CLIPCHILDREN
Richard MacCutchan 11-Sep-14 2:44am    
Nothing wrong with splitting C++ code across multiple lines.
Richard MacCutchan 11-Sep-14 3:39am    
I just tried your code and it works fine, can maximise and un-maximise the window.
time-killer-games 12-Sep-14 17:19pm    
The DLL is being called by a closed source commercial game engine (GameMaker:Studio) thank you for verifying. It appears to be a problem with the game engine I use, not my personal code's fault. I wouldn't have found this out anytime soon if it wasn't for your assistance. Thank you! :D

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900