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
)
37 printf("G %4.4x %4.4x\n", msg
, wParam
);
42 if (wParam
== SC_CLOSE
) wParam
= SC_MINIMIZE
;
45 case WM_CHILDACTIVATE
:
46 case WM_NCLBUTTONDOWN
:
47 Globals
.hActiveGroup
= (HLOCAL
)GetWindowLongPtrW(hWnd
, 0);
48 EnableMenuItem(Globals
.hFileMenu
, PM_MOVE
, MF_GRAYED
);
49 EnableMenuItem(Globals
.hFileMenu
, PM_COPY
, MF_GRAYED
);
52 return DefMDIChildProcW(hWnd
, msg
, wParam
, lParam
);
55 /***********************************************************************
57 * GROUP_RegisterGroupWinClass
60 ATOM
GROUP_RegisterGroupWinClass(void)
64 class.style
= CS_HREDRAW
| CS_VREDRAW
;
65 class.lpfnWndProc
= GROUP_GroupWndProc
;
67 class.cbWndExtra
= sizeof(LONG_PTR
);
68 class.hInstance
= Globals
.hInstance
;
69 class.hIcon
= LoadIconW (0, (LPWSTR
)IDI_WINLOGO
);
70 class.hCursor
= LoadCursorW (0, (LPWSTR
)IDC_ARROW
);
71 class.hbrBackground
= GetStockObject (WHITE_BRUSH
);
72 class.lpszMenuName
= 0;
73 class.lpszClassName
= STRING_GROUP_WIN_CLASS_NAME
;
75 return RegisterClassW(&class);
78 /***********************************************************************
83 VOID
GROUP_NewGroup(void)
85 CHAR szName
[MAX_PATHNAME_LEN
] = "";
86 CHAR szFile
[MAX_PATHNAME_LEN
] = "";
89 if (!DIALOG_GroupAttributes(szName
, szFile
, MAX_PATHNAME_LEN
)) return;
91 if (OpenFile(szFile
, &dummy
, OF_EXIST
) == HFILE_ERROR
)
93 /* File doesn't exist */
95 GROUP_AddGroup(szName
, szFile
, SW_SHOWNORMAL
,
96 DEF_GROUP_WIN_XPOS
, DEF_GROUP_WIN_YPOS
,
97 DEF_GROUP_WIN_WIDTH
, DEF_GROUP_WIN_HEIGHT
, 0, 0,
100 GRPFILE_WriteGroupFile(hGroup
);
102 else /* File exist */
103 GRPFILE_ReadGroupFile(szFile
);
105 /* FIXME Update progman.ini */
108 /***********************************************************************
113 HLOCAL
GROUP_AddGroup(LPCSTR lpszName
, LPCSTR lpszGrpFile
, INT nCmdShow
,
114 INT x
, INT y
, INT width
, INT height
,
115 INT iconx
, INT icony
,
116 BOOL bFileNameModified
, BOOL bOverwriteFileOk
,
117 /* FIXME shouldn't be necessary */
118 BOOL bSuppressShowWindow
)
120 PROGGROUP
*group
, *prior
;
124 HLOCAL hGroup
= LocalAlloc(LMEM_FIXED
, sizeof(PROGGROUP
));
125 HLOCAL hName
= LocalAlloc(LMEM_FIXED
, 1 + strlen(lpszName
));
126 HLOCAL hGrpFile
= LocalAlloc(LMEM_FIXED
, 1 + strlen(lpszGrpFile
));
127 if (!hGroup
|| !hName
|| !hGrpFile
)
129 MAIN_MessageBoxIDS(IDS_OUT_OF_MEMORY
, IDS_ERROR
, MB_OK
);
130 if (hGroup
) LocalFree(hGroup
);
131 if (hName
) LocalFree(hName
);
132 if (hGrpFile
) LocalFree(hGrpFile
);
135 memcpy(LocalLock(hName
), lpszName
, 1 + strlen(lpszName
));
136 memcpy(LocalLock(hGrpFile
), lpszGrpFile
, 1 + strlen(lpszGrpFile
));
138 Globals
.hActiveGroup
= hGroup
;
142 p
= &Globals
.hGroups
;
146 prior
= LocalLock(hPrior
);
148 if (prior
->seqnum
>= seqnum
)
149 seqnum
= prior
->seqnum
+ 1;
153 group
= LocalLock(hGroup
);
154 group
->hPrior
= hPrior
;
156 group
->hName
= hName
;
157 group
->hGrpFile
= hGrpFile
;
158 group
->bFileNameModified
= bFileNameModified
;
159 group
->bOverwriteFileOk
= bOverwriteFileOk
;
160 group
->seqnum
= seqnum
;
161 group
->nCmdShow
= nCmdShow
;
164 group
->width
= width
;
165 group
->height
= height
;
166 group
->iconx
= iconx
;
167 group
->icony
= icony
;
168 group
->hPrograms
= 0;
169 group
->hActiveProgram
= 0;
171 cs
.szClass
= STRING_GROUP_WIN_CLASS_NAME
;
181 group
->hWnd
= (HWND
)SendMessageA(Globals
.hMDIWnd
, WM_MDICREATE
, 0, (LPARAM
)&cs
);
182 SetWindowTextA( group
->hWnd
, lpszName
);
183 SetWindowLongPtrW(group
->hWnd
, 0, (LONG_PTR
) hGroup
);
186 if (!bSuppressShowWindow
) /* FIXME shouldn't be necessary */
189 ShowWindow (group
->hWnd
, nCmdShow
);
190 UpdateWindow (group
->hWnd
);
196 /***********************************************************************
201 VOID
GROUP_ModifyGroup(HLOCAL hGroup
)
203 PROGGROUP
*group
= LocalLock(hGroup
);
204 CHAR szName
[MAX_PATHNAME_LEN
];
205 CHAR szFile
[MAX_PATHNAME_LEN
];
206 lstrcpynA(szName
, LocalLock(group
->hName
), MAX_PATHNAME_LEN
);
207 lstrcpynA(szFile
, LocalLock(group
->hGrpFile
), MAX_PATHNAME_LEN
);
209 if (!DIALOG_GroupAttributes(szName
, szFile
, MAX_PATHNAME_LEN
)) return;
211 if (strcmp(szFile
, LocalLock(group
->hGrpFile
)))
212 group
->bOverwriteFileOk
= FALSE
;
214 MAIN_ReplaceString(&group
->hName
, szName
);
215 MAIN_ReplaceString(&group
->hGrpFile
, szFile
);
217 GRPFILE_WriteGroupFile(hGroup
);
219 /* FIXME Delete old GrpFile if GrpFile changed */
221 /* FIXME Update progman.ini */
223 SetWindowTextA(group
->hWnd
, szName
);
226 /***********************************************************************
228 * GROUP_ShowGroupWindow
231 /* FIXME shouldn't be necessary */
232 VOID
GROUP_ShowGroupWindow(HLOCAL hGroup
)
234 PROGGROUP
*group
= LocalLock(hGroup
);
235 ShowWindow (group
->hWnd
, group
->nCmdShow
);
236 UpdateWindow (group
->hWnd
);
239 /***********************************************************************
244 VOID
GROUP_DeleteGroup(HLOCAL hGroup
)
246 PROGGROUP
*group
= LocalLock(hGroup
);
248 Globals
.hActiveGroup
= 0;
251 ((PROGGROUP
*)LocalLock(group
->hPrior
))->hNext
= group
->hNext
;
252 else Globals
.hGroups
= group
->hNext
;
255 ((PROGGROUP
*)LocalLock(group
->hNext
))->hPrior
= group
->hPrior
;
257 while (group
->hPrograms
)
258 PROGRAM_DeleteProgram(group
->hPrograms
, FALSE
);
260 /* FIXME Update progman.ini */
262 SendMessageW(Globals
.hMDIWnd
, WM_MDIDESTROY
, (WPARAM
)group
->hWnd
, 0);
264 LocalFree(group
->hName
);
265 LocalFree(group
->hGrpFile
);
269 /***********************************************************************
274 HLOCAL
GROUP_FirstGroup(void)
276 return(Globals
.hGroups
);
279 /***********************************************************************
284 HLOCAL
GROUP_NextGroup(HLOCAL hGroup
)
287 if (!hGroup
) return(0);
288 group
= LocalLock(hGroup
);
289 return(group
->hNext
);
292 /***********************************************************************
297 HLOCAL
GROUP_ActiveGroup(void)
299 return(Globals
.hActiveGroup
);
302 /***********************************************************************
307 HWND
GROUP_GroupWnd(HLOCAL hGroup
)
310 if (!hGroup
) return(0);
311 group
= LocalLock(hGroup
);
315 /***********************************************************************
320 LPCSTR
GROUP_GroupName(HLOCAL hGroup
)
323 if (!hGroup
) return(0);
324 group
= LocalLock(hGroup
);
325 return(LocalLock(group
->hName
));