473,383 Members | 1,880 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How to display a MessageBox, which can disappear itself?

I want to display a message to user when machine is doing background
job, when the job is finished the message disappear automatically. Do I
have to create a modeless dialogbox to implement it? Is there a easier
way to to that?

Larry

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Feb 8 '06 #1
7 1168
"larry" <la************@rogers.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
I want to display a message to user when machine is doing background
job, when the job is finished the message disappear automatically. Do I
have to create a modeless dialogbox to implement it? Is there a easier
way to to that?


If you google for

timed message box

you'll get an incredible number of hits describing pre-made solutions.

Regards,
Will

Feb 8 '06 #2
Larry,
First set up a call back function as follows:

LRESULT CALLBACK DlgFn(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
return TRUE;
break;
case WM_COMMAND:
switch (LOWORD(wParam))
{ case IDOK:
case 2:
EndDialog(DlgBoxHandle, LOWORD(wParam));
DlgBoxHandle = NULL;
DlgItemCtrlHandle = NULL;
return TRUE;
break;
}
break;
}
return FALSE;
}

Second: Set up a message function to create and display the dialog box:

void ShowMessage(int type)
{
if (!DlgBoxHandle)
{
DlgBoxHandle = CreateDialog(hInst, MAKEINTRESOURCE
(IDD_DIALOG_BOX),hWnd,(DLGPROC)DlgFn);
DlgItemCtrlHandle = GetDlgItem(DlgBoxHandle, IDC_TEXT_CTRL);
SetDlgItemText(DlgBoxHandle,IDC_TEXT_CTRL,_T(“So me Sample Text”));
}

UpdateWindow(DlgItemCtrlHandle);
ShowWindow(DlgItemCtrlHandle,SW_SHOW);
SetFocus(DlgBoxHandle);
if (DlgBoxHandle && type)
{
DestroyWindow(DlgBoxHandle);
DlgBoxHandle = NULL;
DlgItemCtrlHandle=NULL;
}
}

Third:

Call the function with a parameter of 0 - this will keep the dialog box in
display on top of all other windows until you call it again with
ShowMessage(1) which will destroy the dialog box.
ShowMessage(0);

Some advice: Be very weary of what mvps tell you and especially this one De
Paolo.

regards,
John
"larry" wrote:
I want to display a message to user when machine is doing background
job, when the job is finished the message disappear automatically. Do I
have to create a modeless dialogbox to implement it? Is there a easier
way to to that?

Larry

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com

Feb 10 '06 #3
"John Gabriel" <Jo*********@discussions.microsoft.com> wrote in message
news:D8**********************************@microsof t.com...
Some advice: Be very weary of what mvps tell you and especially this one
De
Paolo.


Stil ROFLMAO.

Regards,
Will
Feb 10 '06 #4
Thank you very much for your help. I really appreciate it.

Larry

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Feb 10 '06 #5
Are you thanking De Paolo or me?

"larry" wrote:
Thank you very much for your help. I really appreciate it.

Larry

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com

Feb 13 '06 #6
Hi John,
Thank you very much for your help. I also thank all the people who tried
to help me.

Have a good day

Larry

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
Feb 14 '06 #7
You are welcome. If you need reliable information about Microsoft products
again, a good site is codeguru.com. Many of the authors do not work for
Microsoft and usually tell it like it is.

Glad I was able to help!

John

"larry" wrote:
Hi John,
Thank you very much for your help. I also thank all the people who tried
to help me.

Have a good day

Larry

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com

Feb 14 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: endus | last post by:
I'm having some trouble getting something to work. I'm not even sure whether or not this is possible, but it *seems* like it should be. I've done a fair amount of experimenting and googling...but...
1
by: Kevin R | last post by:
I'm running the HelloWorldForm example from Microsoft to learn how to use ..net. I'm using Microsoft Visual Studio .NET 2003, 1.1 framework. I run the HelloWorldForm example. The example runs...
7
by: jez123456 | last post by:
Hi, I have the following method where I need to display which database is being processed, however, the label lblDatabase dosn't seem to work until the end. private void...
18
by: Alpha | last post by:
Hi, I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a listbox that I have binded to a dataset table, "source" which has 3 columns. I would like to display 2 of those...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.