Thread: SetDlgItemText?

  1. #1
    BubbleMan
    Guest

    Question SetDlgItemText?

    Ok. I am making a program. I need to know how to resize a multi-line edit box to fit the program window when it's resized. Also, how would I add text to the edit box? Is it SetDlgItemText?

  2. #2
    BubbleMan
    Guest

    Post Well, I tried..

    I need to do it only when the user click Insert -> Text. How do I do that. I tried SetDlgItemText(); but it don't work.

  3. #3
    Unregistered
    Guest

    Post Ok -> Here it is

    I have:

    case WM_CREATE:
    hMenu = CreateMenu();

    hSubMenu = CreatePopupMenu();
    AppendMenu(hSubMenu, MF_STRING, CM_FILE_NEW, "&New");
    AppendMenu(hMenu, MF_STRING + MF_POPUP, (UINT)hSubMenu, "&File");

    hSubMenu = CreatePopupMenu();
    AppendMenu(hSubMenu, MF_STRING, CM_INSERT_LINK, "&Link");
    AppendMenu(hMenu, MF_STRING + MF_POPUP, (UINT)hSubMenu, "&Insert");

    SetMenu(hwnd, hMenu);
    break;
    case WM_COMMAND:
    switch(LOWORD(wParam))
    {
    case CM_FILE_NEW:
    HWND html;

    html = CreateWindowEx(
    WS_EX_STATICEDGE | WS_EX_CLIENTEDGE | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
    "EDIT",
    "",
    WS_CHILD | WS_VISIBLE | ES_MULTILINE | WS_VSCROLL | WS_HSCROLL,
    0, 0,
    540, 330 ,
    hwnd,
    (HMENU) 1,
    hInst,
    NULL
    );
    break;
    case CM_INSERT_LINK:
    SetDlgItemText(html, 0, "<a href=""> </a>");
    break;
    }
    break;

  4. #4
    BubbleMan
    Guest

    Post The handle

    Ok. Now I used:

    #define IDC_NSRT 1001 at the top.

    And:

    html = CreateWindowEx(
    WS_EX_STATICEDGE | WS_EX_CLIENTEDGE | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
    "EDIT",
    "",
    WS_CHILD | WS_VISIBLE | ES_MULTILINE | WS_VSCROLL | WS_HSCROLL,
    0, 0,
    540, 330 ,
    hwnd,
    (HMENU) 1,
    hInst,
    NULL
    );
    break;
    case CM_INSERT_LINK:
    SetDlgItemText(html, IDC_NSRT, "<a href=""> </a>");
    break;

    Wouldn't html be the handle? I used HWND html; before it.

  5. #5
    BubbleMan
    Guest

    Post When I use

    When I use:

    SetDlgItemText((HDLG)html, 0, "<a href=""> </a>");

    I get:

    HDLG undeclared

  6. #6
    BubbleMan
    Guest

    Unhappy Nothing

    Nothing even happens when I do that.

  7. #7
    BubbleMan
    Guest

    Post Sort of

    Well, an HTML page maker, actually. You can edit the HTML and save it or if you need shortcuts, that is what my Insert menu is for.

  8. #8
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    Change your CreateWindowEx to :

    Code:
    html = CreateWindowEx( WS_EX_STATICEDGE | WS_EX_CLIENTEDGE  ,
    			"edit", "", WS_CHILD|WS_VISIBLE|ES_MULTILINE|WS_VSCROLL|WS_HSCROLL|ES_LEFT|ES_AUTOHSCROLL| ES_AUTOVSCROLL,
    			0, 0, 540, 330 , hWnd, (HMENU) 1, hInst, NULL );
    SetDlgItemText() wants a handle to the parent window and an ID of the child window. You can either use the handle to your edit window -

    Code:
    SetWindowText(html,"<a href=""> </a>");
    or use your parent handle -

    Code:
    SetDlgItemText(hWnd, 1,"<a href=""> </a>" );
    You've defined IDC_NSRT as 1001 but given your edit child window an ID of 1 in your CreateWindowEx() call, so if you want to use IDC_NSRT you'll have to change one of the values.
    zen

  9. #9
    BubbleMan
    Guest

    Angry Still

    That still doesn't work.

  10. #10
    BubbleMan
    Guest

    Post Nevermind..I got it!

    that last reply did it! Thank you for helping me!

  11. #11
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    I am assuming this is in a callback function. You may need to set the HWND to a static. Many messages pass thru the callback and it will have lost the value before the next msg is processed.

    Try GetActiveWindow() as this will return the HWND of the dlg with the focus.

    Test that the Edit has been created ie html!=NULL or can see it on screen. Use GetLastError() if not.

    Ensure you are setting the ID (IDC_NSRT) as the HMENU param in the CreateWindowEx, ie

    (HMENU)IDC_NSRT

    Read the help for this.

  12. #12
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Next time look at the second page!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. SetDlgItemText not working
    By viaxd in forum Windows Programming
    Replies: 4
    Last Post: 01-14-2006, 02:55 AM
  2. Dialog doesn't respond to tab key
    By dhaupt in forum Windows Programming
    Replies: 8
    Last Post: 08-11-2004, 12:41 PM
  3. Using the SetDlgItemText function
    By nima_ranjbar in forum Windows Programming
    Replies: 4
    Last Post: 04-25-2002, 02:44 PM
  4. Problem with SetDlgItemText
    By face_master in forum Windows Programming
    Replies: 7
    Last Post: 01-28-2002, 10:24 PM
  5. SetDlgItemText()
    By C_Coder in forum Windows Programming
    Replies: 3
    Last Post: 12-05-2001, 11:02 PM