Announcement

Collapse
No announcement yet.

Unexpected problem with XP Themes

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

  • Unexpected problem with XP Themes

    I ran into an unexpected problem with the size of the listbox portion of a combobox when XP Themes is enabled. The small example below illustrates the problem when the resource statement is not commented out. With the resource statement in, the listbox portion is much larger than when it is out. Perhaps someone has an idea for a work around.

    Code:
    #COMPILE EXE
    #DIM ALL
    #INCLUDE "win32api.inc"
    '#RESOURCE "problem.pbr"
    
    %ID_NamesCmbo = 101
    
    FUNCTION PBMAIN()
       LOCAL hMain, nStyle, i AS LONG, s AS STRING
       nStyle = %WS_SYSMENU OR %WS_MINIMIZEBOX
       s = "Problem with XP Themes"
       DIALOG NEW hMain, s, , , 250, 220, %WS_SYSMENU TO hMain
       nStyle = %WS_VSCROLL OR %CBS_DISABLENOSCROLL OR %WS_TABSTOP OR %CBS_DROPDOWN OR %CBS_SORT
       CONTROL ADD COMBOBOX, hMain, %ID_NamesCmbo, , 50, 45, 90, 100, nStyle
       COMBOBOX RESET hMain, %ID_NamesCmbo
       FOR i = 1 TO 100
           COMBOBOX ADD hMain, %ID_NamesCmbo, ""
       NEXT i
       DIALOG SHOW MODAL hMain
    END FUNCTION
    ------------------------------------------------------------------------

    The "problem.rc" file below was compiled to "problem.pbr"

    Code:
    #include "Resource.h"
    1   24    "XPTheme.xml"
    Last edited by Charles Dietz; 9 Sep 2008, 12:58 AM.

  • #2
    Interesting. It seems as if the theme engine has changed the list height to about twice the normal size. It is not a DDT problem though as SDK dialogs exhibit the same symptoms. The only difference (excluding the theme usage) I could see with DDT is that it uses 13 pixels for the item height, whereas SDK uses 16 pixels, althought this is down to the font used by my test SDK dialog.

    Code:
    #Compile Exe
    #Dim All
    #Include "win32api.inc"
    #Include "commctrl.inc"
    #Resource "themecombo.pbr"
     
    %DDT = 0 ' DDT test ON/OFF
     
    %ID_NamesCmbo = 101
     
    Function PBMain
       Local hMain As Dword
       Local dwStyle As Dword
     
       ' Always call when using themes...
       Initcommoncontrols
     
       #If %DDT
     
       dwStyle = %ws_sysmenu Or %ws_minimizebox Or %ws_caption
       Dialog New hMain, "ThemeCombo", , , 250, 140, dwStyle To hMain
       dwStyle = %ws_vscroll Or %cbs_disablenoscroll Or %ws_tabstop Or %cbs_dropdown Or %cbs_sort
       Control Add ComboBox, hMain, %ID_NamesCmbo, , 50, 45, 90, 100, dwStyle
       ComboBox Reset hMain, %ID_NamesCmbo
       Dialog Show Modal hMain Call dlgProc
     
       #Else
     
           DialogBox(GetModuleHandle(ByVal %NULL), ByVal 100, %HWND_DESKTOP, CodePtr(dlgProc))
     
       #EndIf
     
    End Function
     
    CallBack Function dlgProc
     
      Select Case CbMsg
             Case %wm_initdialog
                  Local I As Long
                  Local Z As Asciiz * 16
                  Z = " "
     
                  For i = 1 To 100
                      #If %DDT
                          ComboBox Add CbHndl, %ID_NamesCmbo, Z
                      #Else
                          SendDlgItemMessage CbHndl, %ID_NamesCmbo, %CB_ADDSTRING, 0, VarPtr(Z)
                      #EndIf
                  Next i
             #If %DDT = 0
     
             Case %WM_SYSCOMMAND
                  Select Case CbWParam
                         Case %sc_close
                              EndDialog CbHndl, 0
                              Function = %TRUE
                  End Select
             #EndIf
     
      End Select
     
    End Function
    Code:
    #include "resource.h"
     
    //1 24 "themecombo.xml" // Enable theme usage
     
    100 DIALOG 50, 50, 250, 140
    STYLE WS_CAPTION | WS_MINIMIZEBOX | WS_SYSMENU
    CAPTION "ThemeCombo"
    BEGIN
      COMBOBOX        101, 50, 45, 90, 100, WS_VSCROLL | CBS_DISABLENOSCROLL | WS_TABSTOP | CBS_DROPDOWN | CBS_SORT
    END
    Last edited by Kev Peel; 9 Sep 2008, 04:56 AM. Reason: typos
    kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

    Comment


    • #3
      Even resetting the height does not work.
      Note that once xp theming is used a different callback for the control is used.
      Afaik it's then a common control and no longer a standard control.
      Different behaviour i guess.
      hellobasic

      Comment

      Working...
      X