Skip to content

Commit 589ec46

Browse files
committed
reproduction scenario now working
1 parent f2c20b8 commit 589ec46

File tree

7 files changed

+69
-189
lines changed

7 files changed

+69
-189
lines changed

GDIGraphicsPOC/CMainFrame2.cpp

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,13 @@ LRESULT fusion::CMainFrame2::OnSize(UINT nType, CSize Extent)
2525
return 1;
2626
}
2727

28-
BOOL fusion::CMainFrame2::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
29-
{
30-
return TRUE;
31-
}
32-
33-
void fusion::CMainFrame2::DisablePaneHeader(CPaneContainer& panecontainer)
34-
{
35-
panecontainer.SetPaneContainerExtendedStyle(PANECNT_NOCLOSEBUTTON, 0);
36-
panecontainer.m_cxyHeader = 0;
37-
}
38-
3928
LRESULT fusion::CMainFrame2::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
4029
{
4130
auto rect = RECT();
4231
GetClientRect(&rect);
43-
rect.bottom = 600;
44-
m_logview.Create(*this, rect, CListViewCtrl::GetWndClassName(), WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | SS_OWNERDRAW, WS_EX_CLIENTEDGE);
32+
rect.bottom = 540; // 40x 13 = 520, + 20 for colomn header
33+
m_logview.Create(*this, rect, CListViewCtrl::GetWndClassName(), WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL, WS_EX_CLIENTEDGE);
4534
AddDummyContent(m_logview);
46-
m_logview.SetBkColor(RGB(10, 10, 255));
4735
return 0;
4836
}
4937

GDIGraphicsPOC/CMainFrame2.h

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,6 @@ extern CAppModule _Module; // WTL version of CComModule
2727

2828
namespace fusion {
2929

30-
typedef CCheckListViewCtrlImplTraits<
31-
0, 0, LVS_EX_CHECKBOXES | LVS_EX_GRIDLINES | LVS_EX_UNDERLINEHOT |
32-
LVS_EX_ONECLICKACTIVATE> CMyCheckListTraits;
33-
34-
class CMyCheckListCtrl :
35-
public CCheckListViewCtrlImpl<CMyCheckListCtrl, CListViewCtrl, CMyCheckListTraits>
36-
{
37-
private:
38-
typedef CCheckListViewCtrlImpl<CMyCheckListCtrl, CListViewCtrl, CMyCheckListTraits> baseClass;
39-
public:
40-
DECLARE_WND_SUPERCLASS(_T("WTL_CheckListView"), GetWndClassName())
41-
42-
BEGIN_MSG_MAP(CMyCheckListCtrl)
43-
CHAIN_MSG_MAP(baseClass)
44-
END_MSG_MAP()
45-
};
46-
4730
class CMainFrame2 : public WTL::CFrameWindowImpl<CMainFrame2, ATL::CWindow, ATL::CFrameWinTraits>
4831
{
4932
public:
@@ -53,15 +36,13 @@ class CMainFrame2 : public WTL::CFrameWindowImpl<CMainFrame2, ATL::CWindow, ATL:
5336
MESSAGE_HANDLER(WM_CREATE, OnCreate)
5437
MESSAGE_HANDLER(WM_CLOSE, OnClose)
5538
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
56-
MSG_WM_MOUSEWHEEL(OnMouseWheel)
5739
MSG_WM_SIZE(OnSize)
5840
CHAIN_MSG_MAP(CFrameWindowImpl<CMainFrame2>)
41+
REFLECT_NOTIFICATIONS();
5942
DEFAULT_REFLECTION_HANDLER()
6043
END_MSG_MAP()
6144

6245
LRESULT OnSize(UINT nType, CSize Extent);
63-
BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
64-
void DisablePaneHeader(CPaneContainer& panecontainer);
6546
LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
6647
LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
6748
LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
@@ -70,23 +51,4 @@ class CMainFrame2 : public WTL::CFrameWindowImpl<CMainFrame2, ATL::CWindow, ATL:
7051
CLogView m_logview;
7152
};
7253

73-
class MainWnd : public CWindowImpl<MainWnd>
74-
{
75-
public:
76-
DECLARE_WND_CLASS(_T("Specific_Class_Name"))
77-
78-
BEGIN_MSG_MAP(MainWnd)
79-
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
80-
END_MSG_MAP()
81-
82-
LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
83-
{
84-
PostQuitMessage(0);
85-
bHandled = FALSE;
86-
return 0;
87-
}
88-
89-
};
90-
91-
9254
} // namespace fusion

