WX.cxx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 __WXDEBUG__ debug mode.\n");
  41. #endif //__WXDEBUG__
  42. #ifdef _DEBUG
  43. printf("If you read this then _DEBUG is defined.\n");
  44. #endif //_DEBUG
  45. wxChar ch = wxT('*');
  46. wxString s = wxT("Hello, world!");
  47. int len = s.Len();
  48. printf("Length of string is: %d\n", len);
  49. //Force testing of Unicode mode
  50. #ifdef __UNICODE__
  51. wprintf(L"Unicode: %s \n", s.c_str());
  52. wprintf(:"Char: %c\n", ch);
  53. #else
  54. printf("ANSI: %s \n", s.c_str());
  55. printf("Char: %c\n", ch);
  56. #endif //__UNICODE__
  57. //return immediately
  58. return TRUE;
  59. }
  60. int MyApp::MainLoop()
  61. {
  62. return 0;
  63. }