I'm currently working on a program that will help me study languages by asking words from a list. What I need is a way to change what's on my Form - there's a different screen in the beginning, then when the program's asking question, another for editing the words in each lists, etc...
How can I change what the user sees, while still working with one Form?
After doing some research all I found was to use multiple Forms, do I have to do that, is it the best way?
Or, for example if I will have two buttons at the same place, just at different screens, I can put them on top of each other on my one and only Form, and then control which one is visible on each screen? And do this for every element? That seems a bit absurd...
I'm sorry if this is a stupid question, I'm pretty new to Visual C++. I have this program working perfectly in a language called FreeBasic, where it was pretty simple to change what's on the screen.
Well there I just cleared the screen and put everything that I needed on it, images, etc... And whenever I needed that screen again I could just call the subroutine to do it.
But that's not what's important; I'm interested in how I can change what's on my window using Visual C++. It's hard to imagine that it's designed to only have a static look... Right now my newest idea was to use these "Panels", each representing a "screen", and then just toggle the panels' visibility and enabled property on and off. Is that the best option available? Using multiple forms seems really weird to me, why would I need more than one window to run my program in? Perhaps a good example would be games (although I'm not really sure Visual C++ is meant for games, at least if you use these Forms), since in games the screen constantly changes - main menu, the game itself, high score board, settings, etc... Is that possible using Forms?
Well, having your mind already set against using multiple "forms" what kind of advice do you expect here?
I was curious to know how people normally handle changing screens in Visual C++. If I knew what kind of advice I was looking for, I'd pretty much would have known the answer.
The only option that remains is your "pretty simple" approach you used previously.
That may be true, but that would be pretty much using C++, not Visual C++, without all the pre-created tools and windows it has to offer. Or so I think based on my experience.
And how this drastically differs from using borderless child dialogs, a.k.a. Forms?
When I inserted a new Form in my program, it created a new file for that form and didn't include it in my main program etc... That bothered me, since I really don't need to work in a whole new file just because I want to change what's on the screen. Also, since this new Form would appear exactly like the previous one, (like it's title, background color, and other things I can adjust; except of course for what's inside of it), it just seemed wrong to have to adjust all those setting to the same thing each time I wanted a new screen. Using panels kept my code in one file, and the Form's setting remain the same.
Besides, are you aware that Forms discussion (if it's really about Windows Forms) does not belong here as well as any other .NET/CLR/Managed C++ related stuff?
Since I'm looking for a way to avoid using Forms, I guess it's not really about forms. Perhaps my idea of what Visual C++ is is incorrect then. I thought by "Visual" the emphasis is on me being able to use the built-in forms, and the toolbox, which helps creating the program visually. So if the components of the toolbox and form aren't the area of this topic, and so isn't the code itself, since that is either plain C++ or Managed C++, then what is? I'm sorry that I didn't know this, as I said, I'm new, and since I'm using Visual C++ I thought I'd post it here.
Okay, now it sounds much clear. And I try to show you a few reasons as well as angles of vision.
At first, about your though of multiple forms (let's call those dialogs to stay with WinAPI/MFC terminology which this forum is really about) as "weird" approach. When you need a different set of controls on your main window this in fact indicates that the aspect of your vision changes. You provide a GUI for some task you want your user to perform. As long as the real program typically may have a good number of such aspects/tasks from user perspective you ultimately appear in danger: your code becomes to be a real mess comprised of fragments related to absolutely different aspects of your whole program. This is what's really weird, and should be avoided as much as possible.
On the other hand, when you deal with separate dialogs representing one certain aspect each, your design becomes more neat and accurate preventing you from mixing horses and bluebirds. Besides, every dialog appears editable with resource editor, so you have visual design along with toolbox and other standard things.
When I inserted a new Form in my program, it created a new file for that form and didn't include it in my main program etc...
I don't know what you exactly did, but it's definitely your fault. VC++ is just a tool, and you have to learn how to control it. And I hope you don't mind to have more than a couple of files in your project.
Since I'm looking for a way to avoid using Forms, I guess it's not really about forms.
Actually, what you described looks to me like a sort of wizard. User does some action/settings with one view and then gets to another view, and another view, etc. In regular programming practice it's typically done by tabbed dialog (a main dialog with tab control on top of it) or wizar-like dialog (a dialog with Back/Next/Finish buttons in the bottom area). Both apps use borderless child dialogs with a single dialog visible at particular moment, which visibility is controlled by either tab control or Back/Next buttons. All logic about processing user input is implemented in particular dialog (procedure or class), and main dialog may provide a menu/toolbar handling (or may not, as MFC internally implements command routing mechanism)