[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Dialog based application MFC Programming - Modeless Dialog

Posted on 2007-10-16
7
Medium Priority
?
1,910 Views
Last Modified: 2013-12-14
Hi,

I am working on a dialog based application. I have created a Modeless dialog box and have placed a static text control to display some text. In the main dailog application i have a button placed. On clicking this button i am creating the modeless dialog using create function and using show window function i am displaying the dialog window.The problem i am facing is the static text is not getting displayed on the modeless dialog. It just simply dislays the dialog window. Can anybody suggest what is the problem and how to handle this.

Thanks in advance.
0
Comment
Question by:umaiyer
6 Comments
 
LVL 22

Expert Comment

by:mahesh1402
ID: 20090934
where and how are you displaying static text on your dialog box ?

It may be reason your dialog window is not fully created at the time you place static text control.Make sure your dialog window is fully created and available at the time you place static text control.

-MAHESH
0
 

Author Comment

by:umaiyer
ID: 20091056
using resource i have created a new dialog with IDD_MODELESS
I have placed a static control to display a message.

i am adding the code snippet for On button press
CModaless *dlg;
dlg = new  CModaless;
dlg->Create(IDD_MODELESS , GetDesktopWindow());
dlg->ShowWindow(1);
Sleep(5000); // show the window for sometime
dlg->DestroyWindow();

Please let me know if there is any problem.
0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 20091214
It makes clearer code if you use predefined values eg.
ShowWindow(SW_SHOW)


Just give this a try - instead of the Sleep(5000) - this isn't good code

CModaless *dlg;
dlg = new  CModaless;
dlg->Create(IDD_MODELESS , GetDesktopWindow());
dlg->ShowWindow(1);
//Sleep(5000); // show the window for sometime
DWORD dw = GetTickCount() + 5000000;
while(GetTickCount() < dw)
{
Sleep(0);
}
dlg->DestroyWindow();
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 45

Accepted Solution

by:
AndyAinscow earned 252 total points
ID: 20091216
>>>Just give this a try - instead of the Sleep(5000) - this isn't good code


The 'this isn't good code' refers to the changes I made for testing purposes, NOT to the Sleep(5000) in the original code.
0
 
LVL 49

Assisted Solution

by:DanRollins
DanRollins earned 248 total points
ID: 20104565
Agreed:  It is very impotant not to do a long "sleep" because nothing happens -- including screen updates or recognition of user keystrokes or mouse operations.

When are you setting the value to display?  The normal procedure is like:

  dlg = new  CModaless;
  dlg->m_sStaticMsg="this is the text for the message";
  dlg->Create(IDD_MODELESS , GetDesktopWindow());
  dlg->ShowWindow(1);

When using the resource editor, click the static control, Press Ctrl=W to bring up the ClassWizard and select "Member variables"  and associate a variable (e.g., m_sStaticMsg) with the static.  You must also provide an ID for the control (other than IID_STATIC).

Then, when the dialog is created, the nomal DDX is executed and it transfers the value from the memory variable onto the sceen automatically.

-- Dan
0
 
LVL 1

Expert Comment

by:Computer101
ID: 20295293
Forced accept.

Computer101
EE Admin
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
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.
Suggested Courses

831 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