Events & windows messages

Hello,

Is there anyway you can use WaitForSingleObjects or 
WaitForMultipleObjects to detect when a new windows message has arrived 
in the processes message queue?

I want to be able to wait on an event such as this within a thread 
process rather than it having to call PeekMessage all the time (which is 
extremely inefficient and needlessly slows down my other threads)

I am using Visual C++ 5.0, 6.0 & 7.0 (.Net)

Many thanks in advance!


newsgroupie
0
7/14/2004 4:34:08 PM
vc.mfc 33608 articles. 0 followers. Follow

6 Replies
655 Views

Similar Articles

[PageSpeed] 17

newsgroupie wrote:

>Hello,
>
>Is there anyway you can use WaitForSingleObjects or 
>WaitForMultipleObjects to detect when a new windows message has arrived 
>in the processes message queue?
>
>I want to be able to wait on an event such as this within a thread 
>process rather than it having to call PeekMessage all the time (which is 
>extremely inefficient and needlessly slows down my other threads)
>
>I am using Visual C++ 5.0, 6.0 & 7.0 (.Net)

Presumably you want to wait forever on one or more HANDLEs yet detect
Windows messages at the same time. In that case, use
MsgWaitForMultipleObjects. Here's a post on that from yesterday(!):

http://groups.google.com/groups?selm=gq79f0tf209iivgo5ovucqtbm4tf72v90u%404ax.com

-- 
Doug Harrison
Microsoft MVP - Visual C++
0
dsh (2498)
7/14/2004 4:51:14 PM
I have a spot in our product where I just want to read in a file and do a
simple message box.  But I have found that if there is "too much data" the
message box won't put up scroll bars.  I understand why this is happening -
since there is no boundary defined for message boxes.  But is there any way,
other than creating a dialog with a single text box in it, to get this basic
behavior?  I wanted to avoid all of the extras that go along with this since
all I want to do is display the contents of a text file.

-- 
Edward Fultz
Sr. Software Engineer
Pamet Systems
Acton, Ma


0
efultz (28)
7/14/2004 4:55:08 PM
Thanks Doug!


In message <ptoaf0921if296hgnc0r7r32srvhcm2ai0@4ax.com>, "Doug Harrison 
[MVP]" <dsh@mvps.org> writes
>newsgroupie wrote:
>
>>Hello,
>>
>>Is there anyway you can use WaitForSingleObjects or
>>WaitForMultipleObjects to detect when a new windows message has arrived
>>in the processes message queue?
>>
>>I want to be able to wait on an event such as this within a thread
>>process rather than it having to call PeekMessage all the time (which is
>>extremely inefficient and needlessly slows down my other threads)
>>
>>I am using Visual C++ 5.0, 6.0 & 7.0 (.Net)
>
>Presumably you want to wait forever on one or more HANDLEs yet detect
>Windows messages at the same time. In that case, use
>MsgWaitForMultipleObjects. Here's a post on that from yesterday(!):
>
>http://groups.google.com/groups?selm=gq79f0tf209iivgo5ovucqtbm4tf72v90u%
>404ax.com
>

-- 
newsgroupie
0
7/14/2004 5:42:38 PM
Hi Ed,

