CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2010
    Posts
    1

    Angry 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);
    	}

  2. #2
    Join Date
    Apr 2010
    Location
    Western WA, USA
    Posts
    59

    Re: Updating text in dialog box when it's inactive

    Quote Originally Posted by typedef View Post
    ... 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
  •  





Click Here to Expand Forum to Full Width

Featured