简体   繁体   English

Win32和窗口样式

[英]Win32, and the window style

So I have a window, and I have coded it so that during run-time it can enter and exit full-screen mode. 因此,我有一个窗口,并对其进行了编码,以便在运行时可以进入和退出全屏模式。 Entering full-screen works, but exiting places the window tile bar in reverse order. 进入全屏模式,但退出则以相反的顺序放置窗口图块栏。

Exit full screen code: 退出全屏代码:

SetWindowLongPtr(hWnd, GWL_EXSTYLE, WS_OVERLAPPEDWINDOW);
SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 640, 480, NULL);
InvalidateRect(hWnd, NULL, TRUE);

Picture of the result: https://www.dropbox.com/s/p15eltz7b2hxx4y/window.png?dl=0 结果图片: https : //www.dropbox.com/s/p15eltz7b2hxx4y/window.png?dl=0

I tried using GWL_STYLE instead of GWL_EXSTYLE but that works even worse, with the window being visible but clicking anything on the window will act like the window is not there and the click on whatever is behind it... 我尝试使用GWL_STYLE而不是GWL_EXSTYLE,但是效果更糟,窗口可见,但是单击窗口上的任何内容都会像窗口不存在一样,并且单击其背后的内容...

Thanks! 谢谢! Philip 菲利浦

Just a thought, couldn't you get the window style (with GetWindowLongPtr), store it as a member variable in you class and then use this as the style to reset in SetWindowLongPtr? 只是想一想,您是否无法获取窗口样式(使用GetWindowLongPtr),将其存储为类中的成员变量,然后将其用作在SetWindowLongPtr中重置的样式?

Following is uncheck code (this is assuming you are using C++), 以下是取消选中的代码(假设您使用的是C ++),

MainWnd::OnFullScreen(...)
{
     m_oldStyle = GetWindowLongPtr(GWL_EXSTYLE, m_hwd);
     /*
         what ever other code is necessary
      */
}



MainWnd::OnExitFullScreen(...)
{
    SetWindowLongPtr(m_hwn, GWL_EXSTYLE, m_oldStyle);
    /*
          and other code as needed
     */
}

I've made two assumptions here: 我在这里做了两个假设:

(1) that you will have two variables, one to contain the old style (m_oldStyle) and one to hold the handle to the window (m_hwd). (1)您将有两个变量,一个变量包含旧样式(m_oldStyle),另一个变量包含窗口句柄(m_hwd)。 Note if you are doing strict SDK style coding then the handle will be passed to you as part of WndProc. 请注意,如果您执行严格的SDK样式编码,则该句柄将作为WndProc的一部分传递给您。 If you are using MFC there should be member function in the class you derived you main window from. 如果您使用的是MFC,则在您从主窗口派生的类中应该有成员函数。 In other cases you are on your own. 在其他情况下,您是一个人。

(2) the second assumption is that SetWindowLongPtr is called prior to any change of screen type. (2)第二个假设是在更改屏幕类型之前先调用SetWindowLongPtr。 I believe that SetWindowLongPtr is called during window construction, but it has been several years since I've done serious windows programming using Microsoft frameworks (now I tend to used QT's framework). 我相信SetWindowLongPtr是在窗口构建期间调用的,但是自从我使用Microsoft框架(现在我倾向于使用QT的框架)进行认真的Windows编程以来已经有好几年了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM