|
I put a break point where my dialog class calls the UpdateRegRules method. I step through that method and everything seems copacetic. If I hit f5, I seem to hang.
I'm totally guessing on the endless looping. I'm actually stumped. I've never used PostMessage before and I'd be willing to bet that that's the root of the problem...
|
|
|
|
|
If you hit F5 and you're creating an endless message loop, you should find yourself hitting the same spot over and over. You can also override PreTranslateMessage to see if this is in fact occuring.
The difference between SendMessage and PostMessage is just that PostMessage sends the message when the current function ends, SendMessage does it right away.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Not really, PostMessage posts the message to the message queue and returns immediately, SendMessage sends the message to the message pump and waits till it gets processed.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Try out with SendMessage instead of PostMessage
<bold>- Nilesh
<italics>"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
You guys ROCK! Thanks so much! SendMessage fixed the problem. I don't think I understand why sending the message right away fixed the problem though. Some crazy timing thing?
I actually thought the difference was that PostMessage added the message to the message queue and SendMessage bypassed the queue (at least that's how someone else explained it to me).
Thanks again, to both of you for your excellent help!
-Ian
|
|
|
|
|
Well you are right about the difference between SendMessage and PostMessage but there is one more thing to be noted that PostMessage as it goes in queue is a blocking call, but it is not the case with SendMessage
<bold>- Nilesh
<italics>
"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
You've been so helpful I hesitate to ask another question...
What is a blocking call?
|
|
|
|
|
<code>
void function1()
{
PostMessage();
//this message box would get displayed only when the lengthy operation of
//ReceiverOfPostMessage function gets over, This is called a blocking call
AfxMessageBox("");
SendMessage();
//this message box would immediately get displayed and would not wait for the
//operation of ReceiverOfPostMessage to get over
AfxMessageBox("");
}
void ReceiverOfPostMessage()
{
//execute a lengthy operation
}
</code>
Hope that's clear
<br></br>
<bold>- Nilesh</bold>
<italics>
"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
</italics>
|
|
|
|
|
Ahhh. I didn't realize you were talking about synchronous VS asynchronous. You explained it perfectly.
Thanks again for all your help! I hope I get the chance to return the favor someday...
-Ian
|
|
|
|
|
Thanks
Glad to be of help
<bold>- Nilesh
<italics>
"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
Nilesh K. wrote:
PostMessage();
//this message box would get displayed only when the lengthy operation of
//ReceiverOfPostMessage function gets over, This is called a blocking call
AfxMessageBox("");
SendMessage();
//this message box would immediately get displayed and would not wait for the
//operation of ReceiverOfPostMessage to get over
AfxMessageBox("");
Are you jokin!, have you consulted MSDN before writing difference between PostMessage and SendMessage Here! or try to run above code in your compiler!
The Defination is actually reverse!, SendMesssage Block the call and PostMessage Return immedietly.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Your are right, thanks for correcting!!
<bold>- Nilesh
<italics>
"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
Nilesh K. wrote:
Your are right, thanks for correcting!!
Sorry for my RUDE Comments!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
It's SendMessage that's blocking, PostMessage returns immediately after posting a message to the message queue. There's more to it, though, take a look at this article (www.codeproject.com/csharp/begininvoke.asp[^]), in particular the "message queues and message pumping" section.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
My guess is that posting the messages is causing the message pump to process it again. That causes CMyEdit::onkeyup to execute again which again posts a message to the message pump and so on.
SendMessage from within the UI thread directly calls the WndProc of the dialog and so it executes correctly.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
I have a program that has many windows that need to be displayed. I am using MFC for the windows. I need to be able to dynamically update the windows from within the program. But I would like them to be displayed in a tab/dockable window fashion. However I can't figure out when you create the window as a property sheet of CFormView how to get access to the object that is created because they have to be created as CRuntimeClass.
Currently for example I just have a bunch of modeless dialog boxes that I instantiate directly and have objects for that I can just call set routines to manipulate the display. I would like to to the same thing just without using modeless dialogs, but CFormview or something similar.
|
|
|
|
|
When I click on the application window's Close X button, it calls my OnClose method. In OnClose, I prompt the user to save the data before closing the application. If the user cancels, I would like the application to remain open as in Microsoft Word, Excel, etc. How do I go about doing this? Thanks.
|
|
|
|
|
don't call the base method, and if the function returns a boolean, return true ( which tells the system you've handled the message, no further processing required ).
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
You can also disable the Close X button of a CWnd derived-object by using CWnd::GetSystemMenu and CMenu::EnableMenuItem on the menu item SC_CLOSE .
For example:
m_MyWndFrame.GetSystemMenu(FALSE)->EnableMenuItem(SC_CLOSE, MF_DISABLED);
|
|
|
|
|
I have a co-worker that created an form in Access 2000. In order to use it every where I need to install MS Access 2000. How can I show this form in MFC and allow the end user to use it without having to install MS Access 2000 on all PC's?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Tom Wright wrote:
I have a co-worker that created an form in Access 2000. In order to use it every where I need to install MS Access 2000. How can I show this form in MFC and allow the end user to use it without having to install MS Access 2000 on all PC's?
Sadly you can't. Access forms require MS Access to be installed (or at least the Access Runtime). If you have the correct licencing you can redistribute the MS Access runtime.
Michael
CP Blog [^] Development Blog [^]
|
|
|
|
|
I have come across a function that looks like a member function being called but there is no class being declared before it, just the two '::'. How does this work?
Thank-you
|
|
|
|
|
It only means that myFunc isn't in a namespace ("no_namespace"::myFunc).
|
|
|
|
|
It means that the function is part of global namespace.
<bold>- Nilesh
<italics>
"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
i'd like to add a little precision... there are 2 scope operators
- the class scope (class::member )
- the global scope (::global_obj )
cheers,
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|