I have a main window and a separate one for user input used occasionally.
Is it better to create it once, then show/hide when needed or create, use, destroy, create, use...
BTW, I'm using CreateWindowEx, not dialogs.
Or move it to negative coordinates. It depends what the second window does. If its like a calculator, show/hide.
Be careful, CloseWindow does not close the window but
QuoteMinimizes (but does not destroy) the specified window. (https://msdn.microsoft.com/fr-fr/library/windows/desktop/ms632678(v=vs.85).aspx)
Quote
Is it better to create it once, then show/hide when needed or create, use, destroy, create, use...
There is no choice better than one another.
If you want to memorize the last state of the window,show/hide it and it is faster.
If you want to start always at the same state,create/destroy it, but it can be slower.
Quote from: Grincheux on January 10, 2016, 03:47:52 PM
Or move it to negative coordinates. It depends what the second window does. If its like a calculator, show/hide.
Be careful, CloseWindow does not close the window but QuoteMinimizes (but does not destroy) the specified window. (https://msdn.microsoft.com/fr-fr/library/windows/desktop/ms632678(v=vs.85).aspx)
It has to disappear, so options are hide or destroy.
Quote from: ToutEnMasm on January 10, 2016, 05:09:24 PM
If you want to start always at the same state,create/destroy it, but it can be slower.
:t that's what I've been doing, speed isn't an issue, all the window does is fill a list with drives and lets the user select one.
I was wondering because I've seen IE, when it closes, flash the favourites window - as if it was just hidden.
Then again, IE isn't a paragon of good programming practice, is it?
Quote from: sinsi on January 10, 2016, 06:33:26 PMspeed isn't an issue, all the window does is fill a list with drives and lets the user select one.
As Yves wrote, both options are OK. Since you need the startup code anyway, and since there is a small risk that the user mounts a new drive while your window was hidden, I'd opt for destroy & recreate.
Quote from: jj2007 on January 10, 2016, 07:37:15 PM
since there is a small risk that the user mounts a new drive while your window was hidden, I'd opt for destroy & recreate.
That's the exact reason.
Does hidden window get WM_DEVICECHANGE message ?
With that message recreate drive list or just when window get focus ?
Search on MSDN.
https://msdn.microsoft.com/fr-fr/library/windows/desktop/aa363480(v=vs.85).aspx
With dialogs I start them then shut the down when finished but on occasions it is useful to hide a window which for example may have taken a lot of processor time to get up and going. Its really a design choice rather than a good or bad programming practice.
Quote from: hutch-- on January 11, 2016, 01:59:15 AM
Its really a design choice rather than a good or bad programming practice.
That's what I was after.
Quote from: TWell on January 10, 2016, 08:29:50 PM
Does hidden window get WM_DEVICECHANGE message ?
With that message recreate drive list or just when window get focus ?
Too much mucking around, easier in this case to do it from scratch every time.