Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

197 lines
3.9 KiB

  1. #pragma once
  2. // Hungarian: lb
  3. class CListBox
  4. {
  5. private:
  6. HWND m_hDlgItem;
  7. public:
  8. CListBox(HWND hDlg, INT nIDDlgItem)
  9. {
  10. m_hDlgItem = GetDlgItem(hDlg, nIDDlgItem);
  11. }
  12. INT GetCount()
  13. {
  14. return (int)SendMessage(m_hDlgItem, LB_GETCOUNT, 0L, 0L);
  15. }
  16. VOID ResetContent()
  17. {
  18. SendMessage(m_hDlgItem, LB_RESETCONTENT, 0L, 0L);
  19. }
  20. INT AddString(WCHAR * psz)
  21. {
  22. return (int)SendMessage(m_hDlgItem, LB_ADDSTRING, 0L, (LPARAM)psz);
  23. }
  24. VOID * GetItemData(INT index)
  25. {
  26. return (VOID *)SendMessage(m_hDlgItem, LB_GETITEMDATA, (WPARAM)index, 0L);
  27. }
  28. VOID SetItemData(INT index, VOID * data)
  29. {
  30. SendMessage(m_hDlgItem, LB_SETITEMDATA, (WPARAM)index, (LPARAM)(data));
  31. }
  32. INT FindItemData(INT indexStart, VOID * data)
  33. {
  34. // Go through each list item and compare its item data with
  35. // the data parameter. Return the index if found or -1 if not
  36. //
  37. int nCount = (int)SendMessage(m_hDlgItem, LB_GETCOUNT, 0, 0);
  38. for (int i = indexStart ; i < nCount; i++)
  39. {
  40. if (GetItemData(i) == data)
  41. {
  42. return i;
  43. }
  44. }
  45. return -1;
  46. }
  47. INT GetCurSel()
  48. {
  49. return (int)SendMessage(m_hDlgItem, LB_GETCURSEL, 0L, 0L);
  50. }
  51. VOID SetCurSel(int index)
  52. {
  53. SendMessage(m_hDlgItem, LB_SETCURSEL, (WPARAM)index, 0L);
  54. }
  55. };
  56. // Hungarian: bm
  57. class CButton
  58. {
  59. private:
  60. HWND m_hDlgItem;
  61. public:
  62. CButton(HWND hDlg, INT nIDDlgItem)
  63. {
  64. m_hDlgItem = GetDlgItem(hDlg, nIDDlgItem);
  65. }
  66. VOID Show(BOOL fShow)
  67. {
  68. ShowWindow(m_hDlgItem, fShow ? SW_SHOW : SW_HIDE);
  69. }
  70. BOOL GetCheck()
  71. {
  72. return (BOOL)SendMessage(m_hDlgItem, BM_GETCHECK, 0L, 0L);
  73. }
  74. VOID SetCheck(BOOL fCheck)
  75. {
  76. SendMessage(m_hDlgItem, BM_SETCHECK, (WPARAM)(fCheck), 0L);
  77. }
  78. };
  79. // Hungarian: cbx
  80. class CComboBox
  81. {
  82. private:
  83. HWND m_hDlgItem;
  84. public:
  85. CComboBox(HWND hDlg, INT nIDDlgItem)
  86. {
  87. m_hDlgItem = GetDlgItem(hDlg, nIDDlgItem);
  88. }
  89. VOID Show(BOOL fShow)
  90. {
  91. ShowWindow(m_hDlgItem, fShow ? SW_SHOW : SW_HIDE);
  92. }
  93. INT GetCount()
  94. {
  95. return (int)SendMessage(m_hDlgItem, CB_GETCOUNT, 0L, 0L);
  96. }
  97. VOID ResetContent()
  98. {
  99. SendMessage(m_hDlgItem, CB_RESETCONTENT, 0L, 0L);
  100. }
  101. VOID * GetItemData(INT index)
  102. {
  103. return (void *)SendMessage(m_hDlgItem, CB_GETITEMDATA,
  104. (WPARAM)index, 0L);
  105. }
  106. VOID SetItemData(INT index, VOID *data)
  107. {
  108. SendMessage(m_hDlgItem, CB_SETITEMDATA, (WPARAM)index, (LPARAM)data);
  109. }
  110. INT AddString(WCHAR *psz)
  111. {
  112. return (INT)SendMessage(m_hDlgItem, CB_ADDSTRING, 0L, (LPARAM)psz);
  113. }
  114. INT GetCurSel()
  115. {
  116. return (INT)SendMessage(m_hDlgItem, CB_GETCURSEL, 0L, 0L);
  117. }
  118. VOID SetCurSel(int index)
  119. {
  120. SendMessage(m_hDlgItem, CB_SETCURSEL, (WPARAM)index, 0L);
  121. }
  122. };
  123. // Hungarian: edt
  124. class CEdit
  125. {
  126. private:
  127. HWND m_hDlgItem;
  128. public:
  129. CEdit(HWND hDlg, INT nIDDlgItem)
  130. {
  131. m_hDlgItem = GetDlgItem(hDlg, nIDDlgItem);
  132. }
  133. VOID Show(BOOL fShow)
  134. {
  135. ShowWindow(m_hDlgItem, fShow ? SW_SHOW : SW_HIDE);
  136. }
  137. VOID SetStyle(LONG lStyle)
  138. {
  139. SetWindowLong(m_hDlgItem, GWL_STYLE, (LONG)lStyle);
  140. }
  141. LONG GetStyle()
  142. {
  143. return GetWindowLong(m_hDlgItem, GWL_STYLE);
  144. }
  145. VOID LimitText(INT cchMax)
  146. {
  147. SendMessage(m_hDlgItem, EM_LIMITTEXT, (WPARAM)(cchMax), 0L);
  148. }
  149. INT GetText(WCHAR * psz, INT cchMax)
  150. {
  151. return GetWindowText(m_hDlgItem, psz, cchMax);
  152. }
  153. VOID SetText(WCHAR * psz)
  154. {
  155. SetWindowText(m_hDlgItem, psz);
  156. }
  157. };