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.

194 lines
4.0 KiB

  1. // test listview control for broken rendering
  2. #include "headers.hxx"
  3. #include "resource.h"
  4. HINSTANCE hResourceModuleHandle = 0;
  5. const wchar_t* HELPFILE_NAME = 0; // no context help available
  6. const wchar_t* RUNTIME_NAME = L"listtest";
  7. DWORD DEFAULT_LOGGING_OPTIONS = Log::OUTPUT_TYPICAL;
  8. void
  9. AddIconImage(HIMAGELIST imageList, int iconResID)
  10. {
  11. LOG_FUNCTION(AddIconImage);
  12. ASSERT(imageList);
  13. ASSERT(iconResID);
  14. if (iconResID && imageList)
  15. {
  16. HICON icon = 0;
  17. HRESULT hr = Win::LoadImage(iconResID, icon);
  18. ASSERT(SUCCEEDED(hr));
  19. if (SUCCEEDED(hr))
  20. {
  21. Win::ImageList_AddIcon(imageList, icon);
  22. // once the icon is added (copied) to the image list, we can
  23. // destroy the original.
  24. Win::DestroyIcon(icon);
  25. }
  26. }
  27. }
  28. static const DWORD HELP_MAP[] =
  29. {
  30. 0, 0
  31. };
  32. class ListViewDialog : public Dialog
  33. {
  34. public:
  35. ListViewDialog()
  36. :
  37. Dialog(IDD_LOOK_FOR, HELP_MAP)
  38. {
  39. }
  40. ~ListViewDialog()
  41. {
  42. }
  43. protected:
  44. // Dialog overrides
  45. virtual
  46. void
  47. OnInit()
  48. {
  49. HWND listview = Win::GetDlgItem(hwnd, IDC_LOOK_FOR_LV);
  50. //
  51. // put listview in checkbox style
  52. //
  53. ListView_SetExtendedListViewStyleEx(
  54. listview,
  55. LVS_EX_CHECKBOXES,
  56. LVS_EX_CHECKBOXES);
  57. //ImageList_Create(16, 16, ILC_COLOR16 | ILC_MASK, 1, 1);
  58. HIMAGELIST images =
  59. Win::ImageList_Create(
  60. 16, // Win::GetSystemMetrics(SM_CXSMICON),
  61. 16, // Win::GetSystemMetrics(SM_CYSMICON),
  62. ILC_MASK,
  63. 1,
  64. 1);
  65. // the order in which these are added must be the same that the
  66. // MemberInfo::Type enum values are listed!
  67. AddIconImage(images, IDI_SCOPE_WORKGROUP);
  68. AddIconImage(images, IDI_LOCAL_GROUP);
  69. AddIconImage(images, IDI_SCOPE_DIRECTORY);
  70. AddIconImage(images, IDI_SCOPE_DOMAIN);
  71. AddIconImage(images, IDI_DISABLED_USER);
  72. AddIconImage(images, IDI_DISABLED_COMPUTER);
  73. Win::ListView_SetImageList(listview, images, LVSIL_SMALL);
  74. //
  75. // Add a single column to the listview
  76. //
  77. LV_COLUMN lvc;
  78. RECT rcLv;
  79. GetClientRect(listview, &rcLv);
  80. ZeroMemory(&lvc, sizeof lvc);
  81. lvc.mask = LVCF_FMT | LVCF_WIDTH;
  82. lvc.fmt = LVCFMT_LEFT;
  83. lvc.cx = rcLv.right;
  84. Win::ListView_InsertColumn(listview, 0, lvc);
  85. static PCWSTR itemLabels[] =
  86. {
  87. L"workgroup",
  88. L"Group",
  89. L"Directory",
  90. L"Domain",
  91. L"User",
  92. L"Computer",
  93. 0
  94. };
  95. LVITEM lvi;
  96. int i = 0;
  97. PCWSTR* labels = itemLabels;
  98. while (*labels)
  99. {
  100. ZeroMemory(&lvi, sizeof lvi);
  101. lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_IMAGE;
  102. lvi.pszText = const_cast<PWSTR>(*labels);
  103. lvi.iImage = i;
  104. ++labels;
  105. ++i;
  106. Win::ListView_InsertItem(listview, lvi);
  107. };
  108. //
  109. // Make the first item in the listview have the focus
  110. //
  111. ListView_SetItemState(
  112. listview,
  113. 0,
  114. LVIS_FOCUSED | LVIS_SELECTED,
  115. LVIS_FOCUSED | LVIS_SELECTED);
  116. }
  117. private:
  118. ListViewDialog(const ListViewDialog&);
  119. const ListViewDialog& operator=(const ListViewDialog&);
  120. };
  121. int WINAPI
  122. WinMain(
  123. HINSTANCE hInstance,
  124. HINSTANCE /* hPrevInstance */ ,
  125. PSTR /* lpszCmdLine */ ,
  126. int /* nCmdShow */)
  127. {
  128. hResourceModuleHandle = hInstance;
  129. int exitCode = 0;
  130. INITCOMMONCONTROLSEX s_e_x;
  131. s_e_x.dwSize = sizeof(s_e_x);
  132. s_e_x.dwICC = ICC_ANIMATE_CLASS | ICC_USEREX_CLASSES;
  133. BOOL init = ::InitCommonControlsEx(&s_e_x);
  134. ASSERT(init);
  135. ListViewDialog().ModalExecute(Win::GetDesktopWindow());
  136. return exitCode;
  137. }