https://bugs.winehq.org/show_bug.cgi?id=50456
Bug ID: 50456 Summary: cannot draw non-client area Product: Wine Version: 6.0-rc4 Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: user32 Assignee: wine-bugs@winehq.org Reporter: chenhaoyang@uniontech.com Distribution: ---
Created attachment 69070 --> https://bugs.winehq.org/attachment.cgi?id=69070 IDE:visual c++ 2008 express edition
cannot draw non-client area.Because the size of the non-client area is incorrect.
https://bugs.winehq.org/show_bug.cgi?id=50456
Haoyang Chen chenhaoyang@uniontech.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Hardware|x86 |x86-64
https://bugs.winehq.org/show_bug.cgi?id=50456
Haoyang Chen chenhaoyang@uniontech.com changed:
What |Removed |Added ---------------------------------------------------------------------------- Attachment #69070|IDE:visual c++ 2008 express |demo(IDE:visual c++ 2008 description|edition |express edition)
--- Comment #1 from Haoyang Chen chenhaoyang@uniontech.com --- Comment on attachment 69070 --> https://bugs.winehq.org/attachment.cgi?id=69070 demo(IDE:visual c++ 2008 express edition)
// test_NCCALCSIZE.cpp : ¶¨ÒåÓ¦ÓóÌÐòµÄÈë¿Úµã¡£ //
#include "stdafx.h" #include "test_NCCALCSIZE.h"
#define MAX_LOADSTRING 100
// È«¾Ö±äÁ¿: HINSTANCE hInst; // µ±Ç°ÊµÀý TCHAR szTitle[MAX_LOADSTRING]; // ±êÌâÀ¸Îı¾ TCHAR szWindowClass[MAX_LOADSTRING]; // Ö÷´°¿ÚÀàÃû
// ´Ë´úÂëÄ£¿éÖаüº¬µÄº¯ÊýµÄÇ°ÏòÉùÃ÷: ATOM MyRegisterClass(HINSTANCE hInstance); BOOL InitInstance(HINSTANCE, int); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine);
// TODO: ÔÚ´Ë·ÅÖôúÂë¡£ MSG msg; HACCEL hAccelTable;
// ³õʼ»¯È«¾Ö×Ö·û´® LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_TEST_NCCALCSIZE, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance);
// Ö´ÐÐÓ¦ÓóÌÐò³õʼ»¯: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; }
hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_TEST_NCCALCSIZE));
// Ö÷ÏûϢѻ·: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAcceleratorW(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } }
return (int) msg.wParam; }
// // º¯Êý: MyRegisterClass() // // Ä¿µÄ: ×¢²á´°¿ÚÀà¡£ // // ×¢ÊÍ: // // ½öµ±Ï£Íû // ´Ë´úÂëÓëÌí¼Óµ½ Windows 95 Öеġ°RegisterClassEx¡± // º¯Êý֮ǰµÄ Win32 ϵͳ¼æÈÝʱ£¬²ÅÐèÒª´Ëº¯Êý¼°ÆäÓ÷¨¡£µ÷Óô˺¯ÊýÊ®·ÖÖØÒª£¬ // ÕâÑùÓ¦ÓóÌÐò¾Í¿ÉÒÔ»ñµÃ¹ØÁªµÄ // ¡°¸ñʽÕýÈ·µÄ¡±Ð¡Í¼±ê¡£ // ATOM MyRegisterClass(HINSTANCE hInstance) { WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TEST_NCCALCSIZE)); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = MAKEINTRESOURCE(IDC_TEST_NCCALCSIZE); wcex.lpszClassName = szWindowClass; wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
return RegisterClassEx(&wcex); }
// // º¯Êý: InitInstance(HINSTANCE, int) // // Ä¿µÄ: ±£´æʵÀý¾ä±ú²¢´´½¨Ö÷´°¿Ú // // ×¢ÊÍ: // // Ôڴ˺¯ÊýÖУ¬ÎÒÃÇÔÚÈ«¾Ö±äÁ¿Öб£´æʵÀý¾ä±ú²¢ // ´´½¨ºÍÏÔʾÖ÷³ÌÐò´°¿Ú¡£ // BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { HWND hWnd;
hInst = hInstance; // ½«ÊµÀý¾ä±ú´æ´¢ÔÚÈ«¾Ö±äÁ¿ÖÐ
hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, 20, 60, 800, 600, NULL, NULL, hInstance, NULL);
if (!hWnd) { return FALSE; }
ShowWindow(hWnd, nCmdShow); SW_SHOWNORMAL; UpdateWindow(hWnd);
return TRUE; }
// // º¯Êý: WndProc(HWND, UINT, WPARAM, LPARAM) // // Ä¿µÄ: ´¦ÀíÖ÷´°¿ÚµÄÏûÏ¢¡£ // // WM_COMMAND - ´¦ÀíÓ¦ÓóÌÐò²Ëµ¥ // WM_PAINT - »æÖÆÖ÷´°¿Ú // WM_DESTROY - ·¢ËÍÍ˳öÏûÏ¢²¢·µ»Ø // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc;
switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // ·ÖÎö²Ëµ¥Ñ¡Ôñ: switch (wmId) { case IDM_ABOUT: DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); break; case IDM_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT: { hdc = BeginPaint(hWnd, &ps); // TODO: ÔÚ´ËÌí¼ÓÈÎÒâ»æͼ´úÂë... HBRUSH brush = CreateSolidBrush(0x00888888); int ret = FillRect(hdc, &ps.rcPaint, brush); EndPaint(hWnd, &ps); break; } case WM_NCPAINT: { RECT rect; GetWindowRect(hWnd, &rect); HRGN region = NULL; int edg_x = GetSystemMetrics(SM_CXEDGE); int edg_y = GetSystemMetrics(SM_CYEDGE); if (wParam == NULLREGION) { region = CreateRectRgn(rect.left, rect.top, rect.right, rect.bottom); } else { HRGN copy = CreateRectRgn(0, 0, 0, 0); if (CombineRgn(copy, (HRGN)wParam, NULL, RGN_COPY)) { region = copy; } else { DeleteObject(copy); } }
HDC dc = GetDCEx(hWnd, region, DCX_WINDOW | DCX_CACHE | DCX_INTERSECTRGN | DCX_LOCKWINDOWUPDATE); if (!dc && region) { DeleteObject(region); } HBRUSH brush = CreateSolidBrush(0x0066666); OffsetRect(&rect,-rect.left, -rect.top); int ret = FillRect(dc, &rect, brush); rect.top = edg_x; rect.bottom = GetSystemMetrics(SM_CYSMCAPTION) + edg_x; SetBkMode(dc, TRANSPARENT); DrawTextA(dc, " ³Â´óÏÀµÄWM_NCCALCSIZE", -1, &rect, DT_SINGLELINE | DT_LEFT | DT_VCENTER); DeleteObject(brush); break; }
case WM_NCCALCSIZE: { int xFrame = GetSystemMetrics(SM_CXEDGE); /*×óÓұ߿òµÄºñ¶È*/ int yFrame = GetSystemMetrics(SM_CYEDGE); /*ϱ߿òµÄºñ¶È*/ int nTHight = GetSystemMetrics(SM_CYSMCAPTION) + GetSystemMetrics(SM_CYMENU); /*±êÌâÀ¸µÄ¸ß¶È*/ NCCALCSIZE_PARAMS * p; /*TRUEÊǵÄÖ¸Õë*/ RECT * rc; /*FALSEÊǵÄÖ¸Õë*/ RECT aRect; RECT bRect; RECT bcRect;
if(wParam == TRUE) { p = (NCCALCSIZE_PARAMS *)lParam;
/*¸´ÖÆA B¾ØÐÎλÖÃ*/ CopyRect(&aRect,&p->rgrc[1]); CopyRect(&bRect,&p->rgrc[0]); /*Ö¸¶¨BCµÄ¾ØÐεÄλÖÃ*/ bcRect.left = bRect.left + xFrame; bcRect.top = bRect.top + nTHight; bcRect.right = bRect.right - xFrame; bcRect.bottom = bRect.bottom - yFrame; /*¸÷¸ö¾ØÐιéλ³ÉBC B A*/ CopyRect(&p->rgrc[0],&bcRect); CopyRect(&p->rgrc[1],&bRect); CopyRect(&p->rgrc[2],&aRect); } else { rc = (RECT *)lParam; rc->left = rc->left + xFrame; rc->top = rc->top + yFrame; rc->right = rc->right - xFrame; rc->bottom = rc->bottom - yFrame; } break;
} case WM_NCACTIVATE: RedrawWindow(hWnd, NULL, NULL, RDW_UPDATENOW); if (!wParam) { return 1; } break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
// ¡°¹ØÓÚ¡±¿òµÄÏûÏ¢´¦Àí³ÌÐò¡£ INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { UNREFERENCED_PARAMETER(lParam); switch (message) { case WM_INITDIALOG: return (INT_PTR)TRUE;
case WM_COMMAND: if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { EndDialog(hDlg, LOWORD(wParam)); return (INT_PTR)TRUE; } break; } return (INT_PTR)FALSE; }