ReactOS  0.4.15-dev-338-g3dad100
program.c File Reference
#include "progman.h"
Include dependency graph for program.c:

Go to the source code of this file.

Functions

VOID PROGRAM_NewProgram (PROGGROUP *hGroup)
 
VOID PROGRAM_ModifyProgram (PROGRAM *hProgram)
 
PROGRAMPROGRAM_AddProgram (PROGGROUP *hGroup, HICON hIcon, LPCWSTR lpszName, INT x, INT y, LPCWSTR lpszCmdLine, LPCWSTR lpszIconFile, INT nIconIndex, LPCWSTR lpszWorkDir, INT nHotKey, INT nCmdShow, BOOL bNewVDM)
 
VOID PROGRAM_CopyMoveProgram (PROGRAM *hProgram, BOOL bMove)
 
VOID PROGRAM_ExecuteProgram (PROGRAM *hProgram)
 
VOID PROGRAM_DeleteProgram (PROGRAM *hProgram, BOOL bUpdateGrpFile)
 
PROGRAMPROGRAM_ActiveProgram (PROGGROUP *hGroup)
 

Function Documentation

◆ PROGRAM_ActiveProgram()

PROGRAM* PROGRAM_ActiveProgram ( PROGGROUP hGroup)

Definition at line 331 of file program.c.

332 {
333  if (!hGroup) return NULL;
334  if (IsIconic(hGroup->hWnd)) return NULL;
335  return hGroup->hActiveProgram;
336 }
HWND hWnd
Definition: progman.h:116
BOOL WINAPI IsIconic(_In_ HWND)
smooth NULL
Definition: ftsmooth.c:416
PROGRAM * hActiveProgram
Definition: progman.h:140

Referenced by MAIN_MainWndProc(), and MAIN_MenuCommand().

◆ PROGRAM_AddProgram()

PROGRAM* PROGRAM_AddProgram ( PROGGROUP hGroup,
HICON  hIcon,
LPCWSTR  lpszName,
INT  x,
INT  y,
LPCWSTR  lpszCmdLine,
LPCWSTR  lpszIconFile,
INT  nIconIndex,
LPCWSTR  lpszWorkDir,
INT  nHotKey,
INT  nCmdShow,
BOOL  bNewVDM 
)

Definition at line 157 of file program.c.

