Registriert seit: 27. Jun 2006
Ort: im hintersten Winkel des RAMs
182 Beiträge
Delphi 2007 Professional
|
Re: TEdit mit Rand
26. Mär 2008, 15:46
so, hab's jetzt mal probiert. allerdings funzt das mit dem OnEnter / OnExit noch nicht. Könntet ihr mir da helfen, was ich da machen muss?
Habe bisher einfach nur einen 1px roten Rahmen zeichnen lassen.
So sieht die Unit aus:
Delphi-Quellcode:
unit SEdit;
interface
uses
Windows, SysUtils, Classes, Controls, StdCtrls, Messages, graphics;
type
TSEdit = class(TEdit)
private
procedure WMNCCalcSize( var Msg: TWMNCCALCSIZE); message WM_NCCALCSIZE;
procedure WMNCPAINT( var Msg: TWMNCPaint); message WM_NCPaint;
procedure unmark;
protected
{ Protected-Deklarationen }
public
procedure RePaint; override;
published
procedure DoEnter;
procedure DoExit;
{ Published-Deklarationen }
end;
procedure Register;
var h: TWMNCPAINT;
dc: hDc;
Pen: hPen;
OldPen: hPen;
OldBrush: hBrush;
sel: boolean=true;
implementation
procedure Register;
begin
RegisterComponents(' Zusätzlich', [TSEdit]);
end;
procedure TSEdit.RePaint;
begin
WMNCPAINT(h);
end;
procedure TSedit.WMNCCalcSize( var Msg: TWMNCCalcSize);
begin
exit;
end;
procedure TSEdit.WMNCPAINT( var Msg: TWMNCPAINT);
begin
inherited;
if not sel then
unmark;
dc := GetWindowDC( Handle);
Msg.Result := 1;
//Change the RGB value to change the color
Pen := CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
OldPen := SelectObject( dc, Pen);
OldBrush := SelectObject( dc, GetStockObject(NULL_BRUSH));
Rectangle( dc, 0, 0, Width, Height);
SelectObject( dc, OldBrush);
SelectObject( dc, OldPen);
DeleteObject(Pen);
ReleaseDC( Handle, Handle);
end;
procedure TSEdit.DoEnter;
begin
sel := true;
end;
procedure TSEdit.DoExit;
begin
sel := false;
end;
procedure TSEdit.unmark;
begin
inherited;
dc := GetWindowDC( Handle);
//Change the RGB value to change the color
Pen := CreatePen(PS_SOLID, 1, color);
OldPen := SelectObject( dc, Pen);
OldBrush := SelectObject( dc, GetStockObject(NULL_BRUSH));
Rectangle( dc, 0, 0, Width, Height);
SelectObject( dc, OldBrush);
SelectObject( dc, OldPen);
DeleteObject(Pen);
ReleaseDC( Handle, Handle);
end;
end.
Real Programmers always confuse Christmas and Halloween because Oct31 = Dec25. - Andrew Rutherford
|
|
Zitat
|