4 * Copyright 1996 Ulrich Schmid
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #define WIN32_LEAN_AND_MEAN
29 /***********************************************************************
34 static LRESULT CALLBACK
GROUP_GroupWndProc(HWND hWnd
, UINT msg
,
35 WPARAM wParam
, LPARAM lParam
)
38 printf("G %4.4x %4.4x\n", msg
, wParam
);
43 if (wParam
== SC_CLOSE
) wParam
= SC_MINIMIZE
;
46 case WM_CHILDACTIVATE
:
47 case WM_NCLBUTTONDOWN
:
48 Globals
.hActiveGroup
= (HLOCAL
) GetWindowLong(hWnd
, 0);
49 EnableMenuItem(Globals
.hFileMenu
, PM_MOVE
, MF_GRAYED
);
50 EnableMenuItem(Globals
.hFileMenu
, PM_COPY
, MF_GRAYED
);
53 return(DefMDIChildProc(hWnd
, msg
, wParam
, lParam
));
56 /***********************************************************************
58 * GROUP_RegisterGroupWinClass
61 ATOM
GROUP_RegisterGroupWinClass()
65 class.style
= CS_HREDRAW
| CS_VREDRAW
;
66 class.lpfnWndProc
= GROUP_GroupWndProc
;
68 class.cbWndExtra
= sizeof(LONG
);
69 class.hInstance
= Globals
.hInstance
;
70 class.hIcon
= LoadIcon (0, IDI_WINLOGO
);
71 class.hCursor
= LoadCursor (0, IDC_ARROW
);
72 class.hbrBackground
= GetStockObject (WHITE_BRUSH
);
73 class.lpszMenuName
= 0;
74 class.lpszClassName
= STRING_GROUP_WIN_CLASS_NAME
;
76 return RegisterClass(&class);
79 /***********************************************************************
86 CHAR szName
[MAX_PATHNAME_LEN
] = "";
87 CHAR szFile
[MAX_PATHNAME_LEN
] = "";
90 if (!DIALOG_GroupAttributes(szName
, szFile
, MAX_PATHNAME_LEN
)) return;
92 if (OpenFile(szFile
, &dummy
, OF_EXIST
) == HFILE_ERROR
)
94 /* File doesn't exist */
96 GROUP_AddGroup(szName
, szFile
, SW_SHOWNORMAL
,
97 DEF_GROUP_WIN_XPOS
, DEF_GROUP_WIN_YPOS
,
98 DEF_GROUP_WIN_WIDTH
, DEF_GROUP_WIN_HEIGHT
, 0, 0,
101 GRPFILE_WriteGroupFile(hGroup
);
103 else /* File exist */
104 GRPFILE_ReadGroupFile(szFile
);
106 /* FIXME Update progman.ini */
109 /***********************************************************************
114 HLOCAL
GROUP_AddGroup(LPCSTR lpszName
, LPCSTR lpszGrpFile
, INT nCmdShow
,
115 INT x
, INT y
, INT width
, INT height
,
116 INT iconx
, INT icony
,
117 BOOL bFileNameModified
, BOOL bOverwriteFileOk
,
118 /* FIXME shouldn't be necessary */
119 BOOL bSuppressShowWindow
)
121 PROGGROUP
*group
, *prior
;
125 HLOCAL hGroup
= LocalAlloc(LMEM_FIXED
, sizeof(PROGGROUP
));
126 HLOCAL hName
= LocalAlloc(LMEM_FIXED
, 1 + lstrlen(lpszName
));
127 HLOCAL hGrpFile
= LocalAlloc(LMEM_FIXED
, 1 + lstrlen(lpszGrpFile
));
128 if (!hGroup
|| !hName
|| !hGrpFile
)
130 MAIN_MessageBoxIDS(IDS_OUT_OF_MEMORY
, IDS_ERROR
, MB_OK
);
131 if (hGroup
) LocalFree(hGroup
);
132 if (hName
) LocalFree(hName
);
133 if (hGrpFile
) LocalFree(hGrpFile
);
136 memcpy(LocalLock(hName
), lpszName
, 1 + lstrlen(lpszName
));
137 memcpy(LocalLock(hGrpFile
), lpszGrpFile
, 1 + lstrlen(lpszGrpFile
));
139 Globals
.hActiveGroup
= hGroup
;
143 p
= &Globals
.hGroups
;
147 prior
= LocalLock(hPrior
);
149 if (prior
->seqnum
>= seqnum
)
150 seqnum
= prior
->seqnum
+ 1;
154 group
= LocalLock(hGroup
);
155 group
->hPrior
= hPrior
;
157 group
->hName
= hName
;
158 group
->hGrpFile
= hGrpFile
;
159 group
->bFileNameModified
= bFileNameModified
;
160 group
->bOverwriteFileOk
= bOverwriteFileOk
;
161 group
->seqnum
= seqnum
;
162 group
->nCmdShow
= nCmdShow
;
165 group
->width
= width
;
166 group
->height
= height
;
167 group
->iconx
= iconx
;
168 group
->icony
= icony
;
169 group
->hPrograms
= 0;
170 group
->hActiveProgram
= 0;
172 cs
.szClass
= STRING_GROUP_WIN_CLASS_NAME
;
173 cs
.szTitle
= (LPSTR
)lpszName
;
182 group
->hWnd
= (HWND
)SendMessage(Globals
.hMDIWnd
, WM_MDICREATE
, 0, (LPARAM
)&cs
);
184 SetWindowLong(group
->hWnd
, 0, (LONG
) hGroup
);
187 if (!bSuppressShowWindow
) /* FIXME shouldn't be necessary */
190 ShowWindow (group
->hWnd
, nCmdShow
);
191 UpdateWindow (group
->hWnd
);
197 /***********************************************************************
202 VOID
GROUP_ModifyGroup(HLOCAL hGroup
)
204 PROGGROUP
*group
= LocalLock(hGroup
);
205 CHAR szName
[MAX_PATHNAME_LEN
];
206 CHAR szFile
[MAX_PATHNAME_LEN
];
207 lstrcpyn(szName
, LocalLock(group
->hName
), MAX_PATHNAME_LEN
);
208 lstrcpyn(szFile
, LocalLock(group
->hGrpFile
), MAX_PATHNAME_LEN
);
210 if (!DIALOG_GroupAttributes(szName
, szFile
, MAX_PATHNAME_LEN
)) return;
212 if (strcmp(szFile
, LocalLock(group
->hGrpFile
)))
213 group
->bOverwriteFileOk
= FALSE
;
215 MAIN_ReplaceString(&group
->hName
, szName
);
216 MAIN_ReplaceString(&group
->hGrpFile
, szFile
);
218 GRPFILE_WriteGroupFile(hGroup
);
220 /* FIXME Delete old GrpFile if GrpFile changed */
222 /* FIXME Update progman.ini */
224 SetWindowText(group
->hWnd
, szName
);
227 /***********************************************************************
229 * GROUP_ShowGroupWindow
232 /* FIXME shouldn't be necessary */
233 VOID
GROUP_ShowGroupWindow(HLOCAL hGroup
)
235 PROGGROUP
*group
= LocalLock(hGroup
);
236 ShowWindow (group
->hWnd
, group
->nCmdShow
);
237 UpdateWindow (group
->hWnd
);
240 /***********************************************************************
245 VOID
GROUP_DeleteGroup(HLOCAL hGroup
)
247 PROGGROUP
*group
= LocalLock(hGroup
);
249 Globals
.hActiveGroup
= 0;
252 ((PROGGROUP
*)LocalLock(group
->hPrior
))->hNext
= group
->hNext
;
253 else Globals
.hGroups
= group
->hNext
;
256 ((PROGGROUP
*)LocalLock(group
->hNext
))->hPrior
= group
->hPrior
;
258 while (group
->hPrograms
)
259 PROGRAM_DeleteProgram(group
->hPrograms
, FALSE
);
261 /* FIXME Update progman.ini */
263 SendMessage(Globals
.hMDIWnd
, WM_MDIDESTROY
, (WPARAM
)group
->hWnd
, 0);
265 LocalFree(group
->hName
);
266 LocalFree(group
->hGrpFile
);
270 /***********************************************************************
275 HLOCAL
GROUP_FirstGroup()
277 return(Globals
.hGroups
);
280 /***********************************************************************
285 HLOCAL
GROUP_NextGroup(HLOCAL hGroup
)
288 if (!hGroup
) return(0);
289 group
= LocalLock(hGroup
);
290 return(group
->hNext
);
293 /***********************************************************************
298 HLOCAL
GROUP_ActiveGroup()
300 return(Globals
.hActiveGroup
);
303 /***********************************************************************
308 HWND
GROUP_GroupWnd(HLOCAL hGroup
)
311 if (!hGroup
) return(0);
312 group
= LocalLock(hGroup
);
316 /***********************************************************************
321 LPCSTR
GROUP_GroupName(HLOCAL hGroup
)
324 if (!hGroup
) return(0);
325 group
= LocalLock(hGroup
);
326 return(LocalLock(group
->hName
));
329 /* Local Variables: */
330 /* c-file-style: "GNU" */