Results 1 to 7 of 7

Thread: TPanel Color property not working..

  1. #1
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default TPanel Color property not working..

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

    Simba Code:
    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

  2. #2
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

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

    Simba Code:
    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.
    Working on: Tithe Farmer

  3. #3
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by masterBB View Post
    Maybe it uses RGB instead of BGR. Let me write something in browser.

    Simba Code:
    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

  4. #4
    Join Date
    Feb 2011
    Location
    The Future.
    Posts
    5,600
    Mentioned
    396 Post(s)
    Quoted
    1598 Post(s)

    Default

    Well it works fine when I change colours:

    Simba Code:
    {$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.
    Last edited by Brandon; 08-12-2013 at 11:07 PM.
    I am Ggzz..
    Hackintosher

  5. #5
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Brandon View Post
    Well it works fine when I change colours:

    Simba Code:
    {$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

  6. #6
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    .PARENTCOLOR := false;

    before setting color.
    Working on: Tithe Farmer

  7. #7
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by masterBB View Post
    .PARENTCOLOR := false;

    before setting color.
    thanks

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •