MFC/C++

In MFC/C++, I always use dialog box to get user input, Is there someway I could put controls (combobox, pushbutton, edit field, etc,) on Main window (view) instead

I tried, I can only put out progress bar and text, not a pushbutton.

Can some guru help Thanks.

Steed



Answer this question

MFC/C++

  • Atanu Maity

    try including WS_CHILD style as well.
  • GPinNY

    Thank you very much, my friend.
  • GPK2005

    I did. My code is like this :

    CProgressCtrl progBar;
    CRect rec(240,180,540,200);
    progBar.Create(WS_VISIBLE|WS_BORDER|PBS_SMOOTH,rec,this,ID_PROGBAR);
    progBar.SetRange(0,4000);
    progBar.SetStep(1);
    for (int ii = 0; ii < 300; ii++)
    progBar.StepIt();

    CButton but;
    CRect rec1(240,250,280,270);
    but.Create("STOP",WS_VISIBLE|WS_BORDER|BS_PUSHBUTTON,rec1,this,ID_BUT);
    for (int ii = 0; ii < 300; ii++)
    progBar.StepIt();

    I got the progress bar, the button is no where to be found.

    Thanks.

    Steed



  • mamatham

    You can create your own controls at runtime. CEdit edit1; edit1.Create(); etc. (See docs for CEdit, etc.)

    Use the main window as the parent, and use coordinates relative to the upper left corner of the main window.


  • Slace

    1. Check to see if but.Create succeded by looking at the return value.
    2. Use Spy++ to see where the button is. Spy++ can highlight it for you.

  • MFC/C++