Colored combobox on Windows 7

Colored combobox on Windows 7

Postby Enrico Maria Giordano » Wed Apr 28, 2010 7:56 am

The following sample works fine on XP but not on Windows 7 (it doesn't change the color of the combobox on W7):

Code: Select all  Expand view
#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oDlg

    LOCAL oCbx, cVar := ""

    DEFINE DIALOG oDlg

    @ 1, 1 COMBOBOX oCbx VAR cVar;
           ITEMS { "1", "2", "3" }

    @ 3, 1 BUTTON "Change color";
           ACTION ( oCbx:SetColor( , CLR_HRED ),;
                    oCbx:Refresh() )

    ACTIVATE DIALOG oDlg;
             CENTER

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Colored combobox on Windows 7

Postby Antonio Linares » Wed Apr 28, 2010 8:25 am

Dear Enrico,

It is working fine here on W7 ultimate 32:

Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Colored combobox on Windows 7

Postby Enrico Maria Giordano » Wed Apr 28, 2010 8:37 am

I forgot to mention that the problem is only for themed apps. Please retry using the theme resource.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Colored combobox on Windows 7

Postby James Bott » Wed Apr 28, 2010 2:53 pm

I would seem that themes should override color settings. How else can they work? How would a theme know which color settings to override and which not to?

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Colored combobox on Windows 7

Postby Enrico Maria Giordano » Wed Apr 28, 2010 3:06 pm

On XP the comboboxes are correctly colored.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Colored combobox on Windows 7

Postby James Bott » Wed Apr 28, 2010 3:19 pm

>On XP the comboboxes are correctly colored.

OK, but one wonders is that a bug, or by design? I still can't figure out how the theme knows which colors to change and which not to.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Colored combobox on Windows 7

Postby Enrico Maria Giordano » Wed Apr 28, 2010 3:27 pm

The other controls get correctly colored. Only the comboboxes are not colored.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Colored combobox on Windows 7

Postby James Bott » Wed Apr 28, 2010 3:42 pm

I note the both TGet and Tcombobox inherit from TControl which inherits from TWindow. Only TWindow has a setColor() method so they all use this method. This will make it more difficult to figure out why TCombobox is not working the same as TGet.

I am making the assumption that TGet does display the colors set using setColor. Is that correct?

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Re: Colored combobox on Windows 7

Postby James Bott » Wed Apr 28, 2010 4:05 pm

There is a ctlColor() method in TWindow. It does not exist in TControl or TGet. However, there is a ctlColor() method in TCombobox so I think this is where the problem is.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Colored combobox on Windows 7

Postby James Bott » Wed Apr 28, 2010 4:20 pm

I don't have Win 7 here for testing, but you could try either commenting out the CtlColor() method in TCombobox or just calling the parent method instead.

Method CtlColor(...) Class TCombobox
return super:ctlColor(...)

If the color is then properly set, then this method is the problem.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Re: Colored combobox on Windows 7

Postby Antonio Linares » Thu Apr 29, 2010 10:55 am

Dear Enrico,

Using themes, the dropdown list gets properly colored:

Image

The combobox bar is painted by the Windows themes engine, so we should not change that, unless I am wrong :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Colored combobox on Windows 7

Postby Enrico Maria Giordano » Thu Apr 29, 2010 11:27 am

On XP the edit parts of the comboboxes get correctly colored.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Colored combobox on Windows 7

Postby Antonio Linares » Thu Apr 29, 2010 11:44 am

Dear Enrico,

In your example, the combobox is not editable (does not contain a GET).
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42082
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Marc Venken and 98 guests