Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This article helped me a lot: <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb773183%28v=vs.85%29.aspx" rel="nofollow noreferrer">Subclassing Controls</a></p> <p>First, I create a separate message processing function for processing child messages.</p> <pre><code>LRESULT CALLBACK MyClass::ChildWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) { static PAINTSTRUCT Ps; static RECT Rect; static HBRUSH hBrush1 = CreateSolidBrush(RGB(50,100,255)); static HBRUSH hBrush2 = CreateSolidBrush(RGB(255,100,50)); HDC hDc; LRESULT lResult; switch (uMsg) { case WM_PAINT: switch (uIdSubclass) { case 1: hDc = BeginPaint(hWnd, &amp;Ps); Rect.left = 0; Rect.right = (LONG) (((double) ITEM2_WIDTH) * Status::GI()-&gt;Get_JobCurPercentage()); Rect.top = 0; Rect.bottom = ITEM_HEIGHT - 3; FillRect(hDc, &amp;Rect, hBrush1); EndPaint(hWnd, &amp;Ps); break; case 2: hDc = BeginPaint(hWnd, &amp;Ps); Rect.left = 0; Rect.right = (LONG) (((double) ITEM2_WIDTH) * Status::GI()-&gt;Get_JobTotPercentage()); Rect.top = 0; Rect.bottom = ITEM_HEIGHT - 3; FillRect(hDc, &amp;Rect, hBrush2); EndPaint(hWnd, &amp;Ps); break; default: return DefSubclassProc(hWnd, uMsg, wParam, lParam); } break; case WM_NCDESTROY: //ReleaseDC(hWnd, hDc); return DefSubclassProc(hWnd, uMsg, wParam, lParam); break; default: return DefSubclassProc(hWnd, uMsg, wParam, lParam); } return 0; } </code></pre> <p>Next, I bind this function to the controls:</p> <pre><code>SetWindowSubclass( /*_In_ HWND hWnd*/ ed_cur_Progress.hWnd, /*_In_ SUBCLASSPROC pfnSubclass*/ ChildWindowProc, /*_In_ UINT_PTR uIdSubclass*/ 1, /*_In_ DWORD_PTR dwRefData*/ (DWORD_PTR) NULL); SetWindowSubclass( /*_In_ HWND hWnd*/ ed_tot_Progress.hWnd, /*_In_ SUBCLASSPROC pfnSubclass*/ ChildWindowProc, /*_In_ UINT_PTR uIdSubclass*/ 2, /*_In_ DWORD_PTR dwRefData*/ (DWORD_PTR) NULL); </code></pre> <p>And, that's all! The result is amazing.</p> <p><img src="https://i.stack.imgur.com/ksWnY.png" alt="appearance"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload