Clearing Windows App screen

so im rebuilding a console app i made that basically has your password stored in a text file, you log on and can write you private document that no one else can read. you are able to change you password too. and im making a replica but as a windows app, i have got the logon screen made with a button and 2 textbox's. if you log on with the proper credentials, a msg box will appear saying "Succesfully Logged In!" and if not the a msg box saying "Wrong Username/Password". i was wondering how i can "Clear" the buttons off the screen if logged in properly. i know how to add more buttons after being logged in, but i need to get rid of the login button and 2 textbox's. i hope this made sence, this is my very first post. if requested i can post either source code.
Just "hide" them using ShowWindow ( windowHandle, SW_HIDE);
Personally, I wouldn't do it like that. I feel that a log on screen/form/dialog should be a seperate screen from the one you get to that performs the main app's function. Therefore, I wouldn't code the app the way you suggest. I'd dismiss the log on screen after the user is done with it, then show the main work screen if the user successfully logged on.
Sorry, but what you say is not that clear.

Windows App screen

Do you mean the windows of a console app? (i.e. a console window?)

i have got the logon screen made with a button and 2 textbox's

Do you mean a dialog, created using the Win32 DialogBox function?

Or are you "drawing" your own buttons, etc using ASCII art in the console window?

a msg box will appear

Using MessageBox, or ASCII art?

If you are talking about ASCII art on a console window, then this MSDN article might help.

Clearing the Screen

The sample shows how to clear the console window (the name cls, clear screen, comes from the olden, DOS says). But the same functions, in particular FillConsoleOutputCharacter, could be used to clear specific bits of the screen as well.

Last edited on
thankyou, and sorry i was not specific enough. i used MessageBox, and CreateWindow for the textboxes and buttons. it is not a console app, rather a windows app. i need to remove/hide/delete the button and txtbox's off the window if the password and username are entered properly.
In that case, I'm with freddie1; I'd make a separate logon screen rather than try to reuse the same window for both the logon and main window.

But ShowWindow will hide the controls, if that's the way you want to go.

If i use ShowWindow to hide the controls, do you know what the downsides are from that? thanks.
If i use ShowWindow to hide the controls, do you know what the downsides are from that?

If coded correctly, it should function well enough.

The downside is that the main window's window proceedure will have to handle the logon sequence is well, which is less elegant from a design point of view.

- the logon window should handle logon
- the main window whatever you app does when it's been successfully logged on

This is known as the "single responsibility principle":

(this is part of object oriented design, but holds for window classes, too.)

Last edited on
So what you need to do is register two seperate Window Classes, i.e., one for your log on dialog, and one for your main app. This will require two seperate Window Procedures.
could someone teach me a little about multiple window procedures? am i able to have them in the same source file?
Take a look at Reply #5 at this link ...

There I teach how to create multiple forms/windows/dialogs in the same program. Actually, starting with Reply #1 at that link wouldn't hurt you, as its all about the same material.

Basically, as Andy said, each form/window/dialog has a job to do, and the Window Procedure of that module should be geared to responding to events related to that job. For example, your Log On screen will have a text box and button perhaps which is related to the job of logging in. Your Main App screen has a different job.

In terms of program organization, you can have a Main.cpp and Main.h file which basically has program initialization and WinMain, then you can have seperate *.cpp and *.h files for the various windows/dialogs/forms your program needs. My example I gave links to above shows that.

Usually what I do is Register my main program window in WinMain(), then register other Window Classes my program needs in the WM_CREATE handler of my main program window. Once a Window Class has been registered, you can create windows of that class anywhere in your code with CreateWindowEx() calls.
alright, thanks!
Topic archived. No new replies allowed.