2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
11 #include <afs/param.h>
15 #include <WINNT/afsapplib.h>
19 * RESIZING WINDOWS ___________________________________________________________
23 rwWindowData awdCover
[] = {
24 { IDC_COVER_BORDER
, raSizeX
| raSizeY
, 0, 0 },
25 { IDC_COVER_DESC
, raSizeX
| raSizeY
| raRepaint
, 0, 0 },
26 { IDC_COVER_BUTTON
, raMoveX
| raMoveY
| raRepaint
, 0, 0 },
27 { idENDLIST
, 0, 0, 0 }
30 #define WS_EX_HIDDENBYCOVER 0x10000000L
34 * DEFINITIONS ________________________________________________________________
38 #define dwCOVER_SIGNATURE 0xC0E0C0E0 // SetWindowLongPtr(hDlgCover,DWLP_USER,#)
40 typedef struct // COVERPARAMS
46 } COVERPARAMS
, *LPCOVERPARAMS
;
50 * PROTOTYPES _________________________________________________________________
54 void OnCoverWindow (WPARAM wp
, LPARAM lp
);
56 HRESULT CALLBACK
Cover_DialogProc (HWND hDlg
, UINT msg
, WPARAM wp
, LPARAM lp
);
60 * ROUTINES ___________________________________________________________________
64 void AfsAppLib_CoverClient (HWND hWnd
, LPTSTR pszDesc
, LPTSTR pszButton
)
66 AfsAppLib_Uncover (hWnd
);
68 LPCOVERPARAMS lpcp
= New (COVERPARAMS
);
72 lpcp
->pszDesc
= CloneString (pszDesc
);
73 lpcp
->pszButton
= CloneString (pszButton
);
75 if (!AfsAppLib_GetMainWindow())
76 OnCoverWindow (0, (LPARAM
)lpcp
);
78 PostMessage (AfsAppLib_GetMainWindow(), WM_COVER_WINDOW
, 0, (LPARAM
)lpcp
);
82 void AfsAppLib_CoverWindow (HWND hWnd
, LPTSTR pszDesc
, LPTSTR pszButton
)
84 AfsAppLib_Uncover (hWnd
);
86 LPCOVERPARAMS lpcp
= New (COVERPARAMS
);
88 lpcp
->fClient
= FALSE
;
90 lpcp
->pszDesc
= CloneString (pszDesc
);
91 lpcp
->pszButton
= CloneString (pszButton
);
93 if (!AfsAppLib_GetMainWindow())
94 OnCoverWindow (0, (LPARAM
)lpcp
);
96 PostMessage (AfsAppLib_GetMainWindow(), WM_COVER_WINDOW
, 0, (LPARAM
)lpcp
);
100 void AfsAppLib_Uncover (HWND hDlg
)
102 if (!AfsAppLib_GetMainWindow())
103 OnCoverWindow ((WPARAM
)hDlg
, 0);
105 PostMessage (AfsAppLib_GetMainWindow(), WM_COVER_WINDOW
, (WPARAM
)hDlg
, 0);
109 void OnCoverWindow (WPARAM wp
, LPARAM lp
)
112 if ((lpcp
= (LPCOVERPARAMS
)lp
) == NULL
)
114 HWND hDlg
= (HWND
)wp
;
116 if (!IsWindowVisible (hDlg
)) // did we create it as a sibling?
118 ShowWindow (hDlg
, TRUE
);
119 EnableWindow (hDlg
, TRUE
);
120 hDlg
= GetParent(hDlg
);
123 for (HWND hChild
= GetWindow (hDlg
, GW_CHILD
);
125 hChild
= GetWindow (hChild
, GW_HWNDNEXT
))
127 TCHAR szClassName
[ cchRESOURCE
];
129 if (GetClassName (hChild
, szClassName
, cchRESOURCE
))
131 if (!lstrcmp (szClassName
, TEXT("#32770"))) // WC_DIALOG
133 if (GetWindowLongPtr (hChild
, DWLP_USER
) == dwCOVER_SIGNATURE
)
135 DestroyWindow (hChild
);
144 HWND hCover
= ModelessDialogParam (IDD_APPLIB_COVER
,
145 (lpcp
->fClient
) ? lpcp
->hWnd
: GetParent(lpcp
->hWnd
),
146 (DLGPROC
)Cover_DialogProc
,
149 ShowWindow (hCover
, TRUE
);
150 SetWindowLongPtr (hCover
, DWLP_USER
, dwCOVER_SIGNATURE
);
152 FreeString (lpcp
->pszDesc
);
153 FreeString (lpcp
->pszButton
);
159 HRESULT CALLBACK
Cover_DialogProc (HWND hDlg
, UINT msg
, WPARAM wp
, LPARAM lp
)
165 lpcp
= (LPCOVERPARAMS
)lp
;
167 SetDlgItemText (hDlg
, IDC_COVER_DESC
, (lpcp
&& lpcp
->pszDesc
) ? lpcp
->pszDesc
: TEXT(""));
169 if (lpcp
&& lpcp
->pszButton
)
171 SetDlgItemText (hDlg
, IDC_COVER_BUTTON
, lpcp
->pszButton
);
175 DestroyWindow (GetDlgItem (hDlg
, IDC_COVER_BUTTON
));
181 // If we're covering a window's client area, we've been created
182 // as a child of that window. Hide its other children, and we'll
185 GetClientRect (lpcp
->hWnd
, &rCover
);
187 for (HWND hChild
= GetWindow (lpcp
->hWnd
, GW_CHILD
);
189 hChild
= GetWindow (hChild
, GW_HWNDNEXT
))
194 if (IsWindowVisible (hChild
))
196 LONG dwStyleEx
= GetWindowLong (hChild
, GWL_EXSTYLE
);
197 SetWindowLong (hChild
, GWL_EXSTYLE
, dwStyleEx
| WS_EX_HIDDENBYCOVER
);
198 ShowWindow (hChild
, FALSE
);
204 // If we're covering a window's complete area, we've been created
205 // as a sibling of that window. Hide that window.
207 GetRectInParent (lpcp
->hWnd
, &rCover
);
208 ShowWindow (lpcp
->hWnd
, FALSE
);
209 EnableWindow (lpcp
->hWnd
, FALSE
);
212 if (lpcp
&& lpcp
->pszButton
)
214 RECT rDesc
; // give the button's space to the Description window
216 GetRectInParent (GetDlgItem (hDlg
, IDC_COVER_DESC
), &rDesc
);
217 GetRectInParent (GetDlgItem (hDlg
, IDC_COVER_BUTTON
), &rButton
);
219 // If the window is higher than it is wide, put the description
220 // above the button. Otherwise, put it to the right of the button.
222 if (cyRECT(rCover
) > cxRECT(rCover
))
224 // shrink description vertically
225 SetWindowPos (GetDlgItem (hDlg
, IDC_COVER_DESC
), NULL
,
228 cyRECT(rDesc
) - rDesc
.bottom
+ rButton
.top
-5,
229 SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOMOVE
);
233 // shrink description horizontally
234 SetWindowPos (GetDlgItem (hDlg
, IDC_COVER_DESC
), NULL
,
236 cxRECT(rDesc
) - rDesc
.right
+ rButton
.left
-5,
238 SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOMOVE
);
242 ResizeWindow (hDlg
, awdCover
, rwaMoveToHere
, &rCover
);
246 // Show all of our parent's other children, in preparation for
250 for (hChild
= GetWindow (GetParent (hDlg
), GW_CHILD
);
252 hChild
= GetWindow (hChild
, GW_HWNDNEXT
))
257 LONG dwStyleEx
= GetWindowLong (hChild
, GWL_EXSTYLE
);
258 if (dwStyleEx
& WS_EX_HIDDENBYCOVER
)
260 SetWindowLong (hChild
, GWL_EXSTYLE
, dwStyleEx
& (~WS_EX_HIDDENBYCOVER
));
261 ShowWindow (hChild
, TRUE
);
267 // if (lp==0), we're minimizing--don't call ResizeWindow().
270 ResizeWindow (hDlg
, awdCover
, rwaFixupGuts
);
276 case IDC_COVER_BUTTON
:
277 PostMessage (GetParent(hDlg
), WM_COMMAND
, wp
, lp
);