[RESOLVED] C++ dialog listbox display outside the dialogbox
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: [RESOLVED] C++ dialog listbox display outside the dialogbox

  1. #1
    Join Date
    Jul 2013
    Posts
    6

    [RESOLVED] C++ dialog listbox display outside the dialogbox

    I'm trying to duplicate a listbox I saw in another application. It
    looks like this:

    Name:  SPEED.BMP
Views: 106
Size:  68.9 KB


    The listbox is hidden until the ownerdrawn pushbutton is selected. So
    far so good, but my listbox is displayed only up to the edge of the
    dialog box which means it shows only two lines and doesn't extend into the
    desktop area. I'd expect this default behavior due to the OS clipping
    applications so they aren't overwriting one another.

    But how did the original dialog get around this? I tried a few options
    with WS_CLIP... SetWindowPos(HWND_TOPMOST... and also creating the
    listbox at INITDIALOG time and have the parent be the desktop, but
    so far it displays just the two lines. Any idea on this?

    Thanks

    René

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,392

    Re: C++ dialog listbox display outside the dialogbox

    Name:  combo.JPG
Views: 75
Size:  30.5 KB
    This combobox has following styles:
    WS_CHILDWINDOW
    WS_VISIBLE
    WS_TABSTOP
    CBS_DROPDOWNLIST
    CBS_OWNERDRAWFIXED
    CBS_SORT
    CBS_HASSTRINGS

    And you can increase the siye of its dropdown listbox in resource editor: xlick with the mouse on its "arrow" and resiye the listbox.
    Victor Nijegorodov

  3. #3
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    5,977

    Re: C++ dialog listbox display outside the dialogbox

    It seems like just a popup window, not the dialog's child.
    Best regards,
    Igor

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,392

    Re: C++ dialog listbox display outside the dialogbox

    Quote Originally Posted by Igor Vartanov View Post
    It seems like just a popup window, not the dialog's child.
    Good point!
    @OP: I guess Spy++ could help!
    Victor Nijegorodov

  5. #5
    Join Date
    Jul 2013
    Posts
    6

    Re: C++ dialog listbox display outside the dialogbox

    Thanks guys -- I'll try Mr. Vartanov's idea of WS_POPUP first. That makes sense to me and I don't know why I didn't think of that earlier. Failing that, I'll try VictorN's suggestion of WS_CHILDWINDOW style, but the POPUP should do it. Thanks again --- René

  6. #6
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    3,891

    Re: C++ dialog listbox display outside the dialogbox

    if you want the window to extend out of the dialog... it cannot be a child of the dialog.


    I'm guessing you currently have the listbox as part of the dialog template and you are changing the WS_VISIBLE style of the listbox ? This won't work, you'll need to dynamically create a WS_POPUP listbox (WS_POPUP and WS_CHILD are exclusive).

  7. #7
    Join Date
    Jul 2013
    Posts
    6

    Re: C++ dialog listbox display outside the dialogbox

    Quote Originally Posted by OReubens View Post
    if you want the window to extend out of the dialog... it cannot be a child of the dialog.


    I'm guessing you currently have the listbox as part of the dialog template and you are changing the WS_VISIBLE style of the listbox ? This won't work, you'll need to dynamically create a WS_POPUP listbox (WS_POPUP and WS_CHILD are exclusive).
    OReubens

    Yes indeed. The earlier post from Igor Vartanov pointed me in the right direction.
    The listbox is not a child of the main dialog in this case. The .RC looks something like:


    IDD_LISTDIALOG DIALOG 30, 80, 130, 120
    STYLE WS_POPUP | DS_3DLOOK | WS_VISIBLE
    FONT 8, "HELV"
    BEGIN
    LISTBOX IDC_LISTBOX, 0, 0, 130, 120,
    LBS_NOTIFY | WS_CHILD | WS_VISIBLE | WS_BORDER |
    WS_VSCROLL | WS_GROUP | WS_TABSTOP | LBS_DISABLENOSCROLL
    END

    And from the parent dialog (hwnd) call it:

    case WM_INITDIALOG:
    hLstBx = CreateDialog(_hInstance, MAKEINTRESOURCE(IDD_LISTDIALOG), hwnd, (DLGPROC) ModelessDialogProc);
    ShowWindow(hLstBx, SW_HIDE);
    SetProp(hwnd, SPEEDLST, (HANDLE) hLstBx);

    When the ownerdrawn pushbutton is selected we do a SetWindowPos() to keep the
    control in the same area relative to the pushbutton and just do a SW_SHOW.

    Worked fine once I got over trying to make the listbox part of the original dialog box !

    René

  8. #8
    Join Date
    Jul 2013
    Posts
    1

    Re: C++ dialog listbox display outside the dialogbox

    It's look like a popup window.The scroll bar and scroll pane are available.You will try to change the coding.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center