News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Window: create/destroy or show/hide?

Started by sinsi, January 10, 2016, 03:25:51 PM

Previous topic - Next topic

sinsi

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.

Grincheux

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.

TouEnMasm

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.


Fa is a musical note to play with CL

sinsi

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.
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?

jj2007

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.

sinsi

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.

TWell

Does hidden window get WM_DEVICECHANGE message ?
With that message recreate drive list or just when window get focus ?

Grincheux

Search on MSDN.

https://msdn.microsoft.com/fr-fr/library/windows/desktop/aa363480(v=vs.85).aspx

hutch--

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.

sinsi

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.