|
As i have understood the message loop dispatches messages synchronously.i.e it executes the handler to that message and then moves to another message .
Also ,Sendmessage(MESSAGE1) call is synchronous i.e. it executes the handler for MESSAGE1 and then returns.
WIth this assumption ,iam posting this question.
Let's say i have handled the KEYDOWN message as OnKeyDown().
I do this
OnKeyDOwn()
{
SendMessage(WM_MOUSEMove...)
}
Iam expecting that SendMessage() as opposed to PostMessage should create a deadlock as it executes synchronously-Its trying to execute /put the message in the same loop from where it was called .But it does not happen .Can Somebody explain this ?
Does this mean SendMessage() does not post the message in the message loop ,but directly calls WndProc() or something like that ?
Cause is my effort;
Effect is God's effort
-- modified at 0:48 Tuesday 22nd November, 2005
|
|
|
|
|
Hi,
Try SendMessageTimeOut()
Bye
Cool Ju
Dream Ur Destiny
|
|
|
|
|
My question was that i expected an dead lock but it did not happen .I just wanted to understand whats really happening behind the scenes of Send Message()
ANyway ,Thanks !
Cause is my effort;
Effect is God's effort
|
|
|
|
|
Hi,
hope this answers ur question
If the specified window was created by the calling thread, the window procedure is called immediately as a subroutine. If the specified window was created by a different thread, the system switches to that thread and calls the appropriate window procedure. Messages sent between threads are processed only when the receiving thread executes message retrieval code. The sending thread is blocked until the receiving thread processes the message. However, the sending thread will process incoming nonqueued messages while waiting for its message to be processed. To prevent this, use SendMessageTimeout with SMTO_BLOCK set. For more information on nonqueued messages
WM_KEYDOWN is a non-queued message.
Bye
Cool Ju
Dream Ur Destiny
|
|
|
|
|
Thanks !!That does answer my question .
Cause is my effort;
Effect is God's effort
|
|
|
|
|
Hello, everyone!
I want to add a PropertyPage into a dialog, not PropertySheet,
How can I do?
Thanks a lot!
|
|
|
|
|
I believe a page is just another dialog with its child property set to TRUE . If you just want to add a child to the main dialog, then create the child using Create(IDD_DIALOG1, this); and ShowWindow(SW_SHOW); Of course without title bar and border. Then position the dialog to any position you like on the parent using MoveWindow() , or SetWindowPos() .
this is this.
|
|
|
|
|
I'm writing two programs, one in c++ and one in c#. These programs need to talk to each other. I can settle on just the c++ program sending the messages, if that is simpler. The c++ program will be telling the c# program to take a picture from a webcam or to start a live feed. I am aware of the createprocess method, but I need something more flexible. Are sockets my only solution? Am I over looking another option? All I really need is a simple one way communication channel.
Thanks
Roy K
|
|
|
|
|
What about (named) pipes?
|
|
|
|
|
Roy K wrote: The c++ program will be telling the c# program to take a picture from a webcam or to start a live feed.
If you both of Program Lie on same computer and you just have to send command to each other then simple Window messaging would be also be both simple and great idea... i.e. Send userdefined messgae
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi,
I need to show some messageboxes (derived from CDialog) from some threads.
The parent window need to be disabled at that time. I disabled the parent window (whenever the messagebox is shown) using EnableWindow(FALSE).
But when any of the messageboxes is closed, the parent becomes enabled. The parent must be disabled until the last messagebox is closed.
What is the solution for this case?
Thank you.
- NS -
|
|
|
|
|
One ugly solution could be:
Declare a variable in the main dialog:
int m_nNoOfChildren;
Set it to -1 in the constructor.
Run a timer using SetTimer(2,200,NULL); etc.
Check the variable in the OnTimer() function. If it is -1, return, if it is greater than zero, disable the main wnd, if zero, enable it.
When a child dialog is created, call a member function:
void ChildCreated()<br />
{<br />
if (m_nNoOfChildren == -1)<br />
m_nNoOfChildren = 1;<br />
else<br />
m_nNoOfChildren++;<br />
}
When a child is destroyed, decrement the variable.
this is this.
|
|
|
|
|
Thank you.
But I can't use a solution like this (watchdog timer) because it is not allowed in my project.
I hooked the window proc of parent and checked for the wm_enable message. If message comes I disable the parent and return. The parent is now at disabled state, but it looks like as an active window. When I just click on it, it become inactive and the focus is changed to one of the messagebox.
A solution to transfer the focus to the message box that is currently active, is needed now...
- NS -
|
|
|
|
|
Couldn't you use SendMessage() to the main window, and then use SetFocus() from inside the child dialog?
this is this.
|
|
|
|
|
Sorry, I didn't get what you meant!
- NS -
|
|
|
|
|
I meant when you create the child dialog, send the message to disable the main wnd: SendMessage(WM_ENABLE, ...);
And after that, SetFocus(); //sets focus to this window.
Would it work? I haven't tested.
this is this.
|
|
|
|
|
Actually the problem is not related to disablng the parent when the dialog comes. It becomes active when the default windows message box comes and close it by the user. I think the windows message box will enable its parent. So I have to block the enabling of parent when there is my dialogs (message dialog) exist.
- NS -
|
|
|
|
|
Modal dialog boxes are an automatic solution.
<marquee direction="up" height="30" scrolldelay="1" step="1" scrollamount="1" hspace="0" vspace="0">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
As they are come from thread it had no good.
- NS -
|
|
|
|
|
How to change CEdit's background color and text color? thanks.
|
|
|
|
|
If you want to do this inside a dialog box handle the WM_CTLCOLOR message.
Another option is using message reflection. Try to sub class the CEdit and handle the ON_WM_CTLCOLOR_REFLECT message.
<marquee direction="up" height="30" scrolldelay="1" step="1" scrollamount="1" hspace="0" vspace="0">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
I want to display value of one var in a progress to status bar immediatly by SendMesage(). How to di this ?
Please help me,
thank.
|
|
|
|
|
What you should do is run your process in another thread, otherwise your core problem is that your status bar won't update itself until your other task finishes.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I would assume you are using MFC.
If you are doing the processing inside CMainFrame, then you could simply use:
m_wndStatusBar.SetPaneText(Pane_No, "New Text");
If you are using the View, then use a user-defined message to send to CMainFrame. You can use resource.h and define your message id:
#define WM_MY_SETTEXT 3020
And include resource.h in mainframe.
From the View, send the message away:
AfxGetApp()->GetMainWnd()->SendMessage(WM_MY_SETTEXT,0,(LPARAM)"Hello old man");
In mainframe.h, declare your own message handler:
LRESULT OnMyMessage(WPARAM, LPARAM);
In mainframe.cpp, include your function in the message-map macro:
...<br />
ON_MESSAGE(WM_MY_SETTEXT,OnMyMessage)<br />
END_MESSAGE_MAP()
Then later in mainframe.cpp, implement it:
LRESULT CMainFrame::OnMyMessage(WPARAM, LPARAM lParam)<br />
{<br />
TCHAR* pS = (TCHAR*)lParam;<br />
TCHAR ss[200];<br />
strcpy(ss,pS);<br />
m_wndStatusBar.SetPaneText(0,ss);<br />
return 0;<br />
}
this is this.
|
|
|
|
|
CStatusBar class has a method called SetPaneText(). You can use that.
For eg:
CStatusBar s;//Your status bar
s.SetPaneText(nIndex, "Caption", TRUE);
This is another option.
<marquee direction="up" height="30" scrolldelay="1" step="1" scrollamount="1" hspace="0" vspace="0">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|