160 {
161  PROGRAM* hProgram;
162  PROGRAM* hPrior;
163  PROGRAM** p;
164  LPWSTR hCmdLine;
165  LPWSTR hIconFile;
166  LPWSTR hName;
167  LPWSTR hWorkDir;
168  LVITEMW lvItem;
169  INT iItem;
170 
171  hProgram = Alloc(HEAP_ZERO_MEMORY, sizeof(*hProgram));
172  hName = Alloc(HEAP_ZERO_MEMORY, (wcslen(lpszName) + 1) * sizeof(WCHAR));
173  hCmdLine = Alloc(HEAP_ZERO_MEMORY, (wcslen(lpszCmdLine) + 1) * sizeof(WCHAR));
174  hIconFile = Alloc(HEAP_ZERO_MEMORY, (wcslen(lpszIconFile) + 1) * sizeof(WCHAR));
175  hWorkDir = Alloc(HEAP_ZERO_MEMORY, (wcslen(lpszWorkDir) + 1) * sizeof(WCHAR));
176  if (!hProgram || !hName || !hCmdLine || !hIconFile || !hWorkDir)
177  {
179  if (hProgram) Free(hProgram);
180  if (hName) Free(hName);
181  if (hCmdLine) Free(hCmdLine);
182  if (hIconFile) Free(hIconFile);
183  if (hWorkDir) Free(hWorkDir);
184  return NULL;
185  }
186  memcpy(hName , lpszName , (wcslen(lpszName) + 1) * sizeof(WCHAR));
187  memcpy(hCmdLine , lpszCmdLine , (wcslen(lpszCmdLine) + 1) * sizeof(WCHAR));
188  memcpy(hIconFile, lpszIconFile, (wcslen(lpszIconFile) + 1) * sizeof(WCHAR));
189  memcpy(hWorkDir , lpszWorkDir , (wcslen(lpszWorkDir) + 1) * sizeof(WCHAR));
190 
191  hGroup->hActiveProgram = hProgram;
192 
193  hPrior = NULL;
194  for (p = &hGroup->hPrograms; *p; p = &hPrior->hNext)
195  hPrior = *p;
196  *p = hProgram;
197 
198  hProgram->hGroup = hGroup;
199  hProgram->hPrior = hPrior;
200  hProgram->hNext = NULL;
201  hProgram->hName = hName;
202  hProgram->hCmdLine = hCmdLine;
203  hProgram->hIconFile = hIconFile;
204  hProgram->nIconIndex = nIconIndex;
205  hProgram->hWorkDir = hWorkDir;
206  hProgram->hIcon = hIcon;
207  hProgram->nCmdShow = nCmdShow;
208  hProgram->nHotKey = nHotKey;
209  hProgram->bNewVDM = bNewVDM;
210  hProgram->TagsSize = 0;
211  hProgram->Tags = NULL;
212 
213  ZeroMemory(&lvItem, sizeof(lvItem));
214  lvItem.mask = LVIF_PARAM | LVIF_IMAGE | LVIF_TEXT;
215  lvItem.pszText = (LPWSTR)lpszName;
216  lvItem.lParam = (LPARAM)hProgram;
217  lvItem.iImage = ImageList_ReplaceIcon(hGroup->hListLarge, -1, hIcon);
219 
220  lvItem.iItem = SendMessageA(hGroup->hListView, LVM_GETITEMCOUNT, 0, 0);
221  iItem = SendMessageW(hGroup->hListView, LVM_INSERTITEMW, 0, (LPARAM)&lvItem);
222  hProgram->iItem = iItem;
223  if (x != -1 && y != -1)
225 
226  return hProgram;
227 }
INT WINAPI ImageList_ReplaceIcon(HIMAGELIST himl, INT nIndex, HICON hIcon)
Definition: imagelist.c:2779
int iImage
Definition: commctrl.h:2363
PROGRAM * hNext
Definition: progman.h:85
SIZE_T TagsSize
Definition: progman.h:101
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
LPWSTR hIconFile
Definition: progman.h:95
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MAKELPARAM(l, h)
Definition: winuser.h:3983
#define ZeroMemory
Definition: winbase.h:1648
PVOID Tags
Definition: progman.h:102
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define IDS_OUT_OF_MEMORY
Definition: resource.h:63
int32_t INT
Definition: typedefs.h:57
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION Free
Definition: exfuncs.h:656
#define LVIF_TEXT
Definition: commctrl.h:2305
LPWSTR hCmdLine
Definition: progman.h:94
LPARAM lParam
Definition: commctrl.h:2364
#define LVM_GETITEMCOUNT
Definition: commctrl.h:2302
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
INT iItem
Definition: progman.h:88
LPWSTR hWorkDir
Definition: progman.h:96
#define LVM_SETITEMPOSITION
Definition: commctrl.h:2476
__wchar_t WCHAR
Definition: xmlstorage.h:180
INT nCmdShow
Definition: progman.h:98
LPWSTR pszText
Definition: commctrl.h:2361
#define LVIF_IMAGE
Definition: commctrl.h:2306
PVOID Alloc(IN DWORD dwFlags, IN SIZE_T dwBytes)
Definition: main.c:63
UINT mask
Definition: commctrl.h:2356
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
INT nHotKey
Definition: progman.h:97
#define LVM_INSERTITEMW
Definition: commctrl.h:2400
PROGRAM * hActiveProgram
Definition: progman.h:140
HWND hListView
Definition: progman.h:118
HICON hIcon
Definition: msconfig.c:44
LPWSTR hName
Definition: progman.h:93
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MB_OK
Definition: winuser.h:784
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
#define IDS_ERROR
Definition: resource.h:18
PROGGROUP * hGroup
Definition: progman.h:83
#define LVIF_PARAM
Definition: commctrl.h:2307
HIMAGELIST hListLarge
Definition: progman.h:119
HICON hIcon
Definition: progman.h:92
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
INT nIconIndex
Definition: progman.h:91
PROGRAM * hPrograms
Definition: progman.h:139
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
PROGRAM * hPrior
Definition: progman.h:84
BOOL bNewVDM
Definition: progman.h:99
INT MAIN_MessageBoxIDS(UINT ids_text, UINT ids_title, WORD type)
Definition: main.c:1159

Referenced by PROGRAM_CopyMoveProgram(), and PROGRAM_NewProgram().

◆ PROGRAM_CopyMoveProgram()

VOID PROGRAM_CopyMoveProgram ( PROGRAM hProgram,
BOOL  bMove 
)

Definition at line 236 of file program.c.

237 {
238  PROGGROUP* hGroup;
239 
240  hGroup = DIALOG_CopyMove(hProgram, bMove);
241  if (!hGroup)
242  return;
243 
244  /* FIXME: shouldn't be necessary */
245  OpenIcon(hGroup->hWnd);
246 
247  if (!PROGRAM_AddProgram(hGroup,
248  hProgram->hIcon,
249  hProgram->hName,
250  hProgram->x,
251  hProgram->y,
252  hProgram->hCmdLine,
253  hProgram->hIconFile,
254  hProgram->nIconIndex,
255  hProgram->hWorkDir,
256  hProgram->nHotKey,
257  hProgram->nCmdShow,
258  hProgram->bNewVDM))
259  {
260  return;
261  }
262 
263  GRPFILE_WriteGroupFile(hGroup);
264 
265  if (bMove)
266  PROGRAM_DeleteProgram(hProgram, TRUE);
267 }
#define TRUE
Definition: types.h:120
LPWSTR hIconFile
Definition: progman.h:95
HWND hWnd
Definition: progman.h:116
LPWSTR hCmdLine
Definition: progman.h:94
BOOL GRPFILE_WriteGroupFile(PROGGROUP *hGroup)
Definition: grpfile.c:358
LPWSTR hWorkDir
Definition: progman.h:96
INT nCmdShow
Definition: progman.h:98
BOOL WINAPI OpenIcon(_In_ HWND)
INT y
Definition: progman.h:90
VOID PROGRAM_DeleteProgram(PROGRAM *hProgram, BOOL bUpdateGrpFile)
Definition: program.c:289
INT nHotKey
Definition: progman.h:97
LPWSTR hName
Definition: progman.h:93
PROGRAM * PROGRAM_AddProgram(PROGGROUP *hGroup, HICON hIcon, LPCWSTR lpszName, INT x, INT y, LPCWSTR lpszCmdLine, LPCWSTR lpszIconFile, INT nIconIndex, LPCWSTR lpszWorkDir, INT nHotKey, INT nCmdShow, BOOL bNewVDM)
Definition: program.c:157
HICON hIcon
Definition: progman.h:92
INT x
Definition: progman.h:89
INT nIconIndex
Definition: progman.h:91
BOOL bNewVDM
Definition: progman.h:99
PROGGROUP * DIALOG_CopyMove(PROGRAM *hProgram, BOOL bMove)
Definition: dialog.c:343

Referenced by MAIN_MenuCommand().

◆ PROGRAM_DeleteProgram()

VOID PROGRAM_DeleteProgram ( PROGRAM hProgram,
BOOL  bUpdateGrpFile 
)

Definition at line 289 of file program.c.

290 {
291  PROGGROUP* group;
292 
293  group = hProgram->hGroup;
294  if (hProgram->hGroup->hActiveProgram == hProgram)
296 
297  SendMessageA(group->hListView, LVM_DELETEITEM, hProgram->iItem, 0);
298 
299  if (hProgram->hPrior)
300  hProgram->hPrior->hNext = hProgram->hNext;
301  else
302  hProgram->hGroup->hPrograms = hProgram->hNext;
303 
304  if (hProgram->hNext)
305  hProgram->hNext->hPrior = hProgram->hPrior;
306 
307  if (bUpdateGrpFile)
308  GRPFILE_WriteGroupFile(hProgram->hGroup);
309 
310 #if 0
311  DestroyWindow(program->hWnd);
312  if (program->hIcon)
313  DestroyIcon(program->hIcon);
314 #endif
315 
316  if (hProgram->Tags)
317  Free(hProgram->Tags);
318  Free(hProgram->hName);
319  Free(hProgram->hCmdLine);
320  Free(hProgram->hIconFile);
321  Free(hProgram->hWorkDir);
322  Free(hProgram);
323 }
PROGRAM * hNext
Definition: progman.h:85
BOOL WINAPI DestroyIcon(_In_ HICON)
Definition: cursoricon.c:2022
LPWSTR hIconFile
Definition: progman.h:95
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
PVOID Tags
Definition: progman.h:102
#define LVM_DELETEITEM
Definition: commctrl.h:2406
BOOL WINAPI DestroyWindow(_In_ HWND)
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION Free
Definition: exfuncs.h:656
LPWSTR hCmdLine
Definition: progman.h:94
BOOL GRPFILE_WriteGroupFile(PROGGROUP *hGroup)
Definition: grpfile.c:358
smooth NULL
Definition: ftsmooth.c:416
INT iItem
Definition: progman.h:88
GLboolean GLuint group
Definition: glext.h:11120
LPWSTR hWorkDir
Definition: progman.h:96
PROGRAM * hActiveProgram
Definition: progman.h:140
GLuint program
Definition: glext.h:6723
LPWSTR hName
Definition: progman.h:93
PROGGROUP * hGroup
Definition: progman.h:83
PROGRAM * hPrograms
Definition: progman.h:139
PROGRAM * hPrior
Definition: progman.h:84

