ReactOS 0.4.15-dev-5666-gc548b97
dirdlg.c
Go to the documentation of this file.
1#include <windows.h>
2#include <string.h>
3#include <stdio.h>
4#include <io.h>
5#include "resource.h"
6
7static char selected[MAX_PATH + 1];
8
12 HWND hwndDlg,
13 UINT uMsg,
16)
17{
18 char dir[MAX_PATH + 1];
19
20 switch(uMsg)
21 {
22 case WM_COMMAND:
23 {
24 switch(HIWORD(wParam))
25 {
26 case LBN_DBLCLK:
27 {
28 switch(LOWORD(wParam))
29 {
30 case IDC_DIRS:
31 {
32 if(DlgDirSelectEx(hwndDlg, dir, MAX_PATH, IDC_DIRS))
33 {
34 chdir(dir);
37 }
38 else
39 {
40 SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_OK, 0), 0);
41 }
42 break;
43 }
44 }
45 break;
46 }
47 default:
48 {
49 switch(LOWORD(wParam))
50 {
51 case IDC_OK:
52 {
53 char file[MAX_PATH + 1];
54 int len;
55
56 if(!DlgDirSelectEx(hwndDlg, file, MAX_PATH, IDC_DIRS))
57 {
60 if(strlen(file))
61 {
62 if(selected[len - 1] != '\\')
63 {
64 lstrcat(selected, "\\");
65 }
67 EndDialog(hwndDlg, IDC_OK);
68 }
69 }
70 break;
71 }
72 case IDC_CANCEL:
73 {
74 EndDialog(hwndDlg, IDC_CANCEL);
75 break;
76 }
77 }
78 break;
79 }
80 }
81 break;
82 }
83 case WM_INITDIALOG:
84 {
88 SetFocus(GetDlgItem(hwndDlg, IDC_DIRS));
89 break;
90 }
91 case WM_CLOSE:
92 {
93 EndDialog(hwndDlg, IDC_CANCEL);
94 return TRUE;
95 }
96 }
97 return FALSE;
98}
99
100int WINAPI
103 HINSTANCE hPrevInstance,
104 LPSTR lpszCmdLine,
105 int nCmdShow)
106{
107 char str[MAX_PATH + 32];
109 {
110 sprintf(str, "You selected \"%s\"", selected);
111 MessageBox(0, str, "Selected file", MB_ICONINFORMATION);
112 }
113 return 0;
114}
115
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
unsigned int dir
Definition: maze.c:112
#define IDC_OK
Definition: resource.h:59
#define IDC_CANCEL
Definition: resource.h:60
#define IDD_MAIN
Definition: resource.h:106
HINSTANCE hInstance
Definition: charmap.c:19
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
Definition: dirdlg.c:101
INT_PTR CALLBACK DlgMainProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dirdlg.c:11
static char selected[MAX_PATH+1]
Definition: dirdlg.c:7
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
#define CALLBACK
Definition: compat.h:35
GLenum GLsizei len
Definition: glext.h:6722
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define IDC_DIREDIT
Definition: resource.h:6
#define IDC_DIRS
Definition: resource.h:5
#define chdir
Definition: syshdrs.h:69
unsigned int UINT
Definition: ndis.h:50
#define LOWORD(l)
Definition: pedump.c:82
const WCHAR * str
Definition: fci.c:127
int32_t INT_PTR
Definition: typedefs.h:64
#define HIWORD(l)
Definition: typedefs.h:247
#define lstrcat
Definition: winbase.h:3742
#define GetCurrentDirectory
Definition: winbase.h:3676
LONG_PTR LPARAM
Definition: windef.h:208
UINT_PTR WPARAM
Definition: windef.h:207
#define WINAPI
Definition: msvc.h:6
#define MAKEWPARAM(l, h)
Definition: winuser.h:3999
#define WM_CLOSE
Definition: winuser.h:1611
#define LBN_DBLCLK
Definition: winuser.h:2061
#define WM_COMMAND
Definition: winuser.h:1730
#define DlgDirList
Definition: winuser.h:5756
#define DDL_DRIVES
Definition: winuser.h:425
#define WM_INITDIALOG
Definition: winuser.h:1729
#define DlgDirSelectEx
Definition: winuser.h:5759
#define LB_SETCOLUMNWIDTH
Definition: winuser.h:2051
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
HWND WINAPI SetFocus(_In_opt_ HWND)
#define DDL_DIRECTORY
Definition: winuser.h:422
#define SendMessage
Definition: winuser.h:5833
#define MessageBox
Definition: winuser.h:5812
#define MB_ICONINFORMATION
Definition: winuser.h:796
#define SendDlgItemMessage
Definition: winuser.h:5832
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define DialogBox
Definition: winuser.h:5751
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
char * LPSTR
Definition: xmlstorage.h:182