SRL Archive - OSR Help

TPanel Color property not working..


rj

2013-08-12 18:40:31

Trying to set my TPanel to a color but it's not working :/

for i := 0 to high(FormData.GPanels) do
begin
FormData.GPanels[i] := TPanel.Create(FormData.Tabs[0]);
with FormData.GPanels[i] do
begin
Parent := FormData.Tabs[0];
Top := Positions[i].x;
Left := Positions[i].y;
Width := Sizes[i].x;
Height := Sizes[i].y;
COLOR := 32768;
end;
end;

It ends up like this


I can't align the Panels properly if I can't see half of it lol..

Btw that color is green so as you can see it's not the right color

I could always use TShapes if I have to but would rather use TPanel

masterBB

2013-08-12 18:47:14

Maybe it uses RGB instead of BGR. Let me write something in browser.

newColor := ((oldcolor shr 16) && $FF) + ((oldcolor shr 8) && $FF) shl 8) + ((oldcolor && $FF) shl 16);

edit:
nvm, didn't look at the image. I don't know what causes that.

rj

2013-08-12 18:49:48

From: masterBB
Maybe it uses RGB instead of BGR. Let me write something in browser.

newColor := ((oldcolor shr 16) && $FF) + ((oldcolor shr 8) && $FF) shl 8) + ((oldcolor && $FF) shl 16);

edit:
nvm, didn't look at the image. I don't know what causes that.

:/ maybe it was never added lol TPanels are one of those what I call "Lost form features" that people seldom use

Brandon

2013-08-12 19:01:01

Well it works fine when I change colours:

{$I SRL/SRL.Simba}

type
TFormGUI = record
XFormGUI: TForm;
pPanel: TPanel;
end;

var
FormGUI: TFormGUI;
procedure FormGUI_Init;
begin
with FormGUI do
begin
XFormGUI := CreateForm;
pPanel := TPanel.Create(XFormGUI);

with XFormGUI do
begin
Left := 376;
Top := 175;
BorderStyle := bsNone;
Caption := 'FormGUI';
ClientHeight := 128;
ClientWidth := 505;
Color := clBtnFace;
Font.Color := clWindowText;
Font.Height := -11;
Font.Name := 'Tahoma';
Font.Style := [];
PixelsPerInch := 96;
end;
with pPanel do
begin
Parent := XFormGUI;
Left := 8;
Top := 5;
Width := 489;
Height := 117;
Caption := 'Control Panel';
TabOrder := 1;
Color := 255;
end;
end;
end;

procedure FormGUI_SafeInit;
var
v: TVariantArray;
begin
SetLength(v, 0);
ThreadSafeCall('FormGUI_Init', v);
end;

function FormGUI_ShowModal: Boolean;
begin
FormGUI.XFormGUI.SHOW;
Result:= FormGUI.XFormGUI.Showing;
end;

function FormGUI_SafeShowModal: Boolean;
var
v: TVariantArray;
begin
SetLength(v, 0);
Result := ThreadSafeCall('FormGUI_ShowModal', v);
end;

Procedure FreeFormGUI;
begin
FreeForm(FormGUI.XFormGUI);
end;

begin
SetupSRL;

FormGUI_SafeInit;
FormGUI_SafeShowModal;
AddOnTerminate('FreeFormGUI');

Repeat
Wait(1000);
Until(False);
end.

rj

2013-08-12 19:08:26

From: Brandon
Well it works fine when I change colours:

{$I SRL/SRL.Simba}

type
TFormGUI = record
XFormGUI: TForm;
pPanel: TPanel;
end;

var
FormGUI: TFormGUI;
procedure FormGUI_Init;
begin
with FormGUI do
begin
XFormGUI := CreateForm;
pPanel := TPanel.Create(XFormGUI);

with XFormGUI do
begin
Left := 376;
Top := 175;
BorderStyle := bsNone;
Caption := 'FormGUI';
ClientHeight := 128;
ClientWidth := 505;
Color := clBtnFace;
Font.Color := clWindowText;
Font.Height := -11;
Font.Name := 'Tahoma';
Font.Style := [];
PixelsPerInch := 96;
end;
with pPanel do
begin
Parent := XFormGUI;
Left := 8;
Top := 5;
Width := 489;
Height := 117;
Caption := 'Control Panel';
TabOrder := 1;
Color := 255;
end;
end;
end;

procedure FormGUI_SafeInit;
var
v: TVariantArray;
begin
SetLength(v, 0);
ThreadSafeCall('FormGUI_Init', v);
end;

function FormGUI_ShowModal: Boolean;
begin
FormGUI.XFormGUI.SHOW;
Result:= FormGUI.XFormGUI.Showing;
end;

function FormGUI_SafeShowModal: Boolean;
var
v: TVariantArray;
begin
SetLength(v, 0);
Result := ThreadSafeCall('FormGUI_ShowModal', v);
end;

Procedure FreeFormGUI;
begin
FreeForm(FormGUI.XFormGUI);
end;

begin
SetupSRL;

FormGUI_SafeInit;
FormGUI_SafeShowModal;
AddOnTerminate('FreeFormGUI');

Repeat
Wait(1000);
Until(False);
end.


try settings the color while the tpanels parent is a ttab

masterBB

2013-08-12 19:29:26

.PARENTCOLOR := false;

before setting color.

rj

2013-08-12 20:11:18

From: masterBB
.PARENTCOLOR := false;

before setting color.


thanks