Print Page | Close Window

Support for system colours

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Property Grid
Forum Description: Topics Related to Codejock Property Grid
URL: http://forum.codejock.com/forum_posts.asp?TID=16707
Printed Date: 21 November 2024 at 12:39pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Support for system colours
Posted By: sbclarke
Subject: Support for system colours
Date Posted: 14 May 2010 at 4:40am
We are migrating our GUI to CodeJock controls to benefit from the modern look and feel and great controls such as the PropertyGrid. However, I cannot find a way to change the functionality of the colour picker to include system colours.

We have a separate colour-picker we could use (although would prefer to use the CodeJock in-built style) by calling from pgMyPropertyGrid_InplaceButtonDown(... and setting Cancel to True, but we then cannot retrieve the colour from Value as it appears to translate system colours to RGB.

Is it possible to add our own small control (ocx) rather than a button into a property grid item? - This would be our preferred solution as we can keep the same look and feel for this control as our previous (but limited) implementation (See below for screen shots).

Alternatively, I could do this with an enumerated list and addiitional in-place button, but cannot find out how to change the background colour of the inplace button (We want the colour preview feature)

Thanks,
Simon

Wish List...




Replies:
Posted By: Aaron
Date Posted: 15 May 2010 at 6:33am
Hi,
 
Q:We have a separate colour-picker we could use (although would prefer to use the CodeJock in-built style) by calling from pgMyPropertyGrid_InplaceButtonDown(... and setting Cancel to True, but we then cannot retrieve the colour from Value as it appears to translate system colours to RGB.
 
A: In ValueChanged event value of Item.Value is long (only Item will show RGB)
 
Q: Is it possible to add our own small control (ocx) rather than a button into a property grid item? - This would be our preferred solution as we can keep the same look and feel for this control as our previous (but limited) implementation (See below for screen shots).
A: You could use a dropdown button and calculate Item position / size and show your control (see VB sample Propertygrid where MenuItem is used for showing dropdown menu)
 
 
Q: Alternatively, I could do this with an enumerated list and addiitional in-place button, but cannot find out how to change the background colour of the inplace button (We want the colour preview feature)

A: There's no property to change the backgroundcolor but you could use an enumerated Item (with a list of System colors) and add Icons as colors (like the combobox in VB IDE) see also propertygrid sample where icons are added in combo.
 
 
Good luck
 
 
 


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....


Posted By: sbclarke
Date Posted: 15 May 2010 at 10:20am
Thanks for your reply Aaron,

"In ValueChanged event value of Item.Value is long (only Item will show RGB)"
We are using VB6 where all colours including system colours are represented by a value of type Long. System colours are enumerated as negative numbers eg:&H8000000F& and API calls are available to convert to RGB and back so the property grid could manage this if it didn't ignore system colours.

"You could use a dropdown button and calculate Item position / size and show your control (see VB sample Propertygrid where MenuItem is used for showing dropdown menu)"
I have tried this and with some success - the problem is we use the scroll bars and I have not found an event that traps the scrolling, so it looks very strange when you scroll, I haven't given up with this yet though although I want avoid using a timer! Other complications are that categories being collapsed will need the control hiding as we want to leave the control visible for the preview colour.

"There's no property to change the backgroundcolor but you could use an enumerated Item (with a list of System colors) and add Icons as colors (like the combobox in VB IDE) see also propertygrid sample where icons are added in combo."
This is a great suggestion - I will look into this as I was not aware I could add icons to the enumerated property lists - I might need to render the icons with the colours selected on the host machine though.

Its a shame CodeJock have chosen not to support system colours with their colour picker

Thanks again,
Simon







Posted By: sbclarke
Date Posted: 28 May 2010 at 3:08am
Solved

I have managed this reasonably cleanly by writing a helper class for the PropertyGrid control. This allows you to create a new colour picker made up of an enumerated list with icons rendered with the system colours (as suggested by Aaron) and an additional in-place button to choose colours using the XtremeSuiteControls CommonDialogue control. It took some effort to work out what all the flags do as I could not find this in the help. The keyboard can be used to type the colour too.  In addition it offers three child sliders to allow you to change the RGB values without the CommonDialogue being open.

I have use very little API code and have rendered the icons using dynamically loaded PictureBoxes and saving the image to the Windows TEMP folder.

I have uploaded the code and documentation if anyone finds it helpful or interesting. This was built and tested for CodeJock 13.3.1 - See uploads/20100528_030528_ColourPropsHelp.zip - uploads/20100528_030528_ColourPropsHelp.zip

I may post an update supporting web safe colours and their names if anyone is interested.

Simon

Screen Shots:

 


-------------
Product: Xtreme SuitePro (ActiveX) version 13.3.1
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0 (mostly)


Posted By: jpbro
Date Posted: 28 May 2010 at 2:40pm
Very nice! Thanks for this Simon.

-------------
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3

Language: Visual Basic 6.0 SP6



Posted By: Aaron
Date Posted: 04 June 2010 at 11:52am
Hi Simon,
 
So you solved the issue yourself !?!? 
If you want system colors in your application it's a nice option to have. Thanks for sharing this
 
And keep up the good work !
 
  


-------------
Product: Xtreme SuitePro (ActiveX) version 15.0.2
Platform: Windows XP (32bit) - SP 2
Language: Visual Basic 6.0

Zero replies is not an option....



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net