Thread: MDIchildedit window functions

  1. #1
    Registered User
    Join Date
    Jan 2004
    Posts
    4

    Smile MDIchildedit window functions

    Not sure if this is a sock problem or a windows problem. Have two programs. 1 server and 1 client. Run both. Client

    connects to server fine. Client has edit box. Text is placed in edit box and hit send button. Here is problem. Only 4

    characters are transmitted or written to the server message box.

    Code:
    case CLIENT_BUTTON_SEND:
    						{
    							GetWindowText(Client_Edit_Message, Buffer, sizeof(Buffer));
    
    							SendtoServer(Buffer);
    						break;
    						}
    char Buffer[50];

    Here is server listen

    Code:
    void ReceivefromClient()
    {
    	char ReceiveBuffer[50];
    
    	while (bRunning)
    	{
    		if (!bClient)
    			continue;
    
    		if (recv(Client, ReceiveBuffer, sizeof(ReceiveBuffer), 0) == SOCKET_ERROR)
    			continue;
    
    		MessageBox(NULL, ReceiveBuffer, "Message", MB_OK); //Message Received
    	}
    }

    Here is second question kind of related. When I use MDI child edit window in function what is the best way to set it

    up? First problem is when I make funcion I have to pass HWND hwnd and everything to funcion because it goes out of

    scope. Second consern is do I pass the drawtext() or settext() to the MDIchild edit control or directly to MDI child

    window?

    Code:
    int testfunction(HWND hwnd) What else should be passed here? hMDIclient? hEdit? (plus pointer to message)
    {
       char childedittext[222];
       char joinedtext[222];
    
      childedittext = getwindowtext(...hchildedit , text , sizeof(text) ...
    
       // do something with text... 
        // this example add passed message to mdichildedit text
    
        joinedtext = strcat( childedittext , message );
    
       // will do other things with function like add more text to child window 
    
       drawtext(hMDIclient, &joinedtext , sizeof(joinedtext)... ); // or use hEdit to send text to edit control?
    
    updatewindow()
    }
    
    ...
    
    
    LRESULT CALLBACK MDIChildWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    {
    	switch(msg)
    	{
    	  ...
    
                 		}
    		break;
    		case WM_COMMAND:
    			switch(LOWORD(wParam))
    			{
                              ...
                                   case ID_MENUITEM1:
    
                                        testfunction("pass this text to addon to edit child window existing text");
    
    
    
                                  }
                                   break;
    
    ...
    The above code may not be correct or functional it is just to give you idea of what I am trying to do. I did look for

    other related threads to no avail. Sadly the two above examples client and server are from ms library.
    kat

  2. #2
    Registered User
    Join Date
    Jan 2004
    Posts
    4

    edit

    i have been looking over the draw text threads to see if there is any thing that might help regarding child windows and edit boxes.

    let me try asking the question "is there a better way to set up a text edit in a child window?"

    drawtext(hMDIclient, &joinedtext , sizeof(joinedtext)... ); // or use hEdit to send text to edit control?

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    I suspect you are using sizeof(Buffer) somewhere that Buffer has degraded to a pointer, probably in SendToServer(). This is equivalent to sizeof(char *) which is 4. Use strlen().

    Otherwise, post the SendToServer() function.

    I'm not sure I understand your second problem, but I'll try.

    Code:
    drawtext(hMDIclient, &joinedtext , sizeof(joinedtext)... );
    // or use hEdit to send text to edit control?
    If you want the text in an edit control, yes use SetWindowText with hEdit.

    There are multiple problems with this line of code.

  4. #4
    Registered User
    Join Date
    Jan 2004
    Posts
    4
    Oh wow.

    I suspect you are using sizeof(Buffer) somewhere that Buffer has degraded to a pointer, probably in SendToServer(). This is equivalent to sizeof(char *) which is 4. Use strlen().
    i see and did not reconize that is what happened.

    second when i enter drawtext( dc here... it did not reconize any thing that i put there. the compile error when i put drawtext() in the function was unreconized symbol. That was when i knew i had to pass which ever dc to the function. i could not decide which was the best way to set the function up. thank you for your suggestion.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  2. how i create a window whith all it's elements
    By rasheed in forum Windows Programming
    Replies: 1
    Last Post: 05-31-2006, 06:53 PM
  3. Button handler
    By Nephiroth in forum Windows Programming
    Replies: 8
    Last Post: 03-12-2006, 06:23 AM
  4. Window scrollbar
    By maxorator in forum Windows Programming
    Replies: 2
    Last Post: 10-07-2005, 12:31 PM
  5. Problem with creating new window, from another window
    By Garfield in forum Windows Programming
    Replies: 6
    Last Post: 01-11-2004, 02:10 PM