ReactOS  0.4.14-dev-55-g2da92ac
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 
7 static char selected[MAX_PATH + 1];
8 
12  HWND hwndDlg,
13  UINT uMsg,
14  WPARAM wParam,
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  {
59  len = strlen(selected);
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 
100 int 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 
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define TRUE
Definition: types.h:120
#define MAKEWPARAM(l, h)
Definition: winuser.h:3948
#define LB_SETCOLUMNWIDTH
Definition: winuser.h:2043
INT_PTR CALLBACK DlgMainProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dirdlg.c:11
#define IDC_DIREDIT
Definition: resource.h:6
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
Definition: dirdlg.c:101
#define DlgDirList
Definition: winuser.h:5667
#define CALLBACK
Definition: compat.h:27
#define DDL_DIRECTORY
Definition: winuser.h:422
HWND WINAPI SetFocus(_In_opt_ HWND)
UINT_PTR WPARAM
Definition: windef.h:207
#define SendDlgItemMessage
Definition: winuser.h:5743
int32_t INT_PTR
Definition: typedefs.h:62
char * LPSTR
Definition: xmlstorage.h:182
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define IDD_MAIN
Definition: resource.h:106
#define sprintf(buf, format,...)
Definition: sprintf.c:55
#define DialogBox
Definition: winuser.h:5662
HINSTANCE hInstance
Definition: charmap.c:20
#define chdir
Definition: syshdrs.h:69
static char selected[MAX_PATH+1]
Definition: dirdlg.c:7
#define GetCurrentDirectory
Definition: winbase.h:3622
const WCHAR * str
LONG_PTR LPARAM
Definition: windef.h:208
unsigned int dir
Definition: maze.c:112
#define IDC_CANCEL
Definition: resource.h:60
#define DlgDirSelectEx
Definition: winuser.h:5670
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDC_DIRS
Definition: resource.h:5
#define WM_CLOSE
Definition: winuser.h:1603
#define MAX_PATH
Definition: compat.h:26
#define WINAPI
Definition: msvc.h:8
#define LBN_DBLCLK
Definition: winuser.h:2053
#define MB_ICONINFORMATION
Definition: winuser.h:796
#define DDL_DRIVES
Definition: winuser.h:425
GLenum GLsizei len
Definition: glext.h:6722
#define MessageBox
Definition: winuser.h:5723
#define WM_COMMAND
Definition: winuser.h:1722
unsigned int UINT
Definition: ndis.h:50
#define SendMessage
Definition: winuser.h:5744
#define HIWORD(l)
Definition: typedefs.h:246
#define IDC_OK
Definition: resource.h:59
#define lstrcat
Definition: winbase.h:3688
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
Definition: fci.c:126