3D Colors

Hi,

Is there any way to set frame's background color to 3D object's background color under Win32? I'd like to pick up this system value at run-time and assign it to the frame! I tried to run GetSyColor() API with COLOR_BTNFACE but it returns with zero.


Best regards,
Gabor
 

Luke Gardiner

New Member
You put system defined colours in the colour table in the progress .ini file.

So in the ini file you can put something like:

color0=0,0,0
....
color16=255,255,0
color17=COLOR-BTNFACE

Then colour 17 is the system-defined button colour....
 
Hi Luke,

That's the way we do it now, but user can change system colour (Display Properties->Appearance) and we'd like to use the same colour in our application.
My idea was to use GetSysColor (which works fine) in order to determine COLOR_BTNFACE and assign it to frame's bgcolor (I could not do).

Best regards,
Gabor
 
Gabor, I think this might do what you're wanting. It might require tweaking to get the right key. We use it to set the background to the user's Windows background colour. Put it in a procedure and call when you open your window.

Code:
DEF VAR cKeyName	 AS CHAR NO-UNDO.
DEF VAR cBackground AS CHAR NO-UNDO.
 
ASSIGN cKeyName = "Control Panel\Colors".
 
	/* Attempt to find the required section in the registry */
	LOAD cKeyName BASE-KEY "HKEY_CURRENT_USER" NO-ERROR.
	IF ERROR-STATUS:ERROR THEN
		RETURN "".
	/* Now try and get the property */
	USE cKeyName.
	GET-KEY-VALUE SECTION "" KEY "Background" VALUE cBackground.
	/* Tidy up */
	UNLOAD cKeyName.
 
	COLOR-TABLE:SET-DYNAMIC(255,TRUE).
	COLOR-TABLE:SET-RED-VALUE(255,INT(ENTRY(1,cBackground," "))).
	COLOR-TABLE:SET-GREEN-VALUE(255,INT(ENTRY(2,cBackground," "))).
	COLOR-TABLE:SET-BLUE-VALUE(255,INT(ENTRY(3,cBackground," "))).
	ASSIGN FRAME {&FRAME-NAME}:BGCOLOR = 255.
 
This should also work (sets color 17 as buttonface color).
Code:
procedure GetSysColor external "user32.dll":
	def input parameter nIndex as long.
	def return parameter ocolor as long.
end procedure.
 
def var iButtonface as int no-undo.
 
run GetSysColor(15, output iButtonface).
if color-table:num-entries < 17 then
	color-table:num-entries = 17.
color-table:set-dynamic (17, true).
color-table:set-rgb-value(17, iButtonface).

You may also want to get highlight and caption colors their GetSysColor Index values are 13 and 2 respectively.
 
Hi,

It tried to run your examples but I had the following Warnings:
**Unable to set attribute SET-DYNAMIC for PSEUDO-WIDGET. (4078)
**Unable to set attribute SET-RGB-VALUEfor PSEUDO-WIDGET. (4078)
and color was not added to color table.

Our dev. environment is: XP SP2 + OpenEdge V10.0B

Best regards,
Gabor
 
Hi,

Finally I could run the code successfully. Before using color-table entry you need to extend it using its num-entries property. So, the final code is:
Code:
PROCEDURE GetSysColor EXTERNAL "user32.dll":
	DEFINE INPUT PARAMETER nDspElement AS LONG.
	DEFINE RETURN PARAMETER COLORREF AS LONG.
END.
DEFINE VAR rgb AS INT NO-UNDO.
DEFINE VAR i AS INT NO-UNDO.
DEFINE FRAME a WITH SIZE 20 BY 10.
i = COLOR-TABLE:NUM-ENTRIES.
COLOR-TABLE:NUM-ENTRIES = i + 1.
RUN GetSysColor(15,OUTPUT rgb).
COLOR-TABLE:SET-DYNAMIC (i, true).
COLOR-TABLE:SET-RGB-VALUE(i, rgb).
FRAME a:BGCOLOR = i.
ENABLE ALL WITH FRAME a.
WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW.

Thanks for your help!!!

Gabor
 
Top