update for HEAD-2003091401
[reactos.git] / lib / user32 / windows / winpos.c
1 /* $Id$
2  *
3  * COPYRIGHT:       See COPYING in the top level directory
4  * PROJECT:         ReactOS user32.dll
5  * FILE:            lib/user32/windows/window.c
6  * PURPOSE:         Window management
7  * PROGRAMMER:      Casper S. Hornstrup (chorns@users.sourceforge.net)
8  * UPDATE HISTORY:
9  *      06-06-2001  CSH  Created
10  */
11
12 /* INCLUDES ******************************************************************/
13
14 #include <windows.h>
15 #include <user32.h>
16 #include <window.h>
17 #include <user32/callback.h>
18 #include <user32/regcontrol.h>
19 #include <user32/wininternal.h>
20 #include <window.h>
21
22 #define NDEBUG
23 #include <debug.h>
24
25 /* FUNCTIONS *****************************************************************/
26
27 BOOL
28 WinPosShowIconTitle(HWND hWnd, BOOL bShow)
29 {
30     PINTERNALPOS lpPos = UserGetInternalPos(hWnd);
31   
32     if( lpPos)
33     {
34         HWND hWnd = lpPos->IconTitle;
35
36         if( !hWnd )
37           lpPos->IconTitle = hWnd = NULL; /*ICONTITLE_Create( pWnd );*/
38         if( bShow )
39         {
40           ULONG Style = GetWindowLongW(hWnd, GWL_STYLE);
41           if( !(Style & WS_VISIBLE) )
42             {
43               SendMessageA( hWnd, WM_SHOWWINDOW, TRUE, 0 );
44               SetWindowPos( hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
45                             SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW );
46             }
47         }
48         else ShowWindow( hWnd, SW_HIDE );
49     }
50     return FALSE;
51 }
52
53 UINT STDCALL
54 WinPosGetMinMaxInfo(HWND hWnd, POINT* MaxSize, POINT* MaxPos,
55                   POINT* MinTrack, POINT* MaxTrack)
56 {
57   MINMAXINFO MinMax;
58   INT XInc, YInc;
59   INTERNALPOS* Pos;
60   ULONG Style = GetWindowLongW(hWnd, GWL_STYLE);
61   ULONG ExStyle = GetWindowLongW(hWnd, GWL_EXSTYLE);
62
63   /* Get default values. */
64   MinMax.ptMaxSize.x = GetSystemMetrics(SM_CXSCREEN);
65   MinMax.ptMaxSize.y = GetSystemMetrics(SM_CYSCREEN);
66   MinMax.ptMinTrackSize.x = GetSystemMetrics(SM_CXMINTRACK);
67   MinMax.ptMinTrackSize.y = GetSystemMetrics(SM_CYMINTRACK);
68   MinMax.ptMaxTrackSize.x = GetSystemMetrics(SM_CXSCREEN);
69   MinMax.ptMaxTrackSize.y = GetSystemMetrics(SM_CYSCREEN);
70
71   if (UserHasDlgFrameStyle(Style, ExStyle))
72     {
73       XInc = GetSystemMetrics(SM_CXDLGFRAME);
74       YInc = GetSystemMetrics(SM_CYDLGFRAME);
75     }
76   else
77     {
78       XInc = YInc = 0;
79       if (UserHasThickFrameStyle(Style, ExStyle))
80         {
81           XInc += GetSystemMetrics(SM_CXFRAME);
82           YInc += GetSystemMetrics(SM_CYFRAME);
83         }
84       if (Style & WS_BORDER)
85         {
86           XInc += GetSystemMetrics(SM_CXBORDER);
87           YInc += GetSystemMetrics(SM_CYBORDER);
88         }
89     }
90   MinMax.ptMaxSize.x += 2 * XInc;
91   MinMax.ptMaxSize.y += 2 * YInc;
92
93   Pos = UserGetInternalPos(hWnd);
94   if (Pos != NULL)
95     {
96       MinMax.ptMaxPosition = Pos->MaxPos;
97     }
98   else
99     {
100       MinMax.ptMaxPosition.x -= XInc;
101       MinMax.ptMaxPosition.y -= YInc;
102     }
103
104   SendMessageW(hWnd, WM_GETMINMAXINFO, 0, (LPARAM)&MinMax);
105
106   MinMax.ptMaxTrackSize.x = max(MinMax.ptMaxTrackSize.x,
107                                 MinMax.ptMinTrackSize.x);
108   MinMax.ptMaxTrackSize.y = max(MinMax.ptMaxTrackSize.y,
109                                 MinMax.ptMinTrackSize.y);
110
111   if (MaxSize) *MaxSize = MinMax.ptMaxSize;
112   if (MaxPos) *MaxPos = MinMax.ptMaxPosition;
113   if (MinTrack) *MinTrack = MinMax.ptMinTrackSize;
114   if (MaxTrack) *MaxTrack = MinMax.ptMaxTrackSize;
115
116   return 0; //FIXME: what does it return?
117 }
118
119
120 /*
121  * @implemented
122  */
123 HWND STDCALL
124 GetActiveWindow(VOID)
125 {
126   return(NtUserGetActiveWindow());
127 }
128
129 /*
130  * @implemented
131  */
132 HWND STDCALL
133 SetActiveWindow(HWND hWnd)
134 {
135   return(NtUserSetActiveWindow(hWnd));
136 }
137