ListBox Confusion

This is a discussion on ListBox Confusion within the Windows Programming forums, part of the Platform Specific Boards category; Im trying to add a list box to a MDIChild to be used as a nicklist for a IRC-Client im ...

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    28

    ListBox Confusion

    Im trying to add a list box to a MDIChild to be used as a nicklist for a IRC-Client im working on.

    Heres PIC-1:
    http://www.btinternet.com/~makina/girc1.jpg

    As you can see the List here is shown correctly but in the wrong position.
    If i attempt to move the ListBox over to the right of the MDIChild (GREYSPACE IN PIC 1), I get the following result...

    http://www.btinternet.com/~makina/girc2.jpg

    As you can see here the ListBox does not have a scroll bar anymore, and the only thing i have changed in the code is the position of the ListBox, NOTHING ELSE!.

    Why is this happening??
    Any help appreciated!

  2. #2
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Without supplying some code all your going to get is guesses and "have you done xyz?" type questions/suggestions. Who knows, maybe someone will guess right first time.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    Registered User
    Join Date
    Nov 2003
    Posts
    28
    Thanks for replying.

    The reason i included no code was because the scroll bar was visible in pic one.
    In pic two all i did was move the listbox to the right and the scroll bar didnt show!?.

    Anyway heres the MDIChild CALLBACK..


    Code:
    LRESULT CALLBACK MDIChildWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
    	switch(msg)
    	{
    		case WM_CREATE:
    		{
    			HWND hEdit;
    			HWND hList;
    			HWND hInput;
    			HFONT hfDefault;
    
    			char szWindowText[1000];
    			GetWindowText(hwnd, szWindowText, 1000);
    
    			// Main Edit Window
    			hEdit = CreateWindowEx(0, "RICHEDIT", "", WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_DISABLENOSCROLL |
    									ES_READONLY | ES_MULTILINE | ES_AUTOVSCROLL, 0, 0, 100, 100,
    									hwnd, (HMENU)IDC_CHILD_EDIT, GetModuleHandle(NULL), NULL);
    
    			hfDefault = (HFONT)GetStockObject(SYSTEM_FIXED_FONT);
    			SendMessage(hEdit, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
    
    			// Input Window
    			hInput = CreateWindowEx(0, "EDIT", "", WS_CHILD | WS_BORDER | WS_VISIBLE | ES_MULTILINE | ES_WANTRETURN,
    									0, 0, 100, 100, hwnd, (HMENU)IDC_CHILD_INPUT, GetModuleHandle(NULL), NULL);
    
    			SendMessage(hInput, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
    
    			wndEdit = (WNDPROC)SetWindowLong(hInput, GWL_WNDPROC, (LONG)EditWndProc);
    			SetFocus(hInput);
    
    			// If Channel Window Create NickList
    			if(szWindowText[0] == '#')
    			{
    				hList = CreateWindowEx(0, "ListBox", "", LBS_DISABLENOSCROLL | WS_CHILD | WS_VISIBLE |
    										WS_VSCROLL | LBS_EXTENDEDSEL | LBS_NOINTEGRALHEIGHT | LBS_STANDARD,
    										0, 0, 100, 100, hwnd, (HMENU)IDC_CHILD_LIST, GetModuleHandle(NULL), NULL);
    
    				// Random Nicks
    				char szNick[10];
    				for ( int i = 0; i < 100; i++ )
    				{
    					if(i < 20) { sprintf(szNick, "_Nick%i", i); }
    					if( (i > 20) && (i < 60) ) { sprintf(szNick, "@_Nick%i", i); }
    					if( (i > 60) && (i < 100) ) { sprintf(szNick, "+_Nick%i", i); }
    					SendMessage(hList, LB_ADDSTRING, 0, (LPARAM)szNick);
    				}
    
    				SendMessage(hList, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0));
    			}
    
    		}
    		break;
    
    		case WM_SIZE:
    		{
    			HWND hEdit;
    			HWND hList;
    			HWND hInput;
    			RECT rcClient;
    			GetClientRect(hwnd, &rcClient);
    			
    			char szWindowText[1000];
    			GetWindowText(hwnd, szWindowText, 1000);
    
    			hEdit = GetDlgItem(hwnd, IDC_CHILD_EDIT);
    			hInput = GetDlgItem(hwnd, IDC_CHILD_INPUT);
    
    			SetWindowPos(hInput, NULL, 0, rcClient.bottom - 22, rcClient.right, rcClient.bottom, SWP_NOZORDER);
    
    			if(szWindowText[0] == '#')
    			{
    				hList = GetDlgItem(hwnd, IDC_CHILD_LIST);
    				SetWindowPos(hList, NULL, rcClient.right - 120, 0, rcClient.right, rcClient.bottom - 22, SWP_NOZORDER);
    				SetWindowPos(hEdit, NULL, 0, 0, rcClient.right - 120, rcClient.bottom - 22, SWP_NOZORDER);
    			}
    			else
    			{
    				SetWindowPos(hEdit, NULL, 0, 0, rcClient.right, rcClient.bottom - 22, SWP_NOZORDER);
    			}
    		}
    		return DefMDIChildProc(hwnd, msg, wParam, lParam);
    
    		case WM_CLOSE:
    		{
    			char szWindowText[1000];
    			GetWindowText(hwnd, szWindowText, 1000);
    
    			if(!IsStringMatch(szWindowText, "Status"))
    			{
    				SendMessage(g_hMDIClient, WM_MDIDESTROY, (WPARAM)hwnd, 0);
    				PartChannel(szWindowText);
    			}
    		}
    		break;
    
    		default:
    		return DefMDIChildProc(hwnd, msg, wParam, lParam);
    	}
    	return 0;
    }
    I'm really stumped as to whats going wrong.
    Any help appreciated!

  4. #4
    Registered User
    Join Date
    Nov 2003
    Posts
    28
    I found the error and now i feel like such a dumb @ss!
    In the "cx" part of the SetWindow message i was setting the end pixel instead of the width!

    Thanks for reading/replying.
    Marc

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Deal or No Deal listbox prob
    By kryptkat in forum Windows Programming
    Replies: 5
    Last Post: 03-30-2009, 07:53 PM
  2. ListBox Extra Data Storage
    By Welder in forum Windows Programming
    Replies: 1
    Last Post: 11-01-2007, 02:46 PM
  3. How to cast a ListBox item to an int for a switch statment?
    By Swaine777 in forum C++ Programming
    Replies: 8
    Last Post: 09-26-2004, 09:52 PM
  4. Listbox stealing focus
    By Calthun in forum Windows Programming
    Replies: 3
    Last Post: 09-12-2004, 05:36 PM
  5. Getting FULL filename from listbox
    By Garfield in forum Windows Programming
    Replies: 8
    Last Post: 01-27-2002, 08:28 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21