Hello! I'm using a custom WM_MYCUSTOM message to send chars received by a thread to my Dialog using PostMessage(). Each char is sent as parameter of that message.
Now, during elaboration of that message I need to know how many times the same char value was received.

So, I'm trying to "walk through" the message queue to count the WM_MYCUSTOM messages that have a lparam wanted, removing those messages.
Code:
UINT MyDlg::privGetNumCharsInQueue(CHAR c)
{
	MSG msg;
	UINT count = 0;
	UINT n = 0;

	while( PeekMessage( &msg, this->m_hWnd, WM_CUSTOMMESSAGE_RECEIVED_CHAR, WM_CUSTOMMESSAGE_RECEIVED_CHAR, PM_NOREMOVE ))
	{
		if( msg.lParam == c )
		{
			count++;
			PeekMessage( &msg, this->m_hWnd, WM_CUSTOMMESSAGE_RECEIVED_CHAR, WM_CUSTOMMESSAGE_RECEIVED_CHAR, PM_REMOVE );
		}
	}
	return count;
}
The problem is that it seems not possible to use PeekMessage() because it returns the first wanted message in the queue, always. If this message is WM_MYCUSTOM but has a wrong lparam, it must remain in the quque and peekmessage will return it again in the next call....

I think I should use different WM_ IDs for each char I need to find....but I'd like to know if there's a better way.

Thank you all.