Referenced by GROUP_DeleteGroup(), MAIN_MenuCommand(), and PROGRAM_CopyMoveProgram().

◆ PROGRAM_ExecuteProgram()

VOID PROGRAM_ExecuteProgram ( PROGRAM hProgram)

Definition at line 274 of file program.c.

275 {
276  // TODO: Use a (private?) shell API with which one can use hProgram->bNewVDM
277 
278  ShellExecuteW(NULL, NULL, hProgram->hCmdLine, NULL, hProgram->hWorkDir, hProgram->nCmdShow);
279 
280  if (Globals.bMinOnRun)
282 }
BOOL WINAPI CloseWindow(_In_ HWND)
CLIPBOARD_GLOBALS Globals
Definition: clipbrd.c:13
LPWSTR hCmdLine
Definition: progman.h:94
smooth NULL
Definition: ftsmooth.c:416
LPWSTR hWorkDir
Definition: progman.h:96
INT nCmdShow
Definition: progman.h:98
HINSTANCE WINAPI ShellExecuteW(HWND hwnd, LPCWSTR lpVerb, LPCWSTR lpFile, LPCWSTR lpParameters, LPCWSTR lpDirectory, INT nShowCmd)
Definition: shlexec.cpp:2274

Referenced by GROUP_GroupWndProc(), MAIN_AutoStart(), and MAIN_MenuCommand().

◆ PROGRAM_ModifyProgram()

VOID PROGRAM_ModifyProgram ( PROGRAM hProgram)

Definition at line 116 of file program.c.

117 {
118  LVITEMW lvItem;
120  WCHAR szWorkDir[MAX_PATHNAME_LEN];
121  WCHAR szCmdLine[MAX_PATHNAME_LEN];
122  WCHAR szIconFile[MAX_PATHNAME_LEN];
123 
124  lstrcpynW(szName , hProgram->hName , ARRAYSIZE(szName));
125  lstrcpynW(szCmdLine , hProgram->hCmdLine , ARRAYSIZE(szCmdLine));
126  lstrcpynW(szIconFile, hProgram->hIconFile, ARRAYSIZE(szIconFile));
127  lstrcpynW(szWorkDir , hProgram->hWorkDir , ARRAYSIZE(szWorkDir));
128 
129  if (!DIALOG_ProgramAttributes(szName, szCmdLine, szWorkDir, szIconFile,
130  &hProgram->hIcon, &hProgram->nIconIndex,
131  &hProgram->nHotKey, &hProgram->nCmdShow,
132  &hProgram->bNewVDM, MAX_PATHNAME_LEN))
133  {
134  return;
135  }
136 
137  MAIN_ReplaceString(&hProgram->hName , szName);
138  MAIN_ReplaceString(&hProgram->hCmdLine , szCmdLine);
139  MAIN_ReplaceString(&hProgram->hIconFile, szIconFile);
140  MAIN_ReplaceString(&hProgram->hWorkDir , szWorkDir);
141 
142  ZeroMemory(&lvItem, sizeof(lvItem));
143  lvItem.mask = LVIF_TEXT;
144  lvItem.iSubItem = 0;
145  lvItem.pszText = szName;
146  SendMessageW(hProgram->hGroup->hListView, LVM_SETITEMTEXTW, hProgram->iItem, (LPARAM)&lvItem);
147 
148  GRPFILE_WriteGroupFile(hProgram->hGroup);
149 }
LPWSTR hIconFile
Definition: progman.h:95
#define ARRAYSIZE(array)
Definition: filtermapper.c:47
#define ZeroMemory
Definition: winbase.h:1648
#define lstrcpynW
Definition: compat.h:406
#define LVIF_TEXT
Definition: commctrl.h:2305
LPWSTR hCmdLine
Definition: progman.h:94
int iSubItem
Definition: commctrl.h:2358
BOOL GRPFILE_WriteGroupFile(PROGGROUP *hGroup)
Definition: grpfile.c:358
LONG_PTR LPARAM
Definition: windef.h:208
INT iItem
Definition: progman.h:88
#define MAX_PATHNAME_LEN
Definition: progman.h:54
LPWSTR hWorkDir
Definition: progman.h:96
__wchar_t WCHAR
Definition: xmlstorage.h:180
INT nCmdShow
Definition: progman.h:98
LPWSTR pszText
Definition: commctrl.h:2361
UINT mask
Definition: commctrl.h:2356
INT nHotKey
Definition: progman.h:97
VOID MAIN_ReplaceString(LPWSTR *string, LPWSTR replace)
Definition: main.c:1192
#define LVM_SETITEMTEXTW
Definition: commctrl.h:2683
HWND hListView
Definition: progman.h:118
LPWSTR hName
Definition: progman.h:93
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
PROGGROUP * hGroup
Definition: progman.h:83
static const WCHAR szName[]
Definition: msipriv.h:1194
HICON hIcon
Definition: progman.h:92
BOOL DIALOG_ProgramAttributes(LPWSTR lpszTitle, LPWSTR lpszCmdLine, LPWSTR lpszWorkDir, LPWSTR lpszIconFile, HICON *lphIcon, INT *lpnIconIndex, INT *lpnHotKey, INT *lpnCmdShow, BOOL *lpbNewVDM, INT nSize)
Definition: dialog.c:864
INT nIconIndex
Definition: progman.h:91
BOOL bNewVDM
Definition: progman.h:99

