Source code of Windows XP (NT5)
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.

136 lines
3.4 KiB

  1. #include "shellprv.h"
  2. #include "duiview.h"
  3. #include "duilist.h"
  4. // DUIListView
  5. DUIListView::~DUIListView()
  6. {
  7. DetachListview();
  8. }
  9. void DUIListView::DetachListview()
  10. {
  11. if (m_hwndListview)
  12. {
  13. // Unhook DUI from the HWND before doing this
  14. HWNDHost::Detach();
  15. if (m_bClientEdge)
  16. SetWindowBits(m_hwndListview, GWL_EXSTYLE, WS_EX_CLIENTEDGE, WS_EX_CLIENTEDGE);
  17. ShowWindow(m_hwndListview, SW_HIDE); // HIDE IT SO IT doesn't flash before switching.
  18. SHSetParentHwnd(m_hwndListview, m_hwndLVOrgParent);
  19. }
  20. }
  21. HRESULT DUIListView::Create(UINT nActive, HWND hwndListView, OUT Element** ppElement)
  22. {
  23. *ppElement = NULL;
  24. DUIListView* pDUIListView = HNewAndZero<DUIListView>();
  25. if (!pDUIListView)
  26. return E_OUTOFMEMORY;
  27. HRESULT hr = pDUIListView->Initialize(nActive, hwndListView);
  28. if (FAILED(hr))
  29. {
  30. pDUIListView->Destroy();
  31. return E_OUTOFMEMORY;
  32. }
  33. pDUIListView->SetAccessible(true);
  34. *ppElement = pDUIListView;
  35. return S_OK;
  36. }
  37. HWND DUIListView::CreateHWND(HWND hwndParent)
  38. {
  39. m_hwndParent = hwndParent;
  40. // Save the original parent window handle
  41. m_hwndLVOrgParent = ::GetParent(m_hwndListview);
  42. SHSetParentHwnd(m_hwndListview, hwndParent);
  43. LONG lExStyle = GetWindowLong(m_hwndListview, GWL_EXSTYLE);
  44. m_bClientEdge = lExStyle & WS_EX_CLIENTEDGE ? TRUE : FALSE;
  45. if (m_bClientEdge)
  46. {
  47. lExStyle &= ~WS_EX_CLIENTEDGE;
  48. SetWindowLong(m_hwndListview, GWL_EXSTYLE, lExStyle);
  49. }
  50. return m_hwndListview;
  51. }
  52. // Global action callback
  53. UINT DUIListView::MessageCallback(GMSG* pGMsg)
  54. {
  55. return HWNDHost::MessageCallback(pGMsg);
  56. }
  57. // Pointer is only guaranteed good for the lifetime of the call
  58. void DUIListView::OnInput(InputEvent* pie)
  59. {
  60. // Bypass HWNDHost::OnInput for tab input events so they aren't forwarded
  61. // to the HWND control. Element::OnInput will handle the events (keyboard nav)
  62. if (pie->nStage == GMF_DIRECT)
  63. {
  64. if (pie->nDevice == GINPUT_KEYBOARD)
  65. {
  66. KeyboardEvent* pke = (KeyboardEvent*)pie;
  67. if (pke->nCode == GKEY_DOWN || pke->nCode == GKEY_UP) // Virtual keys
  68. {
  69. if (pke->ch == VK_TAB)
  70. {
  71. Element::OnInput(pie);
  72. return;
  73. }
  74. }
  75. else if (pke->nCode == GKEY_CHAR) // Characters
  76. {
  77. if (pke->ch == 9)
  78. {
  79. Element::OnInput(pie);
  80. return;
  81. }
  82. }
  83. }
  84. }
  85. HWNDHost::OnInput(pie);
  86. }
  87. ////////////////////////////////////////////////////////
  88. // Property definitions
  89. /** Property template (replace !!!), also update private PropertyInfo* parray and class header (element.h)
  90. // !!! property
  91. static int vv!!![] = { V_INT, -1 }; StaticValue(svDefault!!!, V_INT, 0);
  92. static PropertyInfo imp!!!Prop = { L"!!!", PF_Normal, 0, vv!!!, (Value*)&svDefault!!! };
  93. PropertyInfo* Element::!!!Prop = &imp!!!Prop;
  94. **/
  95. ////////////////////////////////////////////////////////
  96. // ClassInfo (must appear after property definitions)
  97. // Class properties
  98. // Define class info with type and base type, set static class pointer
  99. IClassInfo* DUIListView::Class = NULL;
  100. HRESULT DUIListView::Register()
  101. {
  102. return ClassInfo<DUIListView,HWNDHost>::Register(L"DUIListView", NULL, 0);
  103. }