1
0

WX.cxx 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //For wx
  2. #include <wx/app.h>
  3. #include <wx/dir.h>
  4. static void TestDirEnumHelper(wxDir& dir,
  5. int flags = wxDIR_DEFAULT,
  6. const wxString& filespec = wxEmptyString)
  7. {
  8. wxString filename;
  9. if ( !dir.IsOpened() )
  10. return;
  11. bool cont = dir.GetFirst(&filename, filespec, flags);
  12. while ( cont )
  13. {
  14. wxPrintf(_T("\t%s\n"), filename.c_str());
  15. cont = dir.GetNext(&filename);
  16. }
  17. wxPuts(_T(""));
  18. }
  19. //----------------------------------------------------------------------------
  20. // MyApp
  21. //----------------------------------------------------------------------------
  22. class MyApp: public wxApp
  23. {
  24. public:
  25. MyApp();
  26. bool OnInit();
  27. int MainLoop();
  28. };
  29. IMPLEMENT_APP(MyApp)
  30. MyApp::MyApp()
  31. {
  32. }
  33. bool MyApp::OnInit()
  34. {
  35. //test a directory that exist:
  36. wxDir dir(wxT(".")); //wxDir dir("/tmp");
  37. TestDirEnumHelper(dir, wxDIR_DEFAULT | wxDIR_DOTDOT);
  38. //Testing if link to wx debug library
  39. #ifdef __WXDEBUG__
  40. printf("If you read this you're in debug mode.\n");
  41. #endif //__WXDEBUG__
  42. wxChar ch = wxT('*');
  43. wxString s = wxT("Hello, world!");
  44. int len = s.Len();
  45. printf("Length of string is: %d\n", len);
  46. //Force testing of Unicode mode
  47. #ifdef __UNICODE__
  48. wprintf(L"Unicode: %s \n", s.c_str());
  49. wprintf(:"Char: %c\n", ch);
  50. #else
  51. printf("ANSI: %s \n", s.c_str());
  52. printf("Char: %c\n", ch);
  53. #endif //__UNICODE__
  54. //return immediately
  55. return TRUE;
  56. }
  57. int MyApp::MainLoop()
  58. {
  59. return 0;
  60. }