Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Improving performance in a dialog DLL

Posted on 2002-05-19
5
Medium Priority
?
241 Views
Last Modified: 2010-08-05
Hi experts!
This is my question: I have a dialog based DLL. in the OnInitDialog function I call another function (LoadControls) that init all the combo box-s in the dialog, using the DB. I have a lot of combo and I need to init all of them from DB tables. hence - the OnInitDialog gets very slow. I would like to remove the call to LoadControls from the OnInitDialod and right after that to call it. That way the dialog is displayed and the user is under the impression that all is OK. mean while - I load (behind the scene) all the data for the combos. I imagine that there is an event I have to catch. which one?
0
Comment
Question by:osnat
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 4

Expert Comment

by:mblat
ID: 7020155
You can start separate thread in OnInitDilaog and let it handle combo-box loading...

Of cause you need to make sure that user won't start using comboboxes before you load them...
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 150 total points
ID: 7020237
Here is a simple technique:

Add a small button to the dialog.  Set its ID to 'IDC_ContinueSetup'.  Double-click it and let the wizard create an OnContinueSetup() handler.  In that handler do..

void CMyDlg::OnContinueSetup()
{
    CWaitCursor  wait;
    ... do all of the DB init stuf...
}

Now edit the OnInitDialog function and remove all of the Db init stuf.. Add this line at the the very end of OnInitDialog:

    PostMessage( WM_COMMAND, IDC_ContinueSetup, 0 );

Back in the dialog editor, select the button and make it invisible (uncheck its Visible checkbox in its Properties).

What this does is let OnInitDialog finish its cascade of messages (including all screen drawing), then when all is clear, it executes your ContinueInit fn.  This is a useful technique to use whenever there is a lot of initialization to do.

You don't actually need the hidden button.  You can make a custom Message is and custom message handler, etc.. its just that the ClassWizard makes this technique so easy, there is no need to go to the extra work.

-- Dan
0
 

Author Comment

by:osnat
ID: 7020960
I'm sorry but I don't work with the wizard; I edit the code all by my self! I've added the function manually and did all u said. I added a MessageBox in the function OnContinueSetup  but it never pops up. I'm missing something. what is it?
0
 

Author Comment

by:osnat
ID: 7020970
Forget it! I did it - all it needs was the
ON_COMMAND(IDC_ContinueSetup, OnContinueSetup)
Thanks!
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7021101
hi osnat,
Thanks for accepting my comment as an answer.  However, I am curious as to why you gave me a 'B.'  It seems that my comment help you out a lot, but now my overall grade-point-average has declined.  It is discouraging to me.

-- Dan
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question