Problem with custom Combobox and 4.50

Windows specific forum
User avatar
wichtel
User
User
Posts: 71
Joined: Fri May 02, 2003 11:14 am
Location: Germany
Contact:

Problem with custom Combobox and 4.50

Post by wichtel »

I have a piece of code that worked in 4.41, but does no longer work with 4.50.

Way too much code to post, so I just show the piece that no goes wrong.

Code: Select all

   Case #WM_DRAWITEM 
        *DrawItem.DRAWITEMSTRUCT = lParam 
        If *DrawItem\CtlType = #ODT_COMBOBOX 
          SetBkMode_(*DrawItem\hdc, #TRANSPARENT) ; Text is rendered transparent 
          If *DrawItem\itemState & #ODS_FOCUS 
            FillRect_(*DrawItem\hdc, *DrawItem\rcItem, GetSysColorBrush_(#COLOR_HIGHLIGHT)) 
          Else 
            FillRect_(*DrawItem\hdc, *DrawItem\rcItem, GetSysColorBrush_(#COLOR_MENU) )
          EndIf 
          
          If *DrawItem\itemID <>-1
            text$ = Space(512) 
            SendMessage_(*DrawItem\hwndItem, #CB_GETLBTEXT, *DrawItem\itemID, @text$) 
            Debug text$
            DrawIconEx_(*DrawItem\hdc, *DrawItem\rcItem\left+2   , *DrawItem\rcItem\top+2, hailang(hailangPos2ID(*DrawItem\itemID))\flag, 50, 11, 0, 0, #DI_NORMAL) 
            TextOut_   (*DrawItem\hdc, *DrawItem\rcItem\left+2+56, *DrawItem\rcItem\top+1, text$, Len(text$)) 
          EndIf 
          
        EndIf 
    EndSelect    
Have a look at the line with "debug text$".
In 4.41 text$ contained the text of my combobox item.
In 4.50 text$ shows some weird (asian?) characters.

I am compiling with UNICODE option enabled.

What has changed?

P.S.
The drawing of the custom icons still works.
And I can still set the text behind the custom icons if use some static text.
If I disable all the custom drawing, the original text appears correct as well.
Only the reading of the text does no longer worked.

I just crosschecked. Same code, with 4.41, no prolems.
PB 5.40 LTS, W7,8,10 64bit and Mint x64
User avatar
wichtel
User
User
Posts: 71
Joined: Fri May 02, 2003 11:14 am
Location: Germany
Contact:

Re: Problem with custom Combobox and 4.50

Post by wichtel »

Just found the solution myself.

I have created the combobox with:

Code: Select all

ComboBoxGadget(#hailang,10,10,140,20,#CBS_OWNERDRAWFIXED)
That worked pretty well up tp PB 4.41.

With PB 4.50 I need to create the combobox like this:

Code: Select all

ComboBoxGadget(#hailang,10,10,140,20,#CBS_OWNERDRAWFIXED|#CBS_HASSTRINGS )
Seems that 4.50 does not supply that flag anymore.

I found the hint in MSDN:
http://msdn.microsoft.com/en-us/library/ee504874.aspx
Remarks

If you create the combo box with an owner-drawn style but without the CBS_HASSTRINGS style, the buffer pointed to by the lpszBuffer parameter of the message receives the 32-bit value associated with the item (the item data).

Thanks anyway



Edit:
Ok, I am stupid. I did not notice until now that 4.50 comes with built-in support for combobox images. :cry:
PB 5.40 LTS, W7,8,10 64bit and Mint x64
Post Reply