Guest User

Untitled

a guest
Jun 18th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.63 KB | None | 0 0
  1. WndProc: 0x00000046 WM_WINDOWPOSCHANGING
  2. WndProc: 0x00000024 WM_GETMINMAXINFO
  3. WndProc: 0x00000083 WM_NCCALCSIZE
  4. WndProc: 0x00000093 WM_UAHINITMENU
  5. ===Flickering happens between these two messages!===
  6. WndProc: 0x00000085 WM_NCPAINT
  7. WndProc: 0x00000093 WM_UAHINITMENU
  8. WndProc: 0x00000093 WM_UAHINITMENU
  9. WndProc: 0x00000091 WM_UAHDRAWMENU
  10. WndProc: 0x00000092 WM_UAHDRAWMENUITEM
  11. WndProc: 0x00000092 WM_UAHDRAWMENUITEM
  12. WndProc: 0x00000092 WM_UAHDRAWMENUITEM
  13. WndProc: 0x00000014 WM_ERASEBKGND
  14. WndProc: 0x00000047 WM_WINDOWPOSCHANGED
  15. WndProc: 0x00000003 WM_MOVE
  16. WndProc: 0x00000005 WM_SIZE
  17.  
  18. HWND g_hWndList = NULL;
  19. #define LIST_WIDTH 500
  20. #define LIST_HEIGHT 400
  21.  
  22. void GetListRect(HWND hWnd, RECT& rectList)
  23. {
  24. GetClientRect(hWnd, &rectList);
  25. InflateRect(&rectList, -10, -10);
  26. rectList.left = rectList.right - LIST_WIDTH;
  27. rectList.bottom = rectList.top + LIST_HEIGHT;
  28. }
  29.  
  30. BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
  31. {
  32. hInst = hInstance; // Store instance handle in our global variable
  33.  
  34. HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
  35. CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr);
  36.  
  37. if (!hWnd)
  38. {
  39. return FALSE;
  40. }
  41.  
  42. RECT rectList;
  43. GetListRect(hWnd, rectList);
  44. g_hWndList = CreateWindow(WC_LISTVIEW, TEXT("listL"), WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP | LVS_REPORT,
  45. rectList.left, rectList.top, rectList.right - rectList.left, rectList.bottom - rectList.top, hWnd, nullptr, hInstance, nullptr);
  46.  
  47. ShowWindow(hWnd, nCmdShow);
  48. UpdateWindow(hWnd);
  49.  
  50. return TRUE;
  51. }
  52.  
  53. LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  54. {
  55. switch (message)
  56. {
  57. case WM_COMMAND:
  58. {
  59. int wmId = LOWORD(wParam);
  60. // Parse the menu selections:
  61. switch (wmId)
  62. {
  63. case IDM_ABOUT:
  64. // Resize the window instead of showing "About" dialog
  65. //DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
  66. {
  67. RECT rect;
  68. GetWindowRect(hWnd, &rect);
  69. rect.left += 100;
  70. SetWindowPos(hWnd, nullptr, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOACTIVATE | SWP_NOZORDER);
  71. }
  72. break;
  73. }
  74. }
  75. break;
  76. case WM_WINDOWPOSCHANGED:
  77. {
  78. RECT rectList;
  79. GetListRect(hWnd, rectList);
  80. SetWindowPos(g_hWndList, nullptr, rectList.left, rectList.top, 0, 0, SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE);
  81. }
  82. break;
  83. }
  84. }
  85.  
  86. BOOL g_bExpandingShrinking = FALSE;
  87.  
  88. void OnCommandExpandShrinkWindow(HWND hWnd, BOOL bExpand)
  89. {
  90. RECT rect;
  91. GetWindowRect(hWnd, &rect);
  92. rect.left += bExpand ? -100 : 100;
  93. UINT nFlags = SWP_NOZORDER | SWP_NOACTIVATE;
  94. g_bExpandingShrinking = TRUE;
  95. SetWindowPos(hWnd, nullptr, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, nFlags);
  96. g_bExpandingShrinking = FALSE;
  97. }
  98.  
  99. LRESULT OnNcCalcSize(HWND hWnd, WPARAM wParam, LPARAM lParam)
  100. {
  101. NCCALCSIZE_PARAMS* lpncsp = reinterpret_cast<NCCALCSIZE_PARAMS*>(lParam);
  102. LRESULT res;
  103. if (wParam && g_bExpandingShrinking)
  104. {
  105. // let DefWindowProc calculate the new client rectangle
  106. res = DefWindowProc(hWnd, WM_NCCALCSIZE, wParam, lParam);
  107. // copy the content of the right list control
  108. GetWindowRect(g_hwndListRight, lpncsp->rgrc + 2);
  109. lpncsp->rgrc[1] = lpncsp->rgrc[2];
  110. res = WVR_VALIDRECTS;
  111. }
  112. else
  113. {
  114. res = DefWindowProc(hWnd, WM_NCCALCSIZE, wParam, lParam);
  115. }
  116. return res;
  117. }
Add Comment
Please, Sign In to add comment