Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- WndProc: 0x00000046 WM_WINDOWPOSCHANGING
- WndProc: 0x00000024 WM_GETMINMAXINFO
- WndProc: 0x00000083 WM_NCCALCSIZE
- WndProc: 0x00000093 WM_UAHINITMENU
- ===Flickering happens between these two messages!===
- WndProc: 0x00000085 WM_NCPAINT
- WndProc: 0x00000093 WM_UAHINITMENU
- WndProc: 0x00000093 WM_UAHINITMENU
- WndProc: 0x00000091 WM_UAHDRAWMENU
- WndProc: 0x00000092 WM_UAHDRAWMENUITEM
- WndProc: 0x00000092 WM_UAHDRAWMENUITEM
- WndProc: 0x00000092 WM_UAHDRAWMENUITEM
- WndProc: 0x00000014 WM_ERASEBKGND
- WndProc: 0x00000047 WM_WINDOWPOSCHANGED
- WndProc: 0x00000003 WM_MOVE
- WndProc: 0x00000005 WM_SIZE
- HWND g_hWndList = NULL;
- #define LIST_WIDTH 500
- #define LIST_HEIGHT 400
- void GetListRect(HWND hWnd, RECT& rectList)
- {
- GetClientRect(hWnd, &rectList);
- InflateRect(&rectList, -10, -10);
- rectList.left = rectList.right - LIST_WIDTH;
- rectList.bottom = rectList.top + LIST_HEIGHT;
- }
- BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
- {
- hInst = hInstance; // Store instance handle in our global variable
- HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
- CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr);
- if (!hWnd)
- {
- return FALSE;
- }
- RECT rectList;
- GetListRect(hWnd, rectList);
- g_hWndList = CreateWindow(WC_LISTVIEW, TEXT("listL"), WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP | LVS_REPORT,
- rectList.left, rectList.top, rectList.right - rectList.left, rectList.bottom - rectList.top, hWnd, nullptr, hInstance, nullptr);
- ShowWindow(hWnd, nCmdShow);
- UpdateWindow(hWnd);
- return TRUE;
- }
- LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- switch (message)
- {
- case WM_COMMAND:
- {
- int wmId = LOWORD(wParam);
- // Parse the menu selections:
- switch (wmId)
- {
- case IDM_ABOUT:
- // Resize the window instead of showing "About" dialog
- //DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
- {
- RECT rect;
- GetWindowRect(hWnd, &rect);
- rect.left += 100;
- SetWindowPos(hWnd, nullptr, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOACTIVATE | SWP_NOZORDER);
- }
- break;
- }
- }
- break;
- case WM_WINDOWPOSCHANGED:
- {
- RECT rectList;
- GetListRect(hWnd, rectList);
- SetWindowPos(g_hWndList, nullptr, rectList.left, rectList.top, 0, 0, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE);
- }
- break;
- }
- }
- BOOL g_bExpandingShrinking = FALSE;
- void OnCommandExpandShrinkWindow(HWND hWnd, BOOL bExpand)
- {
- RECT rect;
- GetWindowRect(hWnd, &rect);
- rect.left += bExpand ? -100 : 100;
- UINT nFlags = SWP_NOZORDER | SWP_NOACTIVATE;
- g_bExpandingShrinking = TRUE;
- SetWindowPos(hWnd, nullptr, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, nFlags);
- g_bExpandingShrinking = FALSE;
- }
- LRESULT OnNcCalcSize(HWND hWnd, WPARAM wParam, LPARAM lParam)
- {
- NCCALCSIZE_PARAMS* lpncsp = reinterpret_cast<NCCALCSIZE_PARAMS*>(lParam);
- LRESULT res;
- if (wParam && g_bExpandingShrinking)
- {
- // let DefWindowProc calculate the new client rectangle
- res = DefWindowProc(hWnd, WM_NCCALCSIZE, wParam, lParam);
- // copy the content of the right list control
- GetWindowRect(g_hwndListRight, lpncsp->rgrc + 2);
- lpncsp->rgrc[1] = lpncsp->rgrc[2];
- res = WVR_VALIDRECTS;
- }
- else
- {
- res = DefWindowProc(hWnd, WM_NCCALCSIZE, wParam, lParam);
- }
- return res;
- }
Add Comment
Please, Sign In to add comment