Announcement

Collapse
No announcement yet.

Owner-drawn listbox in DDT TAB control

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Owner-drawn listbox in DDT TAB control

    While working on the new WSA engine, i am trying to skin on the fly a listbox that is a child of a DDT TAB control.

    Usualy i use myself a "STATIC" control for child container with TAB control, while DDT seems to use a dialog class "#32770".

    My problem is that i can't get the %WM_DRAWITEM from a LISTBOX that is the child of DDT TAB "#32770" control.

    How you, DDT experts, handle an owner-drawn LISTBOX from a DDT TAB control?

    ...
    Patrice Terrier
    www.zapsolution.com
    www.objreader.com
    Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).

  • #2
    > can't get the %WM_DRAWITEM

    Did you set the parent of the Listbox to the main window? the tab control? And are looking for WM_DRAWITEM in the right place (it's sent to the owner window).

    Did you respond to WM_MEASUREITEM to tell windows how big this LBS_OWNERDRAWFIXED listbox control is going to be? I'd think if you don't the control has no size and therefore never needs drawing so you never get WM_DRAWITEM.

    For that matter , are you looking for WM_MEASUREITEM in the right place?

    Perhaps a 'compilable example' of what you are trying to do might be in order?
    Michael Mattias
    Tal Systems Inc. (retired)
    Racine WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      Indeed what i am doing, is using subclassing to change on the fly the %GWL_STYLE of the listbox to make it owner-drawn, like this:

      Code:
      WasStyle& = GetWindowLong(hWnd&, %GWL_STYLE) '// Get current LISTBOX style
      IF (WasStyle& AND %LBS_OWNERDRAWFIXED) = 0 THEN
         NewStyle& = %WS_CHILD OR %WS_VISIBLE OR %LBS_NOTIFY OR %WS_TABSTOP OR %LBS_HASSTRINGS OR %LBS_OWNERDRAWFIXED OR %LBS_NOINTEGRALHEIGHT
         nRet& = SetWindowLong(hWnd&, %GWL_STYLE, NewStyle&)
      
         zTrace(STR$(nRet&)+STR$(WasStyle&)+STR$(NewStyle&)+str$(GetWindowLong(hWnd&, %GWL_STYLE)))
      
      END IF
      zTrace print:
      nRet& = 1342242819
      WasStyle& = 1342242819
      NewStyle& = 1342243153
      GetWindowLong(hWnd&, %GWL_STYLE) = 1342243073

      SetWindowLong does not report any error, however the style is not setup correctly.

      Note: The listbox is not empty when i am changing the style.

      Added:
      Looks like the %LBS_OWNERDRAWFIXED and %LBS_HASSTRINGS couldn't be changed on the fly

      ...
      Last edited by Patrice Terrier; 25 Oct 2009, 10:57 AM.
      Patrice Terrier
      www.zapsolution.com
      www.objreader.com
      Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).

      Comment


      • #4
        ...a listbox that is a child of a DDT TAB control.
        ...LISTBOX that is the child of DDT TAB "#32770" control.
        Your terminology is confused and wrong.
        The diagram below shows the hierarchy of the windows involved when a tab control is associated with
        three pages(child dialogs). Notice that the tab control does not have any children. The tab control
        and its pages are siblings and the listbox would a child of one of those pages(Child dialog1 if it is a child of
        the first page).
        Code:
                   Top-level dialog
                    (class = #32770)
                           |
                           |
              _____________|___________________________________                  
             |             |                 |                 |          
             |             |                 |                 |          
             |             |                 |                 |          
        Tab control     Tab Page1         Tab Page2         Tab Page3     
                     (Child dialog1)   (Child dialog2)   (Child dialog3)  
                     (class = #32770)  (class = #32770)  (class = #32770)
                           |
                           |
                           |
                        Listbox
        Last edited by Dominic Mitchell; 25 Oct 2009, 10:57 AM.
        Dominic Mitchell
        Phoenix Visual Designer
        http://www.phnxthunder.com

        Comment


        • #5
          Dominic

          Yes, that is exactly the diagram you are showing, but i can't see anything wrong with it, except that english is not my native language

          But perhaps you are speaking about the use of the "STATIC" class instead of "#32770".

          As i wrote, looks like the %LBS_OWNERDRAW style can't be changed on the fly, once the control has been created, and that's my problem thus nothing related to the use of DDT.

          However we can't trust the value returned by SetWindowLong to detect the error in this case.

          Anyway i know how to work around my problem, thank you!

          ...
          Patrice Terrier
          www.zapsolution.com
          www.objreader.com
          Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).

          Comment


          • #6
            Windows theming does not like you to change major styles after creation.
            Like the ownerdrawn styles for example.
            hellobasic

            Comment


            • #7
              Edwin--

              No problem, i am handling all the drawing myself in the subclassing engine, then no more need to switch to ownerdrawn mode.

              ...
              Patrice Terrier
              www.zapsolution.com
              www.objreader.com
              Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).

              Comment


              • #8
                Allan (and others)

                how i can change ListBox style after creation to be LBS_OwnerDraw;
                You must hook the windows message WM_CREATE and change the style there, after you won't be able to change the %LBS_OWNERDRAWFIXED style on the fly.

                However you could try with CUSTOMDRAW instead of OWNERDRAW.

                ...
                Last edited by Patrice Terrier; 2 Nov 2009, 03:32 PM.
                Patrice Terrier
                www.zapsolution.com
                www.objreader.com
                Addons: GDImage.DLL 32/64-bit (Graphic library), WinLIFT.DLL 32/64-bit (Skin Engine).

                Comment

                Working...
                X