source: trunk/testapp/gui/fileopen/fileopen.cpp@ 22145

Last change on this file since 22145 was 22063, checked in by dmik, 13 years ago

testapp: Add file open test case.

  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1#include <stdio.h>
2#include <windows.h>
3#include <Commdlg.h>
4#include <tchar.h>
5
6#ifndef _MSC_VER
7
8#include <odinlx.h>
9
10int WINAPI WinMain(HINSTANCE hInstance,
11 HINSTANCE hPrevInstance,
12 LPSTR lpCmdLine,
13 int nCmdShow);
14
15int main(int argc, char **argv)
16{
17#ifdef ODIN_FORCE_WIN32_TIB
18 ForceWin32TIB();
19#endif
20 RegisterLxExe(WinMain, NULL);
21}
22
23#endif
24
25//
26// Gobal Variables and declarations.
27//
28OPENFILENAME ofn ;
29
30// a another memory buffer to contain the file name
31TCHAR szFile[100] ;
32
33UINT_PTR CALLBACK OFNHookProc(
34 HWND hdlg,
35 UINT uiMsg,
36 WPARAM wParam,
37 LPARAM lParam
38)
39{
40 printf("*** OFNHookProc\n");
41 return 1;
42}
43
44
45DWORD WINAPI MyThreadFunc( LPVOID lpParam )
46{
47 // open a file name
48 ZeroMemory( &ofn , sizeof( ofn));
49 ofn.lStructSize = sizeof ( ofn );
50 ofn.hwndOwner = NULL ;
51 ofn.lpstrFile = szFile ;
52 ofn.lpstrFile[0] = '\0';
53 ofn.nMaxFile = sizeof( szFile );
54 ofn.lpstrFilter = _T("All\0*.*\0Text\0*.TXT\0");
55 ofn.nFilterIndex =1;
56 ofn.lpstrFileTitle = NULL ;
57 ofn.nMaxFileTitle = 0 ;
58 ofn.lpstrInitialDir=NULL ;
59// ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_ENABLEHOOK|OFN_EXPLORER;
60 ofn.Flags = OFN_ENABLESIZING|OFN_LONGNAMES|OFN_EXPLORER|OFN_ENABLEHOOK|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT;
61 ofn.lpfnHook = OFNHookProc;
62 GetOpenFileName( &ofn );
63
64 // Now simpley display the file name
65 MessageBox ( NULL , ofn.lpstrFile , _T("File Name") , MB_OK);
66 return 0;
67}
68
69int WINAPI WinMain( HINSTANCE hInstance , HINSTANCE hPrevInstance , LPSTR lpCmdLine , int nCmdShow )
70{
71 DWORD dwThread;
72 HANDLE hThread = CreateThread( NULL, 0, MyThreadFunc, NULL, 0, &dwThread);
73
74 WaitForSingleObject( hThread , INFINITE );
75
76 return 0;
77}
Note: See TracBrowser for help on using the repository browser.