GDIGraphicsPOC/Logview.cpp

Lines changed: 31 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -17,75 +17,39 @@
1717
namespace fusion {
1818

1919

20-
BEGIN_MSG_MAP2(CLogView)
21-
MSG_WM_CREATE(OnCreate)
22-
MSG_WM_CLOSE(OnClose)
23-
MSG_WM_TIMER(OnTimer)
24-
25-
REFLECTED_NOTIFY_CODE_HANDLER_EX(LVN_ODSTATECHANGED, OnOdStateChanged)
26-
REFLECTED_NOTIFY_CODE_HANDLER_EX(LVN_ODCACHEHINT, OnOdCacheHint)
27-
28-
CHAIN_MSG_MAP_ALT(COwnerDraw<CLogView>, 1)
29-
//CHAIN_MSG_MAP(CDoubleBufferImpl<CLogView>) //DrMemory: GDI USAGE ERROR: DC 0x3e011cca that contains selected object being deleted
30-
DEFAULT_REFLECTION_HANDLER()
31-
END_MSG_MAP()
32-
33-
3420
CLogView::CLogView()
3521
{
3622
}
3723

38-
void CLogView::OnException() const
39-
{
40-
}
41-
42-
void CLogView::OnException(const std::exception& ex)
43-
{
44-
}
45-
4624
void CLogView::DeleteItem(DELETEITEMSTRUCT* lParam)
4725
{
48-
COwnerDraw<CLogView>::DeleteItem(lParam);
49-
}
50-
51-
LRESULT CLogView::OnCreate(const CREATESTRUCT* /*pCreate*/)
52-
{
53-
DefWindowProc();
54-
SetExtendedListViewStyle(GetWndExStyle(0));
55-
return 0;
26+
COwnerDraw<CLogView>::DeleteItem(lParam);
5627
}
5728

5829
void CLogView::SetFont(HFONT hFont)
5930
{
60-
CListViewCtrl::SetFont(hFont);
61-
GetHeader().Invalidate();
62-
63-
// Trigger WM_MEASUREPOS
64-
// See: http://www.codeproject.com/Articles/1401/Changing-Row-Height-in-an-owner-drawn-Control
65-
CRect rect;
66-
GetWindowRect(&rect);
67-
WINDOWPOS wp;
68-
wp.hwnd = *this;
69-
wp.cx = rect.Width();
70-
wp.cy = rect.Height();
71-
wp.flags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER;
72-
SendMessage(WM_WINDOWPOSCHANGED, 0, reinterpret_cast<LPARAM>(&wp));
31+
CListViewCtrl::SetFont(hFont);
32+
GetHeader().Invalidate();
33+
34+
// Trigger WM_MEASUREPOS
35+
// See: http://www.codeproject.com/Articles/1401/Changing-Row-Height-in-an-owner-drawn-Control
36+
CRect rect;
37+
GetWindowRect(&rect);
38+
WINDOWPOS wp;
39+
wp.hwnd = *this;
40+
wp.cx = rect.Width();
41+
wp.cy = rect.Height();
42+
wp.flags = SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER;
43+
SendMessage(WM_WINDOWPOSCHANGED, 0, reinterpret_cast<LPARAM>(&wp));
7344
}
7445

7546
void CLogView::OnClose()
7647
{
7748
}
7849

79-
void CLogView::OnTimer(UINT_PTR nIDEvent)
80-
{
81-
if (nIDEvent != 1)
82-
return;
83-
84-
}
85-
8650
void CLogView::MeasureItem(MEASUREITEMSTRUCT* pMeasureItemStruct)
8751
{
88-
OutputDebugStringA("CLogView::MeasureItem - debug");
52+
OutputDebugStringA("CLogView::MeasureItem - debug");
8953
CClientDC dc(*this);
9054

9155
Win32::GdiObjectSelection font(dc, GetFont());
@@ -96,48 +60,36 @@ void CLogView::MeasureItem(MEASUREITEMSTRUCT* pMeasureItemStruct)
9660

9761
void CLogView::DrawItem(DRAWITEMSTRUCT* pDrawItemStruct)
9862
{
99-
OutputDebugStringA("CLogView::DrawItem - debug");
100-
63+
OutputDebugStringA("CLogView::DrawItem - debug");
10164
DrawItem(pDrawItemStruct->hDC, pDrawItemStruct->itemID, pDrawItemStruct->itemState);
10265
}
10366

10467
RECT CLogView::GetItemRect(int iItem, unsigned code) const
10568
{
106-
RECT rect;
107-
CListViewCtrl::GetItemRect(iItem, &rect, code);
108-
return rect;
69+
RECT rect;
70+
CListViewCtrl::GetItemRect(iItem, &rect, code);
71+
return rect;
10972
}
11073

11174
void CLogView::DrawItem(CDCHandle dc, int iItem, unsigned /*iItemState*/)
11275
{
113-
SetMsgHandled(false);
114-
}
115-
116-
117-
LRESULT CLogView::OnOdStateChanged(NMHDR* pnmh)
118-
{
119-
auto& nmhdr = *reinterpret_cast<NMLVODSTATECHANGE*>(pnmh);
120-
nmhdr;
76+
auto rect = GetItemRect(iItem, LVIR_BOUNDS);
12177

122-
return 0;
123-
}
78+
bool selected = GetItemState(iItem, LVIS_SELECTED) == LVIS_SELECTED;
79+
bool focused = GetItemState(iItem, LVIS_FOCUSED) == LVIS_FOCUSED;
80+
auto bkColor = selected ? RGB(255, 200, 200) : RGB(255, 255, 255);
81+
auto txColor = RGB(0, 0, 0);
12482

125-
LRESULT CLogView::OnOdCacheHint(NMHDR* pnmh)
126-
{
127-
auto& nmhdr = *reinterpret_cast<NMLVCACHEHINT*>(pnmh);
128-
nmhdr;
129-
return 0;
130-
}
83+
dc.FillSolidRect(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, bkColor);
13184

132-
void CLogView::DoPaint(CDCHandle dc)
133-
{
134-
RECT rect;
135-
dc.GetClipBox(&rect);
85+
Win32::ScopedBkColor bcol(dc, bkColor);
86+
Win32::ScopedTextColor tcol(dc, txColor);
13687

137-
auto fill = RGB(10, 10, 255); //Colors::BackGround
138-
dc.FillSolidRect(&rect, fill);
88+
std::wstring text = wstringbuilder() << iItem +1 << L" If the logview is rendered correctly then exactly 40 lines will fit";
89+
dc.DrawText(text.c_str(), text.size(), &rect, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS);
13990

140-
DefWindowProc(WM_PAINT, reinterpret_cast<WPARAM>(dc.m_hDC), 0);
91+
if (focused)
92+
dc.DrawFocusRect(&rect);
14193
}
14294

14395

GDIGraphicsPOC/Logview.h

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616
#include "atlframe.h"
1717
#include "atlctrls.h"
1818
#include "AtlWinExt.h"
19+
#include <atlcrack.h>
1920

2021

2122
namespace fusion {
2223

2324
template <typename T>
2425
void AddDummyContent(T& t)
2526
{
26-
t.InsertColumn(0, _T("Scoobies"), LVCFMT_LEFT, 100, 0);
27+
t.InsertColumn(0, _T("Scoobies2"), LVCFMT_LEFT, -1, -1);
2728
t.InsertItem(0, _T("01 Willow is een test regel met een hoop tekens er achter"));
2829
t.InsertItem(1, _T("02 Buffy is een test regel met een hoop tekens er achter"));
2930
t.InsertItem(2, _T("03 Giles is een test regel met een hoop tekens er achter"));
@@ -70,38 +71,31 @@ void AddDummyContent(T& t)
7071
t.SetFont(font);
7172
}
7273

73-
class CLogView : public WTL::CDoubleBufferWindowImpl<CLogView, CListViewCtrl,
74+
class CLogView : public CWindowImpl<CLogView, CListViewCtrl,
7475
CWinTraitsOR<
7576
LVS_OWNERDRAWFIXED | LVS_REPORT | LVS_OWNERDATA | LVS_NOSORTHEADER | LVS_SHOWSELALWAYS,
7677
LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP | LVS_EX_HEADERDRAGDROP>>,
77-
public WTL::COwnerDraw<CLogView>,
78-
ExceptionHandler<CLogView, std::exception>
78+
public WTL::COwnerDraw<CLogView>
7979
{
8080
public:
8181
CLogView();
8282

8383
DECLARE_WND_SUPERCLASS(nullptr, CListViewCtrl::GetWndClassName())
8484

85-
void DoPaint(WTL::CDCHandle dc);
86-
void DeleteItem(DELETEITEMSTRUCT* lParam);
87-
85+
BEGIN_MSG_MAP(CLogView)
86+
MSG_WM_CLOSE(OnClose)
87+
CHAIN_MSG_MAP_ALT(COwnerDraw<CLogView>, 1)
88+
DEFAULT_REFLECTION_HANDLER()
89+
END_MSG_MAP()
8890

91+
void DeleteItem(DELETEITEMSTRUCT* lParam);
8992
void MeasureItem(MEASUREITEMSTRUCT* pMeasureItemStruct);
9093
void DrawItem(DRAWITEMSTRUCT* pDrawItemStruct);
9194
void SetFont(HFONT hFont);
92-
private:
93-
DECLARE_MSG_MAP()
9495

95-
void OnException() const;
96-
void OnException(const std::exception& ex);
97-
LRESULT OnCreate(const CREATESTRUCT* pCreate);
96+
private:
9897
void OnClose();
99-
void OnTimer(UINT_PTR nIDEvent);
100-
101-
LRESULT OnOdStateChanged(NMHDR* pnmh);
102-
LRESULT OnOdCacheHint(NMHDR* pnmh);
10398
RECT GetItemRect(int iItem, unsigned code) const;
104-
10599
void DrawItem(CDCHandle dc, int iItem, unsigned iItemState);
106100
};
107101

GDIGraphicsPOC/MainFrame.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ CAppModule _Module;
88
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hInstPrev, LPSTR szCmdLine, int nCmdShow)
99
{
1010
fusion::CMainFrame wndMain;
11-
//fusion::MainWnd wndMain;
1211

1312
// Create & show our main window
1413
if (nullptr == wndMain.Create(nullptr, CWindow::rcDefault, _T("WTL Frame"), WS_OVERLAPPEDWINDOW))
@@ -49,25 +48,6 @@ LRESULT fusion::CMainFrame::OnSize(UINT nType, CSize Extent)
4948
return 1;
5049
}
5150

52-
BOOL fusion::CMainFrame::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
53-
{
54-
//if (zDelta > 0)
55-
//{
56-
// m_timelineView.Zoom(2.0);
57-
//}
58-
//else
59-
//{
60-
// m_timelineView.Zoom(0.5);
61-
//}
62-
return TRUE;
63-
}
64-
65-
void fusion::CMainFrame::DisablePaneHeader(CPaneContainer& panecontainer)
66-
{
67-
panecontainer.SetPaneContainerExtendedStyle(PANECNT_NOCLOSEBUTTON, 0);
68-
panecontainer.m_cxyHeader = 0;
69-
}
70-
7151
void fusion::CMainFrame::AddTab(const std::wstring name)
7252
{
7353
auto lvi = std::make_shared<CLogViewTabItem2>();

GDIGraphicsPOC/MainFrame.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ extern CAppModule _Module; // WTL version of CComModule
3030

3131
namespace fusion {
3232

33+
class ReflectorWindow : public CWindowWithReflectorImpl<ReflectorWindow>
34+
{
35+
};
36+
3337
class CMainFrame : public CTabbedFrameImpl<CMainFrame, CDotNetTabCtrl<CLogViewTabItem2>>
3438
{
3539
public:
@@ -39,14 +43,12 @@ class CMainFrame : public CTabbedFrameImpl<CMainFrame, CDotNetTabCtrl<CLogViewTa
3943
MESSAGE_HANDLER(WM_CREATE, OnCreate)
4044
MESSAGE_HANDLER(WM_CLOSE, OnClose)
4145
MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
42-
MSG_WM_MOUSEWHEEL(OnMouseWheel)
4346
MSG_WM_SIZE(OnSize)
44-
DEFAULT_REFLECTION_HANDLER()
47+
REFLECT_NOTIFICATIONS();
48+
DEFAULT_REFLECTION_HANDLER()
4549
END_MSG_MAP()
4650

4751
LRESULT OnSize(UINT nType, CSize Extent);
48-
BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
49-
void DisablePaneHeader(CPaneContainer& panecontainer);
5052
void AddTab(const std::wstring name);
5153
LRESULT OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);
5254
LRESULT OnClose(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled);

0 commit comments

Comments
 (0)