Programatically create and fill ComboBoxes

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2007
Posts: 37
Reputation: Tales is an unknown quantity at this point 
Solved Threads: 1
Tales Tales is offline Offline
Light Poster

Programatically create and fill ComboBoxes

 
0
  #1
Apr 18th, 2007
For those who want to learn about windows, I leave the code I was looking for...

"Programatically filling a ComboBox and setting it visible or invisible"

    HWND hWndComboBox[10];
    char numChar[20]; // String that contains a number converted to string
    int yPos = 160, xPos = 60;
    int counter1, counter2;    // 
    switch(Msg){
        case WM_INITDIALOG:
            for(counter1 = 0; counter1 < MAX_COMBOS; counter1++){
                hWndComboBox[counter1] = CreateWindow("COMBOBOX", NULL, WS_CHILD | WS_VISIBLE | WS_TABSTOP | CBS_DROPDOWN | WS_VSCROLL, xPos, yPos, 60, 60, hWndDlg, NULL, hInst, NULL);
                if(!hWndComboBox){
                    MessageBox(hWndDlg, "Could not create the combo box", "Failed Control Creation", MB_OK);
                    return FALSE;
                }
                // I'll fill the ComboBoxes with numbers from 1 to LAST_NUMBER
                for(counter2 = 1; counter2 <= LAST_NUMBER; counter2 ++){
                    itoa(counter2 , numChar, 10);
                    SendMessage(hWndComboBox[counter1], CB_ADDSTRING, 0, reinterpret_cast<LPARAM>((LPCTSTR)numChar));
                }
            }
            return TRUE;
     }
...
...
I would like to thank the ones who "made the effort to answer me"... even if it was only to tell me that they didn't know how to do it

"Sometimes is better to say I don't know..."
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,485
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1478
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: Programatically create and fill ComboBoxes

 
0
  #2
Apr 18th, 2007
you might submit this in the C code snippets board
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC