ReactOS 0.4.15-dev-7953-g1f49173
vfdshprop.cpp
Go to the documentation of this file.
1/*
2 vfdshprop.cpp
3
4 Virtual Floppy Drive for Windows
5 Driver control library
6 COM shell extension class property sheet functions
7
8 Copyright (c) 2003-2005 Ken Kato
9*/
10
11#define WIN32_LEAN_AND_MEAN
12#include <windows.h>
13#include <shellapi.h>
14#include <shlobj.h>
15#include <stdio.h>
16
17#include "vfdtypes.h"
18#include "vfdapi.h"
19#include "vfdlib.h"
20#include "vfdver.h"
21#ifndef __REACTOS__
22#include "vfdmsg.h"
23#else
24#include "vfdmsg_lib.h"
25#endif
26#include "vfdguirc.h"
27
28// class header
29#include "vfdshext.h"
30
31// property sheet property ID
32
33#define VFD_PROPERTY_ID "VFD"
34
35//
36// local functions
37//
38#ifndef __REACTOS__
40#else
42#endif
43 HWND hDlg,
44 UINT uMessage,
47
49 HWND hWnd,
50 UINT uMessage,
51 LPPROPSHEETPAGE ppsp);
52
53static void OnPropInit(HWND hDlg);
54static void OnControl(HWND hDlg);
55static void UpdateImageInfo(HWND hDlg, ULONG nDevice);
56
57//
58// property sheet callback function
59//
61 HWND hWnd,
62 UINT uMessage,
63 LPPROPSHEETPAGE ppsp)
64{
66
67 switch(uMessage) {
68 case PSPCB_CREATE:
69 return TRUE;
70
71 case PSPCB_RELEASE:
72 if (ppsp->lParam) {
73 ((LPCVFDSHEXT)(ppsp->lParam))->Release();
74 }
75 return TRUE;
76 }
77 return TRUE;
78}
79
80//
81// property page dialog procedure
82//
83#ifndef __REACTOS__
85#else
87#endif
88 HWND hDlg,
89 UINT uMessage,
92{
94 LPCVFDSHEXT lpcs;
95
96 switch (uMessage) {
97 case WM_INITDIALOG:
98#ifndef __REACTOS__
100#else
102#endif
103
104 if (lParam) {
106
107 OnPropInit(hDlg);
108 UpdateImageInfo(hDlg, lpcs->GetDevice());
109 }
110 return TRUE;
111
112 case WM_COMMAND:
113#ifndef __REACTOS__
115#else
117#endif
118
119 if (!psp) {
120 break;
121 }
122
123 lpcs = (LPCVFDSHEXT)psp->lParam;
124
125 if (!lpcs) {
126 break;
127 }
128
129 switch (wParam) {
130 case IDC_OPEN:
131 if (lpcs->DoVfdOpen(hDlg) == ERROR_SUCCESS) {
134 }
135 UpdateImageInfo(hDlg, lpcs->GetDevice());
136 break;
137
138 case IDC_SAVE:
139 if (lpcs->DoVfdSave(hDlg) == ERROR_SUCCESS) {
142 }
143 UpdateImageInfo(hDlg, lpcs->GetDevice());
144 break;
145
146 case IDC_CLOSE:
147 if (lpcs->DoVfdClose(hDlg) == ERROR_SUCCESS) {
150 }
151 UpdateImageInfo(hDlg, lpcs->GetDevice());
152 break;
153
155 lpcs->DoVfdProtect(hDlg);
156 break;
157
158 case IDC_FORMAT:
159 VfdGuiFormat(hDlg, lpcs->GetDevice());
160 break;
161
162 case IDC_CONTROL:
163 OnControl(hDlg);
164 break;
165 }
166 break;
167
168 case WM_CONTEXTMENU:
170 break;
171
172 case WM_HELP:
173 {
175
176 if (info->iContextType == HELPINFO_WINDOW) {
177 ShowHelpWindow(hDlg, info->iCtrlId);
178 }
179 }
180 return TRUE;
181
182 default:
183 if (uMessage == g_nNotifyMsg) {
184#ifndef __REACTOS__
186#else
188#endif
189
190 if (!psp) {
191 break;
192 }
193
194 lpcs = (LPCVFDSHEXT)psp->lParam;
195
196 if (!lpcs) {
197 break;
198 }
199
200 UpdateImageInfo(hDlg, lpcs->GetDevice());
201 }
202 break;
203 }
204
205 return FALSE;
206}
207
208//
209// initialize the property page
210//
212 HWND hDlg)
213{
214 // set up control text
215
218
219 SetControlText(hDlg, IDC_IMAGEFILE_LABEL, MSG_IMAGEFILE_LABEL);
220 SetControlText(hDlg, IDC_IMAGEDESC_LABEL, MSG_DESCRIPTION_LABEL);
221 SetControlText(hDlg, IDC_DISKTYPE_LABEL, MSG_DISKTYPE_LABEL);
222 SetControlText(hDlg, IDC_MEDIATYPE_LABEL, MSG_MEDIATYPE_LABEL);
223 SetControlText(hDlg, IDC_WRITE_PROTECTED, MSG_MENU_PROTECT);
224 SetControlText(hDlg, IDC_OPEN, MSG_OPEN_BUTTON);
225 SetControlText(hDlg, IDC_SAVE, MSG_SAVE_BUTTON);
226 SetControlText(hDlg, IDC_CLOSE, MSG_CLOSE_BUTTON);
227 SetControlText(hDlg, IDC_FORMAT, MSG_FORMAT_BUTTON);
228 SetControlText(hDlg, IDC_CONTROL, MSG_CONTROL_BUTTON);
229}
230
231//
232// Control Panel button is clicked
233//
235 HWND hDlg)
236{
237 CHAR module_path[MAX_PATH];
238 CHAR full_path[MAX_PATH];
240#ifndef __REACTOS__
241 DWORD ret;
242#else
244#endif
245
247 g_hDllModule, module_path, sizeof(module_path));
248
249 if (ret == 0 || ret >= sizeof(module_path)) {
250 file_name = full_path;
251 }
252 else {
254 module_path, sizeof(full_path), full_path, &file_name);
255
256 if (ret == 0 || ret >= sizeof(full_path)) {
257 file_name = full_path;
258 }
259 }
260
261 strcpy(file_name, "vfdwin.exe");
262
263 VFDTRACE(0, ("Starting %s\n", full_path));
264
265#ifndef __REACTOS__
267 hDlg, NULL, full_path, NULL, NULL, SW_SHOW);
268#else
270 hDlg, NULL, full_path, NULL, NULL, SW_SHOW);
271#endif
272
273 if (ret > 32) {
275 }
276 else {
279 }
280}
281
282//
283// Update image information on the property page
284//
286 HWND hDlg,
287 ULONG nDevice)
288{
289 HANDLE hDevice;
291 VFD_DISKTYPE disk_type;
292 VFD_MEDIA media_type;
293 VFD_FLAGS media_flags;
296 DWORD attrib;
297 ULONG ret;
298
299 hDevice = VfdOpenDevice(nDevice);
300
301 if (hDevice == INVALID_HANDLE_VALUE) {
302 MessageBox(hDlg,
305 return;
306 }
307
308 // get current image information
309
311 hDevice,
312 buf,
313 &disk_type,
314 &media_type,
315 &media_flags,
316 &file_type,
317 &image_size);
318
319 CloseHandle(hDevice);
320
321 if (ret != ERROR_SUCCESS) {
322 MessageBox(hDlg,
325 return;
326 }
327
328 if (media_type == VFD_MEDIA_NONE) {
329
330 // drive is empty
331
336
342
345
347
348 return;
349 }
350
351 // display image file name
352
353 if (buf[0]) {
354 attrib = GetFileAttributes(buf);
355
356 if (attrib == INVALID_FILE_ATTRIBUTES) {
357 attrib = 0;
358 }
359 }
360 else {
361 if (disk_type != VFD_DISKTYPE_FILE) {
362 strcpy(buf, "<RAM>");
363 }
364 attrib = 0;
365 }
366
368
369 // display image description
370
371 VfdMakeFileDesc(buf, sizeof(buf),
372 file_type, image_size, attrib);
373
375
376 // display disk type
377
378 if (disk_type == VFD_DISKTYPE_FILE) {
379 SetDlgItemText(hDlg, IDC_DISKTYPE, "FILE");
380 }
381 else {
382 SetDlgItemText(hDlg, IDC_DISKTYPE, "RAM");
383 }
384
385 // display media type
386
388 VfdMediaTypeName(media_type));
389
390 // set write protect check box
391
392 if (media_flags & VFD_FLAG_WRITE_PROTECTED) {
394 }
395 else {
397 }
398
404
407
409}
410
411//
412// CVfdShExt class members inherited from IShellPropSheetExt
413//
414
415// Add property page
417 LPFNADDPROPSHEETPAGE lpfnAddPage,
419{
420 PROPSHEETPAGE psp;
421 HPROPSHEETPAGE hpage;
422
423 if (!m_pDataObj || m_nDevice == (ULONG)-1) {
424 // not a VFD drive
425 VFDTRACE(0, ("PropPage: Not a VFD drive\n"));
426
427 return NOERROR;
428 }
429
430 psp.dwSize = sizeof(psp); // no extra data.
432 psp.hInstance = g_hDllModule;
433 psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPDIALOG);
434 psp.hIcon = 0;
435 psp.pszTitle = "VFD";
436 psp.pfnDlgProc = VfdPageDlgProc;
437 psp.pcRefParent = &g_cDllRefCnt;
438 psp.pfnCallback = VfdPageCallback;
439 psp.lParam = (LPARAM)this;
440
441 AddRef();
442 hpage = CreatePropertySheetPage(&psp);
443
444 if (hpage) {
445 if (!lpfnAddPage(hpage, lParam)) {
447 Release();
448 }
449 }
450
451 return NOERROR;
452}
453
455 UINT uPageID,
456 LPFNADDPROPSHEETPAGE lpfnReplaceWith,
458{
459 UNREFERENCED_PARAMETER(uPageID);
460 UNREFERENCED_PARAMETER(lpfnReplaceWith);
462 return E_FAIL;
463}
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
HWND hWnd
Definition: settings.c:17
#define IDC_SAVE
Definition: resource.h:16
#define IDC_OPEN
Definition: resource.h:18
#define STDMETHODIMP
Definition: basetyps.h:43
_In_ BOOLEAN Release
Definition: cdrom.h:920
DWORD DoVfdProtect(HWND hParent)
Definition: vfdshmenu.cpp:493
STDMETHODIMP AddPages(LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
Definition: vfdshprop.cpp:416
ULONG GetDevice()
Definition: vfdshext.h:44
DWORD DoVfdOpen(HWND hParent)
Definition: vfdshmenu.cpp:459
LPDATAOBJECT m_pDataObj
Definition: vfdshext.h:25
DWORD DoVfdSave(HWND hParent)
Definition: vfdshmenu.cpp:475
ULONG m_nDevice
Definition: vfdshext.h:26
DWORD DoVfdClose(HWND hParent)
Definition: vfdshmenu.cpp:484
STDMETHODIMP ReplacePage(UINT uPageID, LPFNADDPROPSHEETPAGE lpfnReplaceWith, LPARAM lParam)
Definition: vfdshprop.cpp:454
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define E_FAIL
Definition: ddrawi.h:102
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define IDC_CLOSE
Definition: resource.h:52
BOOL WINAPI DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage)
Definition: propsheet.c:3152
#define CloseHandle
Definition: compat.h:739
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
#define CALLBACK
Definition: compat.h:35
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static VOID ShowContextMenu(HWND hwndDlg, HWND hwndTreeView, PHOTPLUG_DATA pHotplugData)
Definition: hotplug.c:110
ULONG AddRef()
ULONG Release()
if(dx< 0)
Definition: linetemp.h:194
static GLint image_size(GLint width, GLint height, GLenum format, GLenum type)
Definition: mipmap.c:4858
static LPCWSTR file_name
Definition: protocol.c:147
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
unsigned int UINT
Definition: ndis.h:50
#define DWORD
Definition: nt_native.h:44
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define BS_PUSHBUTTON
Definition: pedump.c:651
#define BS_DEFPUSHBUTTON
Definition: pedump.c:652
#define PSBTN_CANCEL
Definition: prsht.h:151
#define PSPCB_CREATE
Definition: prsht.h:38
#define PropSheet_PressButton(d, i)
Definition: prsht.h:348
#define CreatePropertySheetPage
Definition: prsht.h:399
#define PSP_USEREFPARENT
Definition: prsht.h:29
#define PSP_USETITLE
Definition: prsht.h:26
#define PSPCB_RELEASE
Definition: prsht.h:37
#define LPPROPSHEETPAGE
Definition: prsht.h:390
#define PSP_USECALLBACK
Definition: prsht.h:30
BOOL(CALLBACK * LPFNADDPROPSHEETPAGE)(HPROPSHEETPAGE, LPARAM)
Definition: prsht.h:327
#define PROPSHEETPAGE
Definition: prsht.h:389
#define WM_CONTEXTMENU
Definition: richedit.h:64
FD_TYPE file_type(FDSC **curr, char *fixed)
Definition: file.c:221
#define ShellExecute
Definition: shellapi.h:693
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
#define DWORD_PTR
Definition: treelist.c:76
int32_t INT_PTR
Definition: typedefs.h:64
char * PSTR
Definition: typedefs.h:51
uint32_t DWORD_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
void WINAPI VfdMakeFileDesc(PSTR pBuffer, ULONG nBufSize, VFD_FILETYPE nFileType, ULONG nFileSize, DWORD nFileAttr)
Definition: vfdguiut.c:376
DWORD WINAPI VfdGetImageInfo(HANDLE hDevice, PSTR sFileName, PVFD_DISKTYPE pDiskType, PVFD_MEDIA pMediaType, PVFD_FLAGS pMediaFlags, PVFD_FILETYPE pFileType, PULONG pImageSize)
Definition: vfdctl.c:1839
HANDLE WINAPI VfdOpenDevice(ULONG nTarget)
Definition: vfdctl.c:1215
DWORD WINAPI VfdGuiFormat(HWND hParent, ULONG nDevice)
Definition: vfdguiut.c:262
PCSTR WINAPI VfdMediaTypeName(VFD_MEDIA nMediaType)
Definition: vfdctl.c:3280
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define VFDTRACE(LEVEL, STRING)
Definition: vfddbg.h:72
#define IDC_PROPERTY_TITLE
Definition: vfdguirc.h:11
#define IDC_COPYRIGHT_STR
Definition: vfdguirc.h:12
#define IDC_MEDIATYPE_LABEL
Definition: vfdguirc.h:24
#define IDC_WRITE_PROTECTED
Definition: vfdguirc.h:26
#define IDC_DISKTYPE_LABEL
Definition: vfdguirc.h:20
#define IDC_CONTROL
Definition: vfdguirc.h:33
#define IDC_IMAGEFILE_DESC
Definition: vfdguirc.h:16
#define IDC_FORMAT
Definition: vfdguirc.h:32
#define IDC_IMAGEFILE_LABEL
Definition: vfdguirc.h:13
#define IDD_PROPDIALOG
Definition: vfdguirc.h:5
#define IDC_DISKTYPE
Definition: vfdguirc.h:21
#define IDC_IMAGEDESC_LABEL
Definition: vfdguirc.h:15
#define IDC_MEDIATYPE
Definition: vfdguirc.h:25
#define IDC_IMAGEFILE
Definition: vfdguirc.h:14
void ShowHelpWindow(HWND hDlg, UINT nCtl)
Definition: vfdguiut.c:507
void SetControlText(HWND hWnd, UINT nCtrl, DWORD nMsg)
Definition: vfdguiut.c:350
UINT g_cDllRefCnt
HINSTANCE g_hDllModule
PCSTR SystemMessage(DWORD nError)
Definition: vfdlib.c:147
UINT g_nNotifyMsg
#define VFD_MSGBOX_TITLE
Definition: vfdlib.h:53
CVfdShExt * LPCVFDSHEXT
Definition: vfdshext.h:101
static void UpdateImageInfo(HWND hDlg, ULONG nDevice)
Definition: vfdshprop.cpp:285
static BOOL CALLBACK VfdPageDlgProc(HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam)
Definition: vfdshprop.cpp:84
static void OnControl(HWND hDlg)
Definition: vfdshprop.cpp:234
static void OnPropInit(HWND hDlg)
Definition: vfdshprop.cpp:211
static UINT CALLBACK VfdPageCallback(HWND hWnd, UINT uMessage, LPPROPSHEETPAGE ppsp)
Definition: vfdshprop.cpp:60
UCHAR VFD_FILETYPE
Definition: vfdtypes.h:62
UCHAR VFD_MEDIA
Definition: vfdtypes.h:61
UCHAR VFD_DISKTYPE
Definition: vfdtypes.h:60
@ VFD_MEDIA_NONE
Definition: vfdtypes.h:27
@ VFD_DISKTYPE_FILE
Definition: vfdtypes.h:18
#define VFD_FLAG_WRITE_PROTECTED
Definition: vfdtypes.h:68
UCHAR VFD_FLAGS
Definition: vfdtypes.h:63
#define VFD_PRODUCT_DESC
Definition: vfdver.h:66
#define VFD_COPYRIGHT_STR
Definition: vfdver.h:69
int ret
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define GetFileAttributes
Definition: winbase.h:3815
#define GetModuleFileName
Definition: winbase.h:3831
#define GetFullPathName
Definition: winbase.h:3821
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define NOERROR
Definition: winerror.h:2354
#define SetWindowLong
Definition: winuser.h:5853
#define DWLP_USER
Definition: winuser.h:872
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
struct tagHELPINFO * LPHELPINFO
#define BST_UNCHECKED
Definition: winuser.h:199
#define WM_COMMAND
Definition: winuser.h:1740
#define DWL_USER
Definition: winuser.h:867
#define WM_INITDIALOG
Definition: winuser.h:1739
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
HWND WINAPI SetFocus(_In_opt_ HWND)
#define SendMessage
Definition: winuser.h:5843
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define BM_SETSTYLE
Definition: winuser.h:1924
#define GetWindowLong
Definition: winuser.h:5796
HWND WINAPI GetParent(_In_ HWND)
#define MessageBox
Definition: winuser.h:5822
#define MB_ICONSTOP
Definition: winuser.h:803
#define SW_SHOW
Definition: winuser.h:775
#define HELPINFO_WINDOW
Definition: winuser.h:1172
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define SetDlgItemText
Definition: winuser.h:5849
#define BST_CHECKED
Definition: winuser.h:197
char CHAR
Definition: xmlstorage.h:175