Thread: WM_GETTEXT error

  1. #1
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065

    WM_GETTEXT error

    I'm trying to populate a char array with the text in a text box. Here's my code:

    Code:
    //in my global variable declares:
    HWND Txt1;
    
    //in my message handler, case WM_CREATE:
    Txt1=CreateWindowEx(0,"Edit","Text Box",WS_CHILD | WS_VISIBLE, 15,90,90,15,hwnd,NULL,hInstMain,NULL);
    
    //the offending code, called when a cmd btn is pushed:
    int iMaxChar=100;
    char buffTxt1[100];
    SendMessage(Txt1,WM_GETTEXT,iMaxChar,&buffTxt1);
    Error C2664: 'SendMessageA' : cannot convert parameter 4 from 'char *(*)[100]' to 'long'

    I've tried:
    Code:
    SendMessage(Txt1,WM_GETTEXT,iMaxChar,buffTxt1);
    I'm sure I'm missing something simple I just don't see it. Thanks in advance for any help.

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    Code:
    SendMessage(Txt1, WM_GETTEXT, (WPARAM)iMaxChar, (LPARAM)buffTxt1);
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  3. #3
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    Thanks, Uraldor. I noticed the (WPARAM)/(LPARAM) in the MSDN library and didn't even think to try it!

    Like I said, I had a feeling I was missing something simple.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM