MainDlg.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // MainDlg.h : interface of the CMainDlg class
  2. //
  3. /////////////////////////////////////////////////////////////////////////////
  4. #pragma once
  5. #include <thread>
  6. #include <functional>
  7. #define WM_KILLPROPCESS WM_APP+1
  8. #define MSG_WM_KILLPROPCESS(func) if(uMsg==WM_KILLPROPCESS){ SetMsgHandled(TRUE);func();if(IsMsgHandled()) return TRUE;}
  9. #define WM_COMPLETE WM_APP+2
  10. #define MSG_WM_COMPLETE(func) if(uMsg==WM_COMPLETE){ SetMsgHandled(TRUE);func();if(IsMsgHandled()) return TRUE;}
  11. #define IDC_TIMER 2000
  12. class CMainDlg : public CDialogImpl<CMainDlg>
  13. {
  14. public:
  15. enum { IDD = IDD_MAINDLG };
  16. BEGIN_MSG_MAP_EX(CMainDlg)
  17. MSG_WM_INITDIALOG(OnInitDialog)
  18. COMMAND_ID_HANDLER_EX(IDCANCEL, OnCancel)
  19. MSG_WM_KILLPROPCESS(OnKillProcess);
  20. MSG_WM_COMPLETE(OnComplete);
  21. MSG_WM_TIMER(OnTimer)
  22. END_MSG_MAP()
  23. // Handler prototypes (uncomment arguments if needed):
  24. // LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
  25. // LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
  26. // LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)
  27. void OnKillProcess();
  28. void OnComplete();
  29. void OnTimer(UINT id);
  30. LRESULT OnInitDialog(HWND,LPARAM);
  31. void OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND );
  32. private:
  33. void UpdateThread();
  34. private:
  35. CURLcode DownloadFile(const char * url, const char* file);
  36. static size_t DownloadCallback(void* pBuffer, size_t nSize, size_t nMemBytes, FILE* fp);
  37. bool LoadConfig();
  38. void WriteConfig(int32_t version);
  39. std::thread _thread;
  40. int Count;
  41. std::string _url;
  42. int32_t _version;
  43. };