Click here to Skip to main content
15,886,919 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Visual C++ Express receiving a custom message Pin
martinmos23-Jul-11 22:53
martinmos23-Jul-11 22:53 
GeneralRe: Visual C++ Express receiving a custom message Pin
Albert Holguin25-Jul-11 4:07
professionalAlbert Holguin25-Jul-11 4:07 
GeneralRe: Visual C++ Express receiving a custom message Pin
martinmos25-Jul-11 11:12
martinmos25-Jul-11 11:12 
GeneralRe: Visual C++ Express receiving a custom message Pin
Albert Holguin25-Jul-11 12:30
professionalAlbert Holguin25-Jul-11 12:30 
AnswerRe: Visual C++ Express receiving a custom message Pin
Mark Salsbery23-Jul-11 12:29
Mark Salsbery23-Jul-11 12:29 
GeneralRe: Visual C++ Express receiving a custom message Pin
martinmos23-Jul-11 20:42
martinmos23-Jul-11 20:42 
GeneralRe: Visual C++ Express receiving a custom message Pin
Mark Salsbery23-Jul-11 21:07
Mark Salsbery23-Jul-11 21:07 
GeneralRe: Visual C++ Express receiving a custom message Pin
martinmos24-Jul-11 1:08
martinmos24-Jul-11 1:08 
I know nothing about threads yet.
I identify the window of the app to send the message to using FindWindow. I do that at the start of the program before the message loop starts but after the form has been created. Then I send a message to the window and the message contains the handle of the form in my C++ program. The app receiving the message displays the handle in a label so I can see it's worked ok. Then on the other app I have a button, when I click the button to test sending a message back a message is sent back to the C++ app using the window handle that was given. My C++ app recieves the massage ok every time I press the button. But if I set a global int to some value, say 7, when I receive the message, and in my main loop I send a message back if the int is some value, say 7, then the message is sent ok but no more messages are received in my winproc although the other app thinks they are sent ok but the return value is zero whereas in my winproc function I return 76.

My main loop is like this, modified so that it continually loops and doesn't hang waiting for a message. Maybe this is a bad idea?

<pre> // Main message loop:
while (1)
{ switch (msgin)
{ case 7:
SendMessage(hAuWiiWin,wiimsg,4,6);//4, 6 has no signifance at moment, just a test
msgin = 0;
//break;//seems break not allowed on last case?
}

if (PeekMessage(&msg,NULL,0,0,0))//so loop will continue if no msg
{GetMessage(&msg,NULL,0,0);
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

}
Sleep(20);//don't know if this is good idea
}
</pre>

My winproc is like this

<pre>LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;

if (message == wiToMeCommand)
{
//ignore lParam, wParam for moment
msgin = 7;//set global int which is checked in main loop
//SendMessage(hMyWind,WM_CLOSE,0,0);//that works and this app closes
return 76;//just some value to indicate we got the msg
}
else
switch (message)
{
case WM_COMMAND:</pre>
GeneralRe: Visual C++ Express receiving a custom message Pin
Richard MacCutchan24-Jul-11 1:25
mveRichard MacCutchan24-Jul-11 1:25 
GeneralRe: Visual C++ Express receiving a custom message Pin
martinmos24-Jul-11 5:37
martinmos24-Jul-11 5:37 
QuestionC program to start before windows boot Pin
ayandelhi23-Jul-11 4:31
ayandelhi23-Jul-11 4:31 
AnswerRe: C program to start before windows boot Pin
Richard MacCutchan23-Jul-11 6:22
mveRichard MacCutchan23-Jul-11 6:22 
AnswerRe: C program to start before windows boot Pin
Rajesh R Subramanian23-Jul-11 6:56
professionalRajesh R Subramanian23-Jul-11 6:56 
GeneralRe: C program to start before windows boot Pin
Albert Holguin23-Jul-11 8:07
professionalAlbert Holguin23-Jul-11 8:07 
AnswerRe: C program to start before windows boot Pin
ayandelhi23-Jul-11 22:11
ayandelhi23-Jul-11 22:11 
GeneralRe: C program to start before windows boot Pin
Richard MacCutchan23-Jul-11 22:26
mveRichard MacCutchan23-Jul-11 22:26 
GeneralRe: C program to start before windows boot Pin
ayandelhi24-Jul-11 1:03
ayandelhi24-Jul-11 1:03 
GeneralRe: C program to start before windows boot Pin
Randor 24-Jul-11 1:04
professional Randor 24-Jul-11 1:04 
GeneralRe: C program to start before windows boot Pin
ayandelhi24-Jul-11 1:10
ayandelhi24-Jul-11 1:10 
AnswerRe: C program to start before windows boot Pin
Stefan_Lang24-Jul-11 23:14
Stefan_Lang24-Jul-11 23:14 
GeneralRe: C program to start before windows boot Pin
ayandelhi25-Jul-11 1:02
ayandelhi25-Jul-11 1:02 
AnswerRe: C program to start before windows boot Pin
cmk25-Jul-11 8:44
cmk25-Jul-11 8:44 
AnswerRe: C program to start before windows boot Pin
Ni740826-Jul-11 2:01
Ni740826-Jul-11 2:01 
GeneralRe: C program to start before windows boot Pin
ayandelhi26-Jul-11 3:24
ayandelhi26-Jul-11 3:24 
QuestionProblems with structures Pin
rahul.kulshreshtha22-Jul-11 20:45
rahul.kulshreshtha22-Jul-11 20:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.