944,101 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 2639
  • C RSS
Apr 18th, 2007
0

Programatically create and fill ComboBoxes

Expand Post »
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..."
Similar Threads
Reputation Points: 10
Solved Threads: 1
Light Poster
Tales is offline Offline
37 posts
since Mar 2007
Apr 18th, 2007
0

Re: Programatically create and fill ComboBoxes

you might submit this in the C code snippets board
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,961 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: developers forum..
Next Thread in C Forum Timeline: How to detect our session mode in Windows





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC