From 7c0860d4057361aefc8532a2715c3ba8721ae9a1 Mon Sep 17 00:00:00 2001 From: Thomas Bluemel Date: Wed, 19 Nov 2003 19:59:57 +0000 Subject: [PATCH] added a test app to test some (currently unimplemented) dialog functions svn path=/trunk/; revision=6713 --- reactos/apps/tests/Makefile | 2 +- reactos/apps/tests/dirdlg/.cvsignore | 6 ++ reactos/apps/tests/dirdlg/dirdlg.c | 112 +++++++++++++++++++++++++++ reactos/apps/tests/dirdlg/dirdlg.rc | 14 ++++ reactos/apps/tests/dirdlg/makefile | 21 +++++ reactos/apps/tests/dirdlg/resource.h | 6 ++ 6 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 reactos/apps/tests/dirdlg/.cvsignore create mode 100644 reactos/apps/tests/dirdlg/dirdlg.c create mode 100644 reactos/apps/tests/dirdlg/dirdlg.rc create mode 100644 reactos/apps/tests/dirdlg/makefile create mode 100644 reactos/apps/tests/dirdlg/resource.h diff --git a/reactos/apps/tests/Makefile b/reactos/apps/tests/Makefile index e30b632cf22..c8a1db85bab 100644 --- a/reactos/apps/tests/Makefile +++ b/reactos/apps/tests/Makefile @@ -15,7 +15,7 @@ mktime mstest multiwin mutex nptest patblt pipe primitives pteb regtest \ sectest sertest shaptest shm statst statst2 stretchblt suspend \ tcpsvr terminate txtscale thread thread_msg tokentest vmtest \ winhello winhello2 wm_erasebkgnd wm_paint eventpair threadwait \ -map_dup_inherit p_dup_handle apc2 enhmetafile +map_dup_inherit p_dup_handle apc2 enhmetafile dirdlg guithreadinfo TEST_MISC = diff --git a/reactos/apps/tests/dirdlg/.cvsignore b/reactos/apps/tests/dirdlg/.cvsignore new file mode 100644 index 00000000000..d63774a7353 --- /dev/null +++ b/reactos/apps/tests/dirdlg/.cvsignore @@ -0,0 +1,6 @@ +*.o +*.d +*.exe +*.coff +*.sym +*.map diff --git a/reactos/apps/tests/dirdlg/dirdlg.c b/reactos/apps/tests/dirdlg/dirdlg.c new file mode 100644 index 00000000000..8ec75679cc9 --- /dev/null +++ b/reactos/apps/tests/dirdlg/dirdlg.c @@ -0,0 +1,112 @@ +#include +#include +#include +#include +#include "resource.h" + +static char selected[MAX_PATH + 1]; + +BOOL +CALLBACK +DlgMainProc( + HWND hwndDlg, + UINT uMsg, + WPARAM wParam, + LPARAM lParam +) +{ + char dir[MAX_PATH + 1]; + + switch(uMsg) + { + case WM_COMMAND: + { + switch(HIWORD(wParam)) + { + case LBN_DBLCLK: + { + switch(LOWORD(wParam)) + { + case IDC_DIRS: + { + if(DlgDirSelectEx(hwndDlg, dir, MAX_PATH, IDC_DIRS)) + { + chdir(dir); + GetCurrentDirectory(MAX_PATH, dir); + DlgDirList(hwndDlg, dir, IDC_DIRS, IDC_DIREDIT, DDL_DIRECTORY | DDL_DRIVES); + } + else + { + SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_OK, 0), 0); + } + break; + } + } + break; + } + default: + { + switch(LOWORD(wParam)) + { + case IDC_OK: + { + char file[MAX_PATH + 1]; + int len; + + if(!DlgDirSelectEx(hwndDlg, file, MAX_PATH, IDC_DIRS)) + { + GetCurrentDirectory(MAX_PATH, selected); + len = strlen(selected); + if(selected[len - 1] != '\\') + { + lstrcat(selected, "\\"); + } + lstrcat(selected, file); + EndDialog(hwndDlg, IDC_OK); + } + break; + } + case IDC_CANCEL: + { + EndDialog(hwndDlg, IDC_CANCEL); + break; + } + } + break; + } + } + break; + } + case WM_INITDIALOG: + { + SendDlgItemMessage(hwndDlg, IDC_DIRS, LB_SETCOLUMNWIDTH, 150, 0); + GetCurrentDirectory(MAX_PATH, dir); + DlgDirList(hwndDlg, dir, IDC_DIRS, IDC_DIREDIT, DDL_DIRECTORY | DDL_DRIVES); + SetFocus(GetDlgItem(hwndDlg, IDC_DIRS)); + break; + } + case WM_CLOSE: + { + EndDialog(hwndDlg, IDC_CANCEL); + return TRUE; + } + } + return FALSE; +} + +int WINAPI +WinMain( + HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPSTR lpszCmdLine, + int nCmdShow) +{ + char str[MAX_PATH + 32]; + if(DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), 0, DlgMainProc) == IDC_OK) + { + sprintf(str, "You selected \"%s\"", selected); + MessageBox(0, str, "Selected file", MB_ICONINFORMATION); + } + return 0; +} + diff --git a/reactos/apps/tests/dirdlg/dirdlg.rc b/reactos/apps/tests/dirdlg/dirdlg.rc new file mode 100644 index 00000000000..72385411b88 --- /dev/null +++ b/reactos/apps/tests/dirdlg/dirdlg.rc @@ -0,0 +1,14 @@ +#include +#include +#include "resource.h" + +IDD_MAIN DIALOG DISCARDABLE 20, 20, 220, 140 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +FONT 8, "MS Sans Serif" +CAPTION "Select a file" +BEGIN + EDITTEXT IDC_DIREDIT, 5, 5, 210, 13, ES_READONLY | ES_LEFT | WS_CHILD | WS_VISIBLE | WS_TABSTOP + LISTBOX IDC_DIRS, 5, 23, 210, 92, LBS_NOTIFY | LBS_NOINTEGRALHEIGHT | LBS_MULTICOLUMN | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_HSCROLL + PUSHBUTTON "&OK", IDC_OK, 60, 120, 40, 15, BS_DEFPUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP + PUSHBUTTON "&Cancel", IDC_CANCEL, 120, 120, 40, 15, WS_CHILD | WS_VISIBLE | WS_TABSTOP +END diff --git a/reactos/apps/tests/dirdlg/makefile b/reactos/apps/tests/dirdlg/makefile new file mode 100644 index 00000000000..f576e805689 --- /dev/null +++ b/reactos/apps/tests/dirdlg/makefile @@ -0,0 +1,21 @@ +PATH_TO_TOP = ../../.. + +TARGET_NORC = no + +TARGET_TYPE = program + +TARGET_APPTYPE = windows + +TARGET_NAME = dirdlg + +TARGET_SDKLIBS = ntdll.a kernel32.a gdi32.a + +TARGET_OBJECTS = $(TARGET_NAME).o + +TARGET_CFLAGS = -Wall -Werror + +include $(PATH_TO_TOP)/rules.mak + +include $(TOOLS_PATH)/helper.mk + +# EOF diff --git a/reactos/apps/tests/dirdlg/resource.h b/reactos/apps/tests/dirdlg/resource.h new file mode 100644 index 00000000000..7a1063b932e --- /dev/null +++ b/reactos/apps/tests/dirdlg/resource.h @@ -0,0 +1,6 @@ +#define IDD_MAIN 101 + +#define IDC_OK 1 +#define IDC_CANCEL 2 +#define IDC_DIRS 100 +#define IDC_DIREDIT 101