Click here to Skip to main content
16,005,473 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Message Loop Pin
Naveen16-Aug-07 21:05
Naveen16-Aug-07 21:05 
GeneralRe: Message Loop Pin
baerten16-Aug-07 21:13
baerten16-Aug-07 21:13 
GeneralRe: Message Loop Pin
Naveen16-Aug-07 21:17
Naveen16-Aug-07 21:17 
GeneralRe: Message Loop Pin
Stephen Hewitt16-Aug-07 22:26
Stephen Hewitt16-Aug-07 22:26 
GeneralRe: Message Loop Pin
baerten16-Aug-07 22:42
baerten16-Aug-07 22:42 
QuestionRe: Message Loop Pin
David Crow17-Aug-07 4:06
David Crow17-Aug-07 4:06 
GeneralRe: Message Loop Pin
Naveen16-Aug-07 22:47
Naveen16-Aug-07 22:47 
GeneralRe: Message Loop Pin
Stephen Hewitt19-Aug-07 14:46
Stephen Hewitt19-Aug-07 14:46 
You don't need a window to have a message loop. The existence of the PostThreadMessage[^] function should hint at this: it sends a message but takes no window handle. The simple test application which follows proves the point:
// MessageLoopNoWindow.cpp : Defines the entry point for the console application.
//
 
#include "stdafx.h"
#include <windows.h>
#include <iostream>
#include <conio.h>
 
int main(int argc, char* argv[])
{
	using namespace std;
 
	DWORD idUs = GetCurrentThreadId();
	PostThreadMessage(idUs, WM_APP, 0, 0);
 
	MSG msg;
	while (GetMessage(&msg, NULL, 0, 0))
	{
		if (msg.message == WM_APP)
		{
			cout << "Got message but have no window!" << endl;
			PostQuitMessage(0);
		}
	}
 
	cout << "Press any key...";
	_getch();
 
	return 0;
}


In short: messages are sent to threads or windows (and windows are always ownded by a particulat thread) ; message pumps process messages for a particular thread.


Steve

QuestionNo effect Pin
baerten16-Aug-07 23:12
baerten16-Aug-07 23:12 
AnswerRe: No effect Pin
Naveen16-Aug-07 23:30
Naveen16-Aug-07 23:30 
AnswerRe: Message Loop Pin
Gary R. Wheeler18-Aug-07 3:44
Gary R. Wheeler18-Aug-07 3:44 
JokeThanks at you all! Pin
baerten19-Aug-07 21:04
baerten19-Aug-07 21:04 
QuestionConvert CString to const unsigned short * Pin
__yash__16-Aug-07 20:38
professional__yash__16-Aug-07 20:38 
AnswerRe: Convert CString to const unsigned short * Pin
KarstenK16-Aug-07 20:48
mveKarstenK16-Aug-07 20:48 
GeneralRe: Convert CString to const unsigned short * Pin
__yash__16-Aug-07 20:55
professional__yash__16-Aug-07 20:55 
GeneralRe: Convert CString to const unsigned short * Pin
KarstenK16-Aug-07 21:22
mveKarstenK16-Aug-07 21:22 
GeneralRe: Convert CString to const unsigned short * Pin
Naveen16-Aug-07 21:25
Naveen16-Aug-07 21:25 
GeneralRe: Convert CString to const unsigned short * Pin
__yash__16-Aug-07 22:08
professional__yash__16-Aug-07 22:08 
AnswerRe: Convert CString to const unsigned short * Pin
Naveen16-Aug-07 20:52
Naveen16-Aug-07 20:52 
AnswerRe: Convert CString to const unsigned short * Pin
Suneet.0316-Aug-07 22:47
Suneet.0316-Aug-07 22:47 
GeneralRe: Convert CString to const unsigned short * Pin
Suneet.0317-Aug-07 0:04
Suneet.0317-Aug-07 0:04 
QuestionUTF-8 and MultiByte Pin
sandeepkavade16-Aug-07 20:11
sandeepkavade16-Aug-07 20:11 
AnswerRe: UTF-8 and MultiByte Pin
Hans Dietrich17-Aug-07 1:05
mentorHans Dietrich17-Aug-07 1:05 
AnswerRe: UTF-8 and MultiByte Pin
Nemanja Trifunovic17-Aug-07 1:40
Nemanja Trifunovic17-Aug-07 1:40 
GeneralRe: UTF-8 and MultiByte Pin
jhwurmbach17-Aug-07 3:02
jhwurmbach17-Aug-07 3:02 

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.