ReactOS  0.4.14-dev-57-g333b8f1
dirdlg.c File Reference
#include <windows.h>
#include <string.h>
#include <stdio.h>
#include <io.h>
#include "resource.h"
Include dependency graph for dirdlg.c:

Go to the source code of this file.

Functions

INT_PTR CALLBACK DlgMainProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
 

Variables

static char selected [MAX_PATH+1]
 

Function Documentation

◆ DlgMainProc()

INT_PTR CALLBACK DlgMainProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 11 of file dirdlg.c.

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 }
#define TRUE
Definition: types.h:120
#define MAKEWPARAM(l, h)
Definition: winuser.h:3948
#define LB_SETCOLUMNWIDTH
Definition: winuser.h:2043
#define IDC_DIREDIT
Definition: resource.h:6
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define DlgDirList
Definition: winuser.h:5667
#define DDL_DIRECTORY
Definition: winuser.h:422
HWND WINAPI SetFocus(_In_opt_ HWND)
#define SendDlgItemMessage
Definition: winuser.h:5743
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define chdir
Definition: syshdrs.h:69
static char selected[MAX_PATH+1]
Definition: dirdlg.c:7
#define GetCurrentDirectory
Definition: winbase.h:3622
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 LBN_DBLCLK
Definition: winuser.h:2053
#define DDL_DRIVES
Definition: winuser.h:425
GLenum GLsizei len
Definition: glext.h:6722
#define WM_COMMAND
Definition: winuser.h:1722
#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
#define LOWORD(l)
Definition: pedump.c:82
Definition: fci.c:126

Referenced by WinMain().

◆ WinMain()

int WINAPI WinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPSTR  lpszCmdLine,
int  nCmdShow 
)

Definition at line 101 of file dirdlg.c.

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 }
#define MAKEINTRESOURCE
Definition: winuser.h:591
INT_PTR CALLBACK DlgMainProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: dirdlg.c:11
#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
static char selected[MAX_PATH+1]
Definition: dirdlg.c:7
const WCHAR * str
#define MAX_PATH
Definition: compat.h:26
#define MB_ICONINFORMATION
Definition: winuser.h:796
#define MessageBox
Definition: winuser.h:5723
#define IDC_OK
Definition: resource.h:59

Variable Documentation

◆ selected