4 * Copyright 1996 Ulrich Schmid
11 /***********************************************************************
16 static LRESULT
GROUP_GroupWndProc (HWND hWnd
, UINT msg
,
17 WPARAM wParam
, LPARAM lParam
)
20 printf("G %4.4x %4.4x\n", msg
, wParam
);
25 if (wParam
== SC_CLOSE
) wParam
= SC_MINIMIZE
;
28 case WM_CHILDACTIVATE
:
29 case WM_NCLBUTTONDOWN
:
30 Globals
.hActiveGroup
= (HLOCAL
) GetWindowLong(hWnd
, 0);
31 EnableMenuItem(Globals
.hFileMenu
, PM_MOVE
, MF_GRAYED
);
32 EnableMenuItem(Globals
.hFileMenu
, PM_COPY
, MF_GRAYED
);
35 return(DefMDIChildProc(hWnd
, msg
, wParam
, lParam
));
38 /***********************************************************************
40 * GROUP_RegisterGroupWinClass
43 ATOM
GROUP_RegisterGroupWinClass()
47 class.style
= CS_HREDRAW
| CS_VREDRAW
;
48 class.lpfnWndProc
= GROUP_GroupWndProc
;
50 class.cbWndExtra
= sizeof(LONG
);
51 class.hInstance
= Globals
.hInstance
;
52 class.hIcon
= LoadIcon (0, MAKEINTRESOURCE(OIC_WINEICON
));
53 class.hCursor
= LoadCursor (0, IDC_ARROW
);
54 class.hbrBackground
= GetStockObject (WHITE_BRUSH
);
55 class.lpszMenuName
= 0;
56 class.lpszClassName
= STRING_GROUP_WIN_CLASS_NAME
;
58 return RegisterClass(&class);
61 /***********************************************************************
68 CHAR szName
[MAX_PATHNAME_LEN
] = "";
69 CHAR szFile
[MAX_PATHNAME_LEN
] = "";
72 if (!DIALOG_GroupAttributes(szName
, szFile
, MAX_PATHNAME_LEN
)) return;
74 if (OpenFile(szFile
, &dummy
, OF_EXIST
) == HFILE_ERROR
)
76 /* File doesn't exist */
78 GROUP_AddGroup(szName
, szFile
, SW_SHOWNORMAL
,
79 DEF_GROUP_WIN_XPOS
, DEF_GROUP_WIN_YPOS
,
80 DEF_GROUP_WIN_WIDTH
, DEF_GROUP_WIN_HEIGHT
, 0, 0,
83 GRPFILE_WriteGroupFile(hGroup
);
86 GRPFILE_ReadGroupFile(szFile
);
88 /* FIXME Update progman.ini */
91 /***********************************************************************
96 HLOCAL
GROUP_AddGroup(LPCSTR lpszName
, LPCSTR lpszGrpFile
, INT nCmdShow
,
97 INT x
, INT y
, INT width
, INT height
,
99 BOOL bFileNameModified
, BOOL bOverwriteFileOk
,
100 /* FIXME shouldn't be necessary */
101 BOOL bSuppressShowWindow
)
103 GROUP
*group
, *prior
;
107 HLOCAL hGroup
= LocalAlloc(LMEM_FIXED
, sizeof(GROUP
));
108 HLOCAL hName
= LocalAlloc(LMEM_FIXED
, 1 + lstrlen(lpszName
));
109 HLOCAL hGrpFile
= LocalAlloc(LMEM_FIXED
, 1 + lstrlen(lpszGrpFile
));
110 if (!hGroup
|| !hName
|| !hGrpFile
)
112 MAIN_MessageBoxIDS(IDS_OUT_OF_MEMORY
, IDS_ERROR
, MB_OK
);
113 if (hGroup
) LocalFree(hGroup
);
114 if (hName
) LocalFree(hName
);
115 if (hGrpFile
) LocalFree(hGrpFile
);
118 hmemcpy(LocalLock(hName
), lpszName
, 1 + lstrlen(lpszName
));
119 hmemcpy(LocalLock(hGrpFile
), lpszGrpFile
, 1 + lstrlen(lpszGrpFile
));
121 Globals
.hActiveGroup
= hGroup
;
125 p
= &Globals
.hGroups
;
129 prior
= LocalLock(hPrior
);
131 if (prior
->seqnum
>= seqnum
)
132 seqnum
= prior
->seqnum
+ 1;
136 group
= LocalLock(hGroup
);
137 group
->hPrior
= hPrior
;
139 group
->hName
= hName
;
140 group
->hGrpFile
= hGrpFile
;
141 group
->bFileNameModified
= bFileNameModified
;
142 group
->bOverwriteFileOk
= bOverwriteFileOk
;
143 group
->seqnum
= seqnum
;
144 group
->nCmdShow
= nCmdShow
;
147 group
->width
= width
;
148 group
->height
= height
;
149 group
->iconx
= iconx
;
150 group
->icony
= icony
;
151 group
->hPrograms
= 0;
152 group
->hActiveProgram
= 0;
154 cs
.szClass
= STRING_GROUP_WIN_CLASS_NAME
;
155 cs
.szTitle
= (LPSTR
)lpszName
;
164 group
->hWnd
= (HWND
)SendMessage(Globals
.hMDIWnd
, WM_MDICREATE
, 0, (LPARAM
)&cs
);
166 SetWindowLong(group
->hWnd
, 0, (LONG
) hGroup
);
169 if (!bSuppressShowWindow
) /* FIXME shouldn't be necessary */
172 ShowWindow (group
->hWnd
, nCmdShow
);
173 UpdateWindow (group
->hWnd
);
179 /***********************************************************************
184 VOID
GROUP_ModifyGroup(HLOCAL hGroup
)
186 GROUP
*group
= LocalLock(hGroup
);
187 CHAR szName
[MAX_PATHNAME_LEN
];
188 CHAR szFile
[MAX_PATHNAME_LEN
];
189 lstrcpyn(szName
, LocalLock(group
->hName
), MAX_PATHNAME_LEN
);
190 lstrcpyn(szFile
, LocalLock(group
->hGrpFile
), MAX_PATHNAME_LEN
);
192 if (!DIALOG_GroupAttributes(szName
, szFile
, MAX_PATHNAME_LEN
)) return;
194 if (strcmp(szFile
, LocalLock(group
->hGrpFile
)))
195 group
->bOverwriteFileOk
= FALSE
;
197 MAIN_ReplaceString(&group
->hName
, szName
);
198 MAIN_ReplaceString(&group
->hGrpFile
, szFile
);
200 GRPFILE_WriteGroupFile(hGroup
);
202 /* FIXME Delete old GrpFile if GrpFile changed */
204 /* FIXME Update progman.ini */
206 SetWindowText(group
->hWnd
, szName
);
209 /***********************************************************************
211 * GROUP_ShowGroupWindow
214 /* FIXME shouldn't be necessary */
215 VOID
GROUP_ShowGroupWindow(HLOCAL hGroup
)
217 GROUP
*group
= LocalLock(hGroup
);
218 ShowWindow (group
->hWnd
, group
->nCmdShow
);
219 UpdateWindow (group
->hWnd
);
222 /***********************************************************************
227 VOID
GROUP_DeleteGroup(HLOCAL hGroup
)
229 GROUP
*group
= LocalLock(hGroup
);
231 Globals
.hActiveGroup
= 0;
234 ((GROUP
*)LocalLock(group
->hPrior
))->hNext
= group
->hNext
;
235 else Globals
.hGroups
= group
->hNext
;
238 ((GROUP
*)LocalLock(group
->hNext
))->hPrior
= group
->hPrior
;
240 while (group
->hPrograms
)
241 PROGRAM_DeleteProgram(group
->hPrograms
, FALSE
);
243 /* FIXME Update progman.ini */
245 SendMessage(Globals
.hMDIWnd
, WM_MDIDESTROY
, (WPARAM
)group
->hWnd
, 0);
247 LocalFree(group
->hName
);
248 LocalFree(group
->hGrpFile
);
252 /***********************************************************************
257 HLOCAL
GROUP_FirstGroup()
259 return(Globals
.hGroups
);
262 /***********************************************************************
267 HLOCAL
GROUP_NextGroup(HLOCAL hGroup
)
270 if (!hGroup
) return(0);
271 group
= LocalLock(hGroup
);
272 return(group
->hNext
);
275 /***********************************************************************
280 HLOCAL
GROUP_ActiveGroup()
282 return(Globals
.hActiveGroup
);
285 /***********************************************************************
290 HWND
GROUP_GroupWnd(HLOCAL hGroup
)
293 if (!hGroup
) return(0);
294 group
= LocalLock(hGroup
);
298 /***********************************************************************
303 LPCSTR
GROUP_GroupName(HLOCAL hGroup
)
306 if (!hGroup
) return(0);
307 group
= LocalLock(hGroup
);
308 return(LocalLock(group
->hName
));
311 /* Local Variables: */
312 /* c-file-style: "GNU" */