CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Threaded View

  1. #1
    Join Date
    May 2008
    Posts
    38

    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.
    Attached Images Attached Images

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured