0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / WNT / WNT_WndProc.cxx
CommitLineData
7fd59977 1// include windows.h first to have all definitions available
2#include <windows.h>
3
4#include <WNT_Window.hxx>
5
6//***//
7//*** This window procedure provides management of the window background. ***//
8//*** Background belongs to the window class but we need that windows which ***//
9//*** are based on the same class have different backgrounds. So, we are ***//
10//*** using window subclassing technique to provide this ability. ***//
11//***//
12LRESULT CALLBACK WNT_WndProc (
13 HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam
14 ) {
15
16 HDC hDC;
17 HPALETTE hOldPal;
18 WNDPROC lpfnWndProc;
19 WINDOW_DATA* wd;
20 WNT_Window* win;
21 RECT invRect;
22
23 wd = (WINDOW_DATA* )GetWindowLongPtr (hwnd, GWLP_USERDATA);
24 win = (WNT_Window* )wd->WNT_Window_Ptr;
25 lpfnWndProc = (WNDPROC )win->WndProc();
26
27 if ( msg == WM_ERASEBKGND && !( wd -> dwFlags & WDF_NOERASEBKGRND ) ) {
28
29 hDC = ( HDC )wParam;
30
31 if ( wd -> hPal ) {
32
33 hOldPal = SelectPalette ( hDC, wd -> hPal, FALSE );
34
35 if ( RealizePalette ( hDC ) )
36
37 UpdateColors ( hDC );
38
39 } // end if
40
41 GetClipBox ( hDC, &invRect );
42 FillRect ( hDC, &invRect, ( HBRUSH )( win -> HBackground () ) );
43
44 if ( wd -> hPal )
45
46 SelectPalette ( hDC, hOldPal, FALSE );
47
48 return TRUE;
49
50 } else if ( msg == WM_MOVE ) {
51
52 WINDOWPLACEMENT wp;
53
54 wp.length = sizeof ( WINDOWPLACEMENT );
55 GetWindowPlacement ( hwnd, &wp );
56
57 win -> SetPos (
58 wp.rcNormalPosition.left, wp.rcNormalPosition.top,
59 wp.rcNormalPosition.right, wp.rcNormalPosition.bottom
60 );
61
62 } // end else
63
64 return CallWindowProc ( lpfnWndProc, hwnd, msg, wParam, lParam );
65
66} // end WNT_WndProc
67//***//