CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 1999
    Posts
    535

    Why doesn't this work???? HELP!

    Here's my code:

    [ccode]
    char strTitle[101];
    HWND hWnd = NULL;
    HWND hwnd = NULL;



    hWnd = ::FindWindow(NULL, "DlgTitle");
    hwnd = ::GetDlgItem(hWnd, IDC_EDIT);

    ::SetWindowText(hwnd, "test");


    Everything compiles fine, and it runs fine, except for my edit control doesn't say 'test'
    why not?
    I've debuged it and all the HWND's get the proper handles, and none of the functions fail...
    so what could be the problem?
    thank you..
    Cube


  2. #2
    Join Date
    May 1999
    Location
    Toulouse, France
    Posts
    171

    Re: Why doesn't this work???? HELP!

    Perhaps are you in the case described by the doc:
    "However, SetWindowText cannot change the text of a control in another application."

    HTH

    K.

    We're talking ****, 'cause life is a 'biz
    You know it is
    Everybody tryin' to get rich
    God ****!
    All I wanna do is live !

    KoRn, Children of the Korn

  3. #3
    Guest

    Re: Why doesn't this work???? HELP!

    use setdlgitemtext instead


  4. #4
    Join Date
    May 1999
    Location
    CA, USA
    Posts
    586

    Re: Why doesn't this work???? HELP!

    Or ::SendMessage(hwnd, WM_SETTEXT, 0L, (LPARAM)(LPCSTR)lpszText)

    Rail

    ------------
    Recording Engineer/Software Developer
    Rail Jon Rogut Software
    http://home.earthlink.net/~railro/
    [email protected]

  5. #5
    Join Date
    Jan 2001
    Posts
    12

    Re: Why doesn't this work???? HELP!

    This works fine if you want to send a string from CmyListCtrl to CMyListDlg

    Make sure that your DlgTitle is correct tipped

    //// Sample
    #define IDC_EDIT 4321

    GetDlgItem(IDC_EDIT)->GetWindowText(m_String);
    //// Sample

    HWND hWnd = NULL;
    HWND hwnd = NULL;



    hWnd = ::FindWindow(NULL, "DlgTitle");
    hwnd = ::GetDlgItem(hWnd, IDC_EDIT2);

    ::SetWindowText(hwnd, m_String);

    //

    or

    SetDlgItemText(IDC_EDIT2 , m_String);






  6. #6
    Join Date
    Dec 2000
    Location
    Canada
    Posts
    732

    Re: Why doesn't this work???? HELP!


    UpdateData(FALSE);





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