Ingen beskrivning

TestApp1.cpp 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // TestApp1.cpp : Defines the entry point for the application.
  2. //
  3. #ifdef _WIN32
  4. #include "Win32/stdafx.h"
  5. #endif
  6. #include <DK.h>
  7. class TestApp1 : public DKApplication
  8. {
  9. DKObject<DKWindow> window;
  10. public:
  11. void OnInitialize(void) override
  12. {
  13. DKLog("%s", DKGL_FUNCTION_NAME);
  14. DKWindow::WindowCallback cb = {};
  15. cb.draggingFeedback = DKFunction([](DKWindow*, DKWindow::DraggingState state, const DKPoint&, const DKStringArray&) {
  16. DKLog("cb.draggingFeedback: state:%d", state);
  17. return DKWindow::DragOperationCopy;
  18. });
  19. cb.closeRequest = DKFunction([](DKWindow* window)
  20. {
  21. DKLog("Close request?");
  22. if (DKIsDebuggerPresent())
  23. return false;
  24. return true;
  25. });
  26. window = DKWindow::Create("DefaultWindow",
  27. DKWindow::StyleGenericWindow|DKWindow::StyleAcceptFileDrop,
  28. this->EventLoop(),
  29. cb);
  30. window->Activate();
  31. window->AddEventHandler(this,
  32. DKFunction([this](const DKWindow::WindowEvent& e)
  33. {
  34. if (e.type == DKWindow::WindowEvent::WindowClosed)
  35. DKApplication::Instance()->Terminate(0);
  36. }),
  37. DKFunction([this](const DKWindow::KeyboardEvent& e)
  38. {
  39. }),
  40. DKFunction([this](const DKWindow::MouseEvent& e)
  41. {
  42. })
  43. );
  44. }
  45. void OnTerminate(void) override
  46. {
  47. DKLog("%s", DKGL_FUNCTION_NAME);
  48. }
  49. };
  50. #ifdef _WIN32
  51. int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
  52. _In_opt_ HINSTANCE hPrevInstance,
  53. _In_ LPWSTR lpCmdLine,
  54. _In_ int nCmdShow)
  55. #else
  56. int main(int argc, const char * argv[])
  57. #endif
  58. {
  59. DKPropertySet::SystemConfig().SetValue("DisableWindowKey", 1LL);
  60. TestApp1 app;
  61. DKPropertySet::SystemConfig().SetValue("AppDelegate", "AppDelegate");
  62. return app.Run();
  63. }