News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Improving startup times

Started by zemtex, July 21, 2011, 09:14:32 PM

Previous topic - Next topic

zemtex

When you use dialogs and initialize things in the WM_INITDIALOG, it eventually slows down. I want to clean up WM_INITDIALOG so that it is empty, let the window load the dialog with defaults, then after the window is shown, I want to initialize certain "invisible" technical things for the individual controls. What WM_ message should I use to initialize after WM_INITDIALOG has processed? The WM_Message must be one that appears after the window is fully drawn?
I have been puzzling with lego bricks all my life. I know how to do this. When Peter, at age 6 is competing with me, I find it extremely neccessary to show him that I can puzzle bricks better than him, because he is so damn talented that all that is called rational has gone haywire.

qWord

What kind of initialization is so time consuming?
However, you may start an thread while handling WM_INITDIALOG.
FPU in a trice: SmplMath
It's that simple!

dedndave

i was looking at something along these lines
the problem is, what happens under one version of windows may not be the same under another

i wrote a test program to find out what messages are sent to the main window at initialization
i inserted into the list, the 2 messages that have a handle of 0
those represent the beginning and end of the WM_CREATE routine
immediately following that is a WM_SHOWWINDOW
i assume that is a result of the CreateWindow function
shortly after that is the UpdateWindow call, then the message loop starts
notice the real WM_NULL near the end of the list
that might be a good one to use - maybe not - lol
after your code, set a flag so it only gets executed once

i wanted to insert a single instruction
i wound up putting it in WinMain, just before i start the message loop
that worked well in my case

hWin       WM_GETMINMAXINFO
hWin       WM_NCCREATE
hWin       WM_NCCALCSIZE
hWin       WM_CREATE
00000000   WM_NULL
hWin       WM_NOTIFYFORMAT
hWin       WM_QUERYUISTATE
hWin       WM_PARENTNOTIFY
hWin       WM_PARENTNOTIFY
hWin       WM_PARENTNOTIFY
hWin       WM_PARENTNOTIFY
hWin       WM_PARENTNOTIFY
hWin       WM_PARENTNOTIFY
00000000   WM_NULL
hWin       WM_SHOWWINDOW
hWin       WM_WINDOWPOSCHANGING
hWin       WM_WINDOWPOSCHANGING
hWin       WM_ACTIVATEAPP
hWin       WM_NCACTIVATE
hWin       WM_GETICON
hWin       WM_GETICON
hWin       WM_GETICON
hWin       WM_ACTIVATE
hWin       WM_IME_SETCONTEXT
hWin       WM_IME_NOTIFY
hWin       WM_SETFOCUS
hWin       WM_NCPAINT
hWin       WM_ERASEBKGND
hWin       WM_WINDOWPOSCHANGED
hWin       WM_NCCALCSIZE
hWin       WM_NCPAINT
hWin       WM_ERASEBKGND
hWin       WM_SIZE
hWin       WM_MOVE
hWin       WM_PAINT
hWin       WM_NULL
hWin       WM_GETICON

Tedd

I wonder what you're doing that's taking so long, but...

SetTimer in WM_INITDIALOG, set it for about 500ms.
Then you'll receive WM_TIMER (500ms later) - KillTimer (so it doesn't repeat) and then do your fiddling.
No snowflake in an avalanche feels responsible.

zemtex

Quote from: Tedd on July 22, 2011, 12:07:23 PM
I wonder what you're doing that's taking so long, but...

SetTimer in WM_INITDIALOG, set it for about 500ms.
Then you'll receive WM_TIMER (500ms later) - KillTimer (so it doesn't repeat) and then do your fiddling.


I had quite alot of controls that needed special initializations, like accel's and editboxes for example
Then there were quite alot of variables that needed to be read and consumed from INI file
Beyond that I needed to selectively load external modules (DLL's)
Then I had to set alot of other tiny things
In total, the WM_INITDIALOG just got bigger and bigger.

I have now totally cleaned it up. I've done the following:

1: Create a thread in WM_INITDIALOG
2: Thread runs initialization by itself so that window can start before initialization is finished
3: I run window-specific initializations at the very top of the thread to avvoid delays related to the window (and it keeps up)
4: I've converted a few INI variables into command-line variables to remove the need to load extra data from disk (I could also use the registry)
etc.

Yes, you can use a WM_TIMER, in fact I had it in mind yesterday but I didn't want to go for it because I consider it dirty programming to use timed delay for something that can and should be executed immediately so I went for creating a separate thread instead.
There is no need to wait 500ms to initialize the window. When you have reached WM_INITDIALOG, the window is already created and there is no need to wait for it, even if it haven't been shown already. When you get that WM message you can instantly begin to initialize settings in a separate thread. I appreciate the tips anyway. :P
I have been puzzling with lego bricks all my life. I know how to do this. When Peter, at age 6 is competing with me, I find it extremely neccessary to show him that I can puzzle bricks better than him, because he is so damn talented that all that is called rational has gone haywire.