4 * Copyright 1996 Ulrich Schmid
13 /***********************************************************************
18 static LRESULT CALLBACK GROUP_GroupWndProc(HWND hWnd, UINT msg,
19 WPARAM wParam, LPARAM lParam)
22 printf("G %4.4x %4.4x\n", msg, wParam);
27 if (wParam == SC_CLOSE) wParam = SC_MINIMIZE;
30 case WM_CHILDACTIVATE:
31 case WM_NCLBUTTONDOWN:
32 Globals.hActiveGroup = (HLOCAL) GetWindowLong(hWnd, 0);
33 EnableMenuItem(Globals.hFileMenu, PM_MOVE , MF_GRAYED);
34 EnableMenuItem(Globals.hFileMenu, PM_COPY , MF_GRAYED);
37 return(DefMDIChildProc(hWnd, msg, wParam, lParam));
40 /***********************************************************************
42 * GROUP_RegisterGroupWinClass
45 ATOM GROUP_RegisterGroupWinClass()
49 class.style = CS_HREDRAW | CS_VREDRAW;
50 class.lpfnWndProc = GROUP_GroupWndProc;
52 class.cbWndExtra = sizeof(LONG);
53 class.hInstance = Globals.hInstance;
54 class.hIcon = LoadIcon (0, IDI_WINLOGO);
55 class.hCursor = LoadCursor (0, IDC_ARROW);
56 class.hbrBackground = GetStockObject (WHITE_BRUSH);
57 class.lpszMenuName = 0;
58 class.lpszClassName = STRING_GROUP_WIN_CLASS_NAME;
60 return RegisterClass(&class);
63 /***********************************************************************
70 CHAR szName[MAX_PATHNAME_LEN] = "";
71 CHAR szFile[MAX_PATHNAME_LEN] = "";
74 if (!DIALOG_GroupAttributes(szName, szFile, MAX_PATHNAME_LEN)) return;
76 if (OpenFile(szFile, &dummy, OF_EXIST) == HFILE_ERROR)
78 /* File doesn't exist */
80 GROUP_AddGroup(szName, szFile, SW_SHOWNORMAL,
81 DEF_GROUP_WIN_XPOS, DEF_GROUP_WIN_YPOS,
82 DEF_GROUP_WIN_WIDTH, DEF_GROUP_WIN_HEIGHT, 0, 0,
85 GRPFILE_WriteGroupFile(hGroup);
88 GRPFILE_ReadGroupFile(szFile);
90 /* FIXME Update progman.ini */
93 /***********************************************************************
98 HLOCAL GROUP_AddGroup(LPCSTR lpszName, LPCSTR lpszGrpFile, INT nCmdShow,
99 INT x, INT y, INT width, INT height,
100 INT iconx, INT icony,
101 BOOL bFileNameModified, BOOL bOverwriteFileOk,
102 /* FIXME shouldn't be necessary */
103 BOOL bSuppressShowWindow)
105 PROGGROUP *group, *prior;
109 HLOCAL hGroup = LocalAlloc(LMEM_FIXED, sizeof(PROGGROUP));
110 HLOCAL hName = LocalAlloc(LMEM_FIXED, 1 + lstrlen(lpszName));
111 HLOCAL hGrpFile = LocalAlloc(LMEM_FIXED, 1 + lstrlen(lpszGrpFile));
112 if (!hGroup || !hName || !hGrpFile)
114 MAIN_MessageBoxIDS(IDS_OUT_OF_MEMORY, IDS_ERROR, MB_OK);
115 if (hGroup) LocalFree(hGroup);
116 if (hName) LocalFree(hName);
117 if (hGrpFile) LocalFree(hGrpFile);
120 memcpy(LocalLock(hName), lpszName, 1 + lstrlen(lpszName));
121 memcpy(LocalLock(hGrpFile), lpszGrpFile, 1 + lstrlen(lpszGrpFile));
123 Globals.hActiveGroup = hGroup;
127 p = &Globals.hGroups;
131 prior = LocalLock(hPrior);
133 if (prior->seqnum >= seqnum)
134 seqnum = prior->seqnum + 1;
138 group = LocalLock(hGroup);
139 group->hPrior = hPrior;
141 group->hName = hName;
142 group->hGrpFile = hGrpFile;
143 group->bFileNameModified = bFileNameModified;
144 group->bOverwriteFileOk = bOverwriteFileOk;
145 group->seqnum = seqnum;
146 group->nCmdShow = nCmdShow;
149 group->width = width;
150 group->height = height;
151 group->iconx = iconx;
152 group->icony = icony;
153 group->hPrograms = 0;
154 group->hActiveProgram = 0;
156 cs.szClass = STRING_GROUP_WIN_CLASS_NAME;
157 cs.szTitle = (LPSTR)lpszName;
166 group->hWnd = (HWND)SendMessage(Globals.hMDIWnd, WM_MDICREATE, 0, (LPARAM)&cs);
168 SetWindowLong(group->hWnd, 0, (LONG) hGroup);
171 if (!bSuppressShowWindow) /* FIXME shouldn't be necessary */
174 ShowWindow (group->hWnd, nCmdShow);
175 UpdateWindow (group->hWnd);
181 /***********************************************************************
186 VOID GROUP_ModifyGroup(HLOCAL hGroup)
188 PROGGROUP *group = LocalLock(hGroup);
189 CHAR szName[MAX_PATHNAME_LEN];
190 CHAR szFile[MAX_PATHNAME_LEN];
191 lstrcpyn(szName, LocalLock(group->hName), MAX_PATHNAME_LEN);
192 lstrcpyn(szFile, LocalLock(group->hGrpFile), MAX_PATHNAME_LEN);
194 if (!DIALOG_GroupAttributes(szName, szFile, MAX_PATHNAME_LEN)) return;
196 if (strcmp(szFile, LocalLock(group->hGrpFile)))
197 group->bOverwriteFileOk = FALSE;
199 MAIN_ReplaceString(&group->hName, szName);
200 MAIN_ReplaceString(&group->hGrpFile, szFile);
202 GRPFILE_WriteGroupFile(hGroup);
204 /* FIXME Delete old GrpFile if GrpFile changed */
206 /* FIXME Update progman.ini */
208 SetWindowText(group->hWnd, szName);
211 /***********************************************************************
213 * GROUP_ShowGroupWindow
216 /* FIXME shouldn't be necessary */
217 VOID GROUP_ShowGroupWindow(HLOCAL hGroup)
219 PROGGROUP *group = LocalLock(hGroup);
220 ShowWindow (group->hWnd, group->nCmdShow);
221 UpdateWindow (group->hWnd);
224 /***********************************************************************
229 VOID GROUP_DeleteGroup(HLOCAL hGroup)
231 PROGGROUP *group = LocalLock(hGroup);
233 Globals.hActiveGroup = 0;
236 ((PROGGROUP*)LocalLock(group->hPrior))->hNext = group->hNext;
237 else Globals.hGroups = group->hNext;
240 ((PROGGROUP*)LocalLock(group->hNext))->hPrior = group->hPrior;
242 while (group->hPrograms)
243 PROGRAM_DeleteProgram(group->hPrograms, FALSE);
245 /* FIXME Update progman.ini */
247 SendMessage(Globals.hMDIWnd, WM_MDIDESTROY, (WPARAM)group->hWnd, 0);
249 LocalFree(group->hName);
250 LocalFree(group->hGrpFile);
254 /***********************************************************************
259 HLOCAL GROUP_FirstGroup()
261 return(Globals.hGroups);
264 /***********************************************************************
269 HLOCAL GROUP_NextGroup(HLOCAL hGroup)
272 if (!hGroup) return(0);
273 group = LocalLock(hGroup);
274 return(group->hNext);
277 /***********************************************************************
282 HLOCAL GROUP_ActiveGroup()
284 return(Globals.hActiveGroup);
287 /***********************************************************************
292 HWND GROUP_GroupWnd(HLOCAL hGroup)
295 if (!hGroup) return(0);
296 group = LocalLock(hGroup);
300 /***********************************************************************
305 LPCSTR GROUP_GroupName(HLOCAL hGroup)
308 if (!hGroup) return(0);
309 group = LocalLock(hGroup);
310 return(LocalLock(group->hName));
313 /* Local Variables: */
314 /* c-file-style: "GNU" */