Copying Texts from Edit Boxes.

This is a discussion on Copying Texts from Edit Boxes. within the Windows Programming forums, part of the Platform Specific Boards category; I have the following code Code: HWND DialogBoxH; //Get the info on the Edit Box int len = GetWindowTextLength(DialogBoxH=GetDlgItem(hwnd, IDC_EDIT2));//Use ...

  1. #1
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427

    Copying Texts from Edit Boxes.

    I have the following code

    Code:
    
    	HWND DialogBoxH;
    	
    	
    	//Get the info on the Edit Box
    
    	int len = GetWindowTextLength(DialogBoxH=GetDlgItem(hwnd, IDC_EDIT2));//Use GetDlgItem(hwnd, IDC_TEXT)
    															  //to get a handle to the 
    															  //Edit Box
        if(len > 0)//if it's more than zero, meaning it has characters
        {
            
            char* buf;
    
            buf = (char*)GlobalAlloc(GPTR, len + 1);//we add one here for the null 
            GetDlgItemText(hwnd, IDC_EDIT2, buf, len + 1);//get the text from the edit box
    		memcpy(Cliente.ClientName,buf, sizeof buf); //copy the text from buf to the struct
    		
    		MessageBox (DialogBoxH, Cliente.ClientName,"Something", MB_OK);
    		
            //... do stuff with text ...
    
            GlobalFree((HANDLE)buf);
        }

    Why is it that MessageBox doens't print out the whole thing I type on the Edit Box, but only about the first 4 characters.....anyone?
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

  2. #2
    left crog... back when? incognito's Avatar
    Join Date
    Oct 2001
    Posts
    1,427
    Ok, it was a problem with the sizeof funciton it would always, should be strnlen thanks anyhow
    There are some real morons in this world please do not become one of them, do not become a victim of moronitis. PROGRAMMING IS THE FUTURE...THE FUTURE IS NOW!!!!!!!!!

    "...The only real game I thank in the world is baseball..." --Babe Ruth

    "Life is beautiful"-Don Corleone right before he died.

    "The expert on anything was once a beginner" -Baseball poster I own.


    Left cprog on 1-3-2005. Don't know when I am coming back. Thanks to those who helped me over the years.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Edit box(es), and specialized onmouseover
    By Lurker in forum Windows Programming
    Replies: 7
    Last Post: 05-25-2003, 05:13 PM
  2. Edit boxes
    By procyon4476 in forum Windows Programming
    Replies: 1
    Last Post: 05-19-2003, 03:45 PM
  3. Edit Boxes Question
    By Ruben in forum Windows Programming
    Replies: 2
    Last Post: 09-14-2001, 01:06 AM
  4. Edit Boxes Question
    By RubenJ in forum Windows Programming
    Replies: 1
    Last Post: 09-12-2001, 09:01 PM
  5. Password Edit Boxes
    By Unregistered in forum Windows Programming
    Replies: 1
    Last Post: 08-27-2001, 03:40 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21