Referenced by MAIN_MenuCommand().

◆ PROGRAM_NewProgram()

VOID PROGRAM_NewProgram ( PROGGROUP hGroup)

Definition at line 80 of file program.c.

81 {
82  HICON hIcon = NULL;
83  INT nIconIndex = 0;
84  INT nHotKey = 0;
85  INT nCmdShow = SW_SHOWNORMAL;
86  BOOL bNewVDM = FALSE;
88  WCHAR szCmdLine[MAX_PATHNAME_LEN] = L"";
89  WCHAR szIconFile[MAX_PATHNAME_LEN] = L"";
90  WCHAR szWorkDir[MAX_PATHNAME_LEN] = L"";
91 
92  if (!DIALOG_ProgramAttributes(szTitle, szCmdLine, szWorkDir, szIconFile,
93  &hIcon, &nIconIndex, &nHotKey, &nCmdShow, &bNewVDM,
95  {
96  return;
97  }
98 
99  if (!hIcon)
101 
102  if (!PROGRAM_AddProgram(hGroup, hIcon, szTitle, -1, -1, szCmdLine, szIconFile,
103  nIconIndex, szWorkDir, nHotKey, nCmdShow, bNewVDM))
104  {
105  return;
106  }
107 
108  GRPFILE_WriteGroupFile(hGroup);
109 }
static HICON
Definition: imagelist.c:84
int32_t INT
Definition: typedefs.h:57
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL GRPFILE_WriteGroupFile(PROGGROUP *hGroup)
Definition: grpfile.c:358
smooth NULL
Definition: ftsmooth.c:416
#define MAX_PATHNAME_LEN
Definition: progman.h:54
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define IDI_WINLOGO
Definition: winuser.h:704
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
static const WCHAR L[]
Definition: oid.c:1250
#define SW_SHOWNORMAL
Definition: winuser.h:764
HICON hIcon
Definition: msconfig.c:44
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
PROGRAM * PROGRAM_AddProgram(PROGGROUP *hGroup, HICON hIcon, LPCWSTR lpszName, INT x, INT y, LPCWSTR lpszCmdLine, LPCWSTR lpszIconFile, INT nIconIndex, LPCWSTR lpszWorkDir, INT nHotKey, INT nCmdShow, BOOL bNewVDM)
Definition: program.c:157
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
BOOL DIALOG_ProgramAttributes(LPWSTR lpszTitle, LPWSTR lpszCmdLine, LPWSTR lpszWorkDir, LPWSTR lpszIconFile, HICON *lphIcon, INT *lpnIconIndex, INT *lpnHotKey, INT *lpnCmdShow, BOOL *lpbNewVDM, INT nSize)
Definition: dialog.c:864

Referenced by MAIN_MenuCommand().