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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define WIN32_LEAN_AND_MEAN
28 /***********************************************************************
33 static LRESULT CALLBACK
GROUP_GroupWndProc(HWND hWnd
, UINT msg
,
34 WPARAM wParam
, LPARAM lParam
)
39 if (wParam
== SC_CLOSE
) wParam
= SC_MINIMIZE
;
42 case WM_CHILDACTIVATE
:
43 case WM_NCLBUTTONDOWN
:
44 Globals
.hActiveGroup
= (HLOCAL
)GetWindowLongPtrW(hWnd
, 0);
45 EnableMenuItem(Globals
.hFileMenu
, PM_MOVE
, MF_GRAYED
);
46 EnableMenuItem(Globals
.hFileMenu
, PM_COPY
, MF_GRAYED
);
49 return DefMDIChildProcW(hWnd
, msg
, wParam
, lParam
);
52 /***********************************************************************
54 * GROUP_RegisterGroupWinClass
57 ATOM
GROUP_RegisterGroupWinClass(void)
61 class.style
= CS_HREDRAW
| CS_VREDRAW
;
62 class.lpfnWndProc
= GROUP_GroupWndProc
;
64 class.cbWndExtra
= sizeof(LONG_PTR
);
65 class.hInstance
= Globals
.hInstance
;
66 class.hIcon
= LoadIconW (0, (LPWSTR
)IDI_WINLOGO
);
67 class.hCursor
= LoadCursorW (0, (LPWSTR
)IDC_ARROW
);
68 class.hbrBackground
= GetStockObject (WHITE_BRUSH
);
69 class.lpszMenuName
= 0;
70 class.lpszClassName
= STRING_GROUP_WIN_CLASS_NAME
;
72 return RegisterClassW(&class);
75 /***********************************************************************
80 VOID
GROUP_NewGroup(void)
82 CHAR szName
[MAX_PATHNAME_LEN
] = "";
83 CHAR szFile
[MAX_PATHNAME_LEN
] = "";
86 if (!DIALOG_GroupAttributes(szName
, szFile
, MAX_PATHNAME_LEN
)) return;
88 if (OpenFile(szFile
, &dummy
, OF_EXIST
) == HFILE_ERROR
)
90 /* File doesn't exist */
92 GROUP_AddGroup(szName
, szFile
, SW_SHOWNORMAL
,
93 DEF_GROUP_WIN_XPOS
, DEF_GROUP_WIN_YPOS
,
94 DEF_GROUP_WIN_WIDTH
, DEF_GROUP_WIN_HEIGHT
, 0, 0,
97 GRPFILE_WriteGroupFile(hGroup
);
100 GRPFILE_ReadGroupFile(szFile
);
102 /* FIXME Update progman.ini */
105 /***********************************************************************
110 HLOCAL
GROUP_AddGroup(LPCSTR lpszName
, LPCSTR lpszGrpFile
, INT nCmdShow
,
111 INT x
, INT y
, INT width
, INT height
,
112 INT iconx
, INT icony
,
113 BOOL bFileNameModified
, BOOL bOverwriteFileOk
,
114 /* FIXME shouldn't be necessary */
115 BOOL bSuppressShowWindow
)
117 PROGGROUP
*group
, *prior
;
121 HLOCAL hGroup
= LocalAlloc(LMEM_FIXED
, sizeof(PROGGROUP
));
122 HLOCAL hName
= LocalAlloc(LMEM_FIXED
, 1 + strlen(lpszName
));
123 HLOCAL hGrpFile
= LocalAlloc(LMEM_FIXED
, 1 + strlen(lpszGrpFile
));
124 if (!hGroup
|| !hName
|| !hGrpFile
)
126 MAIN_MessageBoxIDS(IDS_OUT_OF_MEMORY
, IDS_ERROR
, MB_OK
);
127 if (hGroup
) LocalFree(hGroup
);
128 if (hName
) LocalFree(hName
);
129 if (hGrpFile
) LocalFree(hGrpFile
);
132 memcpy(LocalLock(hName
), lpszName
, 1 + strlen(lpszName
));
133 memcpy(LocalLock(hGrpFile
), lpszGrpFile
, 1 + strlen(lpszGrpFile
));
135 Globals
.hActiveGroup
= hGroup
;
139 p
= &Globals
.hGroups
;
143 prior
= LocalLock(hPrior
);
145 if (prior
->seqnum
>= seqnum
)
146 seqnum
= prior
->seqnum
+ 1;
150 group
= LocalLock(hGroup
);
151 group
->hPrior
= hPrior
;
153 group
->hName
= hName
;
154 group
->hGrpFile
= hGrpFile
;
155 group
->bFileNameModified
= bFileNameModified
;
156 group
->bOverwriteFileOk
= bOverwriteFileOk
;
157 group
->seqnum
= seqnum
;
158 group
->nCmdShow
= nCmdShow
;
161 group
->width
= width
;
162 group
->height
= height
;
163 group
->iconx
= iconx
;
164 group
->icony
= icony
;
165 group
->hPrograms
= 0;
166 group
->hActiveProgram
= 0;
168 cs
.szClass
= STRING_GROUP_WIN_CLASS_NAME
;
178 group
->hWnd
= (HWND
)SendMessageA(Globals
.hMDIWnd
, WM_MDICREATE
, 0, (LPARAM
)&cs
);
179 SetWindowTextA( group
->hWnd
, lpszName
);
180 SetWindowLongPtrW(group
->hWnd
, 0, (LONG_PTR
) hGroup
);
183 if (!bSuppressShowWindow
) /* FIXME shouldn't be necessary */
186 ShowWindow (group
->hWnd
, nCmdShow
);
187 UpdateWindow (group
->hWnd
);
193 /***********************************************************************
198 VOID
GROUP_ModifyGroup(HLOCAL hGroup
)
200 PROGGROUP
*group
= LocalLock(hGroup
);
201 CHAR szName
[MAX_PATHNAME_LEN
];
202 CHAR szFile
[MAX_PATHNAME_LEN
];
203 lstrcpynA(szName
, LocalLock(group
->hName
), MAX_PATHNAME_LEN
);
204 lstrcpynA(szFile
, LocalLock(group
->hGrpFile
), MAX_PATHNAME_LEN
);
206 if (!DIALOG_GroupAttributes(szName
, szFile
, MAX_PATHNAME_LEN
)) return;
208 if (strcmp(szFile
, LocalLock(group
->hGrpFile
)))
209 group
->bOverwriteFileOk
= FALSE
;
211 MAIN_ReplaceString(&group
->hName
, szName
);
212 MAIN_ReplaceString(&group
->hGrpFile
, szFile
);
214 GRPFILE_WriteGroupFile(hGroup
);
216 /* FIXME Delete old GrpFile if GrpFile changed */
218 /* FIXME Update progman.ini */
220 SetWindowTextA(group
->hWnd
, szName
);
223 /***********************************************************************
225 * GROUP_ShowGroupWindow
228 /* FIXME shouldn't be necessary */
229 VOID
GROUP_ShowGroupWindow(HLOCAL hGroup
)
231 PROGGROUP
*group
= LocalLock(hGroup
);
232 ShowWindow (group
->hWnd
, group
->nCmdShow
);
233 UpdateWindow (group
->hWnd
);
236 /***********************************************************************
241 VOID
GROUP_DeleteGroup(HLOCAL hGroup
)
243 PROGGROUP
*group
= LocalLock(hGroup
);
245 Globals
.hActiveGroup
= 0;
248 ((PROGGROUP
*)LocalLock(group
->hPrior
))->hNext
= group
->hNext
;
249 else Globals
.hGroups
= group
->hNext
;
252 ((PROGGROUP
*)LocalLock(group
->hNext
))->hPrior
= group
->hPrior
;
254 while (group
->hPrograms
)
255 PROGRAM_DeleteProgram(group
->hPrograms
, FALSE
);
257 /* FIXME Update progman.ini */
259 SendMessageW(Globals
.hMDIWnd
, WM_MDIDESTROY
, (WPARAM
)group
->hWnd
, 0);
261 LocalFree(group
->hName
);
262 LocalFree(group
->hGrpFile
);
266 /***********************************************************************
271 HLOCAL
GROUP_FirstGroup(void)
273 return(Globals
.hGroups
);
276 /***********************************************************************
281 HLOCAL
GROUP_NextGroup(HLOCAL hGroup
)
284 if (!hGroup
) return(0);
285 group
= LocalLock(hGroup
);
286 return(group
->hNext
);
289 /***********************************************************************
294 HLOCAL
GROUP_ActiveGroup(void)
296 return(Globals
.hActiveGroup
);
299 /***********************************************************************
304 HWND
GROUP_GroupWnd(HLOCAL hGroup
)
307 if (!hGroup
) return(0);
308 group
= LocalLock(hGroup
);
312 /***********************************************************************
317 LPCSTR
GROUP_GroupName(HLOCAL hGroup
)
320 if (!hGroup
) return(0);
321 group
= LocalLock(hGroup
);
322 return(LocalLock(group
->hName
));