Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit EditColor;
- interface
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls;
- type
- TMyEditColor = class(TEdit)
- private
- { Private declarations }
- FBorder : TColor;
- FBorderColor : TColor;
- FBorderColorEnter: TColor;
- procedure SetBorderColor(const Value: TColor);
- procedure WMNCPaint( var msg: TWMNCPaint ); message WM_NCPAINT;
- procedure CMMouseEnter(var msg: TMessage); message CM_MOUSEENTER;
- procedure CMMouseLeave(var msg: TMessage); message CM_MOUSELEAVE;
- procedure CMEnter(var msg: TCMEnter); message CM_ENTER;
- procedure CMExit(var msg: TCMExit); message CM_EXIT;
- procedure SetBorderColorEnter(const Value: TColor);
- public
- constructor Create( aOwner: TComponent ); override;
- property ParentColor default true;
- published
- property BorderColor : TColor read FBorderColor write SetBorderColor;
- property BordColorEnter: TColor read FBorderColorEnter write SetBorderColorEnter;
- end;
- procedure Register;
- implementation
- procedure Register;
- begin
- RegisterComponents('My Componentes', [TMyEditColor]);
- end;
- { TPBLineEdit }
- procedure TMyEditColor.CMEnter(var msg: TCMEnter);
- begin
- inherited;
- FBorder := FBorderColorEnter;
- SendMessage(Handle, WM_NCPAINT, 0, 0);
- end;
- procedure TMyEditColor.CMExit(var msg: TCMExit);
- begin
- inherited;
- FBorder := FBorderColor;
- SendMessage(Handle, WM_NCPAINT, 0, 0);
- end;
- procedure TMyEditColor.CMMouseEnter(var msg: TMessage);
- begin
- inherited;
- FBorder := FBorderColorEnter;
- SendMessage(Handle, WM_NCPAINT, 0, 0);
- end;
- procedure TMyEditColor.CMMouseLeave(var msg: TMessage);
- begin
- inherited;
- FBorder := FBorderColor;
- SendMessage(Handle, WM_NCPAINT, 0, 0);
- end;
- constructor TMyEditColor.Create(aOwner: TComponent);
- begin
- inherited;
- ParentColor := true;
- end;
- procedure TMyEditColor.SetBorderColorEnter(const Value: TColor);
- begin
- FBorderColorEnter := Value;
- end;
- procedure TMyEditColor.SetBorderColor(const Value: TColor);
- begin
- FBorderColor := Value;
- FBorder := FBorderColor;
- SendMessage(Handle, WM_NCPAINT, 0, 0);
- end;
- procedure TMyEditColor.WMNCPaint(var msg: TWMNCPaint);
- var
- DC: HDC;
- BorderBrush: HBRUSH;
- R: TRect;
- begin
- DC:= GetWindowDC(Handle);
- SetRect(R,0,0,Width,Height);
- BorderBrush:= CreateSolidBrush(FBorder);
- FrameRect(Dc, R, BorderBrush);
- DeleteObject(BorderBrush);
- InflateRect(R,-1,-1);
- end;
- end.
- //somente desenha a borda inferior
- //procedure TMyEditColor.WMNCPaint(var msg: TWMNCPaint);
- //var
- // cv: TCanvas;
- // dc: HDC;
- // r: TRect;
- //begin
- // dc:= GetWindowDC( handle );
- // SaveDC( dc );
- // try
- // cv:= TCanvas.Create;
- // try
- // cv.Handle := dc;
- // cv.Lock;
- // r:= Rect( 0, 0, Width, Height );
- // With cv.Brush Do Begin
- // Color := Self.Color;
- // Style := bsSolid;
- // End;
- // cv.FrameRect( r );
- // InflateRect( r, -1, -1 );
- // cv.FrameRect( r );
- // With cv.Pen Do Begin
- // Color := FBorder;
- // Style := psSolid;
- // Width := 2;
- // End;
- // cv.MoveTo( r.Left, r.Bottom );
- // cv.LineTo( r.right, r.Bottom );
- // finally
- // cv.Unlock;
- // cv.free;
- // end;
- // finally
- // RestoreDC( dc, -1 );
- // ReleaseDC( handle, dc );
- // end;
- //end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement