Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Grid Header Colour

Grid Header Colour

Grid Header Colour

Good morning

I am trying to find the setting where I can change the colour of the grid header when clicked/mouse down.
If I change the Grid Header backcolor property, then it seems to select a random colour for the clicked/mouse down event of the grid header and I can't seem to find a way to customise this colour.

Anybody found a way around this?


RE: Grid Header Colour

1. Only with Grid.Themes = .F. you have full control about colors
2. There only is Backcolor and Forecolor. A Header is no button.

Don't force looks on a VFP application, if you really are after modern UI, you should really change the programming language and go for an HTML or WPF application. Or use Objective C with Cocoa on a Mac.

Bye, Olaf.

Olaf Doschke Software Engineering

RE: Grid Header Colour

Alastair, these are not random colours. When you click on a grid header, the backcolor becomes the forecolour and the forecolor becomes the backcolor. If you want to override that, you can write code in the header object's MouseDown to change the colours, then in the MouseUp to restore them.

But why do you want to do this? The reason that VFP changes the colours when you click the header is to give visual feedback to the user. Why do you want to change that?


Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: Grid Header Colour

I see a subtle difference:

Win10 with themes: The header changes from a light to a slightly darker color. In my case blue, I think it depends on themes, Win10 even has that automatic mode about a color matching the desktop background image.
Win10 without themes: The header is grey unclicked and turns white text on dark grey clicked. Changing colors I see the clicked header is simply inverting colors, ie red turns cyan. White turns black.

So when you absolutely want to have the color you want, you have to set Themes = .F. and do as Mike suggests. But in more detail, you need to set the BackColor and ForeColor to the inverse color of what you want. VFP inverts that. If you invert colors yourself so they actually stay as they are, you see the click still changes the border of the header. So you always see a visual feedback of the click, even if you would minimize it.

Also always make a testdrive with the compiled EXE. The visual experience differs a bit at least about the titlebar of your app vs IDE.

Bye, Olaf.

Olaf Doschke Software Engineering

RE: Grid Header Colour

I have worked out what the colours do:
The colours invert.
So if the forecolor is RGB(0,0,0) when normal, then forecolor will be RGB(255,255,255) when mouse down
If you set the forecolor to say RGB(10,255,120), then the forecolor will be RGB(245,0,135) when mouse down
The same applies for the backcolor. That is why it appears to give random back colours. If you set the backcolor to blue, it will give an orange colour when mouse down.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close