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>
20 #include "svr_window.h"
21 #include "svr_general.h"
22 #include "svr_security.h"
23 #include "set_repprop.h"
24 #include "set_createrep.h"
25 #include "set_rename.h"
27 #include "propcache.h"
33 * RESIZING WINDOWS ___________________________________________________________
37 #define cxMIN_SERVER 75
38 #define cyMIN_SERVER 70
40 #define cxMIN_TABS 100
41 #define cyMIN_TABS 100
43 #define cxMIN_WINDOW_PREVIEW 220
44 #define cyMIN_WINDOW_PREVIEW 250
46 #define cxMIN_WINDOW 120
47 #define cyMIN_WINDOW 120
49 rwWindowData awdMain[] = {
50 { IDC_CELL_BORDER, raSizeX },
51 { IDC_CELL, raSizeX | raRepaint },
52 { IDC_AFS_ID, raSizeX | raRepaint },
53 { IDC_SERVERS, raSizeX | raSizeY, MAKELONG(cxMIN_SERVER,cyMIN_SERVER) },
54 { IDC_COVERDLG, raSizeX | raSizeY },
55 { IDC_ANIMATE, raMoveX },
59 rwWindowData awdMainVert[] = {
60 { IDC_CELL_BORDER, raSizeX },
61 { IDC_CELL, raSizeX | raRepaint },
62 { IDC_AFS_ID, raSizeX | raRepaint },
63 { IDC_SERVERS, raSizeX, MAKELONG(cxMIN_SERVER,cyMIN_SERVER) },
64 { IDC_SPLITTER_SERVER, raSizeX },
65 { IDC_TABS, raSizeX | raSizeY, MAKELONG(cxMIN_TABS,cyMIN_TABS) },
66 { IDC_COVERDLG, raSizeX },
67 { IDC_ANIMATE, raMoveX },
71 rwWindowData awdMainHorz[] = {
72 { IDC_CELL_BORDER, raSizeX },
73 { IDC_CELL, raSizeX | raRepaint },
74 { IDC_AFS_ID, raSizeX | raRepaint },
75 { IDC_SERVERS, raSizeY, MAKELONG(cxMIN_SERVER,cyMIN_SERVER) },
76 { IDC_SPLITTER_SERVER, raSizeY },
77 { IDC_TABS, raSizeX | raSizeY, MAKELONG(cxMIN_TABS,cyMIN_TABS) },
78 { IDC_COVERDLG, raSizeY },
79 { IDC_ANIMATE, raMoveX },
83 rwWindowData awdSplitServer[] = {
84 { IDC_CELL, raRepaint },
85 { IDC_AFS_ID, raRepaint },
86 { IDC_SERVERS, raSizeX | raSizeY, MAKELONG(cxMIN_SERVER,cyMIN_SERVER) },
87 { IDC_SPLITTER_SERVER, raMoveX | raMoveY },
88 { IDC_TABS, raMoveX | raMoveY | raSizeXB | raSizeYB, MAKELONG(cxMIN_TABS,cyMIN_TABS) },
89 { IDC_COVERDLG, raSizeX | raSizeY },
96 * PROTOTYPES _________________________________________________________________
100 void Main_OnNotifyFromDispatch (LPNOTIFYSTRUCT lpns);
102 void Main_OnPreviewPane (BOOL fPreviewNew, BOOL fVertNew, BOOL fStoreView);
103 void Main_OnServerView (int lvsNew);
104 DWORD WINAPI Main_OnOpenServers_ThreadProc (PVOID lp);
105 void Main_OnEndTask_Properties (LPTASKPACKET ptp);
107 void Main_SubclassServers (HWND hDlg);
109 void Main_CreateTabControl (void);
110 void Main_DeleteTabControl (void);
111 void Main_DisplayTab (CHILDTAB iTab);
112 void Main_RearrangeChildren (BOOL fSplitNew, BOOL fVertNew);
114 BOOL Main_HandleDialogKeys (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp);
115 void Main_OnKey_CtrlTab (BOOL fForward);
116 void Main_OnKey_Tab (BOOL fForward);
119 void ExportCell (void);
124 * ROUTINES ___________________________________________________________________
129 static BOOL fEnforceMinimumSize = TRUE;
130 static BOOL fNotifyChildrenForResize = TRUE;
131 static LONG nReqWorking = 0;
132 static int iFrameLast = 0;
134 BOOL CALLBACK Main_DialogProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
136 if (HandleColumnNotify (hDlg, msg, wp, lp, (gr.fPreview && !gr.fVert) ? &gr.diHorz.viewSvr : &gr.diVert.viewSvr))
139 if (Main_HandleDialogKeys (hDlg, msg, wp, lp))
142 if (msg == WM_INITDIALOG) // get this out of the way. :)
145 AfsAppLib_SetMainWindow (g.hMain);
152 LPRECT prTarget = (gr.fPreview) ? &gr.rMainPreview : &gr.rMain;
153 if (prTarget->right == 0)
154 GetWindowRect (g.hMain, prTarget);
155 ResizeWindow (g.hMain, awdMain, rwaMoveToHere, prTarget);
157 Main_SetActionMenus();
159 // Subclass the Servers window, so we can watch for focus changes
160 // and context-menu requests
162 Main_SubclassServers (hDlg);
163 FastList_SetTextCallback (GetDlgItem (hDlg, IDC_SERVERS), GetItemText, (DWORD)((gr.fPreview && !gr.fVert) ? &gr.diHorz.viewSvr : &gr.diVert.viewSvr));
165 // Create the preview pane and rearrange the children of this dialog.
166 // This also fixes the Servers display--was it in Large Icons view?
167 // What columns were shown?
169 Main_OnPreviewPane (gr.fPreview, gr.fVert, FALSE);
171 // Tell our notification dispatcher to let this window know whenever
172 // a cell gets opened or closed (that's what the NULL does--otherwise,
173 // an LPIDENT would go there to indicate we're interested in a
174 // particular server etc).
176 NotifyMe (WHEN_CELL_OPENED, NULL, hDlg, 0); // tell me about any cell
178 // If we weren't around when the cell was created, we might have
179 // missed some notifications. Send a redraw just in case.
181 StartThread (Main_Redraw_ThreadProc, FALSE);
183 SetTimer (hDlg, ID_DISPATCH_TIMER, 200, NULL); // do all notifications
188 KillTimer (hDlg, ID_DISPATCH_TIMER);
191 case WM_QUERYENDSESSION:
192 if (Action_fAnyActive())
194 ShowWindow (g.hMain, SW_SHOW);
195 if (Message (MB_ICONHAND | MB_YESNO, IDS_CANT_QUIT_TITLE, IDS_CANT_QUIT_REBOOT) != IDYES)
201 if (wp == ID_DISPATCH_TIMER)
203 DispatchNotification_OnPump();
208 if ((lp == 0) || (IsAncestor (g.hMain, (HWND)(((LPHELPINFO)lp)->hItemHandle))))
210 WinHelp (hDlg, cszHELPFILENAME, HELP_FINDER, 0);
214 case WM_NOTIFY_FROM_DISPATCH:
215 Main_OnNotifyFromDispatch ((LPNOTIFYSTRUCT)lp);
216 Delete ((LPNOTIFYSTRUCT)lp);
221 if ((ptp = (LPTASKPACKET)lp) != NULL)
223 if (ptp->idTask == taskSVR_GETWINDOWPOS)
224 Server_Open ((LPIDENT)(ptp->lpUser), &TASKDATA(ptp)->rWindow);
225 else if (ptp->idTask == taskSET_REPPROP_INIT)
226 Filesets_OnEndTask_ShowReplication (ptp);
227 else if (ptp->idTask == taskSET_RENAME_INIT)
228 Filesets_OnEndTask_ShowRename (ptp);
229 FreeTaskPacket (ptp);
233 case WM_OPEN_SERVERS:
234 StartThread (Main_OnOpenServers_ThreadProc, 0);
238 StartTask (taskSVR_GETWINDOWPOS, g.hMain, (LPIDENT)lp);
241 case WM_SHOW_CREATEREP_DIALOG:
242 Filesets_CreateReplica ((LPIDENT)wp, (LPIDENT)lp);
245 case WM_SHOW_YOURSELF:
248 ShowWindow (g.hMain, SW_SHOW);
249 BringWindowToTop (g.hMain);
250 Action_WindowToTop (TRUE);
254 case WM_OPEN_ACTIONS:
258 case WM_REFRESHED_CREDENTIALS:
259 g.hCreds = (PVOID)lp;
260 UpdateDisplay_Cell(FALSE);
261 StartTask (taskREFRESH_CREDS, NULL, g.lpiCell);
265 // if (lp==0), we're minimizing--don't call ResizeWindow().
267 Action_WindowToTop ((lp) ? TRUE : FALSE);
270 rwWindowData *pwdResizeInfo;
273 pwdResizeInfo = awdMain;
275 pwdResizeInfo = awdMainVert;
277 pwdResizeInfo = awdMainHorz;
279 if (fNotifyChildrenForResize)
280 ResizeWindow (hDlg, pwdResizeInfo, rwaFixupGuts);
282 ResizeWindow (hDlg, pwdResizeInfo, rwaJustResync);
287 Action_WindowToTop ((wp) ? TRUE : FALSE);
290 StartTask (taskEXPIRED_CREDS);
297 ptScreen.x = LOWORD(lp);
298 ptScreen.y = HIWORD(lp);
301 ScreenToClient ((HWND)wp, &ptClient);
303 if ((HWND)wp == GetDlgItem (g.hMain, IDC_SERVERS))
304 Server_ShowPopupMenu ((HWND)wp, ptClient, ptScreen);
317 Main_OnPreviewPane (FALSE, gr.fVert, TRUE);
318 UpdateDisplay_Servers (FALSE, NULL, 0);
321 Main_OnPreviewPane (TRUE, FALSE, TRUE);
322 UpdateDisplay_Servers (FALSE, NULL, 0);
325 Main_OnPreviewPane (TRUE, TRUE, TRUE);
326 UpdateDisplay_Servers (FALSE, NULL, 0);
329 case M_SVR_VIEW_LARGE:
330 Main_OnServerView (FLS_VIEW_LARGE);
332 case M_SVR_VIEW_SMALL:
333 Main_OnServerView (FLS_VIEW_SMALL);
335 case M_SVR_VIEW_REPORT:
336 Main_OnServerView (FLS_VIEW_LIST);
341 ShowColumnsDialog (hDlg, NULL);
344 CHILDTAB iTab = Server_GetDisplayedTab (g.hMain);
345 if (iTab == tabSERVICES)
346 ShowColumnsDialog (hDlg, &gr.viewSvc);
347 else if (iTab == tabAGGREGATES)
348 ShowColumnsDialog (hDlg, &gr.viewAgg);
349 else if (iTab == tabFILESETS)
350 ShowColumnsDialog (hDlg, &gr.viewSet);
352 ShowColumnsDialog (hDlg, NULL);
357 if ((gr.fActions = !gr.fActions) == TRUE)
360 Action_CloseWindow();
361 Main_SetActionMenus();
370 case IDC_COVER_BUTTON:
371 // The user must have clicked the "Try Again" or "Credentials"
372 // button on the cover we placed over the Servers list.
373 // Refresh the cell or obtain new credentials, as appropriate.
377 TCHAR szButton[ cchRESOURCE ];
378 GetWindowText ((HWND)lp, szButton, cchRESOURCE);
380 TCHAR szTest[ cchRESOURCE ];
382 GetString (szTest, IDS_ALERT_BUTTON_TRYAGAIN);
383 if (!lstrcmp (szTest, szButton))
385 StartTask (taskREFRESH, NULL, g.lpiCell);
389 GetString (szTest, IDS_ALERT_BUTTON_GETCREDS);
390 if (!lstrcmp (szTest, szButton))
399 StartContextCommand (g.hMain, NULL, NULL, LOWORD(wp));
405 switch (((LPNMHDR)lp)->code)
409 int iPage = TabCtrl_GetCurSel (GetDlgItem (g.hMain, IDC_TABS));
410 Main_DisplayTab ((CHILDTAB)iPage);
417 HWND hServers = GetDlgItem (hDlg, IDC_SERVERS);
418 LPIDENT lpi = (LPIDENT)FL_GetSelectedData (hServers);
420 Server_SelectServer (SERVERWINDOW_PREVIEWPANE, lpi);
426 HWND hServers = GetDlgItem (g.hMain, IDC_SERVERS);
428 if (((LPNMHDR)lp)->hwndFrom == hServers)
430 LPIDENT lpi = (LPIDENT)FL_GetSelectedData (hServers);
432 if (lpi && lpi->fIsServer())
436 if (gr.fDoubleClickOpens == 0)
438 else if (gr.fDoubleClickOpens == 1)
440 else if (gr.fPreview)
442 else // (!gr.Preview)
447 PostMessage (hServers, WM_COMMAND, M_PROPERTIES, 0);
449 else // (fOpenWindow)
451 PostMessage (g.hMain, WM_OPEN_SERVER, 0, (LPARAM)lpi);
465 void Main_OnNotifyFromDispatch (LPNOTIFYSTRUCT lpns)
470 StartTask (taskOPENEDCELL, NULL, lpns->Params.lpi1);
474 StartTask (taskCLOSEDCELL, NULL, lpns->Params.lpi1);
477 case evtRefreshStatusEnd:
478 case evtAlertsChanged:
479 if (lpns->Params.lpi1 && lpns->Params.lpi1->fIsCell())
481 UpdateDisplay_Cell (FALSE);
483 else if (lpns->Params.lpi1 && lpns->Params.lpi1->fIsServer())
485 UpdateDisplay_Servers (FALSE, lpns->Params.lpi1, lpns->Params.status);
489 case evtRefreshServersEnd:
490 if (g.lpiCell || lpns->Params.status == 0)
492 UpdateDisplay_Servers (FALSE, NULL, 0);
499 DWORD WINAPI Main_OnOpenServers_ThreadProc (PVOID lp)
503 if (g.lpiCell != NULL)
506 if ((lpCell = g.lpiCell->OpenCell()) != NULL)
509 for (LPSERVER lpServer = lpCell->ServerFindFirst (&hEnum); lpServer; lpServer = lpCell->ServerFindNext (&hEnum))
512 if ((lpsp = (LPSERVER_PREF)lpServer->GetUserParam()) != NULL)
514 if (lpsp->fOpen && !PropCache_Search (pcSERVER, lpServer->GetIdentifier()))
516 PostMessage (g.hMain, WM_OPEN_SERVER, 0, (LPARAM)(lpServer->GetIdentifier()));
530 DWORD WINAPI Main_Redraw_ThreadProc (PVOID lp)
532 BOOL fInvalidate = (BOOL)lp;
535 if (g.lpiCell == NULL)
537 AfsAppLib_Uncover (GetDlgItem (g.hMain, IDC_SERVERS));
541 TCHAR szName[ cchRESOURCE ];
542 g.lpiCell->GetCellName (szName);
544 LPTSTR pszCover = FormatString (IDS_SEARCHING_FOR_SERVERS, TEXT("%s"), szName);
545 AfsAppLib_CoverWindow (GetDlgItem (g.hMain, IDC_SERVERS), pszCover);
546 FreeString (pszCover);
549 LPCELL lpCell = NULL;
550 if (g.lpiCell != NULL)
551 lpCell = g.lpiCell->OpenCell();
557 lpCell->Invalidate();
558 lpCell->RefreshAll();
562 lpCell->RefreshStatus();
563 lpCell->RefreshServers();
566 else // no cell is selected; we'll have to redraw the window directly.
568 UpdateDisplay_Cell (TRUE);
569 UpdateDisplay_Servers (TRUE, NULL, 0);
580 void Main_OnPreviewPane (BOOL fPreviewNew, BOOL fVertNew, BOOL fStoreCurrentView)
582 if (fStoreCurrentView)
584 if (gr.fPreview && !gr.fVert)
585 FL_StoreView (GetDlgItem (g.hMain, IDC_SERVERS), &gr.diHorz.viewSvr);
587 FL_StoreView (GetDlgItem (g.hMain, IDC_SERVERS), &gr.diVert.viewSvr);
590 GetWindowRect (g.hMain, &gr.rMainPreview);
592 GetWindowRect (g.hMain, &gr.rMain);
595 // If switching from having a preview pane to not (or vice-versa),
596 // and we have an alterate gr.rMain* to switch to, resize the window.
598 if (IsWindowVisible (g.hMain))
601 GetWindowRect (g.hMain, &rNow);
603 LPRECT prTarget = (fPreviewNew) ? &gr.rMainPreview : &gr.rMain;
604 if (prTarget->right == 0)
607 if (gr.fPreview && gr.fVert) // preview pane exists below main window?
610 GetWindowRect (GetDlgItem (g.hMain, IDC_TABS), &rPreview);
612 prTarget->bottom -= cyRECT(rPreview);
615 prTarget->right = prTarget->left + cxRECT(rNow); // keep the same width!
617 fEnforceMinimumSize = FALSE;
618 fNotifyChildrenForResize = FALSE;
620 SetWindowPos (g.hMain, NULL,
621 0, 0, cxRECT(*prTarget), cyRECT(*prTarget),
622 SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE);
624 fNotifyChildrenForResize = TRUE;
625 fEnforceMinimumSize = TRUE;
628 // Create a tab control if necessary, or remove it if it should be gone.
630 if (fPreviewNew && !GetDlgItem (g.hMain, IDC_TABS))
632 Main_CreateTabControl();
634 if (!fPreviewNew && GetDlgItem (g.hMain, IDC_TABS))
636 Main_DeleteTabControl();
639 // If there's a tab control, we'll need a splitter; if not, not.
641 if (GetDlgItem (g.hMain, IDC_SPLITTER_SERVER))
643 DeleteSplitter (g.hMain, IDC_SPLITTER_SERVER);
646 Main_RearrangeChildren (fPreviewNew, fVertNew);
650 CreateSplitter (g.hMain, IDC_SERVERS, IDC_TABS, IDC_SPLITTER_SERVER,
651 (fVertNew) ? &gr.diVert.cSplitter : &gr.diHorz.cSplitter,
656 if (GetDlgItem (g.hMain, IDC_TABS))
658 ShowWindow (GetDlgItem (g.hMain, IDC_TABS), SW_SHOW);
661 LPVIEWINFO lpvi = (fPreviewNew && !fVertNew) ? &gr.diHorz.viewSvr : &gr.diVert.viewSvr;
663 FL_RestoreView (GetDlgItem (g.hMain, IDC_SERVERS), lpvi);
665 CheckMenuRadioItem (GetMenu (g.hMain),
666 M_DIVIDE_NONE, M_DIVIDE_H,
667 ( (!fPreviewNew) ? M_DIVIDE_NONE :
668 (fVertNew) ? M_DIVIDE_V :
673 gr.fPreview = fPreviewNew;
675 Main_SetServerViewMenus();
679 void Main_OnServerView (int lvsNew)
681 HWND hServers = GetDlgItem (g.hMain, IDC_SERVERS);
683 if (gr.fPreview && !gr.fVert)
684 FL_StoreView (hServers, &gr.diHorz.viewSvr);
686 FL_StoreView (hServers, &gr.diVert.viewSvr);
688 if (gr.fPreview && !gr.fVert)
689 gr.diHorz.viewSvr.lvsView = lvsNew;
691 gr.diVert.viewSvr.lvsView = lvsNew;
693 if (gr.fPreview && !gr.fVert)
694 FL_RestoreView (hServers, &gr.diHorz.viewSvr);
696 FL_RestoreView (hServers, &gr.diVert.viewSvr);
698 Main_SetServerViewMenus();
699 FastList_SetTextCallback (GetDlgItem (g.hMain, IDC_SERVERS), GetItemText, (DWORD)((gr.fPreview && !gr.fVert) ? &gr.diHorz.viewSvr : &gr.diVert.viewSvr));
700 UpdateDisplay_Servers (FALSE, NULL, 0);
704 void Main_SetServerViewMenus (void)
708 if (gr.fPreview && !gr.fVert)
709 lvs = gr.diHorz.viewSvr.lvsView;
711 lvs = gr.diVert.viewSvr.lvsView;
713 CheckMenuRadioItem (GetMenu (g.hMain),
714 M_SVR_VIEW_LARGE, M_SVR_VIEW_REPORT,
715 ( (lvs == FLS_VIEW_SMALL) ? M_SVR_VIEW_SMALL :
716 (lvs == FLS_VIEW_LIST) ? M_SVR_VIEW_REPORT :
720 ICONVIEW ivSvr = Display_GetServerIconView();
722 CheckMenuRadioItem (GetMenu (g.hMain),
723 M_SVR_VIEW_ONEICON, M_SVR_VIEW_STATUS,
724 (ivSvr == ivTWOICONS) ? M_SVR_VIEW_TWOICONS :
725 (ivSvr == ivONEICON) ? M_SVR_VIEW_ONEICON : M_SVR_VIEW_STATUS,
728 EnableMenu (GetMenu (g.hMain), M_SVR_VIEW_ONEICON, (lvs == FLS_VIEW_LIST) ? TRUE : FALSE);
729 EnableMenu (GetMenu (g.hMain), M_SVR_VIEW_TWOICONS, (lvs == FLS_VIEW_LIST) ? TRUE : FALSE);
730 EnableMenu (GetMenu (g.hMain), M_SVR_VIEW_STATUS, (lvs == FLS_VIEW_LIST) ? TRUE : FALSE);
734 void Main_SetActionMenus (void)
736 CheckMenu (GetMenu (g.hMain), M_ACTIONS, gr.fActions);
740 void Main_CreateTabControl (void)
742 HWND hTab = CreateWindowEx (WS_EX_CLIENTEDGE,
745 WS_CHILD | WS_CLIPSIBLINGS | WS_TABSTOP,
746 0, 0, 128, 128, // arbitrary, but not too small
747 SERVERWINDOW_PREVIEWPANE,
754 HFONT hf = (HFONT)GetStockObject (DEFAULT_GUI_FONT);
755 SendMessage (hTab, WM_SETFONT, (WPARAM)hf, MAKELPARAM(TRUE,0));
757 Server_PrepareTabControl (hTab);
759 LPIDENT lpi = (LPIDENT)FL_GetSelectedData (GetDlgItem (g.hMain, IDC_SERVERS));
760 Server_SelectServer (SERVERWINDOW_PREVIEWPANE, lpi);
765 void Main_DeleteTabControl (void)
767 if (GetDlgItem (SERVERWINDOW_PREVIEWPANE, IDC_TABS))
769 DestroyWindow (GetDlgItem (SERVERWINDOW_PREVIEWPANE, IDC_TABS));
774 void Main_DisplayTab (CHILDTAB iTab)
778 Server_DisplayTab (SERVERWINDOW_PREVIEWPANE, iTab);
779 gr.tabLast = (CHILDTAB)iTab;
784 void Main_RearrangeChildren (BOOL fPreviewNew, BOOL fVertNew)
789 // Start with the Servers window taking up the entire dialog's client area,
790 // leaving a space at the top for the cell combobox.
793 GetRectInParent (GetDlgItem (g.hMain, IDC_AFS_ID), &rCell);
795 GetClientRect (g.hMain, &rServers);
796 rServers.top = rCell.bottom +3;
798 // Then, if the preview tab is to be displayed, make the server window
799 // share the space equally with the tab control (vertically or horizontally)
807 rServers.bottom = rServers.top + cyRECT(rServers)/2 - 1;
808 rPreview.top = rServers.bottom + 2;
812 rServers.right = rServers.left + cxRECT(rServers)/2 - 1;
813 rPreview.left = rServers.right + 2;
816 // Adjust the server/tab windows for the Server splitter's position
820 LONG cyMod = gr.diVert.cSplitter;
822 if (cyRECT(rServers) > cyMIN_SERVER)
823 cyMod = min( cyMod, cyRECT(rServers)-cyMIN_SERVER );
824 if (cyRECT(rPreview) > cyMIN_TABS)
825 cyMod = min( cyMod, cyRECT(rPreview)-cyMIN_TABS );
827 rServers.bottom += cyMod;
828 rPreview.top += cyMod;
832 LONG cxMod = gr.diHorz.cSplitter;
834 if (cxRECT(rServers) > cxMIN_SERVER)
835 cxMod = min( cxMod, cxRECT(rServers)-cxMIN_SERVER );
836 if (cxRECT(rPreview) > cxMIN_TABS)
837 cxMod = min( cxMod, cxRECT(rPreview)-cxMIN_TABS );
839 rServers.right += cxMod;
840 rPreview.left += cxMod;
844 // Now move the children to their new places!
847 if (GetDlgItem (g.hMain, IDC_COVERDLG))
849 if (GetDlgItem (g.hMain, IDC_TABS))
851 HDWP dwp = BeginDeferWindowPos (nWindows);
853 DeferWindowPos (dwp, GetDlgItem (g.hMain, IDC_SERVERS), NULL,
854 rServers.left, rServers.top,
855 cxRECT(rServers), cyRECT(rServers),
856 SWP_NOACTIVATE | SWP_NOZORDER);
858 if (GetDlgItem (g.hMain, IDC_COVERDLG))
860 DeferWindowPos (dwp, GetDlgItem (g.hMain, IDC_COVERDLG), NULL,
861 rServers.left, rServers.top,
862 cxRECT(rServers), cyRECT(rServers),
863 SWP_NOACTIVATE | SWP_NOZORDER);
866 if (GetDlgItem (g.hMain, IDC_TABS))
868 DeferWindowPos (dwp, GetDlgItem (g.hMain, IDC_TABS), NULL,
869 rPreview.left, rPreview.top,
870 cxRECT(rPreview), cyRECT(rPreview),
871 SWP_NOACTIVATE | SWP_NOZORDER);
874 EndDeferWindowPos (dwp);
879 static LONG procServers = 0;
881 LRESULT CALLBACK Main_SubclassServersProc (HWND hServers, UINT msg, WPARAM wp, LPARAM lp)
885 if (procServers == 0)
886 rc = DefWindowProc (hServers, msg, wp, lp);
888 rc = CallWindowProc ((WNDPROC)procServers, hServers, msg, wp, lp);
893 if (procServers != 0)
894 SetWindowLong (hServers, GWL_WNDPROC, procServers);
900 case M_SVR_VIEW_LARGE:
901 case M_SVR_VIEW_SMALL:
902 case M_SVR_VIEW_REPORT:
903 SendMessage (g.hMain, msg, wp, lp);
907 case M_VIEW_TWOICONS:
909 SendMessage (g.hMain, msg, wp, lp);
913 ShowColumnsDialog (g.hMain, NULL);
917 StartContextCommand (g.hMain,
919 (LPIDENT)FL_GetSelectedData (hServers),
930 void Main_SubclassServers (HWND hDlg)
932 HWND hServers = GetDlgItem (hDlg, IDC_SERVERS);
933 procServers = GetWindowLong (hServers, GWL_WNDPROC);
934 SetWindowLong (hServers, GWL_WNDPROC, (LONG)Main_SubclassServersProc);
939 void ExportCell (void)
944 TCHAR szFilter[ cchRESOURCE ];
945 lstrcpy (szFilter, TEXT("Text File|*.TXT|"));
946 TCHAR chFilter = szFilter[ lstrlen(szFilter)-1 ];
947 for (LPTSTR pszFilter = szFilter;
948 (*pszFilter) && ((pszFilter = (LPTSTR)lstrchr (pszFilter, chFilter)) != NULL);
951 *pszFilter = TEXT('\0');
954 TCHAR szSaveAs[ MAX_PATH ] = TEXT("export");
957 memset (&sfn, 0x00, sizeof(sfn));
958 sfn.lStructSize = sizeof(sfn);
959 sfn.hwndOwner = g.hMain;
960 sfn.hInstance = THIS_HINST;
961 sfn.lpstrFilter = szFilter;
962 sfn.nFilterIndex = 1;
963 sfn.lpstrFile = szSaveAs;
964 sfn.nMaxFile = MAX_PATH;
965 sfn.Flags = OFN_HIDEREADONLY | OFN_NOREADONLYRETURN |
966 OFN_OVERWRITEPROMPT | OFN_PATHMUSTEXIST;
967 sfn.lpstrDefExt = TEXT("txt");
969 if (GetSaveFileName (&sfn))
971 LPTSTR psz = CloneString (szSaveAs);
972 StartTask (taskEXPORTCELL, NULL, psz);
978 void Main_StartWorking (void)
980 if (InterlockedIncrement(&nReqWorking) == 1)
982 AfsAppLib_StartAnimation (GetDlgItem (g.hMain, IDC_ANIMATE));
986 void Main_StopWorking (void)
988 if (InterlockedDecrement(&nReqWorking) == 0)
990 AfsAppLib_StopAnimation (GetDlgItem (g.hMain, IDC_ANIMATE));
995 void Main_AnimateIcon (HWND hIcon, int *piFrameLast)
998 static HICON hiFrame[8];
999 static BOOL fLoaded = FALSE;
1003 hiStop = TaLocale_LoadIcon (IDI_SPINSTOP);
1004 hiFrame[0] = TaLocale_LoadIcon (IDI_SPIN1);
1005 hiFrame[1] = TaLocale_LoadIcon (IDI_SPIN2);
1006 hiFrame[2] = TaLocale_LoadIcon (IDI_SPIN3);
1007 hiFrame[3] = TaLocale_LoadIcon (IDI_SPIN4);
1008 hiFrame[4] = TaLocale_LoadIcon (IDI_SPIN5);
1009 hiFrame[5] = TaLocale_LoadIcon (IDI_SPIN6);
1010 hiFrame[6] = TaLocale_LoadIcon (IDI_SPIN7);
1011 hiFrame[7] = TaLocale_LoadIcon (IDI_SPIN8);
1017 *piFrameLast = (*piFrameLast == 7) ? 0 : (1+*piFrameLast);
1020 SendMessage (hIcon, STM_SETICON, (WPARAM)((piFrameLast) ? hiFrame[ *piFrameLast ] : hiStop), 0);
1024 BOOL Main_HandleDialogKeys (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
1026 if (msg == WM_COMMAND)
1031 Server_OnKey_Return();
1035 Main_OnKey_CtrlTab (TRUE);
1038 case M_KEY_CTRLBACKTAB:
1039 Main_OnKey_CtrlTab (FALSE);
1043 Main_OnKey_Tab (TRUE);
1047 Main_OnKey_Tab (FALSE);
1051 Server_OnKey_Menu();
1058 case M_KEY_PROPERTIES:
1059 Server_OnKey_Properties();
1068 void Main_OnKey_Tab (BOOL fForward)
1070 // The tab-cycle should go:
1071 // ServerList <-> TabsOnQuickViewPane <-> TabChildControls
1073 // If the quick-view pane isn't showing, there's nowhere to tab to.
1077 HWND hFocus = GetFocus();
1078 HWND hTabChild = GetTabChild (GetDlgItem (g.hMain, IDC_TABS));
1082 if (hFocus == GetDlgItem (g.hMain, IDC_SERVERS))
1084 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetDlgItem (g.hMain, IDC_TABS), TRUE);
1086 else if (hFocus == GetDlgItem (g.hMain, IDC_TABS))
1088 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetNextDlgTabItem (hTabChild, NULL, FALSE), TRUE);
1092 if (GetNextDlgTabItem (hTabChild, hFocus, FALSE) == GetNextDlgTabItem (hTabChild, NULL, FALSE))
1093 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetDlgItem (g.hMain, IDC_SERVERS), TRUE);
1095 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetNextDlgTabItem (hTabChild, hFocus, FALSE), TRUE);
1100 if (hFocus == GetDlgItem (g.hMain, IDC_SERVERS))
1102 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetLastDlgTabItem (hTabChild), TRUE);
1104 else if (hFocus == GetDlgItem (g.hMain, IDC_TABS))
1106 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetDlgItem (g.hMain, IDC_SERVERS), TRUE);
1110 if (hFocus == GetNextDlgTabItem (hTabChild, NULL, FALSE))
1111 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetDlgItem (g.hMain, IDC_TABS), TRUE);
1113 PostMessage (g.hMain, WM_NEXTDLGCTL, (WPARAM)GetNextDlgTabItem (hTabChild, hFocus, TRUE), TRUE);
1120 void Main_OnKey_CtrlTab (BOOL fForward)
1124 Server_OnKey_CtrlTab (SERVERWINDOW_PREVIEWPANE, fForward);