6 #include "TaAfsUsrMgr.h"
11 #include "usr_create.h"
12 #include "usr_search.h"
14 #include "grp_create.h"
16 #include "mch_create.h"
22 * DEFINITIONS ________________________________________________________________
28 * VARIABLES __________________________________________________________________
37 * PROTOTYPES _________________________________________________________________
41 BOOL InitApplication (HINSTANCE hInst, LPTSTR pszCmdLine, int nCmdShow);
42 void ExitApplication (void);
46 * ROUTINES ___________________________________________________________________
50 int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR pszCmdLineA, int nCmdShow)
52 LPTSTR pszCmdLine = AnsiToString (pszCmdLineA);
54 if (InitApplication (hInst, pszCmdLine, nCmdShow))
60 FreeString (pszCmdLine, pszCmdLineA);
65 BOOL InitApplication (HINSTANCE hInst, LPTSTR pszCmdLine, int nCmdShow)
67 TaLocale_LoadCorrespondingModule (hInst);
69 memset (&g, 0x00, sizeof(g));
71 g.hAccel = TaLocale_LoadAccelerators (ACCEL_MAIN);
74 TCHAR szTitle[ cchRESOURCE ];
75 GetString (szTitle, IDS_APP_TITLE);
76 if ((hPrevious = FindWindow (TEXT("AFSAccountManagerClass"), szTitle)) != NULL)
79 SendMessage (hPrevious, WM_SHOW_YOURSELF, 0, 0);
83 AfsAppLib_SetAppName(szTitle);
84 AfsAppLib_SetPumpRoutine(PumpMessage);
87 memset (&tqp, 0x00, sizeof(tqp));
89 tqp.fnCreateTaskPacket = CreateTaskPacket;
90 tqp.fnPerformTask = PerformTask;
91 tqp.fnFreeTaskPacket = FreeTaskPacket;
92 AfsAppLib_InitTaskQueue (&tqp);
96 // Determine how the app is supposed to look--that is, remember what it
97 // looked like last time, and if there was no "last time", pick some
100 if (!RestoreSettings (REGSTR_SETTINGS_BASE, REGSTR_SETTINGS_PATH, REGVAL_SETTINGS, &gr, sizeof(gr), wVerGLOBALS_RESTORED))
102 memset (&gr, 0x00, sizeof(gr));
103 SetRectEmpty (&gr.rMain);
104 gr.cminRefreshRate = 60; // 1 hour default refresh rate
106 User_SetDefaultCreateParams (&gr.CreateUser);
107 Group_SetDefaultCreateParams (&gr.CreateGroup);
108 Machine_SetDefaultCreateParams (&gr.CreateMachine);
109 Actions_SetDefaultView (&gr.viewAct);
110 User_SetDefaultView (&gr.viewUsr, &gr.ivUsr);
111 Group_SetDefaultView (&gr.viewGrp, &gr.ivGrp);
112 Machine_SetDefaultView (&gr.viewMch, &gr.ivMch);
113 Users_SetDefaultSearchParams (&gr.SearchUsers);
116 // Create a variation on WC_DIALOG, so we get appropriate icons on
120 GetClassInfo (THIS_HINST, MAKEINTRESOURCE( WC_DIALOG ), &wc);
121 wc.hInstance = THIS_HINST;
122 wc.hIcon = TaLocale_LoadIcon (IDI_MAIN);
123 wc.lpszClassName = TEXT("AFSAccountManagerClass");
124 wc.style |= CS_GLOBALCLASS;
127 // Okay, the big step: create the main window. Note that it doesn't
130 CMDLINEOP op = ParseCommandLine (pszCmdLine);
131 if (op == opCLOSEAPP)
134 // Okay, the big step: create the main window.
135 // Note that it doesn't get shown yet!
137 g.hMain = ModelessDialog (IDD_MAIN, NULL, (DLGPROC)Main_DialogProc);
141 if (op != opNOCELLDIALOG)
143 if (OpenCellDialog() != IDOK)
151 void ExitApplication (void)
157 asc_CellClose (g.idClient, g.idCell, &status);
158 AfsAppLib_CloseAdminServer();
165 if (g.hMain && IsWindow(g.hMain))
168 wpl.length = sizeof(wpl);
169 if (GetWindowPlacement (g.hMain, &wpl))
170 gr.rMain = wpl.rcNormalPosition;
173 StoreSettings (REGSTR_SETTINGS_BASE, REGSTR_SETTINGS_PATH, REGVAL_SETTINGS, &gr, sizeof(gr), wVerGLOBALS_RESTORED);
178 void PumpMessage (MSG *lpm)
180 if (g.hMain && IsWindow (g.hMain))
182 if (GetActiveWindow())
184 if (TranslateAccelerator (GetActiveWindow(), g.hAccel, lpm))
189 if (!IsMemoryManagerMessage (lpm))
191 TranslateMessage (lpm);
192 DispatchMessage (lpm);
197 BOOL cdecl StartThread (DWORD (WINAPI *lpfnStart)(PVOID lp), ...)
200 va_start (arg, lpfnStart);
201 PVOID lp = va_arg (arg, PVOID);
206 if ((hThread = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE)lpfnStart, lp, 0, &dwThreadID)) == NULL)
209 SetThreadPriority (hThread, THREAD_PRIORITY_BELOW_NORMAL);