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

Thread: Combo box

  1. #1
    Join Date
    May 2012
    Posts
    8

    Combo box

    Hi, i'm new to Visual C++. I currently taking courses on it.. due to i have no understanding on the lecturer i am having problem with it..

    I want to create win32 winapi application
    i basically can do combobox already.. but my question is.. if i have a list of selection... how to select and get message from my selection?
    example:
    let say a,b and c..
    when i select 'a', and press button "go", i want to make pop up message that said 'a is selected'..
    when i select 'b', and press button "go", i want to make pop up message that said 'b is selected'.. and so on...

    how do i programmed this? thank you....

  2. #2
    Ejaz's Avatar
    Ejaz is offline Elite Member Power Poster
    Join Date
    Jul 2002
    Location
    Lahore, Pakistan
    Posts
    4,211

    Re: Combo box

    Quote Originally Posted by kurogane1031 View Post
    due to i have no understanding on the lecturer i am having problem with it..
    You need to pay more attention in the lecture

    Anyway, with reference to your question, take a look at

    ComboBox_GetCurSel
    ComboBox_GetLBText

  3. #3
    Join Date
    May 2012
    Posts
    8

    Re: Combo box

    hehe.. thank you for ur help...



    regards,
    Kurogane.

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: Combo box

    So, "hehe" usually means either somebody gets the point completely, or otherwise, has no idea about the thing that was said. What variant is yours?
    Best regards,
    Igor

  5. #5
    Join Date
    May 2012
    Posts
    8

    Re: Combo box

    well.. u make me realize the negative effects of instant messaging. sorry for by my bad use of language. 'Hehe' actually show i'm happy when people are helping me. and i have no idea on how to use those command. just a beginner in this programming.

    do you have any simple example that i can refer to?

    regard,
    kurogane

  6. #6
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: Combo box

    The examples are going to depend on "i basically can do combobox already.." real meaning. What is your background in "basically doing" combobox? What approach is used for teaching you Windows programming? Was you taught to plain WinAPI? Or MFC? Or any other framework?
    Best regards,
    Igor

  7. #7
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: Combo box

    MFC sample
    Attached Files Attached Files
    Best regards,
    Igor

  8. #8
    Join Date
    May 2012
    Posts
    8

    Re: Combo box

    I am using visual basic 2010 win32 application non mfc, not console.. the following code are my program.

    Code:
    #include <windows.h>
    
    
    LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
    
    HINSTANCE g_hinst;
    
    int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, 
        LPSTR lpCmdLine, int nCmdShow)
    {
      HWND hwnd;
      MSG  msg ;    
      WNDCLASS wc = {0};
      wc.lpszClassName = TEXT("Components");
      wc.hInstance     = hInstance ;
      wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
      wc.lpfnWndProc   = WndProc ;
      wc.hCursor       = LoadCursor(0,IDC_ARROW);
    
      g_hinst = hInstance;
      
      RegisterClass(&wc);
      hwnd = CreateWindow(wc.lpszClassName, TEXT("Combo Box"),
                    WS_OVERLAPPEDWINDOW | WS_VISIBLE,
                    100, 100, 520, 260, 0, 0, hInstance, 0);  
    
    
      while( GetMessage(&msg, NULL, 0, 0))
      {
        DispatchMessage(&msg);
      }
      return (int) msg.wParam;
    }
    
    LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
    {
    
      static HWND hwndCombo, hwndStatic, hwndSelect;
      const TCHAR *items[] = { TEXT("Resistor"), TEXT("BJT"), 
          TEXT("Amplifier")};
      int i;
      LRESULT sel = 0;
    
      switch(msg)  
      {
          
               case WM_CREATE:
                hwndCombo = CreateWindow(TEXT("combobox"), NULL, 
                      WS_CHILD | WS_VISIBLE | CBS_DROPDOWN,
                      10, 10, 380, 110, hwnd, NULL, g_hinst, NULL);   
    
                CreateWindow(TEXT("button"), TEXT("GO"), 
                      WS_CHILD | WS_VISIBLE,
                      400,180, 90, 25, hwnd, (HMENU)1, g_hinst, NULL); 
    
                hwndStatic = CreateWindow(TEXT("static"), TEXT(""), 
                      WS_CHILD | WS_VISIBLE,
                      150, 80, 90, 25, hwnd, NULL, g_hinst, NULL); 
    
    
                for ( i = 0; i < 3; i++ ) {
                    SendMessage(hwndCombo, CB_ADDSTRING, 0, (LPARAM) items[i]); //add list into the combo box
    			}			
    
                break;
    
          case WM_DESTROY:
              PostQuitMessage(0);
              break; 
      }
      return DefWindowProc(hwnd, msg, wParam, lParam);
    }
    This is my program for my combo box.

  9. #9
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Combo box

    Quote Originally Posted by kurogane1031 View Post
    I am using visual basic 2010 win32 application non mfc, not console..
    But how are you learning how to write Windows API programs? Trial and error? (Hopefully not).

    Regards,

    Paul McKenzie

  10. #10
    Join Date
    May 2012
    Posts
    8

    Re: Combo box

    But how are you learning how to write Windows API programs? Trial and error? (Hopefully not).
    This is a core subject that i currently taking. Since I have no background knowledge in winapi programming, it's kind of hard to understand the lecture.


    Regard,
    Kurogane

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