1 Attachment(s)
listbox creation problems
I'm trying to make a win32 application consisting of one treeview and one listbox side by side. The problem i'm having is that despite seemingly passing the same size to each control on creation there's a weird offset between the two that I can't explain.....
Relevant code is.......
Code:
LRESULT CALLBACK WndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
PAINTSTRUCT ps;
HDC hDC;
RECT rc;
TEXTMETRIC tm;
static HWND hLB;
switch (uMsg)
{
case WM_CREATE:
g_hTV = CreateTreeView(hwnd);
InitTreeViewItems(g_hTV);
GetClientRect(hwnd, &rc);
hLB = CreateWindowEx(0, WC_LISTBOX, NULL, WS_CHILDWINDOW | WS_VISIBLE | LBS_STANDARD, (rc.right / 2)+1, 0, rc.right/2, rc.bottom, hwnd,NULL, (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE), NULL);
Then bit of CreateTreeView()....
Code:
RECT rcClient; //dim of client area
HWND hwndTV; // handle to our treeview
InitCommonControls();
GetClientRect(hwndParent, &rcClient);
hwndTV = CreateWindowEx(0, WC_TREEVIEW, "Tree View", WS_VISIBLE | WS_CHILD | WS_BORDER | TVS_HASLINES | TVS_HASBUTTONS | TVS_LINESATROOT, 0, 0, rcClient.right/2, rcClient.bottom, hwndParent, NULL, (HINSTANCE)GetWindowLong(hwndParent, GWL_HINSTANCE), NULL);
And a pic demostrating what i might have explained poorly...the red bit shows the messed up bit...
Anybody had any experience like or any thoughts on what might be causing it? Cheers peeps.
Re: listbox creation problems
Ignore me, I'm an idiot, 5 mins more reading and I could've avoided posting here. For anyone who's remotely interested, it's because according to MSDN "Normally, the system sizes a list box so that the list box does not display partial items." so adding LBS_NOINTEGRALHEIGHT as the list-box style sorted this.....