Read-only edit fields

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #36108
    Pete Williams
    Participant

    Hi

    Is there any way I can create code that colours TEdit fields that are read-only to a slightly different colour, so it clear it is read only to users.

    Pete.

    #51813
    CheshireCat
    Participant

    Hello Pete,

    maybe that's a solution for you:

    Code:
    uses
    sSkinManager, sEdit, GraphUtil;

    type

    TsEdit = Class(sEdit.TsEdit)
    procedure WndProc(var Message: TMessage); override;
    end;

    procedure TsEdit.WndProc(var Message: TMessage);
    begin
    case Message.Msg of
    WM_PAINT:
    begin
    if ReadOnly then
    begin
    SkinData.CustomColor := True;
    Color := ColorAdjustLuma(ColorToRGB(Form1.sSkinManager1.Palette[pcEditBG]), -25, True);
    end else SkinData.CustomColor := False;
    end;
    end;
    inherited WndProc(Message);
    end;

    Example:

    [attachment=6726:sEdit.jpg]

    #51816
    Pete Williams
    Participant

    That is absolutely awesome, thank you. Will report back to confirm.

    'CheshireCat' wrote:

    Hello Pete,

    maybe that's a solution for you:

    Code:
    uses
    sSkinManager, sEdit, GraphUtil;

    type

    TsEdit = Class(sEdit.TsEdit)
    procedure WndProc(var Message: TMessage); override;
    end;

    procedure TsEdit.WndProc(var Message: TMessage);
    begin
    case Message.Msg of
    WM_PAINT:
    begin
    if ReadOnly then
    begin
    SkinData.CustomColor := True;
    Color := ColorAdjustLuma(ColorToRGB(Form1.sSkinManager1.Palette[pcEditBG]), -25, True);
    end else SkinData.CustomColor := False;
    end;
    end;
    inherited WndProc(Message);
    end;

    Example:

    [attachment=6726:sEdit.jpg]

    #51830
    Support
    Keymaster

    Other solution: you can try to change the SkinData.SkinSection property. To 'PANEL_LOW', for instance.

    #51845
    JasonToms
    Participant
    'Support' wrote:

    Other solution: you can try to change the SkinData.SkinSection property. To 'PANEL_LOW', for instance.

    Perfect, thanks.

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.