ReactOS  0.4.12-dev-18-gf469aca
toolspage.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Applications
3  * LICENSE: LGPL - See COPYING in the top level directory
4  * FILE: base/applications/msconfig/toolspage.c
5  * PURPOSE: Tools page message handler
6  * COPYRIGHT: Copyright 2005-2006 Christoph von Wittich <Christoph@ApiViewer.de>
7  *
8  */
9 
10 #include "precomp.h"
11 
12 #include <shlwapi.h>
13 
17 
18 void AddItem ( DWORD, DWORD, DWORD, DWORD, int );
19 void FillListView ( void );
20 
24 
25 void AddItem ( DWORD name_id, DWORD descr_id, DWORD cmd_id , DWORD param_id, int csidl ) {
26  TCHAR szTemp[256];
27  LV_ITEM item;
28 
29  LoadString(hInst, name_id, szTemp, 256);
30  memset(&item, 0, sizeof(LV_ITEM));
31  item.mask = LVIF_TEXT;
32  item.iImage = 0;
33  item.pszText = szTemp;
34  item.iItem = ListView_GetItemCount(hToolsListCtrl);
35  item.lParam = 0;
36  (void)ListView_InsertItem(hToolsListCtrl, &item);
37 
38  ListItems_Cmds[item.iItem] = cmd_id;
39  ListItems_Params[item.iItem] = param_id;
40  ListItems_Locations[item.iItem] = csidl;
41 
42  LoadString(hInst, descr_id, szTemp, 256);
43  item.pszText = szTemp;
44  item.iSubItem = 1;
45  SendMessage(hToolsListCtrl, LVM_SETITEMTEXT, item.iItem, (LPARAM) &item);
46 }
47 
48 void FillListView ( void ) {
53 }
54 
57 {
59  TCHAR szTemp[MAX_PATH*2];
60  TCHAR szTemp2[256];
61  TCHAR * Ptr = NULL;
62  LPNMITEMACTIVATE lpnmitem;
63  LPNMHDR nmh;
64  DWORD dwStyle;
66  STARTUPINFO si;
67 
68  switch (message)
69  {
70  case WM_INITDIALOG:
71  {
72  hToolsListCtrl = GetDlgItem(hDlg, IDC_TOOLS_LIST);
73  hToolsDialog = hDlg;
74 
75  dwStyle = (DWORD) SendMessage(hToolsListCtrl, LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
76  dwStyle = dwStyle | LVS_EX_FULLROWSELECT;
77  SendMessage(hToolsListCtrl, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, dwStyle);
78 
80 
81  // Initialize the application page's controls
82  column.mask = LVCF_TEXT | LVCF_WIDTH;
83 
84  LoadString(hInst, IDS_TOOLS_COLUMN_NAME, szTemp, 256);
85  column.pszText = szTemp;
86  column.cx = 150;
87  (void)ListView_InsertColumn(hToolsListCtrl, 0, &column);
88 
89  column.mask = LVCF_TEXT | LVCF_WIDTH;
91  column.pszText = szTemp;
92  column.cx = 500;
93  (void)ListView_InsertColumn(hToolsListCtrl, 1, &column);
94 
95  FillListView();
96  return TRUE;
97  }
98  case WM_COMMAND:
99  {
100  switch (LOWORD(wParam))
101  {
102  case IDC_BTN_RUN:
103  {
104  if (ListView_GetSelectionMark(hToolsListCtrl) != -1)
105  {
107  Ptr = PathAddBackslash(szTemp);
108 
109  if (!Ptr)
110  Ptr = szTemp;
111 
112  szTemp2[0] = _T('\0');
113  LoadString(hInst, ListItems_Cmds[ListView_GetSelectionMark(hToolsListCtrl)], Ptr, 256);
114  LoadString(hInst, ListItems_Params[ListView_GetSelectionMark(hToolsListCtrl)], szTemp2, 256);
115  if (_tcslen(szTemp2))
116  {
117  _tcscat(szTemp, _T(" "));
118  _tcscat(Ptr, szTemp2);
119  }
120  ZeroMemory(&si, sizeof(STARTUPINFO));
121  si.cb = sizeof(STARTUPINFO);
122  if (CreateProcess(NULL, szTemp, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
123  {
124  CloseHandle(pi.hThread);
125  CloseHandle(pi.hProcess);
126  }
127  }
128  }
129  }
130  break;
131  }
132  case WM_NOTIFY:
133  {
134  nmh = (LPNMHDR) lParam;
135  if (nmh->hwndFrom == hToolsListCtrl)
136  {
137  switch (nmh->code)
138  {
139  case LVN_ITEMCHANGED:
140  {
141  lpnmitem = (LPNMITEMACTIVATE) lParam;
142  if (lpnmitem->iItem > -1)
143  {
144  LoadString(hInst, ListItems_Cmds[lpnmitem->iItem], szTemp, 256);
145  szTemp2[0] = _T('\0');
146  LoadString(hInst, ListItems_Params[lpnmitem->iItem], szTemp2, 256);
147  _tcscat(szTemp, _T(" "));
148  _tcscat(szTemp, szTemp2);
149  SendDlgItemMessage(hToolsDialog, IDC_TOOLS_CMDLINE, WM_SETTEXT, 0, (LPARAM) szTemp);
150  }
151  break;
152  }
153  case NM_DBLCLK:
154  {
155  lpnmitem = (LPNMITEMACTIVATE) lParam;
156  if (lpnmitem->iItem > -1)
157  {
159  Ptr = PathAddBackslash(szTemp);
160 
161  if (!Ptr)
162  Ptr = szTemp;
163 
164  szTemp2[0] = _T('\0');
165  LoadString(hInst, ListItems_Cmds[lpnmitem->iItem], Ptr, 256);
166  LoadString(hInst, ListItems_Params[lpnmitem->iItem], szTemp2, 256);
167  if (_tcslen(szTemp2))
168  {
169  _tcscat(szTemp, _T(" "));
170  _tcscat(Ptr, szTemp2);
171  }
172  ZeroMemory(&si, sizeof(STARTUPINFO));
173  si.cb = sizeof(STARTUPINFO);
174  if (CreateProcess(NULL, szTemp, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
175  {
176  CloseHandle(pi.hThread);
177  CloseHandle(pi.hProcess);
178  }
179  }
180  break;
181  }
182  }
183  }
184  }
185  break;
186  }
187  return 0;
188 }
189 
#define LV_ITEM
Definition: commctrl.h:2307
#define IDS_TOOLS_INFO_CMD
Definition: resource.h:96
Definition: tftpd.h:59
#define TRUE
Definition: types.h:120
#define IDS_TOOLS_SYSDM_NAME
Definition: resource.h:104
#define CloseHandle
Definition: compat.h:398
#define IDS_TOOLS_CMD_DESCR
Definition: resource.h:90
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:47
#define LVCF_WIDTH
Definition: commctrl.h:2557
#define LVCF_TEXT
Definition: commctrl.h:2558
DWORD ListItems_Cmds[20]
Definition: toolspage.c:21
#define DWORD
Definition: msvc.h:34
#define LV_COLUMN
Definition: commctrl.h:2517
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
#define LVN_ITEMCHANGED
Definition: commctrl.h:3101
#define CALLBACK
Definition: compat.h:27
#define LVS_EX_FULLROWSELECT
Definition: commctrl.h:2704
#define IDS_TOOLS_INFO_DESCR
Definition: resource.h:95
#define ZeroMemory
Definition: winbase.h:1635
#define IDS_TOOLS_REGEDIT_NAME
Definition: resource.h:99
#define IDS_TOOLS_SYSDM_DESCR
Definition: resource.h:105
#define SendDlgItemMessage
Definition: winuser.h:5708
#define ListView_InsertItem(hwnd, pitem)
Definition: commctrl.h:2378
#define SWP_NOZORDER
Definition: winuser.h:1232
int32_t INT_PTR
Definition: typedefs.h:62
WPARAM wParam
Definition: combotst.c:138
HWND hToolsListCtrl
Definition: toolspage.c:15
struct tagNMHDR * LPNMHDR
#define LVM_SETITEMTEXT
Definition: commctrl.h:2659
UINT_PTR WPARAM
Definition: windef.h:207
#define LVIF_TEXT
Definition: commctrl.h:2279
UINT code
Definition: winuser.h:3112
void FillListView(void)
Definition: toolspage.c:48
#define ListView_InsertColumn(hwnd, iCol, pcol)
Definition: commctrl.h:2606
#define IDS_TOOLS_REGEDIT_DESCR
Definition: resource.h:100
LONG_PTR LPARAM
Definition: windef.h:208
#define IDS_TOOLS_CMD_CMD
Definition: resource.h:91
#define PathAddBackslash
Definition: shlwapi.h:783
size_t __cdecl _tcslen(const _TCHAR *str)
Definition: tcslen.h:9
smooth NULL
Definition: ftsmooth.c:416
DWORD ListItems_Params[20]
Definition: toolspage.c:22
#define ListView_GetItemCount(hwnd)
Definition: commctrl.h:2277
#define CSIDL_WINDOWS
Definition: shlobj.h:1911
#define IDS_TOOLS_SYSDM_PARAM
Definition: resource.h:107
#define WM_SETTEXT
Definition: winuser.h:1599
struct tagNMITEMACTIVATE * LPNMITEMACTIVATE
#define IDC_TOOLS_LIST
Definition: resource.h:18
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
DWORD cb
Definition: winbase.h:796
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDC_BTN_RUN
Definition: resource.h:16
#define SWP_NOACTIVATE
Definition: winuser.h:1227
#define MAX_PATH
Definition: compat.h:26
unsigned int UINT
Definition: ndis.h:50
unsigned long DWORD
Definition: ntddk_ex.h:95
#define LVM_SETEXTENDEDLISTVIEWSTYLE
Definition: commctrl.h:2694
HWND hToolsDialog
Definition: toolspage.c:16
#define IDS_TOOLS_INFO_PARAM
Definition: resource.h:97
static DWORD pi
Definition: protocol.c:150
void AddItem(DWORD, DWORD, DWORD, DWORD, int)
Definition: toolspage.c:25
#define WM_COMMAND
Definition: winuser.h:1716
HWND hwndFrom
Definition: winuser.h:3110
#define CreateProcess
Definition: winbase.h:3572
#define IDS_TOOLS_REGEDIT_CMD
Definition: resource.h:101
#define IDS_TOOLS_INFO_NAME
Definition: resource.h:94
#define LVM_GETEXTENDEDLISTVIEWSTYLE
Definition: commctrl.h:2697
#define IDS_TOOLS_CMD_PARAM
Definition: resource.h:92
#define SWP_NOSIZE
Definition: winuser.h:1230
HINSTANCE hInst
Definition: dxdiag.c:13
static ATOM item
Definition: dde.c:856
#define NM_DBLCLK
Definition: commctrl.h:131
HWND hToolsPage
Definition: toolspage.c:14
STARTUPINFOA STARTUPINFO
Definition: winbase.h:3533
#define SHGetSpecialFolderPath
Definition: shlobj.h:1320
#define IDS_TOOLS_CMD_NAME
Definition: resource.h:89
#define IDS_TOOLS_COLUMN_NAME
Definition: resource.h:79
INT_PTR CALLBACK ToolsPageWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
Definition: toolspage.c:56
#define IDC_TOOLS_CMDLINE
Definition: resource.h:15
#define SendMessage
Definition: winuser.h:5709
_TCHAR * _tcscat(_TCHAR *s, const _TCHAR *append)
Definition: tcscat.h:8
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define CSIDL_SYSTEM
Definition: shlobj.h:1912
#define IDS_TOOLS_REGEDIT_PARAM
Definition: resource.h:102
GLenum GLenum GLvoid GLvoid * column
Definition: glext.h:5664
#define ListView_GetSelectionMark(hwnd)
Definition: commctrl.h:2759
#define memset(x, y, z)
Definition: compat.h:39
#define WM_INITDIALOG
Definition: winuser.h:1715
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define LoadString
Definition: winuser.h:5685
#define WM_NOTIFY
Definition: richedit.h:61
#define IDS_TOOLS_COLUMN_DESCR
Definition: resource.h:80
#define SWP_NOOWNERZORDER
Definition: winuser.h:1234
DWORD ListItems_Locations[20]
Definition: toolspage.c:23
#define IDS_TOOLS_SYSDM_CMD
Definition: resource.h:106