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
14 #include <afs/param.h>
23 #include "svr_window.h"
24 #include "svr_general.h"
25 #include "svr_security.h"
26 #include "set_repprop.h"
27 #include "set_createrep.h"
28 #include "set_rename.h"
30 #include "propcache.h"
36 * RESIZING WINDOWS ___________________________________________________________
40 #define cxMIN_SERVER 75
41 #define cyMIN_SERVER 70
43 #define cxMIN_TABS 100
44 #define cyMIN_TABS 100
46 #define cxMIN_WINDOW_PREVIEW 220
47 #define cyMIN_WINDOW_PREVIEW 250
49 #define cxMIN_WINDOW 120
50 #define cyMIN_WINDOW 120
52 rwWindowData awdMain
[] = {
53 { IDC_CELL_BORDER
, raSizeX
, 0, 0 },
54 { IDC_CELL
, raSizeX
| raRepaint
, 0, 0 },
55 { IDC_AFS_ID
, raSizeX
| raRepaint
, 0, 0 },
56 { IDC_SERVERS
, raSizeX
| raSizeY
, MAKELONG(cxMIN_SERVER
,cyMIN_SERVER
), 0 },
57 { IDC_COVERDLG
, raSizeX
| raSizeY
, 0, 0 },
58 { IDC_ANIMATE
, raMoveX
, 0, 0 },
59 { idENDLIST
, 0, 0, 0 }
62 rwWindowData awdMainVert
[] = {
63 { IDC_CELL_BORDER
, raSizeX
, 0, 0 },
64 { IDC_CELL
, raSizeX
| raRepaint
, 0, 0 },
65 { IDC_AFS_ID
, raSizeX
| raRepaint
, 0, 0 },
66 { IDC_SERVERS
, raSizeX
, MAKELONG(cxMIN_SERVER
,cyMIN_SERVER
), 0 },
67 { IDC_SPLITTER_SERVER
, raSizeX
, 0, 0 },
68 { IDC_TABS
, raSizeX
| raSizeY
, MAKELONG(cxMIN_TABS
,cyMIN_TABS
), 0 },
69 { IDC_COVERDLG
, raSizeX
, 0, 0 },
70 { IDC_ANIMATE
, raMoveX
, 0, 0 },
71 { idENDLIST
, 0, 0, 0 }
74 rwWindowData awdMainHorz
[] = {
75 { IDC_CELL_BORDER
, raSizeX
, 0, 0 },
76 { IDC_CELL
, raSizeX
| raRepaint
, 0, 0 },
77 { IDC_AFS_ID
, raSizeX
| raRepaint
, 0, 0 },
78 { IDC_SERVERS
, raSizeY
, MAKELONG(cxMIN_SERVER
,cyMIN_SERVER
), 0 },
79 { IDC_SPLITTER_SERVER
, raSizeY
, 0, 0 },
80 { IDC_TABS
, raSizeX
| raSizeY
, MAKELONG(cxMIN_TABS
,cyMIN_TABS
), 0 },
81 { IDC_COVERDLG
, raSizeY
, 0, 0 },
82 { IDC_ANIMATE
, raMoveX
, 0, 0 },
83 { idENDLIST
, 0, 0, 0 }
86 rwWindowData awdSplitServer
[] = {
87 { IDC_CELL
, raRepaint
, 0, 0 },
88 { IDC_AFS_ID
, raRepaint
, 0, 0 },
89 { IDC_SERVERS
, raSizeX
| raSizeY
, MAKELONG(cxMIN_SERVER
,cyMIN_SERVER
), 0 },
90 { IDC_SPLITTER_SERVER
, raMoveX
| raMoveY
, 0, 0 },
91 { IDC_TABS
, raMoveX
| raMoveY
| raSizeXB
| raSizeYB
, MAKELONG(cxMIN_TABS
,cyMIN_TABS
), 0 },
92 { IDC_COVERDLG
, raSizeX
| raSizeY
, 0, 0 },
93 { IDC_ANIMATE
, 0, 0, 0 },
94 { idENDLIST
, 0, 0, 0 }
99 * PROTOTYPES _________________________________________________________________
103 void Main_OnNotifyFromDispatch (LPNOTIFYSTRUCT lpns
);
105 void Main_OnPreviewPane (BOOL fPreviewNew
, BOOL fVertNew
, BOOL fStoreView
);
106 DWORD WINAPI
Main_OnOpenServers_ThreadProc (PVOID lp
);
108 void Main_SubclassServers (HWND hDlg
);
110 void Main_CreateTabControl (void);
111 void Main_DeleteTabControl (void);
112 void Main_DisplayTab (CHILDTAB iTab
);
113 void Main_RearrangeChildren (BOOL fSplitNew
, BOOL fVertNew
);
115 BOOL
Main_HandleDialogKeys (HWND hDlg
, UINT msg
, WPARAM wp
, LPARAM lp
);
116 void Main_OnKey_CtrlTab (BOOL fForward
);
117 void Main_OnKey_Tab (BOOL fForward
);
120 void ExportCell (void);
125 * ROUTINES ___________________________________________________________________
130 static BOOL fEnforceMinimumSize
= TRUE
;
131 static BOOL fNotifyChildrenForResize
= TRUE
;
132 static LONG nReqWorking
= 0;
133 static int iFrameLast
= 0;
135 BOOL CALLBACK
Main_DialogProc (HWND hDlg
, UINT msg
, WPARAM wp
, LPARAM lp
)
137 if (HandleColumnNotify (hDlg
, msg
, wp
, lp
, (gr
.fPreview
&& !gr
.fVert
) ? &gr
.diHorz
.viewSvr
: &gr
.diVert
.viewSvr
))
140 if (Main_HandleDialogKeys (hDlg
, msg
, wp
, lp
))
143 if (msg
== WM_INITDIALOG
) // get this out of the way. :)
146 AfsAppLib_SetMainWindow (g
.hMain
);
153 LPRECT prTarget
= (gr
.fPreview
) ? &gr
.rMainPreview
: &gr
.rMain
;
154 if (prTarget
->right
== 0)
155 GetWindowRect (g
.hMain
, prTarget
);
156 ResizeWindow (g
.hMain
, awdMain
, rwaMoveToHere
, prTarget
);
158 Main_SetActionMenus();
160 // Subclass the Servers window, so we can watch for focus changes
161 // and context-menu requests
163 Main_SubclassServers (hDlg
);
164 FastList_SetTextCallback (GetDlgItem (hDlg
, IDC_SERVERS
), GetItemText
, ((gr
.fPreview
&& !gr
.fVert
) ? &gr
.diHorz
.viewSvr
: &gr
.diVert
.viewSvr
));
166 // Create the preview pane and rearrange the children of this dialog.
167 // This also fixes the Servers display--was it in Large Icons view?
168 // What columns were shown?
170 Main_OnPreviewPane (gr
.fPreview
, gr
.fVert
, FALSE
);
172 // Tell our notification dispatcher to let this window know whenever
173 // a cell gets opened or closed (that's what the NULL does--otherwise,
174 // an LPIDENT would go there to indicate we're interested in a
175 // particular server etc).
177 NotifyMe (WHEN_CELL_OPENED
, NULL
, hDlg
, 0); // tell me about any cell
179 // If we weren't around when the cell was created, we might have
180 // missed some notifications. Send a redraw just in case.
182 StartThread (Main_Redraw_ThreadProc
, FALSE
);
184 SetTimer (hDlg
, ID_DISPATCH_TIMER
, 200, NULL
); // do all notifications
189 KillTimer (hDlg
, ID_DISPATCH_TIMER
);
192 case WM_QUERYENDSESSION
:
193 if (Action_fAnyActive())
195 ShowWindow (g
.hMain
, SW_SHOW
);
196 if (Message (MB_ICONHAND
| MB_YESNO
, IDS_CANT_QUIT_TITLE
, IDS_CANT_QUIT_REBOOT
) != IDYES
)
202 if (wp
== ID_DISPATCH_TIMER
)
204 DispatchNotification_OnPump();
209 if ((lp
== 0) || (IsAncestor (g
.hMain
, (HWND
)(((LPHELPINFO
)lp
)->hItemHandle
))))
211 WinHelp (hDlg
, cszHELPFILENAME
, HELP_FINDER
, 0);
215 case WM_NOTIFY_FROM_DISPATCH
:
216 Main_OnNotifyFromDispatch ((LPNOTIFYSTRUCT
)lp
);
217 Delete ((LPNOTIFYSTRUCT
)lp
);
222 if ((ptp
= (LPTASKPACKET
)lp
) != NULL
)
224 if (ptp
->idTask
== taskSVR_GETWINDOWPOS
)
225 Server_Open ((LPIDENT
)(ptp
->lpUser
), &TASKDATA(ptp
)->rWindow
);
226 else if (ptp
->idTask
== taskSET_REPPROP_INIT
)
227 Filesets_OnEndTask_ShowReplication (ptp
);
228 else if (ptp
->idTask
== taskSET_RENAME_INIT
)
229 Filesets_OnEndTask_ShowRename (ptp
);
230 FreeTaskPacket (ptp
);
234 case WM_OPEN_SERVERS
:
235 StartThread (Main_OnOpenServers_ThreadProc
, 0);
239 StartTask (taskSVR_GETWINDOWPOS
, g
.hMain
, (LPIDENT
)lp
);
242 case WM_SHOW_CREATEREP_DIALOG
:
243 Filesets_CreateReplica ((LPIDENT
)wp
, (LPIDENT
)lp
);
246 case WM_SHOW_YOURSELF
:
249 ShowWindow (g
.hMain
, SW_SHOW
);
250 BringWindowToTop (g
.hMain
);
251 Action_WindowToTop (TRUE
);
255 case WM_OPEN_ACTIONS
:
259 case WM_REFRESHED_CREDENTIALS
:
260 g
.hCreds
= (UINT_PTR
)lp
;
261 UpdateDisplay_Cell(FALSE
);
262 StartTask (taskREFRESH_CREDS
, NULL
, g
.lpiCell
);
266 // if (lp==0), we're minimizing--don't call ResizeWindow().
268 Action_WindowToTop ((lp
) ? TRUE
: FALSE
);
271 rwWindowData
*pwdResizeInfo
;
274 pwdResizeInfo
= awdMain
;
276 pwdResizeInfo
= awdMainVert
;
278 pwdResizeInfo
= awdMainHorz
;
280 if (fNotifyChildrenForResize
)
281 ResizeWindow (hDlg
, pwdResizeInfo
, rwaFixupGuts
);
283 ResizeWindow (hDlg
, pwdResizeInfo
, rwaJustResync
);
288 Action_WindowToTop ((wp
) ? TRUE
: FALSE
);
291 StartTask (taskEXPIRED_CREDS
);
298 ptScreen
.x
= LOWORD(lp
);
299 ptScreen
.y
= HIWORD(lp
);
302 ScreenToClient ((HWND
)wp
, &ptClient
);
304 if ((HWND
)wp
== GetDlgItem (g
.hMain
, IDC_SERVERS
))
305 Server_ShowPopupMenu ((HWND
)wp
, ptClient
, ptScreen
);
318 Main_OnPreviewPane (FALSE
, gr
.fVert
, TRUE
);
319 UpdateDisplay_Servers (FALSE
, NULL
, 0);
322 Main_OnPreviewPane (TRUE
, FALSE
, TRUE
);
323 UpdateDisplay_Servers (FALSE
, NULL
, 0);
326 Main_OnPreviewPane (TRUE
, TRUE
, TRUE
);
327 UpdateDisplay_Servers (FALSE
, NULL
, 0);
330 case M_SVR_VIEW_LARGE
:
331 Main_OnServerView (FLS_VIEW_LARGE
);
333 case M_SVR_VIEW_SMALL
:
334 Main_OnServerView (FLS_VIEW_SMALL
);
336 case M_SVR_VIEW_REPORT
:
337 Main_OnServerView (FLS_VIEW_LIST
);
342 ShowColumnsDialog (hDlg
, NULL
);
345 CHILDTAB iTab
= Server_GetDisplayedTab (g
.hMain
);
346 if (iTab
== tabSERVICES
)
347 ShowColumnsDialog (hDlg
, &gr
.viewSvc
);
348 else if (iTab
== tabAGGREGATES
)
349 ShowColumnsDialog (hDlg
, &gr
.viewAgg
);
350 else if (iTab
== tabFILESETS
)
351 ShowColumnsDialog (hDlg
, &gr
.viewSet
);
353 ShowColumnsDialog (hDlg
, NULL
);
358 if ((gr
.fActions
= !gr
.fActions
) == TRUE
)
361 Action_CloseWindow();
362 Main_SetActionMenus();
371 case IDC_COVER_BUTTON
:
372 // The user must have clicked the "Try Again" or "Credentials"
373 // button on the cover we placed over the Servers list.
374 // Refresh the cell or obtain new credentials, as appropriate.
378 TCHAR szButton
[ cchRESOURCE
];
379 GetWindowText ((HWND
)lp
, szButton
, cchRESOURCE
);
381 TCHAR szTest
[ cchRESOURCE
];
383 GetString (szTest
, IDS_ALERT_BUTTON_TRYAGAIN
);
384 if (!lstrcmp (szTest
, szButton
))
386 StartTask (taskREFRESH
, NULL
, g
.lpiCell
);
390 GetString (szTest
, IDS_ALERT_BUTTON_GETCREDS
);
391 if (!lstrcmp (szTest
, szButton
))
400 StartContextCommand (g
.hMain
, NULL
, NULL
, LOWORD(wp
));
406 switch (((LPNMHDR
)lp
)->code
)
410 int iPage
= TabCtrl_GetCurSel (GetDlgItem (g
.hMain
, IDC_TABS
));
411 Main_DisplayTab ((CHILDTAB
)iPage
);
418 HWND hServers
= GetDlgItem (hDlg
, IDC_SERVERS
);
419 LPIDENT lpi
= (LPIDENT
)FL_GetSelectedData (hServers
);
421 Server_SelectServer (SERVERWINDOW_PREVIEWPANE
, lpi
);
427 HWND hServers
= GetDlgItem (g
.hMain
, IDC_SERVERS
);
429 if (((LPNMHDR
)lp
)->hwndFrom
== hServers
)
431 LPIDENT lpi
= (LPIDENT
)FL_GetSelectedData (hServers
);
433 if (lpi
&& lpi
->fIsServer())
437 if (gr
.fDoubleClickOpens
== 0)
439 else if (gr
.fDoubleClickOpens
== 1)
441 else if (gr
.fPreview
)
443 else // (!gr.Preview)
448 PostMessage (hServers
, WM_COMMAND
, M_PROPERTIES
, 0);
450 else // (fOpenWindow)
452 PostMessage (g
.hMain
, WM_OPEN_SERVER
, 0, (LPARAM
)lpi
);
466 void Main_OnNotifyFromDispatch (LPNOTIFYSTRUCT lpns
)
471 StartTask (taskOPENEDCELL
, NULL
, lpns
->Params
.lpi1
);
475 StartTask (taskCLOSEDCELL
, NULL
, lpns
->Params
.lpi1
);
478 case evtRefreshStatusEnd
:
479 case evtAlertsChanged
:
480 if (lpns
->Params
.lpi1
&& lpns
->Params
.lpi1
->fIsCell())
482 UpdateDisplay_Cell (FALSE
);
484 else if (lpns
->Params
.lpi1
&& lpns
->Params
.lpi1
->fIsServer())
486 UpdateDisplay_Servers (FALSE
, lpns
->Params
.lpi1
, lpns
->Params
.status
);
490 case evtRefreshServersEnd
:
491 if (g
.lpiCell
|| lpns
->Params
.status
== 0)
493 UpdateDisplay_Servers (FALSE
, NULL
, 0);
500 DWORD WINAPI
Main_OnOpenServers_ThreadProc (PVOID lp
)
504 if (g
.lpiCell
!= NULL
)
507 if ((lpCell
= g
.lpiCell
->OpenCell()) != NULL
)
510 for (LPSERVER lpServer
= lpCell
->ServerFindFirst (&hEnum
); lpServer
; lpServer
= lpCell
->ServerFindNext (&hEnum
))
513 if ((lpsp
= (LPSERVER_PREF
)lpServer
->GetUserParam()) != NULL
)
515 if (lpsp
->fOpen
&& !PropCache_Search (pcSERVER
, lpServer
->GetIdentifier()))
517 PostMessage (g
.hMain
, WM_OPEN_SERVER
, 0, (LPARAM
)(lpServer
->GetIdentifier()));
531 DWORD WINAPI
Main_Redraw_ThreadProc (PVOID lp
)
533 BOOL fInvalidate
= (BOOL
)(UINT_PTR
)lp
;
536 if (g
.lpiCell
== NULL
)
538 AfsAppLib_Uncover (GetDlgItem (g
.hMain
, IDC_SERVERS
));
542 TCHAR szName
[ cchRESOURCE
];
543 g
.lpiCell
->GetCellName (szName
);
545 LPTSTR pszCover
= FormatString (IDS_SEARCHING_FOR_SERVERS
, TEXT("%s"), szName
);
546 AfsAppLib_CoverWindow (GetDlgItem (g
.hMain
, IDC_SERVERS
), pszCover
);
547 FreeString (pszCover
);
550 LPCELL lpCell
= NULL
;
551 if (g
.lpiCell
!= NULL
)
552 lpCell
= g
.lpiCell
->OpenCell();
558 lpCell
->Invalidate();
559 lpCell
->RefreshAll();
563 lpCell
->RefreshStatus();
564 lpCell
->RefreshServers();
567 else // no cell is selected; we'll have to redraw the window directly.
569 UpdateDisplay_Cell (TRUE
);
570 UpdateDisplay_Servers (TRUE
, NULL
, 0);
581 void Main_OnPreviewPane (BOOL fPreviewNew
, BOOL fVertNew
, BOOL fStoreCurrentView
)
583 if (fStoreCurrentView
)
585 if (gr
.fPreview
&& !gr
.fVert
)
586 FL_StoreView (GetDlgItem (g
.hMain
, IDC_SERVERS
), &gr
.diHorz
.viewSvr
);
588 FL_StoreView (GetDlgItem (g
.hMain
, IDC_SERVERS
), &gr
.diVert
.viewSvr
);
591 GetWindowRect (g
.hMain
, &gr
.rMainPreview
);
593 GetWindowRect (g
.hMain
, &gr
.rMain
);
596 // If switching from having a preview pane to not (or vice-versa),
597 // and we have an alterate gr.rMain* to switch to, resize the window.
599 if (IsWindowVisible (g
.hMain
))
602 GetWindowRect (g
.hMain
, &rNow
);
604 LPRECT prTarget
= (fPreviewNew
) ? &gr
.rMainPreview
: &gr
.rMain
;
605 if (prTarget
->right
== 0)
608 if (gr
.fPreview
&& gr
.fVert
) // preview pane exists below main window?
611 GetWindowRect (GetDlgItem (g
.hMain
, IDC_TABS
), &rPreview
);
613 prTarget
->bottom
-= cyRECT(rPreview
);
616 prTarget
->right
= prTarget
->left
+ cxRECT(rNow
); // keep the same width!
618 fEnforceMinimumSize
= FALSE
;
619 fNotifyChildrenForResize
= FALSE
;
621 SetWindowPos (g
.hMain
, NULL
,
622 0, 0, cxRECT(*prTarget
), cyRECT(*prTarget
),
623 SWP_NOZORDER
| SWP_NOACTIVATE
| SWP_NOMOVE
);
625 fNotifyChildrenForResize
= TRUE
;
626 fEnforceMinimumSize
= TRUE
;
629 // Create a tab control if necessary, or remove it if it should be gone.
631 if (fPreviewNew
&& !GetDlgItem (g
.hMain
, IDC_TABS
))
633 Main_CreateTabControl();
635 if (!fPreviewNew
&& GetDlgItem (g
.hMain
, IDC_TABS
))
637 Main_DeleteTabControl();
640 // If there's a tab control, we'll need a splitter; if not, not.
642 if (GetDlgItem (g
.hMain
, IDC_SPLITTER_SERVER
))
644 DeleteSplitter (g
.hMain
, IDC_SPLITTER_SERVER
);
647 Main_RearrangeChildren (fPreviewNew
, fVertNew
);
651 CreateSplitter (g
.hMain
, IDC_SERVERS
, IDC_TABS
, IDC_SPLITTER_SERVER
,
652 (fVertNew
) ? &gr
.diVert
.cSplitter
: &gr
.diHorz
.cSplitter
,
657 if (GetDlgItem (g
.hMain
, IDC_TABS
))
659 ShowWindow (GetDlgItem (g
.hMain
, IDC_TABS
), SW_SHOW
);
662 LPVIEWINFO lpvi
= (fPreviewNew
&& !fVertNew
) ? &gr
.diHorz
.viewSvr
: &gr
.diVert
.viewSvr
;
664 FL_RestoreView (GetDlgItem (g
.hMain
, IDC_SERVERS
), lpvi
);
666 CheckMenuRadioItem (GetMenu (g
.hMain
),
667 M_DIVIDE_NONE
, M_DIVIDE_H
,
668 ( (!fPreviewNew
) ? M_DIVIDE_NONE
:
669 (fVertNew
) ? M_DIVIDE_V
:
674 gr
.fPreview
= fPreviewNew
;
676 Main_SetServerViewMenus();
680 void Main_OnServerView (int lvsNew
)
682 HWND hServers
= GetDlgItem (g
.hMain
, IDC_SERVERS
);
684 if (gr
.fPreview
&& !gr
.fVert
)
685 FL_StoreView (hServers
, &gr
.diHorz
.viewSvr
);
687 FL_StoreView (hServers
, &gr
.diVert
.viewSvr
);
689 if (gr
.fPreview
&& !gr
.fVert
)
690 gr
.diHorz
.viewSvr
.lvsView
= lvsNew
;
692 gr
.diVert
.viewSvr
.lvsView
= lvsNew
;
694 if (gr
.fPreview
&& !gr
.fVert
)
695 FL_RestoreView (hServers
, &gr
.diHorz
.viewSvr
);
697 FL_RestoreView (hServers
, &gr
.diVert
.viewSvr
);
699 Main_SetServerViewMenus();
700 FastList_SetTextCallback (GetDlgItem (g
.hMain
, IDC_SERVERS
), GetItemText
, ((gr
.fPreview
&& !gr
.fVert
) ? &gr
.diHorz
.viewSvr
: &gr
.diVert
.viewSvr
));
701 UpdateDisplay_Servers (FALSE
, NULL
, 0);
705 void Main_SetServerViewMenus (void)
709 if (gr
.fPreview
&& !gr
.fVert
)
710 lvs
= gr
.diHorz
.viewSvr
.lvsView
;
712 lvs
= gr
.diVert
.viewSvr
.lvsView
;
714 CheckMenuRadioItem (GetMenu (g
.hMain
),
715 M_SVR_VIEW_LARGE
, M_SVR_VIEW_REPORT
,
716 ( (lvs
== FLS_VIEW_SMALL
) ? M_SVR_VIEW_SMALL
:
717 (lvs
== FLS_VIEW_LIST
) ? M_SVR_VIEW_REPORT
:
721 ICONVIEW ivSvr
= Display_GetServerIconView();
723 CheckMenuRadioItem (GetMenu (g
.hMain
),
724 M_SVR_VIEW_ONEICON
, M_SVR_VIEW_STATUS
,
725 (ivSvr
== ivTWOICONS
) ? M_SVR_VIEW_TWOICONS
:
726 (ivSvr
== ivONEICON
) ? M_SVR_VIEW_ONEICON
: M_SVR_VIEW_STATUS
,
729 EnableMenu (GetMenu (g
.hMain
), M_SVR_VIEW_ONEICON
, (lvs
== FLS_VIEW_LIST
) ? TRUE
: FALSE
);
730 EnableMenu (GetMenu (g
.hMain
), M_SVR_VIEW_TWOICONS
, (lvs
== FLS_VIEW_LIST
) ? TRUE
: FALSE
);
731 EnableMenu (GetMenu (g
.hMain
), M_SVR_VIEW_STATUS
, (lvs
== FLS_VIEW_LIST
) ? TRUE
: FALSE
);
735 void Main_SetActionMenus (void)
737 CheckMenu (GetMenu (g
.hMain
), M_ACTIONS
, gr
.fActions
);
741 void Main_CreateTabControl (void)
743 HWND hTab
= CreateWindowEx (WS_EX_CLIENTEDGE
,
746 WS_CHILD
| WS_CLIPSIBLINGS
| WS_TABSTOP
,
747 0, 0, 128, 128, // arbitrary, but not too small
748 SERVERWINDOW_PREVIEWPANE
,
755 HFONT hf
= (HFONT
)GetStockObject (DEFAULT_GUI_FONT
);
756 SendMessage (hTab
, WM_SETFONT
, (WPARAM
)hf
, MAKELPARAM(TRUE
,0));
758 Server_PrepareTabControl (hTab
);
760 LPIDENT lpi
= (LPIDENT
)FL_GetSelectedData (GetDlgItem (g
.hMain
, IDC_SERVERS
));
761 Server_SelectServer (SERVERWINDOW_PREVIEWPANE
, lpi
);
766 void Main_DeleteTabControl (void)
768 if (GetDlgItem (SERVERWINDOW_PREVIEWPANE
, IDC_TABS
))
770 DestroyWindow (GetDlgItem (SERVERWINDOW_PREVIEWPANE
, IDC_TABS
));
775 void Main_DisplayTab (CHILDTAB iTab
)
779 Server_DisplayTab (SERVERWINDOW_PREVIEWPANE
, iTab
);
780 gr
.tabLast
= (CHILDTAB
)iTab
;
785 void Main_RearrangeChildren (BOOL fPreviewNew
, BOOL fVertNew
)
790 // Start with the Servers window taking up the entire dialog's client area,
791 // leaving a space at the top for the cell combobox.
794 GetRectInParent (GetDlgItem (g
.hMain
, IDC_AFS_ID
), &rCell
);
796 GetClientRect (g
.hMain
, &rServers
);
797 rServers
.top
= rCell
.bottom
+3;
799 // Then, if the preview tab is to be displayed, make the server window
800 // share the space equally with the tab control (vertically or horizontally)
808 rServers
.bottom
= rServers
.top
+ cyRECT(rServers
)/2 - 1;
809 rPreview
.top
= rServers
.bottom
+ 2;
813 rServers
.right
= rServers
.left
+ cxRECT(rServers
)/2 - 1;
814 rPreview
.left
= rServers
.right
+ 2;
817 // Adjust the server/tab windows for the Server splitter's position
821 LONG cyMod
= gr
.diVert
.cSplitter
;
823 if (cyRECT(rServers
) > cyMIN_SERVER
)
824 cyMod
= min( cyMod
, cyRECT(rServers
)-cyMIN_SERVER
);
825 if (cyRECT(rPreview
) > cyMIN_TABS
)
826 cyMod
= min( cyMod
, cyRECT(rPreview
)-cyMIN_TABS
);
828 rServers
.bottom
+= cyMod
;
829 rPreview
.top
+= cyMod
;
833 LONG cxMod
= gr
.diHorz
.cSplitter
;
835 if (cxRECT(rServers
) > cxMIN_SERVER
)
836 cxMod
= min( cxMod
, cxRECT(rServers
)-cxMIN_SERVER
);
837 if (cxRECT(rPreview
) > cxMIN_TABS
)
838 cxMod
= min( cxMod
, cxRECT(rPreview
)-cxMIN_TABS
);
840 rServers
.right
+= cxMod
;
841 rPreview
.left
+= cxMod
;
845 // Now move the children to their new places!
848 if (GetDlgItem (g
.hMain
, IDC_COVERDLG
))
850 if (GetDlgItem (g
.hMain
, IDC_TABS
))
852 HDWP dwp
= BeginDeferWindowPos (nWindows
);
854 DeferWindowPos (dwp
, GetDlgItem (g
.hMain
, IDC_SERVERS
), NULL
,
855 rServers
.left
, rServers
.top
,
856 cxRECT(rServers
), cyRECT(rServers
),
857 SWP_NOACTIVATE
| SWP_NOZORDER
);
859 if (GetDlgItem (g
.hMain
, IDC_COVERDLG
))
861 DeferWindowPos (dwp
, GetDlgItem (g
.hMain
, IDC_COVERDLG
), NULL
,
862 rServers
.left
, rServers
.top
,
863 cxRECT(rServers
), cyRECT(rServers
),
864 SWP_NOACTIVATE
| SWP_NOZORDER
);
867 if (GetDlgItem (g
.hMain
, IDC_TABS
))
869 DeferWindowPos (dwp
, GetDlgItem (g
.hMain
, IDC_TABS
), NULL
,
870 rPreview
.left
, rPreview
.top
,
871 cxRECT(rPreview
), cyRECT(rPreview
),
872 SWP_NOACTIVATE
| SWP_NOZORDER
);
875 EndDeferWindowPos (dwp
);
880 static LONG_PTR procServers
= 0;
882 LRESULT CALLBACK
Main_SubclassServersProc (HWND hServers
, UINT msg
, WPARAM wp
, LPARAM lp
)
886 if (procServers
== 0)
887 rc
= DefWindowProc (hServers
, msg
, wp
, lp
);
889 rc
= (LRESULT
) CallWindowProc ((WNDPROC
)procServers
, hServers
, msg
, wp
, lp
);
894 if (procServers
!= 0)
895 SetWindowLongPtr (hServers
, GWLP_WNDPROC
, procServers
);
901 case M_SVR_VIEW_LARGE
:
902 case M_SVR_VIEW_SMALL
:
903 case M_SVR_VIEW_REPORT
:
904 SendMessage (g
.hMain
, msg
, wp
, lp
);
908 case M_VIEW_TWOICONS
:
910 SendMessage (g
.hMain
, msg
, wp
, lp
);
914 ShowColumnsDialog (g
.hMain
, NULL
);
918 StartContextCommand (g
.hMain
,
920 (LPIDENT
)FL_GetSelectedData (hServers
),
931 void Main_SubclassServers (HWND hDlg
)
933 HWND hServers
= GetDlgItem (hDlg
, IDC_SERVERS
);
934 procServers
= GetWindowLongPtr (hServers
, GWLP_WNDPROC
);
935 SetWindowLongPtr (hServers
, GWLP_WNDPROC
, (LONG_PTR
)Main_SubclassServersProc
);
940 void ExportCell (void)
945 TCHAR szFilter
[ cchRESOURCE
];
946 lstrcpy (szFilter
, TEXT("Text File|*.TXT|"));
947 TCHAR chFilter
= szFilter
[ lstrlen(szFilter
)-1 ];
948 for (LPTSTR pszFilter
= szFilter
;
949 (*pszFilter
) && ((pszFilter
= (LPTSTR
)lstrchr (pszFilter
, chFilter
)) != NULL
);
952 *pszFilter
= TEXT('\0');
955 TCHAR szSaveAs
[ MAX_PATH
] = TEXT("export");
958 memset (&sfn
, 0x00, sizeof(sfn
));
959 sfn
.lStructSize
= sizeof(sfn
);
960 sfn
.hwndOwner
= g
.hMain
;
961 sfn
.hInstance
= THIS_HINST
;
962 sfn
.lpstrFilter
= szFilter
;
963 sfn
.nFilterIndex
= 1;
964 sfn
.lpstrFile
= szSaveAs
;
965 sfn
.nMaxFile
= MAX_PATH
;
966 sfn
.Flags
= OFN_HIDEREADONLY
| OFN_NOREADONLYRETURN
|
967 OFN_OVERWRITEPROMPT
| OFN_PATHMUSTEXIST
;
968 sfn
.lpstrDefExt
= TEXT("txt");
970 if (GetSaveFileName (&sfn
))
972 LPTSTR psz
= CloneString (szSaveAs
);
973 StartTask (taskEXPORTCELL
, NULL
, psz
);
979 void Main_StartWorking (void)
981 if (InterlockedIncrement(&nReqWorking
) == 1)
983 AfsAppLib_StartAnimation (GetDlgItem (g
.hMain
, IDC_ANIMATE
));
987 void Main_StopWorking (void)
989 if (InterlockedDecrement(&nReqWorking
) == 0)
991 AfsAppLib_StopAnimation (GetDlgItem (g
.hMain
, IDC_ANIMATE
));
996 void Main_AnimateIcon (HWND hIcon
, int *piFrameLast
)
999 static HICON hiFrame
[8];
1000 static BOOL fLoaded
= FALSE
;
1004 hiStop
= TaLocale_LoadIcon (IDI_SPINSTOP
);
1005 hiFrame
[0] = TaLocale_LoadIcon (IDI_SPIN1
);
1006 hiFrame
[1] = TaLocale_LoadIcon (IDI_SPIN2
);
1007 hiFrame
[2] = TaLocale_LoadIcon (IDI_SPIN3
);
1008 hiFrame
[3] = TaLocale_LoadIcon (IDI_SPIN4
);
1009 hiFrame
[4] = TaLocale_LoadIcon (IDI_SPIN5
);
1010 hiFrame
[5] = TaLocale_LoadIcon (IDI_SPIN6
);
1011 hiFrame
[6] = TaLocale_LoadIcon (IDI_SPIN7
);
1012 hiFrame
[7] = TaLocale_LoadIcon (IDI_SPIN8
);
1018 *piFrameLast
= (*piFrameLast
== 7) ? 0 : (1+*piFrameLast
);
1021 SendMessage (hIcon
, STM_SETICON
, (WPARAM
)((piFrameLast
) ? hiFrame
[ *piFrameLast
] : hiStop
), 0);
1025 BOOL
Main_HandleDialogKeys (HWND hDlg
, UINT msg
, WPARAM wp
, LPARAM lp
)
1027 if (msg
== WM_COMMAND
)
1032 Server_OnKey_Return();
1036 Main_OnKey_CtrlTab (TRUE
);
1039 case M_KEY_CTRLBACKTAB
:
1040 Main_OnKey_CtrlTab (FALSE
);
1044 Main_OnKey_Tab (TRUE
);
1048 Main_OnKey_Tab (FALSE
);
1052 Server_OnKey_Menu();
1059 case M_KEY_PROPERTIES
:
1060 Server_OnKey_Properties();
1069 void Main_OnKey_Tab (BOOL fForward
)
1071 // The tab-cycle should go:
1072 // ServerList <-> TabsOnQuickViewPane <-> TabChildControls
1074 // If the quick-view pane isn't showing, there's nowhere to tab to.
1078 HWND hFocus
= GetFocus();
1079 HWND hTabChild
= GetTabChild (GetDlgItem (g
.hMain
, IDC_TABS
));
1083 if (hFocus
== GetDlgItem (g
.hMain
, IDC_SERVERS
))
1085 PostMessage (g
.hMain
, WM_NEXTDLGCTL
, (WPARAM
)GetDlgItem (g
.hMain
, IDC_TABS
), TRUE
);
1087 else if (hFocus
== GetDlgItem (g
.hMain
, IDC_TABS
))
1089 PostMessage (g
.hMain
, WM_NEXTDLGCTL
, (WPARAM
)GetNextDlgTabItem (hTabChild
, NULL
, FALSE
), TRUE
);
1093 if (GetNextDlgTabItem (hTabChild
, hFocus
, FALSE
) == GetNextDlgTabItem (hTabChild
, NULL
, FALSE
))
1094 PostMessage (g
.hMain
, WM_NEXTDLGCTL
, (WPARAM
)GetDlgItem (g
.hMain
, IDC_SERVERS
), TRUE
);
1096 PostMessage (g
.hMain
, WM_NEXTDLGCTL
, (WPARAM
)GetNextDlgTabItem (hTabChild
, hFocus
, FALSE
), TRUE
);
1101 if (hFocus
== GetDlgItem (g
.hMain
, IDC_SERVERS
))
1103 PostMessage (g
.hMain
, WM_NEXTDLGCTL
, (WPARAM
)GetLastDlgTabItem (hTabChild
), TRUE
);
1105 else if (hFocus
== GetDlgItem (g
.hMain
, IDC_TABS
))
1107 PostMessage (g
.hMain
, WM_NEXTDLGCTL
, (WPARAM
)GetDlgItem (g
.hMain
, IDC_SERVERS
), TRUE
);
1111 if (hFocus
== GetNextDlgTabItem (hTabChild
, NULL
, FALSE
))
1112 PostMessage (g
.hMain
, WM_NEXTDLGCTL
, (WPARAM
)GetDlgItem (g
.hMain
, IDC_TABS
), TRUE
);
1114 PostMessage (g
.hMain
, WM_NEXTDLGCTL
, (WPARAM
)GetNextDlgTabItem (hTabChild
, hFocus
, TRUE
), TRUE
);
1121 void Main_OnKey_CtrlTab (BOOL fForward
)
1125 Server_OnKey_CtrlTab (SERVERWINDOW_PREVIEWPANE
, fForward
);