1
0

setupPageWnd.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. #include "./setupPage.h"
  2. #include "./setupListbox.h"
  3. #include "../common.h"
  4. #include "../resource.h"
  5. #include "../api__ml_online.h"
  6. static ATOM SETUPPAGE_PROP = 0;
  7. #define GetPage(__hwnd) ((SetupPage*)GetPropW((__hwnd), MAKEINTATOM(SETUPPAGE_PROP)))
  8. static INT_PTR WINAPI SetupPage_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
  9. HWND SetupPage_CreateWindow(HWND hParent, SetupPage *page)
  10. {
  11. return WASABI_API_CREATEDIALOGPARAMW(IDD_SETUPPAGE, hParent, SetupPage_DialogProc, (LPARAM)page);
  12. }
  13. static INT_PTR SetupPage_OnInitDialog(HWND hwnd, HWND hFocus, LPARAM lParam)
  14. {
  15. if (0 == SETUPPAGE_PROP)
  16. {
  17. SETUPPAGE_PROP = GlobalAddAtom(L"omSetupPageProp");
  18. if (0 == SETUPPAGE_PROP) return FALSE;
  19. }
  20. SetupPage *page = (SetupPage*)lParam;
  21. if (NULL != page && page->AttachWindow(hwnd))
  22. {
  23. SetProp(hwnd, MAKEINTATOM(SETUPPAGE_PROP), page);
  24. }
  25. return FALSE;
  26. }
  27. static void SetupPage_OnDestroy(HWND hwnd)
  28. {
  29. SetupPage *page = GetPage(hwnd);
  30. if (NULL != page)
  31. {
  32. page->DetachWindow();
  33. }
  34. RemoveProp(hwnd, MAKEINTATOM(SETUPPAGE_PROP));
  35. }
  36. static void SetupPage_OnCommand(HWND hwnd, INT controlId, INT eventId, HWND hControl)
  37. {
  38. SetupPage *page;
  39. switch(controlId)
  40. {
  41. case IDC_SERVICELIST:
  42. switch(eventId)
  43. {
  44. case LBN_SELCHANGE:
  45. page = GetPage(hwnd);
  46. if (NULL != page)
  47. page->ListboxSelectionChanged();
  48. break;
  49. }
  50. break;
  51. }
  52. }
  53. static BOOL SetupPage_OnMeasureItem(HWND hwnd, MEASUREITEMSTRUCT *pmis)
  54. {
  55. SetupListbox *instance;
  56. switch(pmis->CtlID)
  57. {
  58. case IDC_SERVICELIST:
  59. instance = SetupListbox::GetInstance(GetDlgItem(hwnd, pmis->CtlID));
  60. if (NULL != instance)
  61. {
  62. return instance->MeasureItem(pmis->itemID, &pmis->itemWidth, &pmis->itemHeight);
  63. }
  64. break;
  65. }
  66. return FALSE;
  67. }
  68. static BOOL SetupPage_OnDrawItem(HWND hwnd, DRAWITEMSTRUCT *pdis)
  69. {
  70. SetupListbox *instance;
  71. switch(pdis->CtlID)
  72. {
  73. case IDC_SERVICELIST:
  74. instance = SetupListbox::GetInstance(pdis->hwndItem);
  75. if (NULL != instance)
  76. {
  77. return instance->DrawItem(pdis->hDC, &pdis->rcItem, pdis->itemID, pdis->itemState, pdis->itemAction);
  78. }
  79. break;
  80. }
  81. return FALSE;
  82. }
  83. static INT_PTR SetupPage_OnCharToItem(HWND hwnd, INT vKey, INT caretPos, HWND hList)
  84. {
  85. if (IDC_SERVICELIST == GetDlgCtrlID(hList))
  86. {
  87. SetupListbox *instance = SetupListbox::GetInstance(hList);
  88. if (NULL != instance)
  89. return instance->CharToItem(vKey, caretPos);
  90. }
  91. return -1;
  92. }
  93. static INT_PTR SetupPage_OnKeyToItem(HWND hwnd, INT vKey, INT caretPos, HWND hList)
  94. {
  95. if (IDC_SERVICELIST == GetDlgCtrlID(hList))
  96. {
  97. SetupListbox *instance = SetupListbox::GetInstance(hList);
  98. if (NULL != instance)
  99. return instance->KeyToItem(vKey, caretPos);
  100. }
  101. return -1;
  102. }
  103. static void SetupPage_OnUpdateList(HWND hwnd, INT groupId)
  104. {
  105. HWND hList = GetDlgItem(hwnd, IDC_SERVICELIST);
  106. if (NULL != hList)
  107. {
  108. SetupListbox *listbox = SetupListbox::GetInstance(hList);
  109. if (NULL != listbox)
  110. {
  111. listbox->UpdateCount();
  112. }
  113. }
  114. }
  115. static INT_PTR WINAPI SetupPage_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  116. {
  117. switch(uMsg)
  118. {
  119. case WM_INITDIALOG: return SetupPage_OnInitDialog(hwnd, (HWND)wParam, lParam);
  120. case WM_DESTROY: SetupPage_OnDestroy(hwnd); break;
  121. case WM_COMMAND: SetupPage_OnCommand(hwnd, LOWORD(wParam), HIWORD(wParam), (HWND)lParam); break;
  122. case WM_MEASUREITEM: return SetupPage_OnMeasureItem(hwnd, (MEASUREITEMSTRUCT*)lParam);
  123. case WM_DRAWITEM: return SetupPage_OnDrawItem(hwnd, (DRAWITEMSTRUCT*)lParam);
  124. case WM_CHARTOITEM: return SetupPage_OnCharToItem(hwnd, LOWORD(wParam), HIWORD(wParam), (HWND)lParam);
  125. case WM_VKEYTOITEM: return SetupPage_OnKeyToItem(hwnd, LOWORD(wParam), HIWORD(wParam), (HWND)lParam);
  126. case SPM_UPDATELIST: SetupPage_OnUpdateList(hwnd, (INT)wParam); return TRUE;
  127. }
  128. return 0;
  129. }