如何使用opengl在c ++中禁用窗口的最大化按钮? [英] how can i disable the maximize button of a window in c++ using opengl?

查看:195
本文介绍了如何使用opengl在c ++中禁用窗口的最大化按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这段代码创建了一个可以最小化和最大化的窗口,但是我想禁用最大化按钮.我该怎么办?

this code creates a window which can be minimized and maximzed but i want to disable the maximize button. how can i do ths?

glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowSize(windowWidth,windowHeight);
glutInitWindowPosition(50,50);
glutCreateWindow("gaMe");

推荐答案

我现在忘记了如何获取GLUT窗口的句柄(如果GLUT确实包含执行此操作的方法),尽管通常以下代码将执行此任务:

I forget right now how to get the handle of a GLUT window (if indeed GLUT includes a method to do this), though typically the following code will perform this task:

long dwStyle = GetWindowLong(hwnd, GWL_STYLE);
dwStyle ^= WS_MAXIMIZEBOX;
SetWindowLong(hwnd, GWL_STYLE, dwStyle);




1.获取当前的窗口样式
2.切换最大化框位
3.将新样式发送回窗口


您只需要(a)获取GLUT来为该窗口提供句柄,或(2)使用标准的Windows函数来获得该窗口的句柄-应该相当琐碎,因为您已经创建了窗口,知道它的窗口文本(标题)是什么.



不,GLUT否包括检索主窗口的HWND的功能,您将必须自己执行此操作.请在下面找到一个可以为您做很多事情的功能.

功能




1. Get the current window style
2. Toggle the maximize-box bit
3. Send the new style back to the window


You''ll just have to either (a) get GLUT to give you a handle for this window, or (2) use the standard windows functions for getting a handle to this window - should be reasonably trivial, since you''ve created the window and know what it''s window text(title) is.



Nope, GLUT no includes a function to retrieve a HWND of the main window, you''ll have to do this yourself. Please find below a function that will do the lot for you.

Function

void toggleGlutWindowMaximizeBox(char *szWindowTitle)
{
    long dwStyle;
    HWND hwndGlut;

    hwndGlut = FindWindow(NULL, szWindowTitle);

    dwStyle = GetWindowLong(hwndGlut, GWL_STYLE);
    dwStyle ^= WS_MAXIMIZEBOX;
    SetWindowLong(hwndGlut, GWL_STYLE, dwStyle);
}



使用示例



Example of Use

char *szWindowTitle = "GLUT Shapes";
....
....
....
glutCreateWindow(szWindowTitle);
toggleGlutWindowMaximizeBox(szWindowTitle);


这篇关于如何使用opengl在c ++中禁用窗口的最大化按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