~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/programs/progman/program.c

Version: ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2  * Program Manager
  3  *
  4  * Copyright 1996 Ulrich Schmid
  5  *
  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.
 10  *
 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.
 15  *
 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
 19  */
 20 
 21 #define WIN32_LEAN_AND_MEAN
 22 
 23 #include <string.h>
 24 #include "windows.h"
 25 #include "progman.h"
 26 
 27 /***********************************************************************
 28  *
 29  *           PROGRAM_ProgramWndProc
 30  */
 31 
 32 static LRESULT CALLBACK PROGRAM_ProgramWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
 33 {
 34   switch (msg)
 35     {
 36     case WM_NCLBUTTONDOWN:
 37       {
 38         HLOCAL  hProgram = (HLOCAL) GetWindowLongPtr(hWnd, 0);
 39         PROGRAM *program = LocalLock(hProgram);
 40         PROGGROUP   *group   = LocalLock(program->hGroup);
 41         group->hActiveProgram = hProgram;
 42         EnableMenuItem(Globals.hFileMenu, PM_MOVE , MF_ENABLED);
 43         EnableMenuItem(Globals.hFileMenu, PM_COPY , MF_ENABLED);
 44         break;
 45       }
 46     case WM_NCLBUTTONDBLCLK:
 47       {
 48         PROGRAM_ExecuteProgram((HLOCAL) GetWindowLongPtr(hWnd, 0));
 49         return(0);
 50       }
 51 
 52     case WM_PAINTICON:
 53     case WM_NCPAINT:
 54       {
 55         PROGRAM *program;
 56         PAINTSTRUCT      ps;
 57         HDC              hdc;
 58         hdc     = BeginPaint(hWnd,&ps);
 59         program = LocalLock((HLOCAL) GetWindowLongPtr(hWnd, 0));
 60         if (program->hIcon)
 61           DrawIcon(hdc, 0, 0, program->hIcon);
 62         EndPaint(hWnd,&ps);
 63         break;
 64       }
 65     }
 66   return(DefWindowProc(hWnd, msg, wParam, lParam));
 67 }
 68 
 69 /***********************************************************************
 70  *
 71  *           PROGRAM_RegisterProgramWinClass
 72  */
 73 
 74 ATOM PROGRAM_RegisterProgramWinClass(void)
 75 {
 76   WNDCLASS class;
 77 
 78   class.style         = CS_HREDRAW | CS_VREDRAW;
 79   class.lpfnWndProc   = PROGRAM_ProgramWndProc;
 80   class.cbClsExtra    = 0;
 81   class.cbWndExtra    = sizeof(LONG_PTR);
 82   class.hInstance     = Globals.hInstance;
 83   class.hIcon         = 0;
 84   class.hCursor       = LoadCursor (0, IDC_ARROW);
 85   class.hbrBackground = GetStockObject (WHITE_BRUSH);
 86   class.lpszMenuName  = 0;
 87   class.lpszClassName = STRING_PROGRAM_WIN_CLASS_NAME;
 88 
 89   return RegisterClass(&class);
 90 }
 91 
 92 /***********************************************************************
 93  *
 94  *           PROGRAM_NewProgram
 95  */
 96 
 97 VOID PROGRAM_NewProgram(HLOCAL hGroup)
 98 {
 99   INT  nCmdShow = SW_SHOWNORMAL;
100   INT  nHotKey = 0;
101   INT  nIconIndex = 0;
102   CHAR szName[MAX_PATHNAME_LEN] = "";
103   CHAR szCmdLine[MAX_PATHNAME_LEN] = "";
104   CHAR szIconFile[MAX_PATHNAME_LEN] = "";
105   CHAR szWorkDir[MAX_PATHNAME_LEN] = "";
106   HICON hIcon = 0;
107 
108   if (!DIALOG_ProgramAttributes(szName, szCmdLine, szWorkDir, szIconFile,
109                                 &hIcon, &nIconIndex, &nHotKey,
110                                 &nCmdShow, MAX_PATHNAME_LEN))
111     return;
112 
113   if (!hIcon) hIcon = LoadIcon(0, IDI_WINLOGO);
114 
115 
116   if (!PROGRAM_AddProgram(hGroup, hIcon, szName, 0, 0, szCmdLine, szIconFile,
117                           nIconIndex, szWorkDir, nHotKey, nCmdShow))
118     return;
119 
120   GRPFILE_WriteGroupFile(hGroup);
121 }
122 
123 /***********************************************************************
124  *
125  *           PROGRAM_ModifyProgram
126  */
127 
128 VOID PROGRAM_ModifyProgram(HLOCAL hProgram)
129 {
130   PROGRAM *program = LocalLock(hProgram);
131   CHAR szName[MAX_PATHNAME_LEN];
132   CHAR szCmdLine[MAX_PATHNAME_LEN];
133   CHAR szIconFile[MAX_PATHNAME_LEN];
134   CHAR szWorkDir[MAX_PATHNAME_LEN];
135 
136   lstrcpyn(szName, LocalLock(program->hName), MAX_PATHNAME_LEN);
137   lstrcpyn(szCmdLine, LocalLock(program->hCmdLine), MAX_PATHNAME_LEN);
138   lstrcpyn(szIconFile, LocalLock(program->hIconFile), MAX_PATHNAME_LEN);
139   lstrcpyn(szWorkDir, LocalLock(program->hWorkDir), MAX_PATHNAME_LEN);
140 
141   if (!DIALOG_ProgramAttributes(szName, szCmdLine, szWorkDir, szIconFile,
142                                 &program->hIcon, &program->nIconIndex,
143                                 &program->nHotKey, &program->nCmdShow,
144                                 MAX_PATHNAME_LEN))
145     return;
146 
147   MAIN_ReplaceString(&program->hName, szName);
148   MAIN_ReplaceString(&program->hCmdLine, szCmdLine);
149   MAIN_ReplaceString(&program->hIconFile, szIconFile);
150   MAIN_ReplaceString(&program->hWorkDir, szWorkDir);
151 
152   SetWindowText(program->hWnd, szName);
153   UpdateWindow(program->hWnd);
154 
155   GRPFILE_WriteGroupFile(program->hGroup);
156 
157   return;
158 }
159 
160 /***********************************************************************
161  *
162  *           PROGRAM_AddProgram
163  */
164 
165 HLOCAL PROGRAM_AddProgram(HLOCAL hGroup, HICON hIcon, LPCSTR lpszName,
166                           INT x, INT y, LPCSTR lpszCmdLine,
167                           LPCSTR lpszIconFile, INT nIconIndex,
168                           LPCSTR lpszWorkDir, INT nHotKey, INT nCmdShow)
169 {
170   PROGGROUP *group = LocalLock(hGroup);
171   PROGRAM *program;
172   HLOCAL hPrior, *p;
173   HLOCAL hProgram  = LocalAlloc(LMEM_FIXED, sizeof(PROGRAM));
174   HLOCAL hName     = LocalAlloc(LMEM_FIXED, 1 + lstrlen(lpszName));
175   HLOCAL hCmdLine  = LocalAlloc(LMEM_FIXED, 1 + lstrlen(lpszCmdLine));
176   HLOCAL hIconFile = LocalAlloc(LMEM_FIXED, 1 + lstrlen(lpszIconFile));
177   HLOCAL hWorkDir  = LocalAlloc(LMEM_FIXED, 1 + lstrlen(lpszWorkDir));
178   if (!hProgram || !hName || !hCmdLine || !hIconFile || !hWorkDir)
179     {
180       MAIN_MessageBoxIDS(IDS_OUT_OF_MEMORY, IDS_ERROR, MB_OK);
181       if (hProgram)  LocalFree(hProgram);
182       if (hName)     LocalFree(hName);
183       if (hCmdLine)  LocalFree(hCmdLine);
184       if (hIconFile) LocalFree(hIconFile);
185       if (hWorkDir)  LocalFree(hWorkDir);
186       return(0);
187     }
188   memcpy(LocalLock(hName),     lpszName,     1 + lstrlen(lpszName));
189   memcpy(LocalLock(hCmdLine),  lpszCmdLine,  1 + lstrlen(lpszCmdLine));
190   memcpy(LocalLock(hIconFile), lpszIconFile, 1 + lstrlen(lpszIconFile));
191   memcpy(LocalLock(hWorkDir),  lpszWorkDir,  1 + lstrlen(lpszWorkDir));
192 
193   group->hActiveProgram  = hProgram;
194 
195   hPrior = 0;
196   p = &group->hPrograms;
197   while (*p)
198     {
199       hPrior = *p;
200       p = &((PROGRAM*)LocalLock(hPrior))->hNext;
201     }
202   *p = hProgram;
203 
204   program = LocalLock(hProgram);
205   program->hGroup     = hGroup;
206   program->hPrior     = hPrior;
207   program->hNext      = 0;
208   program->hName      = hName;
209   program->hCmdLine   = hCmdLine;
210   program->hIconFile  = hIconFile;
211   program->nIconIndex = nIconIndex;
212   program->hWorkDir   = hWorkDir;
213   program->hIcon      = hIcon;
214   program->nCmdShow   = nCmdShow;
215   program->nHotKey    = nHotKey;
216 
217   program->hWnd =
218     CreateWindow (STRING_PROGRAM_WIN_CLASS_NAME, lpszName,
219                   WS_CHILD | WS_CAPTION,
220                   x, y, CW_USEDEFAULT, CW_USEDEFAULT,
221                   group->hWnd, 0, Globals.hInstance, 0);
222 
223   SetWindowLongPtr(program->hWnd, 0, (LONG_PTR) hProgram);
224 
225   ShowWindow (program->hWnd, SW_SHOWMINIMIZED);
226   SetWindowPos (program->hWnd, 0, x, y, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE);
227   UpdateWindow (program->hWnd);
228 
229   return hProgram;
230 }
231 
232 /***********************************************************************
233  *
234  *           PROGRAM_CopyMoveProgram
235  */
236 
237 VOID PROGRAM_CopyMoveProgram(HLOCAL hProgram, BOOL bMove)
238 {
239   PROGRAM *program = LocalLock(hProgram);
240   PROGGROUP   *fromgroup = LocalLock(program->hGroup);
241   HLOCAL hGroup = DIALOG_CopyMove(LocalLock(program->hName),
242                                   LocalLock(fromgroup->hName), bMove);
243   if (!hGroup) return;
244 
245   /* FIXME shouldn't be necessary */
246   OpenIcon(((PROGGROUP*)LocalLock(hGroup))->hWnd);
247 
248   if (!PROGRAM_AddProgram(hGroup,
249 #if 0
250                           CopyIcon(program->hIcon),
251 #else
252                           program->hIcon,
253 #endif
254                           LocalLock(program->hName),
255                           program->x, program->y,
256                           LocalLock(program->hCmdLine),
257                           LocalLock(program->hIconFile),
258                           program->nIconIndex,
259                           LocalLock(program->hWorkDir),
260                           program->nHotKey, program->nCmdShow)) return;
261   GRPFILE_WriteGroupFile(hGroup);
262 
263   if (bMove) PROGRAM_DeleteProgram(hProgram, TRUE);
264 }
265 
266 /***********************************************************************
267  *
268  *           PROGRAM_ExecuteProgram
269  */
270 
271 VOID PROGRAM_ExecuteProgram(HLOCAL hProgram)
272 {
273   PROGRAM *program = LocalLock(hProgram);
274   LPSTR lpszCmdLine = LocalLock(program->hCmdLine);
275   LPSTR lpszWorkDir = LocalLock(program->hWorkDir);
276 
277   /* FIXME set working directory */
278   lpszWorkDir = lpszWorkDir;
279 
280   WinExec(lpszCmdLine, program->nCmdShow);
281   if (Globals.bMinOnRun) CloseWindow(Globals.hMainWnd);
282 }
283 
284 /***********************************************************************
285  *
286  *           PROGRAM_DeleteProgram
287  */
288 
289 VOID PROGRAM_DeleteProgram(HLOCAL hProgram, BOOL bUpdateGrpFile)
290 {
291   PROGRAM *program = LocalLock(hProgram);
292   PROGGROUP   *group   = LocalLock(program->hGroup);
293 
294   group->hActiveProgram = 0;
295 
296   if (program->hPrior)
297     ((PROGRAM*)LocalLock(program->hPrior))->hNext = program->hNext;
298   else
299     ((PROGGROUP*)LocalLock(program->hGroup))->hPrograms = program->hNext;
300 
301   if (program->hNext)
302     ((PROGRAM*)LocalLock(program->hNext))->hPrior = program->hPrior;
303 
304   if (bUpdateGrpFile)
305     GRPFILE_WriteGroupFile(program->hGroup);
306 
307   DestroyWindow(program->hWnd);
308 #if 0
309   if (program->hIcon)
310     DestroyIcon(program->hIcon);
311 #endif
312   LocalFree(program->hName);
313   LocalFree(program->hCmdLine);
314   LocalFree(program->hIconFile);
315   LocalFree(program->hWorkDir);
316   LocalFree(hProgram);
317 }
318 
319 /***********************************************************************
320  *
321  *           PROGRAM_FirstProgram
322  */
323 
324 HLOCAL PROGRAM_FirstProgram(HLOCAL hGroup)
325 {
326   PROGGROUP *group;
327   if (!hGroup) return(0);
328   group = LocalLock(hGroup);
329   return(group->hPrograms);
330 }
331 
332 /***********************************************************************
333  *
334  *           PROGRAM_NextProgram
335  */
336 
337 HLOCAL PROGRAM_NextProgram(HLOCAL hProgram)
338 {
339   PROGRAM *program;
340   if (!hProgram) return(0);
341   program = LocalLock(hProgram);
342   return(program->hNext);
343 }
344 
345 /***********************************************************************
346  *
347  *           PROGRAM_ActiveProgram
348  */
349 
350 HLOCAL PROGRAM_ActiveProgram(HLOCAL hGroup)
351 {
352   PROGGROUP *group;
353   if (!hGroup) return(0);
354   group = LocalLock(hGroup);
355   if (IsIconic(group->hWnd)) return(0);
356 
357   return(group->hActiveProgram);
358 }
359 
360 /***********************************************************************
361  *
362  *           PROGRAM_ProgramName
363  */
364 
365 LPCSTR PROGRAM_ProgramName(HLOCAL hProgram)
366 {
367   PROGRAM *program;
368   if (!hProgram) return(0);
369   program = LocalLock(hProgram);
370   return(LocalLock(program->hName));
371 }
372 
373 /* Local Variables:    */
374 /* c-file-style: "GNU" */
375 /* End:                */
376 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.