detourtest.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. #include <windows.h>
  2. #include <commctrl.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include "resource.h"
  6. #include "..\coolsb\coolscroll.h"
  7. #include "..\coolsb_detours\coolsb_detours.h"
  8. #pragma comment (lib, "detours.lib")
  9. void PopulateItem( HWND hTree, HTREEITEM hParent, int childs, int depth )
  10. {
  11. int i;
  12. char szText[32];
  13. TV_INSERTSTRUCT tvis;
  14. for(i = 0; i < childs; i++)
  15. {
  16. wsprintf(szText, "Item %d - %d", depth, i);
  17. tvis.hParent = hParent;
  18. tvis.hInsertAfter = TVI_LAST;
  19. tvis.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_STATE;
  20. tvis.item.pszText = (LPTSTR) szText;
  21. tvis.item.iImage = 0;
  22. tvis.item.iSelectedImage = 0;
  23. tvis.item.state = 0;
  24. tvis.item.stateMask = 0;
  25. tvis.item.lParam = i;
  26. if ( depth > 0 )
  27. PopulateItem(hTree, TreeView_InsertItem(hTree, &tvis), childs, depth-1);
  28. }
  29. TreeView_Expand(hTree, hParent, TVE_EXPAND);
  30. }
  31. BOOL CALLBACK DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  32. {
  33. HWND hwndCtrl;
  34. LVCOLUMN lvcol;
  35. int i;
  36. char szText[32];
  37. switch(msg)
  38. {
  39. case WM_INITDIALOG:
  40. //
  41. // Apply Cool Scrollbars to EDIT control
  42. //
  43. hwndCtrl = GetDlgItem(hwnd, IDC_EDIT1);
  44. InitializeCoolSB(hwndCtrl);
  45. CoolSB_SetStyle(hwndCtrl, SB_BOTH, CSBS_HOTTRACKED);
  46. //
  47. // Apply Cool Scrollbars to LISTBOX control
  48. //
  49. hwndCtrl = GetDlgItem(hwnd, IDC_LIST1);
  50. InitializeCoolSB(hwndCtrl);
  51. CoolSB_SetStyle(hwndCtrl, SB_BOTH, CSBS_HOTTRACKED);
  52. for(i = 0; i < 50; i++)
  53. {
  54. wsprintf(szText, "Line %d", i);
  55. SendMessage(hwndCtrl, LB_ADDSTRING, 0, (LONG)szText);
  56. }
  57. //
  58. // Apply Cool Scrollbars to LISTVIEW control
  59. //
  60. hwndCtrl = GetDlgItem(hwnd, IDC_LIST2);
  61. lvcol.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_FMT;
  62. lvcol.cx = 64;
  63. lvcol.iSubItem = 0;
  64. lvcol.pszText = "Name";
  65. ListView_InsertColumn(hwndCtrl, 0, &lvcol);
  66. lvcol.pszText = "Size";
  67. lvcol.cx = 64;
  68. lvcol.fmt = LVCFMT_RIGHT;
  69. ListView_InsertColumn(hwndCtrl, 1, &lvcol);
  70. for(i = 0; i < 50; i++)
  71. {
  72. LVITEM lvitem;
  73. lvitem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
  74. lvitem.iSubItem = 0;
  75. lvitem.pszText = "item";
  76. lvitem.iItem = i;
  77. lvitem.state = 0;
  78. lvitem.stateMask = 0;
  79. ListView_InsertItem(hwndCtrl, &lvitem);
  80. wsprintf(szText, "%d", i);
  81. ListView_SetItemText(hwndCtrl, i, 1, szText);
  82. }
  83. InitializeCoolSB(hwndCtrl);
  84. CoolSB_SetStyle(hwndCtrl, SB_BOTH, CSBS_HOTTRACKED);
  85. //
  86. // Apply Cool Scrollbars to a TREEVIEW control!
  87. //
  88. hwndCtrl = GetDlgItem(hwnd, IDC_TREE);
  89. PopulateItem( hwndCtrl, TVI_ROOT, 2, 10 );
  90. InitializeCoolSB(hwndCtrl);
  91. CoolSB_SetStyle(hwndCtrl, SB_BOTH, CSBS_HOTTRACKED);
  92. return TRUE;
  93. case WM_CLOSE:
  94. EndDialog(hwnd, 0);
  95. return TRUE;
  96. case WM_COMMAND:
  97. switch(LOWORD(wParam))
  98. {
  99. case IDOK: case IDCANCEL:
  100. EndDialog(hwnd, 0);
  101. return TRUE;
  102. }
  103. break;
  104. }
  105. return FALSE;
  106. }
  107. int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nShowCmd)
  108. {
  109. CoolSB_InitializeApp();
  110. DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG1), 0, DlgProc);
  111. CoolSB_UninitializeApp();
  112. return 0;
  113. }
  114. /*
  115. #include <windows.h>
  116. #include <commctrl.h>
  117. #include "resource.h"
  118. #include "..\coolsb\coolscroll.h"
  119. #include "..\coolsb_detours\coolsb_detours.h"
  120. #pragma comment (lib, "..\\coolsb_detours\\detours.lib")
  121. BOOL CALLBACK DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
  122. {
  123. HWND hwndCtrl;
  124. LVCOLUMN lvcol;
  125. int i;
  126. char szText[32];
  127. switch(msg)
  128. {
  129. case WM_INITDIALOG:
  130. //
  131. // Apply Cool Scrollbars to EDIT control
  132. //
  133. hwndCtrl = GetDlgItem(hwnd, IDC_EDIT1);
  134. InitializeCoolSB(hwndCtrl);
  135. CoolSB_SetStyle(hwndCtrl, SB_BOTH, CSBS_HOTTRACKED);
  136. //
  137. // Apply Cool Scrollbars to LISTBOX control
  138. //
  139. hwndCtrl = GetDlgItem(hwnd, IDC_LIST1);
  140. InitializeCoolSB(hwndCtrl);
  141. CoolSB_SetStyle(hwndCtrl, SB_BOTH, CSBS_HOTTRACKED);
  142. for(i = 0; i < 50; i++)
  143. {
  144. wsprintf(szText, "Line %d", i);
  145. SendMessage(hwndCtrl, LB_ADDSTRING, 0, (LONG)szText);
  146. }
  147. //
  148. // Apply Cool Scrollbars to LISTVIEW control
  149. //
  150. hwndCtrl = GetDlgItem(hwnd, IDC_LIST2);
  151. lvcol.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM | LVCF_FMT;
  152. lvcol.cx = 64;
  153. lvcol.iSubItem = 0;
  154. lvcol.pszText = "Name";
  155. ListView_InsertColumn(hwndCtrl, 0, &lvcol);
  156. lvcol.pszText = "Size";
  157. lvcol.cx = 64;
  158. lvcol.fmt = LVCFMT_RIGHT;
  159. ListView_InsertColumn(hwndCtrl, 1, &lvcol);
  160. for(i = 0; i < 50; i++)
  161. {
  162. LVITEM lvitem;
  163. lvitem.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
  164. lvitem.iSubItem = 0;
  165. lvitem.pszText = "item";
  166. lvitem.iItem = i;
  167. lvitem.state = 0;
  168. lvitem.stateMask = 0;
  169. ListView_InsertItem(hwndCtrl, &lvitem);
  170. wsprintf(szText, "%d", i);
  171. ListView_SetItemText(hwndCtrl, i, 1, szText);
  172. }
  173. InitializeCoolSB(hwndCtrl);
  174. CoolSB_SetStyle(hwndCtrl, SB_BOTH, CSBS_HOTTRACKED);
  175. return TRUE;
  176. case WM_CLOSE:
  177. EndDialog(hwnd, 0);
  178. return TRUE;
  179. case WM_COMMAND:
  180. switch(LOWORD(wParam))
  181. {
  182. case IDOK: case IDCANCEL:
  183. EndDialog(hwnd, 0);
  184. return TRUE;
  185. }
  186. break;
  187. }
  188. return FALSE;
  189. }
  190. int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, int nShowCmd)
  191. {
  192. CoolSB_InitializeApp();
  193. DialogBox(hInst, MAKEINTRESOURCE(IDD_DIALOG1), 0, DlgProc);
  194. CoolSB_UninitializeApp();
  195. return 0;
  196. }*/