[Win32]只允许最大化最小化窗口,禁止双击标题栏、拖动窗体、点击复原按钮来改变窗口大小

    //^WS_THICKFRAME 禁止拖动边框
    HWND hWnd = CreateWindow(g_szAppWindowClass, g_szAppTitle, WS_OVERLAPPEDWINDOW ^ WS_THICKFRAME,
        CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);


// 处理主窗口的消息。
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam)
{
	UINT wmId;
    UINT wmEvent;

    HDC hdc;
    PAINTSTRUCT ps;

    LPMINMAXINFO lpMinMaxInfo;

	switch (nMsg) {
	case WM_COMMAND://用户菜单命令
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);

        switch (wmId) {
		    case IDM_ABOUT:
                DialogBox(g_hAppInstance, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			    break; 
		    case IDM_EXIT:
			    DestroyWindow(hWnd);
			    break;
		    default:
			    return DefWindowProc(hWnd, nMsg, wParam, lParam);
		}
		break;
	case WM_KEYDOWN://按键消息
		if(wParam == VK_F1)//F1键
		{
		}
		break;
    case WM_PAINT:
        hdc = BeginPaint(hWnd, &ps);
        OnPaint(hdc);
        EndPaint(hWnd, &ps);
        break; 
	case WM_SYSCOMMAND://系统菜单命令:最大化按钮,最小化按,复原按钮,关闭按钮;与用户菜单命令WM_COMMAND有区别哦
		if (wParam == SC_RESTORE)//复原按钮
		{ 
			wParam = SC_MAXIMIZE;
		} 
		if (wParam == SC_CLOSE)//关闭按钮
		{
			if(g_GameMainPage.m_GameMainWnd.m_bOutputCardStarted)
			{
				if (IDCANCEL == MessageBox(hWnd,L"游戏正在进行,若退出则会扣分!!!",L"关闭",MB_OKCANCEL))
				{
					return 0;
				} 
				else
				{ 
                                  //别的操作
				}
			}
		}
		DefWindowProc(hWnd, nMsg, wParam, lParam); 
		break;
	case WM_NCRBUTTONDOWN://在非工作区按下右键
	case WM_NCLBUTTONDBLCLK://在非工作区双击右击
		return 0;
		break;
	case WM_DESTROY: 
		PostQuitMessage(0);
		break; 
	case WM_TIMER:
            OnTimer(wParam, lParam);
        break; 
	default:
		return DefWindowProc(hWnd, nMsg, wParam, lParam);
	}
	return 0;
}
/* MessageBox()的返回值有:
#define IDOK                1
#define IDCANCEL            2
#define IDABORT             3
#define IDRETRY             4
#define IDIGNORE            5
#define IDYES               6
#define IDNO                7
#if(WINVER >= 0x0400)
#define IDCLOSE         8
#define IDHELP          9 
*/

你可能感兴趣的:([Win32]只允许最大化最小化窗口,禁止双击标题栏、拖动窗体、点击复原按钮来改变窗口大小)