Problem with windows messages routing, DoModal and MessageBox

Consider a working thread, periodically posting WM messages to GUI thread so
the event handler CMyDialog:OmMyMsg is called.
When I show another dialogs form CMyDialog:OmMyMsg() , and pass them "this"
as a parent, MFC calls CMyDialog:OmMyMsg() again and again because there are
more messages waiting (and the working thread posting them again and again).
Now we throw away these messages with static guard but what we really want
is the messages to wait in a queue _as if_ those another dialogs were shown
from another thread.
What are the possible solutions for the problem?

Use an I/O Completion Port. See my essay on I/O Completion Ports on my MVP Tips site.
Without more details, it is hard to give a detailed solution, but I've used I/O Completion
Ports as a general queuing mechanism for a while now, including making sure the GUI queue
is not overrun or saturated, and this solution works very well.
joe
On Sun, 19 Jun 2005 21:53:44 +0400, "Vyacheslav Lanovets" <xentrax_umail.ru> wrote:
>
>Consider a working thread, periodically posting WM messages to GUI thread so
>the event handler CMyDialog:OmMyMsg is called.
>
>
>When I show another dialogs form CMyDialog:OmMyMsg() , and pass them "this"
>as a parent, MFC calls CMyDialog:OmMyMsg() again and again because there are
>more messages waiting (and the working thread posting them again and again).
>
>Now we throw away these messages with static guard but what we really want
>is the messages to wait in a queue _as if_ those another dialogs were shown
>from another thread.
>
>What are the possible solutions for the problem?
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

Hello, Joseph!
You wrote on Sun, 19 Jun 2005 22:20:59 -0400:
JMN> Without more details, it is hard to give a detailed solution, but I've
JMN> used I/O Completion Ports as a general queuing mechanism for a while
JMN> now, including making sure the GUI queue is not overrun or saturated,
JMN> and this solution works very well.
The problem is that operating system is Windows CE which lacks most of
overlapped capavilities of the elder brother - WinNT+. Anyway, something of
this kind is what we are thinking of.
I.e. there will be our own queue which will be receiving our user defined
WMs instead of GUI thread.
GUI and this queue will use Win32 event to control when GUI thread is ready
to receive new windows messages of some types....
Best regards, Vyacheslav Lanovets

0

Vyacheslav

6/20/2005 4:35:22 AM

There is always the option to create your own queue and mange it yourself. You can't queue
user-defined WM_ messages in it; you can only do this if it is the input message queue of
a UI thread. Use of an event is probably, almost certainly, the wrong choice. See my essay
on semaphore management. An event will almost always give you the wrong result. You are
also confusing transmission and receipt of messages.
The way to do this is to create a CList structure protected by a semaphore and a mutex.
It would work something like this:
To put something in the queue, lock the mutex, and do an AddToTail or similar operation to
insert the queued request. Then ReleaseSemaphore the semaphore object. In this case,
Then PostMessage a message to the main GUI thread. WM_NULL is a good message to post. You
might want to post this only if the semaphore count was originally 0, because otherwise
you can still flood the queue if the messages arrive too quickly. However, WM_NULL
requires virtually no processing, so is a very fast message, so I'm not sure where the
correct tradeoff would be here.
By breaking out of the GetMessage, you will then have the option of your app having its
OnIdle handler called. What I did was queue up a set of MSG structures, so it worked like
this:
BOOL CWinApp::OnIdle(long count)
{
switch(::WaitForSingleObject(queuesemaphore, 0))
{ /* wait */
case WAIT_OBJECT_0:
{
MSG msg = queue.RemoveFromHead();
PostMessage(msg.hWnd, msg.msg, msg.wParam, msg.lParam);
return TRUE;
case WAIT_TIMEOUT:
break;
} /* wait */
return CWinApp::OnIdle(count);
}
Note that if there are messages to process, you will process them in preference to
dequeuing pending messages. If there is no message to process, you will dequeue one
message (or as I show in my example, n messages), by removing them from the queue and
posting them to the GUI queue. But you can't "flood" the queue because if you move the
mouse or something like that then there will be a "real" message in the queue and it will
be dequeued in preference (or after at most n messages have been processed). This keeps
the GUI responsive. If there is nothing to do, you will typically just call the default
OnIdle handler, which will in turn eventually return FALSE, allowing the message pump to
block on a GetMessage. The WM_NULL breaks it loose from this blocked state, does nothing
(DefWIndowProc of WM_NULL is a "do-nothing" handler), but allows the OnIdle sequence to be
re-executed.
I think this is a complete solution, although I have a nagging feeling that there could be
a race condition where a WM_NULL should be sent but isn't. But the usual WM_ENTERIDLE
message should kick it out of wait (but they arrive at the resolution of hundreds of
millisconds) or you could throw a timer at it to force a more frequent entry into the
OnIdle handler.
joe
On Mon, 20 Jun 2005 08:35:22 +0400, "Vyacheslav Lanovets" <xentrax_umail_ru> wrote:
>Hello, Joseph!
>You wrote on Sun, 19 Jun 2005 22:20:59 -0400:
>
> JMN> Without more details, it is hard to give a detailed solution, but I've
> JMN> used I/O Completion Ports as a general queuing mechanism for a while
> JMN> now, including making sure the GUI queue is not overrun or saturated,
> JMN> and this solution works very well.
>
>The problem is that operating system is Windows CE which lacks most of
>overlapped capavilities of the elder brother - WinNT+. Anyway, something of
>this kind is what we are thinking of.
>
>I.e. there will be our own queue which will be receiving our user defined
>WMs instead of GUI thread.
>GUI and this queue will use Win32 event to control when GUI thread is ready
>to receive new windows messages of some types....
>
>Best regards, Vyacheslav Lanovets
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm

Outlook 2003 PST problemsI just installed Office 2003 professional on a new computer
& am having problems with outlook. I copied my Outlook.pst
file into the appropriate directory & although it is
recognized the calendar is not working properly. I cannot
attach any of the colored labels to my appointments - so
everything is pretty much in black & white. I totally
uninstalled & reinstalled office... first removing my pst
file... but there appears to be an ini file... or something
that is retaining some information... does anyone know of a
fix for the labels... or how to TOTALLY uninstall office
(so I...

having trouble with windows mailThe message could not be sent. The authentication setting might not be
correct for your outgoing e-mail [SMTP] server. For help solving this
problem, go to Help, search for "Troubleshoot Windows Mail", and read the
"I'm having problems sending e-mail" section. If you need help determining
the proper server settings, please contact your e-mail service provider.
The rejected e-mail address was 'Foreverzetaclassy@live.com'. Subject
'Application Data For Mental Health Worker', Account: 'pop3.aol.com', Server:
'smtp.aol.com', Pr...

Problem shortcuts in WordHello,
I work with Word 2008.
In the beginning there is no problem, but suddenly i have problem with
shortcuts. When i want to do "cmd c" it make an other shortcuts same thing
for "cmd s", "cmd v" and surly some other. But when i write there is no
problem "c" is "c"...
If somebody have an idea please help me.
Thank you.
Unless you indicate your specific update level of Office as well as OS X &
describe what the keystrokes *are* doing contrary to what you expect there
isn't much we can offer.
--
Regards |:>)...

encoding problem in Outlook 2007 importing Outlook 2000 personal foldersI use Outlook 2007 to import the pst file of Outlook 2000. The Chinese
characters in the subject became unreadable but it's ok to display in
message body. In Outlook 2000, there's no problem to display the
Chinese characters in the subject. What's wrong with Outlook 2007?
What setttings should I change to fix the problem? Thanks.
cyl <u8526505@gmail.com> wrote:
> I use Outlook 2007 to import the pst file of Outlook 2000. The Chinese
> characters in the subject became unreadable but it's ok to display in
> message body. In Outlook 2000, there's no problem t...

Outlook not sending messages from correct POP3 accountI am a tech support person, supporting several companies
from my home. Therefore, I have several pop3 email
accounts setup on my computer in Outlook.
When I reply to an email, I need to make sure that the
correct account shows up in the "From" field. This works
for some messages, but for others, the email is sent from
the wrong account (making me look real bad :-)). This
happens even when it says it's going to be sent from the
correct account, if I check the sent items afterward,
I'll see that it was sent from the wrong account.
This is driving me batty and I nee...

Problem with AuthenticationThe CRM application was running smooth. But now I can't logging. It ask my
credentials and than return a 401.1 error. I had already reinstalled the CRM
server but it won't work.
I'm accessing it in the same local network.
I'm running CRM 3.0 in SBS.
Best regards,
Erico
Hi
When you open a Internet explorer and type the name of the CRM server, it
prompts for user and password ?
Are you logged in with domain credentials ( AD user ) ?
If you are, so add url of the crm server in Local intranet.
Enable "Automatic logon only in intranet", this is under security,c...

Missing windowsHi
Can anyone let me know what I have to do to get the windows back that show's
the cell reference for where you are. This has gone missing along with the
window that's used to type the formula into
Sorry to be a pain on a triviality, but I can't find the answer anywhere
TIA
Steve
View>Formula Bar
The cell reference "window" is called the Name Box.
Also, you can type formulas into a cell, not only into the formula bar.
Gord Dibben MS Excel MVP
On Mon, 29 Jan 2007 21:29:57 -0000, "Steve" <sr2000{at}talk21{dot}com> wrote:
>Hi
>
>C...

Outlook 2007 and Windows 7After installing Office 2007 on Windows 7 machine, I get no new mail sound,
pop up notifications or the new unread mail icon in task bar. Every thing
else seems to work fine. Any hints?
are the icons in the overflow?
--
--
Diane Poremsky [MVP - Outlook]
Outlook Tips: http://www.outlook-tips.net/
Outlook & Exchange Solutions Center: http://www.slipstick.com/
Outlook Tips by email:
mailto:dailytips-subscribe-request@lists.outlooktips.net
EMO - a weekly newsletter about Outlook and Exchange:
mailto:EMO-NEWSLETTER-SUBSCRIBE-REQUEST@PEACH.EASE.LSOFT.COM
Poll: What v...

Vista blue screen problem...please help!
I've seen some other threads, here are the dump files:
'RapidShare: 1-CLICK Web hosting - Easy Filehosting'
(http://rapidshare.com/files/347103149/Minidump.rar.html)
Please, help me out here.
--
ceVil
It might be better to know at what point the bsod occurs and what the actual
err.msg given is
"ceVil" <guest@unknown-email.com> wrote in message
news:0b9a0c60b90bf6c0be88bda30f2820ab@nntp-gateway.com...
>
> I've seen some other threads, here are the dump files:
> 'RapidShare: 1-CLICK Web hosting - Easy Filehosting'
> (...

calendar problemDear all,
I am using both mail and calendar function in outlook 2002. Everything is
ok until recently, when I try to make a new appointment or checking any old
appointments, an error message "out of memory or resource, try to close some
windows..." pop up. The mail function is still ok. Can anyone tell me how
can I solve this? I have already installed sp2. The version of office is
the professional one with frontpage. Thanks.
tp
...

Window MailPlease help me to set up Windows Mail to retrive my gmail account
I got lost...
This newsgroup is for technical discussion of, and questions and answers
about, Microsoft Access database software. More than likely, if you lost
your account or password, you'll need to contact gmail directly. If your
question deals with how to enter account and password information into
Windows Mail, you should seek a newsgroup or online forum that deals with
Windows Vista or Windows 2010.
Larry Linson
Microsoft Office Access MVP
"Jabez" <olena.jabezfurniture@gmail.com> ...

problem #4Hi,
I am facing this new problem... i.e a user has installed Office 2003 on win2k prof platform.. whenever she is working on a outlook.. she gets a Microsoft error message... saying to send the report or don't send the report... Usually I have seen this problem in IE... But for outlook it is new to me... after clicking on send or don't send report.. the outlook closes. And there are no IE open..... and if atall it is open.. the IE does not close...
Need your help
regards,
KAH
What is logged to the Event Viewer regarding this?
Try one of the following already;
http://www.howt...

95 and 97 problemFor some unknown reason there is Excel 95 and 97 on this
pc.When i double click on an Excel file, the pc defaults
to the 95 program (Which incidently doesn't work properly).
So my question is how do i get the pc to default to 97.
Cheers Craig
Craig,
Have a look at Windows Help.
From Windows 2000 Help (Index under Programs Associating with File Types)
To change which program starts when you open a file
In My Computer or Windows Explorer, on the View menu, click Folder Options.
Click the File Types tab.
In the list of file types, click the one you want to change.
Click Edit.
In Act...

Outlook 2000 + Windows Xp on 2000 domainI have one user who has WinXP installed on his laptop.
He has Outlook 2000 connected to an exchange 5.5.
When logging into the network the logon script runs and
maps various network drives. However when logging into
Outlook he gets the exhcange login box. (Username, Domain,
Password.) The exchange setting in his profile is set to
NT Password Authentication. The account is not locked on
the server. If you enter the same details that were used
to log into the laptop Outlook will open and get connected
to the exchange server.
I cannot find anything on the internet about this problem
if an...

Importing Message ArchivalHello everyone,
I have turned on the message archival under IMS logging to for the purpose
of backup. I can open these file with notepad for administrative purposes,
but what I really need to do is to import these into a mail box or a pst
file so I can read them using outlook.
Any input is welcome,
Thanks.
Calvin wrote:
> Hello everyone,
>
> I have turned on the message archival under IMS logging to for the purpose
> of backup. I can open these file with notepad for administrative purposes,
> but what I really need to do is to import these into a mail box or a pst
&gt...

Date problemI can't believe there's no post on this, but I can't find it. I've
tried the solutions I could find (see below) and still get the error:
"The expression is typed incorrectly or it is too complex to be
evaluated. For example....Try simplifying...."
I have a date field, formatted as Date/Time, General Date, default
Value = Now().
I like having the date and the time - in case we need it.
I want to run a report on calls taken just for one day.
I have CallDate: CallDateAndTime in my query, with "criteria" as
Between ([Forms]![frmReports]![txtStartDate]) A...

sync problemsI have all of my info on an HP Ipac. I had to reformat
the hard drive and I did not make a back-up file. I am
trying to move everything back to the computer but it
says there is an error with syncing it.
How can I move everything from the PDA back to Outlook
again?
Please help- thanks
...

Office 2007 - HELPI have used Word for many years and love it - not too thrilled with the
changes in Office 2007, but my bigger issue is with Publisher 2007.
I have an image that I have used in Word just fine - meaning, the on screen
colors are correct and when printed the colors are correct.
Someone sent me a Publisher file and asked me to add the image - I did this
- now the image is messed up - the colors are correct on screen, but when
printed FROM MY computer the image colors are all wrong - but if I transport
the file to a different computer it prints fine
I have reinstalled Office - no good
Any id...

Installation Problem!!I am having a problem installing MSCRM 1.2.
My configuration consists of a Domain Controller running Win 2000
Server SP4 . I am trying to install MSCRM on a member of the domain running
Windows 2000 Server SP4. There is a DNS Server on the DC which is integrated
with AD, and a SQL Server 2000 running on the Win 2K machine.
The install errors out when CRM creates the root business with the message:
Setup was unable to install Microsoft CRM Server.
Setup was unable to provision your organization.
Setup was unable to create the root business.
The configuration of ASP.NET seems to be ok, the pr...

Extender-Create a new data entry windowIs it possible to create a new extender form or window (not sure of the
terminology) to enter data into Dynamics? Specifically the Sales Forecast
Window in Manufacturing is terrible for entering data, everytime you move to
the right, it the scrolling window jumps back to the top and you have to find
the item again.
Anyway, I would like a new window to enter a sales forecast, is this
possible?
thanks
--
Doug
Unfortunately Extender data is stored in Extender tables and cannot be stored
in the Sales Forecast tables. I agree with you that the data entry screen is
horrible. I am tal...

Directory Replication Problem #2Hi, recently my Exchange Server directory database
receives changes from other servers but does not send out
its own changes. Check from the knowledge base, to
correct the USN discrepancy need to use Authrest.exe
(need to amke changes for about 100+ users).
Does anybody know where to get this file 'Authrest.exe'
for exchange server 5.5? Exchange server 5.5 CD only
provide this file for ver.4.0. Have anyone use it before?
Regards,
"Sharon Tan" <sharon_tansk@yahoo.com.sg> wrote:
>Hi, recently my Exchange Server directory database
>receives changes from ot...

Outlook won't open after reinstalling it after installing WindowsMy computer crashed. I installed Windows 7, and then reinstalled Office 2007.
Outlook will not open.
Any suggestions?
Margye Hixson
Suggest providing information. Include what you did, what happened and any
and all error messages. Be detailed as if we weren't there and don't know
what happened.
--
Russ Valentine
"Margye" <Margye@discussions.microsoft.com> wrote in message
news:9F85CAAC-2042-4CAB-A329-EF6B3A682189@microsoft.com...
> My computer crashed. I installed Windows 7, and then reinstalled Office
> 2007.
> Outlook will not open....

Problems Creating a disclaimer in Exchange 2003I am trying to create a server based disclaimer that will stamp all of my smtp emails going to the internet. I have been following KB article 317680 with no luck. I get an error like the one below.
Binding Display Name Specified: smtpscriptinghost
** Registration Failed **
Err.Number (HRESULT) = 0x1AD
Err.Description = ActiveX component can't create object
ProgID = cdo.ss_smtponarrival
COM Category = {FF3CAA23-00B9-11d2-9DFB-00C04FA322BA}
Corresponding Event = onarrival
** Have you registered your sink COM class on this machine?
I am puttin...

Resource editor problemsHello all,
Under VC++ 7.1...
Please consider these two lines:
IDC_ARROW_ADD_CANCEL DISCARDABLE "res\\cur00004.cur"
IDC_ARROW_ADD_CANCEL CURSOR DISCARDABLE "res\\cur00004.cur"
The second is a hand-edited change to the first. Both will compile just fine
in the resource compiler. However, after I use a text editor to make this
change, I cannot open the .rc file in the resource editor. The resource
editor issues the following error open attempting to open the .rc file:
error RC2135 : file not found: CURSOR
Can anyone shed light on what's going on here?
Thanks,
Dave
...

Cell FormatI have a spreadsheet with cells that I'm trying to type
the date into. I type in the date exactly like this:
09/26/03. When I hit "enter" MS Excel displays "37890"
in the cell. No matter what I do I can't the cell to
show: 09/26/03. I think that somehow I need to "strip"
the cell of what it's original format is, but I can't
figure out how. I try to use the Date option in the
format cell screen but it doesn't work.
Curtis
I tried this and it didn't work. I also tried the "Text
to columns" feature. No success.
&gt...