I don't know of a good way to do this with a message box.  If I were you I'd
either use a simple dialog with an edit control (you can make it read only
if you'd like) or if the data is line oriented you could use a ListBox
control.  Alternatively you could use a CRichEditCtrl and have the
appearance be a little nicer.  The message box thing is mostly for quick
messages.

Tom

"Ed Fultz" <efultz@yahoo.com> wrote in message
news:exWJTNcaEHA.2840@TK2MSFTNGP11.phx.gbl...
> I have a spot in our product where I just want to read in a file and do a
> simple message box.  But I have found that if there is "too much data" the
> message box won't put up scroll bars.  I understand why this is
happening -
> since there is no boundary defined for message boxes.  But is there any
way,
> other than creating a dialog with a single text box in it, to get this
basic
> behavior?  I wanted to avoid all of the extras that go along with this
since
> all I want to do is display the contents of a text file.
>
> -- 
> Edward Fultz
> Sr. Software Engineer
> Pamet Systems
> Acton, Ma
>
>


0
tserface (3860)
7/14/2004 6:01:16 PM
yes, there is a limit. In that case, don't use MessageBox. Create a dialog with an edit
control, dump the text into the edit control. Should take about five minuts to type in.

Create dialog with OK and Cancel buttons. Get rid of the OK button. 

Recaption the Cancel button as "Close", move it to the top of the dialog.

Draw an edit control that covers the rest of the dialog.

Mark it as readonly, autovscroll, etc.

Use ClassWizard to add a value-member variable.
	CString m_Contents;

When you want to bring it up
	CMyDisplay dlg;
	dlg.m_Conents = ...file contents...
	dlg.DoModal();

done. 

So there is no reason to NOT use a dialog to handle this. There is NEVER a good reason to
avoid creating the controls and objects you need to solve the problem. Certainly not one
of "avoid[ing] all the extras" when the "extras" consist of a few minutes of typing.
			joe

On Wed, 14 Jul 2004 12:55:08 -0400, "Ed Fultz" <efultz@yahoo.com> wrote:

>I have a spot in our product where I just want to read in a file and do a
>simple message box.  But I have found that if there is "too much data" the
>message box won't put up scroll bars.  I understand why this is happening -
>since there is no boundary defined for message boxes.  But is there any way,
>other than creating a dialog with a single text box in it, to get this basic
>behavior?  I wanted to avoid all of the extras that go along with this since
>all I want to do is display the contents of a text file.

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
7/14/2004 6:50:45 PM
I ended up biting the bullet and doing a dialog with an edit box.  It was
probably the right way to go from the start but I was trying to get a cheap
solution.

Thanks for the input.

-- 
Edward Fultz
Sr. Software Engineer
Pamet Systems
Acton, Ma
www.pametsystems.com
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
news:grvaf0dk6227eos33hmmnshp1q2lv933v6@4ax.com...
> yes, there is a limit. In that case, don't use MessageBox. Create a dialog
with an edit
> control, dump the text into the edit control. Should take about five
minuts to type in.
>
> Create dialog with OK and Cancel buttons. Get rid of the OK button.
>
> Recaption the Cancel button as "Close", move it to the top of the dialog.
>
> Draw an edit control that covers the rest of the dialog.
>
> Mark it as readonly, autovscroll, etc.
>
> Use ClassWizard to add a value-member variable.
> CString m_Contents;
>
> When you want to bring it up
> CMyDisplay dlg;
> dlg.m_Conents = ...file contents...
> dlg.DoModal();
>
> done.
>
> So there is no reason to NOT use a dialog to handle this. There is NEVER a
good reason to
> avoid creating the controls and objects you need to solve the problem.
Certainly not one
> of "avoid[ing] all the extras" when the "extras" consist of a few minutes
of typing.
> joe
>
> On Wed, 14 Jul 2004 12:55:08 -0400, "Ed Fultz" <efultz@yahoo.com> wrote:
>
> >I have a spot in our product where I just want to read in a file and do a
> >simple message box.  But I have found that if there is "too much data"
the
> >message box won't put up scroll bars.  I understand why this is
happening -
> >since there is no boundary defined for message boxes.  But is there any
way,
> >other than creating a dialog with a single text box in it, to get this
basic
> >behavior?  I wanted to avoid all of the extras that go along with this
since
> >all I want to do is display the contents of a text file.
>
> Joseph M. Newcomer [MVP]
> email: newcomer@flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm


0
efultz (28)
7/14/2004 9:29:02 PM
Reply:

Similar Artilces:

I get an error message when opening one of my word documents
When i try to open one of my word documents I get an error message that states the following: the file cannot be opened because there are problems with the contents When i click on the option that says details it tells me the following: The name in the end tag of the element must match the element in the start tag. Location: Part:/word/document.xml, Line 2, Column 697477 I have tried to open and repair were it simply did nothing (came up with a blank document). Thank you for your help! Some information that I didn't include in the post above: I am using the Micro...

Printing Private events/appts. on Calendars
A while ago I asked about how to stop Outlook printing private appointments or events in the calendars. Someone said to check "don't print private events" in the print screen which I did. Anyway, the calendar that gets printed, in the day that there is a private event it says "Private Event". How do I stop it from printing them altogether? I want it to appear on the calendar as nothing. ie. if there is only that event then the calendar should appear with no events for that day. Thanks ...

OnLoad event criteria
If have the code below in the OnLoad event which is working fine for the most part. The second line is causing a problem for cases where there is no matching record. The code is setting the value - I'd like to have it check the value first, and if it matches the value for the related field in the current form recordset, set the value, otherwise just open the form without setting the value. If CurrentProject.AllForms("AllOpen").IsLoaded Then Me.Combo1 = Forms!AllOpen!ID ' Find the record that matches the control. Dim rs As Object Set rs ...

Exchange 2000 & Windows 2003
Is Exchange 2000 Enterprise supported on Windows 2003 Standard? Thanks. No, Exchange 2000 any version is not supported on Windows 2003 Server. -- John Oliver, Jr. MCSE, MCT, CCNA, Exchange MVP Microsoft Certified Partner "Zortex" <news@111222333444aaabbbccc.com> wrote in message news:%238551Z4yFHA.3408@TK2MSFTNGP09.phx.gbl... > Is Exchange 2000 Enterprise supported on Windows 2003 Standard? > > Thanks. > ...

transferring saved messages
Hi, I hope someone can help me. I want to transfer some messages to a new computer and I don't know how to. Is there a way other than transferring the file to a usb drive? Thanks for your help csviens ...

Error in Event Viewer event id 1023 pop3 connector, 1029, 1036, 10
Hello Exchange Administrators, I am getting these Error in Event Viewer "event id 1023 pop3 connector, 1029, 1036, 1015, 1019, 1015" on regular basis after every 15 min for every user. I need yours help to fix these errors. Also tell me why these error are logged in event viewer or cause of these errors We are using WIndoes 2003 SBS, Exchange Server 2003. Thanks you for yours help in advance. On Fri, 1 Sep 2006 11:11:01 -0700, Guri <Guri@discussions.microsoft.com> wrote: >Hello Exchange Administrators, > >I am getting these Error in Event Viewer "event id 1...

cannot "reply to" or "forward" messages in OWA (outlook web access)
My OWA (outlook web access) functioned well, but now I cannot "reply to" or "forward" email messages. I now need to "compose" a new email, which I am able to send. Any suggestions are appreciated...Thank you, tom Do you have any type of pop-up stopper installed? (e.g. Google toolbar) -- Neo [MVP Outlook] Due to recent events in spam and malicious programs, all e-mails sent to this account will be deleted w/out reading. "Tom McRay" <anonymous@discussions.microsoft.com> wrote in message news:76c501c3e875$fcb53ea0$a301280a@phx.gbl... > M...

deleting events in calender
Version: 2008 Operating System: Mac OS X 10.4 (Tiger) Processor: Intel Email Client: pop I have inadvertently imported a weekly event into my calender. Each event seems to be logged as an individual event rather than a repeat event. I do not know how to delete it. Am trying, unsuccessfully, to show all events in one window so that I can easily select this irrelevant event, but cant display that window. Can you help me, either showing that elusive window, or how to otherwise delete MANY events. In article <59bb30c6.-1@webcrossing.JaKIaxP2ac0>, <leaest@officeformac.com> w...

Windows firewall on Exchange 2003 Server
Hi, I have Exchange 2003 (AD integrated) and would like to use the Windows 2003 built-in firewall. What ports do I need to open up? OWA is being used as well. I found the following article http://support.microsoft.com/?kbid=278339 but am confused on what to open. Below is an example: Protocol: LDAP Port (TCP/UDP): 389 (TCP) Do I open both TCP and UDP or just TCP since it specifies that next to the por number. Thanks Here's an article to assist. Try the Security Configuration Wizard (SCW). http://www.msexchange.org/tutorials/Protecting-Exchange-2003-Windows-Firewall.html "b...

Locate link browser window problem on Windows 7
Every time I click on a link in an email in Outlook, a "locate link browser" window appears. There's a lot of help on the web to fix it for Win XP, but those steps don't appear to work for Windows 7. I tried pointing it to iexplorer.exe and the window isn't coming up anymore, but it just launches IE and my home page... not the link that was in the email. I've also tried setting the default browser to Firefox... and then the links in emails work. But, if I then try and set the defaul browser back to IE, clicking on a link in an email will launch IE...

Error Message 05-14-10
The connection to the server has failed. Subject 'Test', Account: 'Windows Live Email', Server: 'smtp.live.com', Protocol: SMTP, Port: 25, Secure(SSL): Yes, Socket Error: 10060, Error Number: 0x800CCC0E Here is the error message that popped up when I tried to send a message (it was just a test) and I'm not sure what I'm doing wrong. Can anyone help me??? Olivia Change port 25 to port 587. You can do so here: Go to Tools, Accounts, select that account, Properties, Advanced. --=20 Gary VanderMolen, Microsoft MVP (Mail) Microsoft MVP progra...

4117 Event ID Error
Starting 1-29-04 we started getting 4117 error messages just like those discussed in Micrisoft's Knowledge Base Article 190084. The only thing that arcticle suggests is to update to SP 4 which is already installed on the machine. I have never seen this message before and now we are getting one every few minutes. Any help would be appreciated. Thanks Sean Seems like you have something else going on then, check out the following articles and see if these help: 126497 XADM: Limiting the Number of Recipients of a Message http://support.microsoft.com/?id=126497 230250 XFOR: Internet ...

Returning to Windows 7
Hello, I recenlty purchased two laptops for a client installed with Windows 7 in XP mode. Can these be switched to Windows 7 and how. Thank you and God Bless, Mark A. Sam Mark A. Sam wrote: > I recenlty purchased two laptops for a client installed with Windows 7 in > XP mode. Can these be switched to Windows 7 and how. You are actually some guru for this "client" and yet you think Windows 7 itself is running under XP mode? Do some research. I pity your clients. Those laptops already have Windows 7 whether or not XP mode was installed. Hi Ma...

Catch click event button
Hi all, I was wondering... Is it possible to "catch" a click-event on a BuildIn Offie Button? In order to execute your own VBA-code? e.g. I want to be able to catch the "Undo" button in order to execute a piece of macro code in stead of just "Undoing" only the last action. Greetz, Bert -- Neron It is possible to catch ("intercept") most built-in Word commands, as described at http://www.word.mvps.org/FAQs/MacrosVBA/InterceptSavePrint.htm. In this case, the macro you need to write is named EditUndo, as in Public Sub E...

Sending messages to other windows
Hi, I would like to know how I can send user-defined messages to windows in another application. For example I have two dialog applications. Sometimes one dialog app needs to send the other dialog app a message telling it somethings has happened. Are there any examples or tutorials on how I could implement this?? check the following article by Joseph M. Newcomer. http://www.codeproject.com/dialog/messagemgmt.asp -- Cheers suhredayan _________________ there is no spoon... "W Akthar" <wakthar@hotmail.com> wrote in message news:687c01c42ea5$2bd70590$a301280a@phx.gbl... &g...

How to show the aphabet list toolbar in the contacts window
Hi, I remember having a alphabet toolbar in the contacts list (when in View>Phone List). Now I don't seem to have it anymore. Does anyone know how to re-enable it? Thanks. On Wed, 3 Nov 2004 11:32:12 +0800, "Tom" <faai_dee_mail@fastmail.fm> wrote: >Hi, > >I remember having a alphabet toolbar in the contacts list (when in >View>Phone List). Now I don't seem to have it anymore. Does anyone know >how to re-enable it? > Try viewing your contacts in Address Card view. Your alphabet list will appear on the right side of the view. -- <...

Messages showing up as enclosures?
Hi - When I send messages from my office email (Outlook 2000, Exchange 2000) to 2 specific people, my messages show up as an enclosure or an attachment to a message. Any attachments I had sent are gone. When I send that same message to others, including my personal email address, they are fine. They both use Outlook, one uses 2000, not sure about the other. Also, if I paste a table from Word into the email, they see a string of text, the table is gone. Any suggestions as to what I can look for to fix this? Thanks - Brian ...

Outlook 2007 send error or failure, message remains in Outbox
I cannot get Outlook to send an email. Receive works fine. Outlook 2003 worked fine, other than the occasional email that got stuck in the Outbox, when I revised it before it was sent. I deleted all the emails in the Outbox of Outllok 2007 and tried a simple test message. It would not send. Any suggestions as to why send continues to fail, would be very welcome. On Wed, 10 Jan 2007 15:08:51 -0500, fisherman <fisherman@deepwater.com> wrote: >I cannot get Outlook to send an email. Receive works fine. > >Outlook 2003 worked fine, other than the occasional email that got &...

Macro warning message
Anyone else had this problem. We installed Excel97 on an NT Server.We then installed Excel2000 over it, and set the macros security setting to low. We re using NetOp to connect to that server, and when we open an Excel workbook with macros, no problems. However, if the screensaver kicks in, and a workbook is opened by a scheduled job, we get a dialog box regarding the macros. If we are connected, we can respond, but as we run 300 Excel queries, and as we won't be connected to the server most of the time, this is a problem. Anyone else experienced it, and know the solution? Bob ...

Event
I have recorded a macro that I need to automatically run at 6:45am daily. How do I specify this in the code? Everything you need to know about OnTime procedures (but were afraid to ask): http://www.cpearson.com/excel/ontime.htm You'll need to have excel running for this to work. ===== Some versions of windows have scheduler programs. (Or you can get a freeware/shareware version on the web (www.shareware.com is where I look first.) Then you could have that scheduling program start an excel workbook. If you name the macro Auto_Open, then it'll run when the workbook opens. (But ...

Console App w/ MFC (hiding console window)
I've created a console app and added MFC support. The idea is that my app can run either with a dialog user interface or a console. It all works fine except that I cannot figure out how to hide the console window when running in the dialog ui mode. Anyone know how I might do this? -Brett- Brett , > I've created a console app and added MFC support. The idea is that my app > can run either with a dialog user interface or a console. It all works fine > except that I cannot figure out how to hide the console window when running > in the dialog ui mode. You can set yo...

Event After the sale
Hi to all Is any way to bypass the event that after you complete the sale you get a window with the change in it, in order to go to the next sale you have either hit OK or enter because if you scan an item from that point it does not scan in and it appears to me that you can miss an item from been scanned in any way to fix this issue. Also if you have scan several items into the system and you go to del one item in the middle of the page RMS is loosing its focus and starts to scan into the next line down which deletes the items that have been scanned.I think it should go to the next ...

How to... in Outlook 2000 . .. how to segregate outgoing messages?
In Outlook 2000 I have several e-mail accounts in different domains. So I have as well appropriate number of incoming e-mail folders. When I respond from a particular folder, Outlook properly addresses the sender - with a correct domain. But after the messages are sent, they all go to the "elements sent" folder. Is there any way to dispatch tem to the different "elements sent" folders, basing on the email account which was used to send them? I have not found any apropriate rukes to use in Outlook... I mean - a simple way. I can imagine two rather complicated: 1. To write...

What event when I click the record selector
I have some labels on the form would like to populate its value (they are calculated values) when I select the record selector, next, previous or last or first. What event should I write the code into? On Tue, 22 May 2007 11:01:23 +1000, "Alan T" <alanpltseNOSPAM@yahoo.com.au> wrote: >I have some labels on the form would like to populate its value (they are >calculated values) when I select the record selector, next, previous or last >or first. > >What event should I write the code into? > Well, don't use Labels for this purpose; use textboxes ...

Settings to send JPEG-Pictures with Windows Mail.
Hallo Experts, my english is not so good, but I hope you will understand the following question: I want to send JPEG-Pictures with "Windows Mail" runnig under Windows Vista. Usually I clicked the JPEG-Picture and a Window opened. I could chose to send it to an addressee by Windows Mail. Then I coud also chose the size of pixels. Then the "Windows Mail" window opened and I could typ in the adresse, subjekt and some text. This feature does not function any more since I made a new setup of my computer. Everthing else is functioning well. I know only a very small adj...