Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

BlackHC

changing the window style

This topic is 5722 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

Is it possible to change the style of a window after its creation ? I''ve read that you can change the window style with SetWindowLong but after I changed it the window wasn''t painted properly any more. Thanks for help. BlackHC

Share this post


Link to post
Share on other sites
Advertisement
SetWindowLong is the way to go, but what style flags are you changing? I don''t think SWL performs any validation (so you could mess up the window style in ways that CreateWindow wouldn''t normally let you).

Share this post


Link to post
Share on other sites
The window I created has the WS_OVERLAPPEDWINDOW style.
I changed it to WS_POPUP because I wanted to remove the title bar and the border.
If I set the new style, the window disappears and I must use ShowWindow to show it again. But it's always corrupted.

BlackHC

[edited by - BlackHC on April 19, 2003 1:58:18 PM]

Share this post


Link to post
Share on other sites
Got it.
WS_POPUP is not a real window style - btw I set the window style to WS_POPUP only and thats not enough.
WS_POPUPWINDOW is the right choice !

Thanks for your help.

BlackHC

Share this post


Link to post
Share on other sites
You can''t just specify a new window style with SetWindowLong. You have to first get the current style, then invert it to get rid of that style. Then you add in the new style. Code is worth a billion words.


  
void BaseWindow::GoFullScreen(HWND hWnd, BOOL bFullscreen)
{
HDC hDc = GetDC(hWnd);
//Gather information

long style = GetWindowLong(hWnd, GWL_STYLE);

//Change our resolutions

if(bFullscreen)
{
//Set our new window style

style &= ~WS_OVERLAPPEDWINDOW; //Out with the old

style |= WS_POPUP; //In with the new

SetWindowLong(hWnd, GWL_STYLE, style); //Now set it

//Update our window.

SetWindowPos(hWnd, HWND_TOPMOST,0, 0, GetDeviceCaps(hDc, HORZRES) + GetSystemMetrics(SM_CXBORDER),
GetDeviceCaps(hDc, VERTRES) + GetSystemMetrics(SM_CYBORDER) ,SWP_FRAMECHANGED);
}
else
{
style &= ~WS_POPUP; //Out with the old

style |= WS_OVERLAPPEDWINDOW; //In with the new

SetWindowLong(hWnd, GWL_STYLE, style); //Now set it.

SetWindowPos(hWnd, HWND_TOPMOST, 100, 100, 800, 600, SWP_FRAMECHANGED); //Update our window


}
ReleaseDC(hWnd, hDc);
}

Share this post


Link to post
Share on other sites
I''ve never had to invert or anything. Here''s my code:


  
void c_core::set_window_style()
{
if(screen.is_windowed == true)
{
// Set the style.

SetWindowLong(
window_handle,
GWL_STYLE,
(!(flags & CORE_NOTSIZABLE))?
(WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_VISIBLE)
:
(WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_BORDER | WS_MINIMIZEBOX | WS_VISIBLE));

}
else
{
// Set the style.

SetWindowLong(
window_handle,
GWL_STYLE,
WS_POPUP);
}
}

Share this post


Link to post
Share on other sites

  • 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!