Thread: Adding Default values to controls in Dialog boxes

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    17

    Adding Default values to controls in Dialog boxes

    Sir,

    I am using AppWizard in VC++ to make certain windows which have controls like edit boxes, combo boxes etc.

    What I require is that when my window is opened it should contain certain values in the edit area of the edit box and combo box (which are my default values).

    How can I do it.

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    156
    If you're using an MFC dialog use the code below in OnInitDialog for all the windows you want to initialize.
    Code:
    CWD* pw = GetDlgItem( nID );
    if( pw )
    {
        pw->SetWindowText( "blah blah" );
    }

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    411
    you can assocate a variable with an edit box with the appwizard(ctrl w), use a CString.

    Then just look for its initilazation in the source and change it to whatever you want.

    As for combo boxes, there are 2 ways.

    First you need to attach a variable like you did before, but make it a CComboBox class.

    You can add the names to appear in the box in the combo box properties window, use the data tab.

    You can get current selection with CComboBox::GetCurSel(); function

    Hope i helped.

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    17
    Thank You,

    I have used your suggestion successfully to enter default values in edit boxes and combo boxes.

    I have another problem.

    I have a group box on that window which contains two radio buttons . what I require is that when my window opens one of the radio button in that group box should be in the checked state.

    How can I do so.

    Best Regards


    juhi

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Common Dialog boxes GetOpenFileName()
    By A10 in forum Windows Programming
    Replies: 3
    Last Post: 09-02-2008, 08:56 PM
  2. Replies: 9
    Last Post: 02-13-2008, 02:59 PM
  3. adding ASCII values
    By watshamacalit in forum C Programming
    Replies: 1
    Last Post: 12-26-2002, 07:16 PM
  4. Adding progress bar to a dialog box.
    By Brian in forum Windows Programming
    Replies: 1
    Last Post: 11-15-2002, 06:27 PM
  5. Problem with static text in dialog boxes
    By Clyde in forum Windows Programming
    Replies: 11
    Last Post: 05-28-2002, 12:51 PM