Thread: MFC. displaying text in a label recieved from a Edit Field box

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    2

    Question MFC. displaying text in a label recieved from a Edit Field box

    ok what im trying to do is ..to type some text into a text box ..then by clicking a button have that text display in a
    lable ................

    heres some of my code this is the function from the button click

    lbl.SetWindowText("Hello there ");

    the above code at the moment will display text "Hello there"
    into the lable...........
    Now what im wanting to do is to recieve text from the text box

    here is the code for my Edit field
    // Word Search Text Field
    CRect rect1(170,170,280,190);
    IdWordField.Create (WS_CHILD|WS_VISIBLE|WS_BORDER ,rect1,this,ID_BTNsearchWord);

    i had a go at doing this by using the following code but it didnt work
    it gave me an error
    lbl.SetWindowText(IdWordField);

    so how do i do this .......please help
    cheers

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    Hi,

    Firstly, this question should have been asked in the windows forum (as it is windows specific, not c++ specified).

    Secondly, your problem is that can't just pass one edit box handle to the label when you call SetWindowText.

    Rather than completely spoonfeed you, go and have a look at GetWindowText().

    so the kind of thing you want to do is:

    edit.GetWindowText();
    label.SetWindowText();

    yes, i haven't given you the complete answer, but it should point you in the right direction

    good luck!
    U.
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 02-13-2008, 02:59 PM
  2. Capture Enter key press in EDIT Box
    By richiev in forum Windows Programming
    Replies: 4
    Last Post: 07-14-2005, 12:03 AM
  3. How do I make my edit box move text to the next line?
    By ElWhapo in forum Windows Programming
    Replies: 2
    Last Post: 01-04-2005, 11:21 PM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  5. How do I get text from an edit box?
    By Strider in forum Windows Programming
    Replies: 3
    Last Post: 11-05-2001, 05:43 PM