Solved

What message's next, after WM_INITDIALOG?

Posted on 1998-01-26
2
1,020 Views
Last Modified: 2013-11-20
Dear Expert-Exchange Community,

QUESTION 1 of 2:
-----------------------------
Background:
I am programming in MFC (using the class wizards and etc.) using VC5++ on the NT(4.0) platform. My software's framework is of a dialog based type. The software I'm writing is of an image-analysis nature (application - Industrial Automation) and it has to interface with a machine's handler. I have simulated this dialog base framework such that it has a main menu and looks just exactly like an SDI.

Question:
To initialize my dialog's values, I've trapped the WM_INITDIALOG message and added all the necessary things I need to do there. Then, in the main class, I call dlg.DoModal().

What is the next message to trap after the dialog has been displayed? Because I need to invoke a function which I declared (eg: myFunction() )after the dialog has been displayed. How do I do that?

See.... once the dialog box is displayed, I have to invoke MyFunction(), without any user intervention. MyFunction() contains a while-loop which keeps detecting an external machine's trigger (signal) and if I detect a trigger from this
machine, I have to perform certain image-analysis operations.

Aside:
Initially, I tried to call MyFunction() inside OnInitDialog() but since MyFunction contains a while-loop, I never got to see my dialog displayed since calling MyFunction() has send the program into a while-loop. (further illustration below)

OnInitDialog()
{
    .........
    .......
    MyFunction();   // By placing this function here,
                             // I was unable to visually see the
                             // dialog which I have created.
    return(TRUE);
}



QUESTION 2 of 2:
------------------------------

First, I am not sure what you call that box that pops up right in the middle of the screen to inform the user to wait while some task is being perform and it takes some time (and I'm not referring to the box with a progress bar.. just somthing simple)

Secondly, I want to be able to do that. How do I go about doing it. Can you please give me some starting points (ie: what classes to look up). I know I cannot use AfxMessageBox or the CWnd's Message Box bec both needs user response, which I don't want.

What I need is to achieve is described below in a simple pseudo-code.

(please refer to Q1 for the Background to this question)

OnPerformSomeFunction()
{
        - Display the PopUp Box right in the middle of the                   screen
        - Perform a time consuming task
        - Once, task is completed, repaint the screen
          so that the popup box disappear.
}


Thanking You for you time in advance.



Vivien A.
0
Comment
Question by:vcl
2 Comments
 
LVL 2

Accepted Solution

by:
rajesh032097 earned 300 total points
ID: 1314884
You need to create a separate thread for both of your questions. There are a lot of issues that need to be taken care of while using multithreading depending upon what your application is. The very first step would be to initiate your MyFunction() in a seperate thread using AfxBeginThread(). This will display your dialog box even if MyFunction() is running. Then you need to create events to establish proper communication between the two threads. See the documentation for CEvent, CMutex, CSingleLock and classes in similar category. For the second question, it can again be implemented using another thread which creates a dialog box and typically allows the user to cancel the operation like in Printing action. In previous case the thread would be a worker thread ( unless you have a seperate user interface for MyFunction()) and in the second case it would be User interface thread. You would find some samples like MtGDI and similar ones in VC++ CD and also on Microsoft web site in kb section. If further clarifications are needed, please let me know.

0
 

Author Comment

by:vcl
ID: 1314885
Thanks, Raj, for getting to my questions so quickly. I will try it out and get back to you if I have any questions.

All The Best,
Vivien A.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 42
sumNumber challenge 16 122
wordmultiple challenge 12 135
Path of Workbook 3 79
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

809 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