11 #include "svr_window.h"
12 #include "svr_general.h"
13 #include "svr_security.h"
14 #include "set_repprop.h"
15 #include "set_createrep.h"
16 #include "set_rename.h"
18 #include "propcache.h"
24 * RESIZING WINDOWS ___________________________________________________________
28 #define cxMIN_SERVER 75
29 #define cyMIN_SERVER 70
31 #define cxMIN_TABS 100
32 #define cyMIN_TABS 100
34 #define cxMIN_WINDOW_PREVIEW 220
35 #define cyMIN_WINDOW_PREVIEW 250
37 #define cxMIN_WINDOW 120
38 #define cyMIN_WINDOW 120
40 rwWindowData awdMain[] = {
41 { IDC_CELL_BORDER, raSizeX },
42 { IDC_CELL, raSizeX | raRepaint },
43 { IDC_AFS_ID, raSizeX | raRepaint },
44 { IDC_SERVERS, raSizeX | raSizeY, MAKELONG(cxMIN_SERVER,cyMIN_SERVER) },
45 { IDC_COVERDLG, raSizeX | raSizeY },
46 { IDC_ANIMATE, raMoveX },
50 rwWindowData awdMainVert[] = {
51 { IDC_CELL_BORDER, raSizeX },
52 { IDC_CELL, raSizeX | raRepaint },
53 { IDC_AFS_ID, raSizeX | raRepaint },
54 { IDC_SERVERS, raSizeX, MAKELONG(cxMIN_SERVER,cyMIN_SERVER) },
55 { IDC_SPLITTER_SERVER, raSizeX },
56 { IDC_TABS, raSizeX | raSizeY, MAKELONG(cxMIN_TABS,cyMIN_TABS) },
57 { IDC_COVERDLG, raSizeX },
58 { IDC_ANIMATE, raMoveX },
62 rwWindowData awdMainHorz[] = {
63 { IDC_CELL_BORDER, raSizeX },
64 { IDC_CELL, raSizeX | raRepaint },
65 { IDC_AFS_ID, raSizeX | raRepaint },
66 { IDC_SERVERS, raSizeY, MAKELONG(cxMIN_SERVER,cyMIN_SERVER) },
67 { IDC_SPLITTER_SERVER, raSizeY },
68 { IDC_TABS, raSizeX | raSizeY, MAKELONG(cxMIN_TABS,cyMIN_TABS) },
69 { IDC_COVERDLG, raSizeY },
70 { IDC_ANIMATE, raMoveX },
74 rwWindowData awdSplitServer[] = {
75 { IDC_CELL, raRepaint },
76 { IDC_AFS_ID, raRepaint },
77 { IDC_SERVERS, raSizeX | raSizeY, MAKELONG(cxMIN_SERVER,cyMIN_SERVER) },
78 { IDC_SPLITTER_SERVER, raMoveX | raMoveY },
79 { IDC_TABS, raMoveX | raMoveY | raSizeXB | raSizeYB, MAKELONG(cxMIN_TABS,cyMIN_TABS) },
80 { IDC_COVERDLG, raSizeX | raSizeY },
87 * PROTOTYPES _________________________________________________________________
91 void Main_OnNotifyFromDispatch (LPNOTIFYSTRUCT lpns);
93 void Main_OnPreviewPane (BOOL fPreviewNew, BOOL fVertNew, BOOL fStoreView);
94 void Main_OnServerView (int lvsNew);
95 DWORD WINAPI Main_OnOpenServers_ThreadProc (PVOID lp);
96 void Main_OnEndTask_Properties (LPTASKPACKET ptp);
98 void Main_SubclassServers (HWND hDlg);
100 void Main_CreateTabControl (void);
101 void Main_DeleteTabControl (void);
102 void Main_DisplayTab (CHILDTAB iTab);
103 void Main_RearrangeChildren (BOOL fSplitNew, BOOL fVertNew);
105 BOOL Main_HandleDialogKeys (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
106 void Main_OnKey_CtrlTab (BOOL fForward);
107 void Main_OnKey_Tab (BOOL fForward);
110 void ExportCell (void);
115 * ROUTINES ___________________________________________________________________
120 static BOOL fEnforceMinimumSize = TRUE;
121 static BOOL fNotifyChildrenForResize = TRUE;
122 static LONG nReqWorking = 0;
123 static int iFrameLast = 0;
125 BOOL CALLBACK Main_DialogProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
127 if (HandleColumnNotify (hDlg, msg, wp, lp, (gr.fPreview && !gr.fVert) ? &gr.diHorz.viewSvr : &gr.diVert.viewSvr))
130 if (Main_HandleDialogKeys (hDlg, msg, wp, lp))
133 if (msg == WM_INITDIALOG) // get this out of the way. :)
136 AfsAppLib_SetMainWindow (g.hMain);
143 LPRECT prTarget = (gr.fPreview) ? &gr.rMainPreview : &gr.rMain;
144 if (prTarget->right == 0)
145 GetWindowRect (g.hMain, prTarget);
146 ResizeWindow (g.hMain, awdMain, rwaMoveToHere, prTarget);
148 Main_SetActionMenus();
150 // Subclass the Servers window, so we can watch for focus changes
151 // and context-menu requests
153 Main_SubclassServers (hDlg);
154 FastList_SetTextCallback (GetDlgItem (hDlg, IDC_SERVERS), GetItemText, (DWORD)((gr.fPreview && !gr.fVert) ? &gr.diHorz.viewSvr : &gr.diVert.viewSvr));
156 // Create the preview pane and rearrange the children of this dialog.
157 // This also fixes the Servers display--was it in Large Icons view?
158 // What columns were shown?
160 Main_OnPreviewPane (gr.fPreview, gr.fVert, FALSE);
162 // Tell our notification dispatcher to let this window know whenever
163 // a cell gets opened or closed (that's what the NULL does--otherwise,
164 // an LPIDENT would go there to indicate we're interested in a
165 // particular server etc).
167 NotifyMe (WHEN_CELL_OPENED, NULL, hDlg, 0); // tell me about any cell
169 // If we weren't around when the cell was created, we might have
170 // missed some notifications. Send a redraw just in case.
172 StartThread (Main_Redraw_ThreadProc, FALSE);
174 SetTimer (hDlg, ID_DISPATCH_TIMER, 200, NULL); // do all notifications
179 KillTimer (hDlg, ID_DISPATCH_TIMER);
182 case WM_QUERYENDSESSION:
183 if (Action_fAnyActive())
185 ShowWindow (g.hMain, SW_SHOW);
186 if (Message (MB_ICONHAND | MB_YESNO, IDS_CANT_QUIT_TITLE, IDS_CANT_QUIT_REBOOT) != IDYES)
192 if (wp == ID_DISPATCH_TIMER)
194 DispatchNotification_OnPump();
199 if ((lp == 0) || (IsAncestor (g.hMain, (HWND)(((LPHELPINFO)lp)->hItemHandle))))
201 WinHelp (hDlg, cszHELPFILENAME, HELP_FINDER, 0);
205 case WM_NOTIFY_FROM_DISPATCH:
206 Main_OnNotifyFromDispatch ((LPNOTIFYSTRUCT)lp);
207 Delete ((LPNOTIFYSTRUCT)lp);
212 if ((ptp = (LPTASKPACKET)lp) != NULL)
214 if (ptp->idTask == taskSVR_GETWINDOWPOS)
215 Server_Open ((LPIDENT)(ptp->lpUser), &TASKDATA(ptp)->rWindow);
216 else if (ptp->idTask == taskSET_REPPROP_INIT)
217 Filesets_OnEndTask_ShowReplication (ptp);
218 else if (ptp->idTask == taskSET_RENAME_INIT)
219 Filesets_OnEndTask_ShowRename (ptp);
220 FreeTaskPacket (ptp);
224 case WM_OPEN_SERVERS:
225 StartThread (Main_OnOpenServers_ThreadProc, 0);
229 StartTask (taskSVR_GETWINDOWPOS, g.hMain, (LPIDENT)lp);
232 case WM_SHOW_CREATEREP_DIALOG:
233 Filesets_CreateReplica ((LPIDENT)wp, (LPIDENT)lp);
236 case WM_SHOW_YOURSELF:
239 ShowWindow (g.hMain, SW_SHOW);
240 BringWindowToTop (g.hMain);
241 Action_WindowToTop (TRUE);
245 case WM_OPEN_ACTIONS:
249 case WM_REFRESHED_CREDENTIALS:
250 g.hCreds = (PVOID)lp;
251 UpdateDisplay_Cell(FALSE);
252 StartTask (taskREFRESH_CREDS, NULL, g.lpiCell);
256 // if (lp==0), we're minimizing--don't call ResizeWindow().
258 Action_WindowToTop ((lp) ? TRUE : FALSE);
261 rwWindowData *pwdResizeInfo;
264 pwdResizeInfo = awdMain;
266 pwdResizeInfo = awdMainVert;
268 pwdResizeInfo = awdMainHorz;
270 if (fNotifyChildrenForResize)
271 ResizeWindow (hDlg, pwdResizeInfo, rwaFixupGuts);
273 ResizeWindow (hDlg, pwdResizeInfo, rwaJustResync);
278 Action_WindowToTop ((wp) ? TRUE : FALSE);
281 StartTask (taskEXPIRED_CREDS);
288 ptScreen.x = LOWORD(lp);
289 ptScreen.y = HIWORD(lp);
292 ScreenToClient ((HWND)wp, &ptClient);
294 if ((HWND)wp == GetDlgItem (g.hMain, IDC_SERVERS))
295 Server_ShowPopupMenu ((HWND)wp, ptClient, ptScreen);
308 Main_OnPreviewPane (FALSE, gr.fVert, TRUE);
309 UpdateDisplay_Servers (FALSE, NULL, 0);
312 Main_OnPreviewPane (TRUE, FALSE, TRUE);
313 UpdateDisplay_Servers (FALSE, NULL, 0);
316 Main_OnPreviewPane (TRUE, TRUE, TRUE);
317 UpdateDisplay_Servers (FALSE, NULL, 0);
320 case M_SVR_VIEW_LARGE:
321 Main_OnServerView (FLS_VIEW_LARGE);
323 case M_SVR_VIEW_SMALL:
324 Main_OnServerView (FLS_VIEW_SMALL);
326 case M_SVR_VIEW_REPORT:
327 Main_OnServerView (FLS_VIEW_LIST);
332 ShowColumnsDialog (hDlg, NULL);
335 CHILDTAB iTab = Server_GetDisplayedTab (g.hMain);
336 if (iTab == tabSERVICES)
337 ShowColumnsDialog (hDlg, &gr.viewSvc);
338 else if (iTab == tabAGGREGATES)
339 ShowColumnsDialog (hDlg, &gr.viewAgg);
340 else if (iTab == tabFILESETS)
341 ShowColumnsDialog (hDlg, &gr.viewSet);
343 ShowColumnsDialog (hDlg, NULL);
348 if ((gr.fActions = !gr.fActions) == TRUE)
351 Action_CloseWindow();
352 Main_SetActionMenus();
361 case IDC_COVER_BUTTON:
362 // The user must have clicked the "Try Again" or "Credentials"
363 // button on the cover we placed over the Servers list.
364 // Refresh the cell or obtain new credentials, as appropriate.
368 TCHAR szButton[ cchRESOURCE ];
369 GetWindowText ((HWND)lp, szButton, cchRESOURCE);
371 TCHAR szTest[ cchRESOURCE ];
373 GetString (szTest, IDS_ALERT_BUTTON_TRYAGAIN);
374 if (!lstrcmp (szTest, szButton))
376 StartTask (taskREFRESH, NULL, g.lpiCell);
380 GetString (szTest, IDS_ALERT_BUTTON_GETCREDS);
381 if (!lstrcmp (szTest, szButton))
390 StartContextCommand (g.hMain, NULL, NULL, LOWORD(wp));
396 switch (((LPNMHDR)lp)->code)
400 int iPage = TabCtrl_GetCurSel (GetDlgItem (g.hMain, IDC_TABS));
401 Main_DisplayTab ((CHILDTAB)iPage);
408 HWND hServers = GetDlgItem (hDlg, IDC_SERVERS);
409 LPIDENT lpi = (LPIDENT)FL_GetSelectedData (hServers);
411 Server_SelectServer (SERVERWINDOW_PREVIEWPANE, lpi);
417 HWND hServers = GetDlgItem (g.hMain, IDC_SERVERS);
419 if (((LPNMHDR)lp)->hwndFrom == hServers)
421 LPIDENT lpi = (LPIDENT)FL_GetSelectedData (hServers);
423 if (lpi && lpi->fIsServer())
427 if (gr.fDoubleClickOpens == 0)
429 else if (gr.fDoubleClickOpens == 1)
431 else if (gr.fPreview)
433 else // (!gr.Preview)
438 PostMessage (hServers, WM_COMMAND, M_PROPERTIES, 0);
440 else // (fOpenWindow)
442 PostMessage (g.hMain, WM_OPEN_SERVER, 0, (LPARAM)lpi);
456 void Main_OnNotifyFromDispatch (LPNOTIFYSTRUCT lpns)
461 StartTask (taskOPENEDCELL, NULL, lpns->Params.lpi1);
465 StartTask (taskCLOSEDCELL, NULL, lpns->Params.lpi1);
468 case evtRefreshStatusEnd:
469 case evtAlertsChanged:
470 if (lpns->Params.lpi1 && lpns->Params.lpi1->fIsCell())
472 UpdateDisplay_Cell (FALSE);
474 else if (lpns->Params.lpi1 && lpns->Params.lpi1->fIsServer())
476 UpdateDisplay_Servers (FALSE, lpns->Params.lpi1, lpns->Params.status);
480 case evtRefreshServersEnd:
481 if (g.lpiCell || lpns->Params.status == 0)
483 UpdateDisplay_Servers (FALSE, NULL, 0);
490 DWORD WINAPI Main_OnOpenServers_ThreadProc (PVOID lp)
494 if (g.lpiCell != NULL)
497 if ((lpCell = g.lpiCell->OpenCell()) != NULL)
500 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
503 if ((lpsp = (LPSERVER_PREF)lpServer->GetUserParam()) != NULL)
505 if (lpsp->fOpen && !PropCache_Search (pcSERVER, lpServer->GetIdentifier()))
507 PostMessage (g.hMain, WM_OPEN_SERVER, 0, (LPARAM)(lpServer->GetIdentifier()));
521 DWORD WINAPI Main_Redraw_ThreadProc (PVOID lp)
523 BOOL fInvalidate = (BOOL)lp;
526 if (g.lpiCell == NULL)
528 AfsAppLib_Uncover (GetDlgItem (g.hMain, IDC_SERVERS));
532 TCHAR szName[ cchRESOURCE ];
533 g.lpiCell->GetCellName (szName);
535 LPTSTR pszCover = FormatString (IDS_SEARCHING_FOR_SERVERS, TEXT("%s"), szName);
536 AfsAppLib_CoverWindow (GetDlgItem (g.hMain, IDC_SERVERS), pszCover);
537 FreeString (pszCover);
540 LPCELL lpCell = NULL;
541 if (g.lpiCell != NULL)
542 lpCell = g.lpiCell->OpenCell();
548 lpCell->Invalidate();
549 lpCell->RefreshAll();
553 lpCell->RefreshStatus();
554 lpCell->RefreshServers();
557 else // no cell is selected; we'll have to redraw the window directly.
559 UpdateDisplay_Cell (TRUE);
560 UpdateDisplay_Servers (TRUE, NULL, 0);
571 void Main_OnPreviewPane (BOOL fPreviewNew, BOOL fVertNew, BOOL fStoreCurrentView)
573 if (fStoreCurrentView)
575 if (gr.fPreview && !gr.fVert)
576 FL_StoreView (GetDlgItem (g.hMain, IDC_SERVERS), &gr.diHorz.viewSvr);
578 FL_StoreView (GetDlgItem (g.hMain, IDC_SERVERS), &gr.diVert.viewSvr);
581 GetWindowRect (g.hMain, &gr.rMainPreview);
583 GetWindowRect (g.hMain, &gr.rMain);
586 // If switching from having a preview pane to not (or vice-versa),
587 // and we have an alterate gr.rMain* to switch to, resize the window.
589 if (IsWindowVisible (g.hMain))
592 GetWindowRect (g.hMain, &rNow);
594 LPRECT prTarget = (fPreviewNew) ? &gr.rMainPreview : &gr.rMain;
595 if (prTarget->right == 0)
598 if (gr.fPreview && gr.fVert) // preview pane exists below main window?
601 GetWindowRect (GetDlgItem (g.hMain, IDC_TABS), &rPreview);
603 prTarget->bottom -= cyRECT(rPreview);
606 prTarget->right = prTarget->left + cxRECT(rNow); // keep the same width!
608 fEnforceMinimumSize = FALSE;
609 fNotifyChildrenForResize = FALSE;
611 SetWindowPos (g.hMain, NULL,
612 0, 0, cxRECT(*prTarget), cyRECT(*prTarget),
613 SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE);
615 fNotifyChildrenForResize = TRUE;
616 fEnforceMinimumSize = TRUE;
619 // Create a tab control if necessary, or remove it if it should be gone.
621 if (fPreviewNew && !GetDlgItem (g.hMain, IDC_TABS))
623 Main_CreateTabControl();
625 if (!fPreviewNew && GetDlgItem (g.hMain, IDC_TABS))
627 Main_DeleteTabControl();
630 // If there's a tab control, we'll need a splitter; if not, not.
632 if (GetDlgItem (g.hMain, IDC_SPLITTER_SERVER))
634 DeleteSplitter (g.hMain, IDC_SPLITTER_SERVER);
637 Main_RearrangeChildren (fPreviewNew, fVertNew);
641 CreateSplitter (g.hMain, IDC_SERVERS, IDC_TABS, IDC_SPLITTER_SERVER,
642 (fVertNew) ? &gr.diVert.cSplitter : &gr.diHorz.cSplitter,
647 if (GetDlgItem (g.hMain, IDC_TABS))
649 ShowWindow (GetDlgItem (g.hMain, IDC_TABS), SW_SHOW);
652 LPVIEWINFO lpvi = (fPreviewNew && !fVertNew) ? &gr.diHorz.viewSvr : &gr.diVert.viewSvr;
654 FL_RestoreView (GetDlgItem (g.hMain, IDC_SERVERS), lpvi);
656 CheckMenuRadioItem (GetMenu (g.hMain),
657 M_DIVIDE_NONE, M_DIVIDE_H,
658 ( (!fPreviewNew) ? M_DIVIDE_NONE :
659 (fVertNew) ? M_DIVIDE_V :
664 gr.fPreview = fPreviewNew;
666 Main_SetServerViewMenus();
670 void Main_OnServerView (int lvsNew)
672 HWND hServers = GetDlgItem (g.hMain, IDC_SERVERS);
674 if (gr.fPreview && !gr.fVert)
675 FL_StoreView (hServers, &gr.diHorz.viewSvr);
677 FL_StoreView (hServers, &gr.diVert.viewSvr);
679 if (gr.fPreview && !gr.fVert)
680 gr.diHorz.viewSvr.lvsView = lvsNew;
682 gr.diVert.viewSvr.lvsView = lvsNew;
684 if (gr.fPreview && !gr.fVert)
685 FL_RestoreView (hServers, &gr.diHorz.viewSvr);
687 FL_RestoreView (hServers, &gr.diVert.viewSvr);
689 Main_SetServerViewMenus();
690 FastList_SetTextCallback (GetDlgItem (g.hMain, IDC_SERVERS), GetItemText, (DWORD)((gr.fPreview && !gr.fVert) ? &gr.diHorz.viewSvr : &gr.diVert.viewSvr));
691 UpdateDisplay_Servers (FALSE, NULL, 0);
695 void Main_SetServerViewMenus (void)
699 if (gr.fPreview && !gr.fVert)
700 lvs = gr.diHorz.viewSvr.lvsView;
702 lvs = gr.diVert.viewSvr.lvsView;
704 CheckMenuRadioItem (GetMenu (g.hMain),
705 M_SVR_VIEW_LARGE, M_SVR_VIEW_REPORT,
706 ( (lvs == FLS_VIEW_SMALL) ? M_SVR_VIEW_SMALL :
707 (lvs == FLS_VIEW_LIST) ? M_SVR_VIEW_REPORT :
711 ICONVIEW ivSvr = Display_GetServerIconView();
713 CheckMenuRadioItem (GetMenu (g.hMain),
714 M_SVR_VIEW_ONEICON, M_SVR_VIEW_STATUS,
715 (ivSvr == ivTWOICONS) ? M_SVR_VIEW_TWOICONS :
716 (ivSvr == ivONEICON) ? M_SVR_VIEW_ONEICON : M_SVR_VIEW_STATUS,
719 EnableMenu (GetMenu (g.hMain), M_SVR_VIEW_ONEICON, (lvs == FLS_VIEW_LIST) ? TRUE : FALSE);
720 EnableMenu (GetMenu (g.hMain), M_SVR_VIEW_TWOICONS, (lvs == FLS_VIEW_LIST) ? TRUE : FALSE);
721 EnableMenu (GetMenu (g.hMain), M_SVR_VIEW_STATUS, (lvs == FLS_VIEW_LIST) ? TRUE : FALSE);
725 void Main_SetActionMenus (void)
727 CheckMenu (GetMenu (g.hMain), M_ACTIONS, gr.fActions);
731 void Main_CreateTabControl (void)
733 HWND hTab = CreateWindowEx (WS_EX_CLIENTEDGE,
736 WS_CHILD | WS_CLIPSIBLINGS | WS_TABSTOP,
737 0, 0, 128, 128, // arbitrary, but not too small
738 SERVERWINDOW_PREVIEWPANE,
745 HFONT hf = (HFONT)GetStockObject (DEFAULT_GUI_FONT);
746 SendMessage (hTab, WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE,0));
748 Server_PrepareTabControl (hTab);
750 LPIDENT lpi = (LPIDENT)FL_GetSelectedData (GetDlgItem (g.hMain, IDC_SERVERS));
751 Server_SelectServer (SERVERWINDOW_PREVIEWPANE, lpi);
756 void Main_DeleteTabControl (void)
758 if (GetDlgItem (SERVERWINDOW_PREVIEWPANE, IDC_TABS))
760 DestroyWindow (GetDlgItem (SERVERWINDOW_PREVIEWPANE, IDC_TABS));
765 void Main_DisplayTab (CHILDTAB iTab)
769 Server_DisplayTab (SERVERWINDOW_PREVIEWPANE, iTab);
770 gr.tabLast = (CHILDTAB)iTab;
775 void Main_RearrangeChildren (BOOL fPreviewNew, BOOL fVertNew)
780 // Start with the Servers window taking up the entire dialog's client area,
781 // leaving a space at the top for the cell combobox.
784 GetRectInParent (GetDlgItem (g.hMain, IDC_AFS_ID), &rCell);
786 GetClientRect (g.hMain, &rServers);
787 rServers.top = rCell.bottom +3;
789 // Then, if the preview tab is to be displayed, make the server window
790 // share the space equally with the tab control (vertically or horizontally)
798 rServers.bottom = rServers.top + cyRECT(rServers)/2 - 1;
799 rPreview.top = rServers.bottom + 2;
803 rServers.right = rServers.left + cxRECT(rServers)/2 - 1;
804 rPreview.left = rServers.right + 2;
807 // Adjust the server/tab windows for the Server splitter's position
811 LONG cyMod = gr.diVert.cSplitter;
813 if (cyRECT(rServers) > cyMIN_SERVER)
814 cyMod = min( cyMod, cyRECT(rServers)-cyMIN_SERVER );
815 if (cyRECT(rPreview) > cyMIN_TABS)
816 cyMod = min( cyMod, cyRECT(rPreview)-cyMIN_TABS );
818 rServers.bottom += cyMod;
819 rPreview.top += cyMod;
823 LONG cxMod = gr.diHorz.cSplitter;
825 if (cxRECT(rServers) > cxMIN_SERVER)
826 cxMod = min( cxMod, cxRECT(rServers)-cxMIN_SERVER );
827 if (cxRECT(rPreview) > cxMIN_TABS)
828 cxMod = min( cxMod, cxRECT(rPreview)-cxMIN_TABS );
830 rServers.right += cxMod;
831 rPreview.left += cxMod;
835 // Now move the children to their new places!
838 if (GetDlgItem (g.hMain, IDC_COVERDLG))
840 if (GetDlgItem (g.hMain, IDC_TABS))
842 HDWP dwp = BeginDeferWindowPos (nWindows);
844 DeferWindowPos (dwp, GetDlgItem (g.hMain, IDC_SERVERS), NULL,
845 rServers.left, rServers.top,
846 cxRECT(rServers), cyRECT(rServers),
847 SWP_NOACTIVATE | SWP_NOZORDER);
849 if (GetDlgItem (g.hMain, IDC_COVERDLG))
851 DeferWindowPos (dwp, GetDlgItem (g.hMain, IDC_COVERDLG), NULL,
852 rServers.left, rServers.top,
853 cxRECT(rServers), cyRECT(rServers),
854 SWP_NOACTIVATE | SWP_NOZORDER);
857 if (GetDlgItem (g.hMain, IDC_TABS))
859 DeferWindowPos (dwp, GetDlgItem (g.hMain, IDC_TABS), NULL,
860 rPreview.left, rPreview.top,
861 cxRECT(rPreview), cyRECT(rPreview),
862 SWP_NOACTIVATE | SWP_NOZORDER);
865 EndDeferWindowPos (dwp);
870 static LONG procServers = 0;
872 LRESULT CALLBACK Main_SubclassServersProc (HWND hServers, UINT msg, WPARAM wp, LPARAM lp)
876 if (procServers == 0)
877 rc = DefWindowProc (hServers, msg, wp, lp);
879 rc = CallWindowProc ((WNDPROC)procServers, hServers, msg, wp, lp);
884 if (procServers != 0)
885 SetWindowLong (hServers, GWL_WNDPROC, procServers);
891 case M_SVR_VIEW_LARGE:
892 case M_SVR_VIEW_SMALL:
893 case M_SVR_VIEW_REPORT:
894 SendMessage (g.hMain, msg, wp, lp);
898 case M_VIEW_TWOICONS:
900 SendMessage (g.hMain, msg, wp, lp);
904 ShowColumnsDialog (g.hMain, NULL);
908 StartContextCommand (g.hMain,
910 (LPIDENT)FL_GetSelectedData (hServers),
921 void Main_SubclassServers (HWND hDlg)
923 HWND hServers = GetDlgItem (hDlg, IDC_SERVERS);
924 procServers = GetWindowLong (hServers, GWL_WNDPROC);
925 SetWindowLong (hServers, GWL_WNDPROC, (LONG)Main_SubclassServersProc);
930 void ExportCell (void)
935 TCHAR szFilter[ cchRESOURCE ];
936 lstrcpy (szFilter, TEXT("Text File|*.TXT|"));
937 TCHAR chFilter = szFilter[ lstrlen(szFilter)-1 ];
938 for (LPTSTR pszFilter = szFilter;
939 (*pszFilter) && ((pszFilter = (LPTSTR)lstrchr (pszFilter, chFilter)) != NULL);
942 *pszFilter = TEXT('\0');
945 TCHAR szSaveAs[ MAX_PATH ] = TEXT("export");
948 memset (&sfn, 0x00, sizeof(sfn));
949 sfn.lStructSize = sizeof(sfn);
950 sfn.hwndOwner = g.hMain;
951 sfn.hInstance = THIS_HINST;
952 sfn.lpstrFilter = szFilter;
953 sfn.nFilterIndex = 1;
954 sfn.lpstrFile = szSaveAs;
955 sfn.nMaxFile = MAX_PATH;
956 sfn.Flags = OFN_HIDEREADONLY | OFN_NOREADONLYRETURN |
957 OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
958 sfn.lpstrDefExt = TEXT("txt");
960 if (GetSaveFileName (&sfn))
962 LPTSTR psz = CloneString (szSaveAs);
963 StartTask (taskEXPORTCELL, NULL, psz);
969 void Main_StartWorking (void)
971 if (InterlockedIncrement(&nReqWorking) == 1)
973 AfsAppLib_StartAnimation (GetDlgItem (g.hMain, IDC_ANIMATE));
977 void Main_StopWorking (void)
979 if (InterlockedDecrement(&nReqWorking) == 0)
981 AfsAppLib_StopAnimation (GetDlgItem (g.hMain, IDC_ANIMATE));
986 void Main_AnimateIcon (HWND hIcon, int *piFrameLast)
989 static HICON hiFrame[8];
990 static BOOL fLoaded = FALSE;
994 hiStop = TaLocale_LoadIcon (IDI_SPINSTOP);
995 hiFrame[0] = TaLocale_LoadIcon (IDI_SPIN1);
996 hiFrame[1] = TaLocale_LoadIcon (IDI_SPIN2);
997 hiFrame[2] = TaLocale_LoadIcon (IDI_SPIN3);
998 hiFrame[3] = TaLocale_LoadIcon (IDI_SPIN4);
999 hiFrame[4] = TaLocale_LoadIcon (IDI_SPIN5);
1000 hiFrame[5] = TaLocale_LoadIcon (IDI_SPIN6);
1001 hiFrame[6] = TaLocale_LoadIcon (IDI_SPIN7);
1002 hiFrame[7] = TaLocale_LoadIcon (IDI_SPIN8);
1008 *piFrameLast = (*piFrameLast == 7) ? 0 : (1+*piFrameLast);
1011 SendMessage (hIcon, STM_SETICON, (WPARAM)((piFrameLast) ? hiFrame[ *piFrameLast ] : hiStop), 0);
1015 BOOL Main_HandleDialogKeys (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
1017 if (msg == WM_COMMAND)
1022 Server_OnKey_Return();
1026 Main_OnKey_CtrlTab (TRUE);
1029 case M_KEY_CTRLBACKTAB:
1030 Main_OnKey_CtrlTab (FALSE);
1034 Main_OnKey_Tab (TRUE);
1038 Main_OnKey_Tab (FALSE);
1042 Server_OnKey_Menu();
1049 case M_KEY_PROPERTIES:
1050 Server_OnKey_Properties();
1059 void Main_OnKey_Tab (BOOL fForward)
1061 // The tab-cycle should go:
1062 // ServerList <-> TabsOnQuickViewPane <-> TabChildControls
1064 // If the quick-view pane isn't showing, there's nowhere to tab to.
1068 HWND hFocus = GetFocus();
1069 HWND hTabChild = GetTabChild (GetDlgItem (g.hMain, IDC_TABS));
1073 if (hFocus == GetDlgItem (g.hMain, IDC_SERVERS))
1075 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetDlgItem (g.hMain, IDC_TABS), TRUE);
1077 else if (hFocus == GetDlgItem (g.hMain, IDC_TABS))
1079 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetNextDlgTabItem (hTabChild, NULL, FALSE), TRUE);
1083 if (GetNextDlgTabItem (hTabChild, hFocus, FALSE) == GetNextDlgTabItem (hTabChild, NULL, FALSE))
1084 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetDlgItem (g.hMain, IDC_SERVERS), TRUE);
1086 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetNextDlgTabItem (hTabChild, hFocus, FALSE), TRUE);
1091 if (hFocus == GetDlgItem (g.hMain, IDC_SERVERS))
1093 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetLastDlgTabItem (hTabChild), TRUE);
1095 else if (hFocus == GetDlgItem (g.hMain, IDC_TABS))
1097 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetDlgItem (g.hMain, IDC_SERVERS), TRUE);
1101 if (hFocus == GetNextDlgTabItem (hTabChild, NULL, FALSE))
1102 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetDlgItem (g.hMain, IDC_TABS), TRUE);
1104 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetNextDlgTabItem (hTabChild, hFocus, TRUE), TRUE);
1111 void Main_OnKey_CtrlTab (BOOL fForward)
1115 Server_OnKey_CtrlTab (SERVERWINDOW_PREVIEWPANE, fForward);