M
miben
I am creating a ListView through CreateWindowEx(). It works fine when
I create it as a child window as so:
hControl = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, NULL,
WS_VISIBLE | WS_CHILD | LVS_REPORT, 300, 100, 100, 100, hWnd, NULL,
NULL, NULL);
However, I want to create the control with no parent, then add it to
the parent form later. Something like this...
hControl = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, NULL,
LVS_REPORT, 300, 100, 100, 100, NULL, NULL, NULL, NULL);
SetParent(hControl, hWnd);
The drawing of the ListView in that code goofs up the window drawing.
I played arround a bit and came up with this:
hControl = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, NULL,
WS_POPUP, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
SetParent(hControl, hWnd);
dwStyle = GetWindowLong(hControl, GWL_STYLE);
dwStyle &= ~(WS_CLIPSIBLINGS | WS_POPUP);
dwStyle |= WS_CHILD | WS_VISIBLE | LVS_REPORT;
SetWindowLong(hControl, GWL_STYLE, dwStyle);
ShowWindow(hControl, SW_SHOW);
This works for the drawing, but if you right click in the header area,
you will get a stack error. Any ideas?
I create it as a child window as so:
hControl = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, NULL,
WS_VISIBLE | WS_CHILD | LVS_REPORT, 300, 100, 100, 100, hWnd, NULL,
NULL, NULL);
However, I want to create the control with no parent, then add it to
the parent form later. Something like this...
hControl = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, NULL,
LVS_REPORT, 300, 100, 100, 100, NULL, NULL, NULL, NULL);
SetParent(hControl, hWnd);
The drawing of the ListView in that code goofs up the window drawing.
I played arround a bit and came up with this:
hControl = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, NULL,
WS_POPUP, 100, 100, 100, 100, NULL, NULL, NULL, NULL);
SetParent(hControl, hWnd);
dwStyle = GetWindowLong(hControl, GWL_STYLE);
dwStyle &= ~(WS_CLIPSIBLINGS | WS_POPUP);
dwStyle |= WS_CHILD | WS_VISIBLE | LVS_REPORT;
SetWindowLong(hControl, GWL_STYLE, dwStyle);
ShowWindow(hControl, SW_SHOW);
This works for the drawing, but if you right click in the header area,
you will get a stack error. Any ideas?