|
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
|
|
|
|
|
Anyone able to get boost compiled with VC8? If so...what did you do, how ...etc?
ed
~"Watch your thoughts; they become your words. Watch your words they become your actions.
Watch your actions; they become your habits. Watch your habits; they become your character.
Watch your character; it becomes your destiny."
-Frank Outlaw.
|
|
|
|
|
I've torn out what little hair I have on this.
I'm using VS 2005 Beta in case it makes a difference.
I create a new Dialog-based MFC App.
I put a picture control on it (CStatic with frame style).
I align a couple of scrollbars to the frame edge.
(I gave up trying to get the inherent CWnd scrollbars to work, but they behave the same.)
I try to code behind the scrollbars with calls to:
- SetScrollInfo()
- EnableScrollBar()
- ShowScrollBar()
( slightly different functions are required for the CWnd scrollbars)
The effects of SetScrollInfo() can be seen in the thumb size, and the ShowScrollBar() works as expected. But do you think I can actually get the scroll bar to do anything -- let me move the thumb, or trip my breakpoint in the OnVScroll() handler I have waiting to pounce?
I can't see the magic secret in any projects I've downloaded. Help!
|
|
|
|
|
What's more, in the resources, the scrollbars show in a nice Windows XP style. When the app runs, they are flat and ugly. Hmmm. If there is someone out there that can take 5 mins to do this in both VS 2005 Beta and VS 2003, and find that I'm beating my head against a bug in VS 2005 Beta, that would at least be partial relief!
|
|
|
|
|
Jamaica wrote: But do you think I can actually get the scroll bar to do anything -- let me move the thumb, or trip my breakpoint in the OnVScroll() handler I have waiting to pounce?
The image is most certainly not going to move by itself, you need to write your OnPaint handler to show the image based on the scroll position, then call Invalidate() when a scroll event fires. You say you've got one, there's obviously a problem with it being hooked up at this point in time, if it's not fired.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
What you say is all true... but has not advanced my cause
There certainly is a hidden problem here. I've read the entire CScrollBar documentation several times, satisfied myself (e.g. by calling SetScrollPos()) that the scrollbar is just itching to be useful to me. The main problem appears to be getting any messages to or from it. There are handlers for WM_HSCROLL and WM_VSCROLL in the dialog containing the frame and scrollbars... but they simply don't respond, and nor do the scrollbars themselves. I get the sense I'm going to shoot myself when I discover how simple the answer is....
|
|
|
|
|
Jamaica wrote: What you say is all true... but has not advanced my cause
*grin* I'm sorry, without looking at the code, that's about all could offer.
Jamaica wrote: There are handlers for WM_HSCROLL and WM_VSCROLL in the dialog containing the frame and scrollbars... but they simply don't respond, and nor do the scrollbars themselves.
I have vs2005 final, and I created an MFC app, added a scroll bar and a message handler, and it fired fine. Why don't you create a new app that just does those things and see if it works ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Is it just me, or do you consider code like the following to be somewhat overkill or wasteful for testing for an empty string...
if( 0 == stricmp(szString, "") ){
or
if( 0 == strlen(szString) ){
when I think it is sufficient to merely do this:
if( !szString[0] ){
What are some of your opinions on this matter?
|
|
|
|