Nothing is done till either task switch or mouse over

Started by
5 comments, last by MaxxJag 20 years, 1 month ago
My problem is that I''m trying to code a kind of Messenger/ICQ program and the windows don''t add the text received until the user puts either mouse over the window (main or chat) or switches to them. my question is, how do you make the program run in background so I can get that window to flash on message arrival?
Advertisement
To flash the window, use the FlashWindow function. Your apparent problem is that you aren''t doing any processing without handling a window message, so why not define a user message (WM_USER + offset) and have that sent whenever a message arrives? Or something.
As far as I can tell, that''s not the issue. I check for incoming on the windows socket in a while loop that, as far as I can tell doesn''t stop going thru even without any messages being sent. As for the flashwindow, I knew about that I just need to check why the window doesn''t do anything until I do something. You might be right about the message thing though, I just can''t find out where that might be.
        while (GetMessage(&msg, NULL, 0, 0)) 	{//		if (CheckWindows(&msg))//			continue;		CheckIncoming (hWnd);		if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))		{			TranslateMessage(&msg);			DispatchMessage(&msg);		}	} 


this is the main loop. CheckIncoming checks the winsock buffer for any received stuff, now I'm not too sure about the rest since I've only begun the Windows API programming.

[edited by - MaxxJag on April 3, 2004 12:52:40 PM]
Ah. See, GetMessage blocks until a window message arrives - so your CheckIncoming won't get called until you move the mouse or click on something. Try this instead:
while( true ){  CheckIncoming(hwnd);  if( PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) &&      !TranslateAccelerator(msg.hwnd, hAccelTable, &msg) )  {    TranslateMessage(&msg);    DispatchMessage(&msg);  }  Sleep(0);  // play nice with other apps}

[Edit: Left out TranslateAccelerator.]

[edited by - Oluseyi on April 3, 2004 2:05:17 PM]
You could also use WSAAsyncSelect().
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
Thanks for the help, should work now.

This topic is closed to new replies.

Advertisement