Solved

VC++ 5.0 GUI doubt

Posted on 1998-11-10
9
237 Views
Last Modified: 2010-04-02
i would like to know how could i place a button at runtime into my dialog box ?
0
Comment
Question by:charul
  • 3
  • 3
  • 2
  • +1
9 Comments
 

Author Comment

by:charul
ID: 1177473
none
0
 

Author Comment

by:charul
ID: 1177474
Edited text of question
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1177475
The simplest solution to your problem would be to have the button exist all the time in the dialog, but have it hidden.  You can change the visible status by going to the button's properties.  Then, when you need the button, use something like GetDlgItem (YOUR_BUTTON_RESOURCE_IDENTIFIER)->ShowWindow (SHOW);

If you have any questions on implementing this solution, please feel free to ask.  Thanks!
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 32

Accepted Solution

by:
jhance earned 100 total points
ID: 1177476
If you're using MFC here is how to do it:

   CButton  xbutton = new CButton();
    xbutton->Create(
        "Some Name",
        WS_CHILD | WS_VISIBLE | WS_BORDER,
        CRect(0, 240, 200, 270), this, XBUTTON
    );
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1177477
jhance - Don't you think my solution would be easier since you wouldn't need to worry about coordinates and things of that nature?  You would be able to place the button using the Resource Editor which is much easier than:
1) Choose coordinates
2) Compile
3) Does it look right?  If no, go to 1.

?
0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1177478
I would do it your way thresh if there's only 1 or 2 buttons, use ShowWIndow to show/hide buttons, use EnableWindow to enable/disable buttons

I haven't tested it out - but does the button created dynamically in jhance's way get added to the keyboard sequence (e.g. can you tab to it, and then off it to another control).  I seem to recall, it won't on a dialog, unless you also make the dialog handle the tabbing about messages...but this is fuzzy, so perhaps I'm wrong here
0
 
LVL 32

Expert Comment

by:jhance
ID: 1177479
thresher...

I agree that your method (i.e. hiding/showing a button) is preferred but it's not what the question asked.  Sometimes you don't know what button you will need until runtime.  An example of this would be a dialog editor type application which cannot use your method.
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1177480
That's true, good point.  Thanks for clarifying.
0
 

Author Comment

by:charul
ID: 1177481
Thanks very much. Let me try out the suggestion.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Exception thrown at 0x00007FFD5BC81F28 7 50
Best book to learn C++ 4 85
Issues with C++ Class 19 101
Indy 10 not Receiving UDP broadcast 3 23
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question