-
December 10th, 2010, 01:52 AM
#1
Updating text in dialog box when it's inactive
Hello there,
I've been trying to create a little IM client, for my own server. And I'm using a dialog box, with 2 edit boxes, one is read only for the output text and the other one is writable for input text to send over IM to the other client. My sockets and everything work fine, I can receive/send text. The only problem is that whenever the dialog box is inactive the output edit box does not get updated with the new text messages that I have been receiving, unless I move the mouse over the dialog box and activate it, it will display the text. Here is some code, just a basic while loop for the WINAPI.
Code:
while (status = GetMessage (& msg, 0, 0, 0)) {
char buffer[256];
if(udpSocket->ReceiveFrom(buffer) == true) {
udpSocket->SendMsg(buffer, 0); // send the received message to the output window
}
if (msg.message==WM_KEYDOWN && msg.wParam==VK_RETURN) {
char lpString[256];
GetDlgItemText(hDialog, IDC_EDIT2, lpString, 252);
SetDlgItemText(hDialog, IDC_EDIT2, 0);
if(strlen(lpString) != 0) {
udpSocket->UdpSend(lpString); // send the text to the server
}
}
if (!IsDialogMessage (hDialog, & msg))
{
TranslateMessage ( & msg );
DispatchMessage ( & msg );
}
Sleep(10);
}
-
December 10th, 2010, 06:07 PM
#2
Re: Updating text in dialog box when it's inactive
Originally Posted by typedef
... The only problem is that whenever the dialog box is inactive the output edit box does not get updated with the new text messages that I have been receiving, unless I move the mouse over the dialog box and activate it, it will display the text.
Try putting UpdateWindow(hWnd) into your code where you want the window to update.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|