1
0

MainThread.cpp 891 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include "MainThread.h"
  2. LRESULT CALLBACK MarshallProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
  3. {
  4. switch (message)
  5. {
  6. case WM_USER:
  7. {
  8. Lambda *lambda = (Lambda *)wParam;
  9. lambda->Run();
  10. delete lambda;
  11. return 0;
  12. }
  13. default:
  14. return DefWindowProc(hWnd, message, wParam, lParam);
  15. }
  16. return 0;
  17. }
  18. MainThread::MainThread()
  19. {
  20. WNDCLASSEX wcex;
  21. wcex.cbSize = sizeof(WNDCLASSEX);
  22. wcex.style = 0;
  23. wcex.lpfnWndProc = (WNDPROC)MarshallProc;
  24. wcex.cbClsExtra = 0;
  25. wcex.cbWndExtra = 0;
  26. wcex.hInstance = GetModuleHandle(0);
  27. wcex.hIcon = 0;
  28. wcex.hCursor = 0;
  29. wcex.hbrBackground = 0;
  30. wcex.lpszMenuName = 0;
  31. wcex.lpszClassName = "MainWindowMarshaller";
  32. wcex.hIconSm = 0;
  33. RegisterClassEx(&wcex);
  34. mainWindow = CreateWindow( "MainWindowMarshaller", "MainWindowMarshaller", WS_DISABLED, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(0), NULL);
  35. }
  36. MainThread mainThread;