Handling of COLORREF

Forums for specific tips, techniques and example code
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Handling of COLORREF

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:30 pm

by Jens Richnow >> Thu, 1 Feb 2001 23:32:08 GMT

Can somebody please help with the COLORREF array which is used in some API function calls as an io parameter. For instance, using the SetSysColors funtion, requires to pass the pointer to the correct COLORREF values. In programming languages, like VB etc., this poses no problem, as RGB() is defined and can be used as the parameter to pass.

Passing a pointer is a different problem than passing types or structures which often can be passed in Jade using binaries (although it is really cumbersome if you deal with fairly large types).

Is there a way to pass the COLORREF to API functions from within Jade? I checked the Jade help manuals etc. over and over again but could not find anything. Since structures and types are not supported as such by Jade I presume it applies to this problem as well.

I'm still hopefull, that somebody knows how to do it.

Thanks very much in advance!

Jens

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Handling of COLORREF

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:31 pm

by BeeJay >> Fri, 2 Feb 2001 1:13:32 GMT

SetSysColors is expecting 3 parameters:

(1) count of elements
(2) array of color indexes
(3) array of rgb values

To get Jade to handle this, define an external funtion

setSysColors(num:Integer; colorIndexes:Integer io; rgbs:Integer io):Integer is SetSysColors in user32;

and call it with only one set of values:

vars
systemColourIndex : Integer;
rgb : Integer;begin

systemColourIndex := 2; // active caption - but you could use the predefined JADE constants
rgb := 255; // red - or whatever colour you want to use
call setSysColors(1, systemColourIndex, rgb);

The parameters need to be marked as io so Jade passes the address of the variables not the values.

Hope that helps.
BeeJay.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Handling of COLORREF

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:31 pm

by Jens Richnow >> Fri, 2 Feb 2001 2:17:14 GMT

Thanks, it works fine! I have to remember the "io" in the future. Also, to store the initial system settings before changing them, so that after closing the Jade app, everything is restored.

Thanks again!

Jens

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Handling of COLORREF

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:31 pm

by BeeJay >> Fri, 2 Feb 2001 2:27:09 GMT
Thanks, it works fine! I have to remember the "io" in the future. Also, to store the initial system settings before changing them, so that after closing the Jade app, everything is restored.

Or perhaps even restore the initial system settings whenever your application loses the focus as well ?!

BeeJay.

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Handling of COLORREF

Postby ConvertFromOldNGs » Fri Aug 07, 2009 2:31 pm

by Jens Richnow >> Fri, 2 Feb 2001 2:34:43 GMT

A very good idea, but how do I know when the Jade application loses focus? A quick browse through the Help did not give any hint. Do I have to dig in the Windows messaging and use some kind of hooks?

Jens


Return to “Tips and Techniques”

Who is online

Users browsing this forum: No registered users and 18 guests

cron