| partytime4321 (28) | |||
|
Hi all, I am very new to windows gui programming and I was wondering how I would go about destroying a window and then creating another different window right after. I am making a sort of database program. The first window that opens asks the user for the name of a file in the same directory. After a non null character array is successfully captured, I would like the program to close the first window, do some background work such as sorting and file I/O, and then make a new window that is different from the inital file selection window. I was wondering, how to go about this... Can I just call DestroyWindow, do the processing like any console application, and then call CreateWindow with the information for the new window? What code would I need to repeate, and can any of the code that originally came in the project be reused in the new window? Here is the code I have so far... This makes one window with some form elements, and an alert box if input is null:
Line 115 is the place of interest, where if that code executes, I would like to destroy the window and proceed with the program (without closing the process) Also, is there any easy way to redraw an existing window (if for example, I assign variables to staic text boxes, and then the variables change through out the program, can I just refresh the window somehow?) Thanks so much, Ryan | |||
|
|
|||
| freddie1 (847) | |
|
Why destroy the data entry window? Just put a "Submit" button on it, a click of which inserts the record in the database, clears the existing text in the data entry text boxes, and awaits for a new piece of data entry in the existing window. But to exactly answer your question, you can use CreateWindow() or CreateWindowEx() calls to create any kind of window which has been registered with Windows through a RegisterClass() or RegisterClassEx() function call. That isn't exactly right, but 'close enough for goverment work'. | |
|
|
|
| andywestken (1964) | |
|
What you're doing is rather non-standard. The idiomatic approach would be to use a dialog to get the file name. You could either: - display the dialog before creating the main window, in WinMain - or create the main window (without making it visible to start with) and then get it to display the dialog. The main window would then be made visible, if the use clicks OK or the app instructed to exit, if they cancel. It is possible to create a new top level window in your WM_COMMAND handler, but then you would have to make the WM_DESTROY handler smarter so it doesn't just call PostQuitMessage and terminate the program (in both this WndProc and the other one you'll need for your other window) It would also be possible to code a window which destroys and creates different child windows (or controls). But then the WndProc would get rather messy. You'd need to work what role the window was playing before responding to a message. The idiomatic solution to your problem would be to use a dialog. Andy | |
|
Last edited on
|
|
| partytime4321 (28) | |
|
Thanks for your reply, What i ended up doing is just destroying the child elements on the inital window, then instead of killing it, i resized it with no reposition set, then drawing new child elemnts on the window after that happens. Seems to work well... though I like the idea of creating a dialog box. unfortunatly it was already due (extension untill midnight though) so I dont think I will be able to implement it in this project. Id like to thank you both for your replies, and Andy you contributed a lot on various other threads, so thanks a lot. Ryan | |
|
|
|