You've already forked lazarus-ccr
mbColorLib: Fix DeskPickerButton.
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@5483 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -4,6 +4,8 @@ object ScreenForm: TScreenForm
|
|||||||
Top = 117
|
Top = 117
|
||||||
Width = 149
|
Width = 149
|
||||||
Align = alClient
|
Align = alClient
|
||||||
|
AlphaBlend = True
|
||||||
|
AlphaBlendValue = 1
|
||||||
BorderIcons = []
|
BorderIcons = []
|
||||||
BorderStyle = bsNone
|
BorderStyle = bsNone
|
||||||
Caption = 'Pick a color...'
|
Caption = 'Pick a color...'
|
||||||
|
@ -33,7 +33,6 @@ type
|
|||||||
FOnKeyDown: TKeyEvent;
|
FOnKeyDown: TKeyEvent;
|
||||||
|
|
||||||
protected
|
protected
|
||||||
procedure CreateParams(var Params:TCreateParams); override;
|
|
||||||
procedure CMHintShow(var Message: TCMHintShow); message CM_HINTSHOW;
|
procedure CMHintShow(var Message: TCMHintShow); message CM_HINTSHOW;
|
||||||
|
|
||||||
public
|
public
|
||||||
@ -62,18 +61,20 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function GetDesktopColor(const X, Y: Integer): TColor;
|
function GetDesktopColor(const X, Y: Integer): TColor;
|
||||||
{$IFDEF DELPHI}
|
|
||||||
var
|
var
|
||||||
c: TCanvas;
|
c: TCanvas;
|
||||||
|
screenDC: HDC;
|
||||||
begin
|
begin
|
||||||
c := TCanvas.Create;
|
c := TCanvas.Create;
|
||||||
try
|
try
|
||||||
c.Handle := GetWindowDC(GetDesktopWindow);
|
screenDC := GetDC(0);
|
||||||
Result := GetPixel(c.Handle, X, Y);
|
c.Handle := screenDC;
|
||||||
|
Result := c.Pixels[X, Y];
|
||||||
finally
|
finally
|
||||||
c.Free;
|
c.Free;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
(*
|
||||||
{$ELSE}
|
{$ELSE}
|
||||||
var
|
var
|
||||||
bmp: TBitmap;
|
bmp: TBitmap;
|
||||||
@ -87,12 +88,7 @@ begin
|
|||||||
bmp.Free;
|
bmp.Free;
|
||||||
end;
|
end;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
*)
|
||||||
procedure TScreenForm.CreateParams(var Params:TCreateParams);
|
|
||||||
Begin
|
|
||||||
inherited CreateParams(Params);
|
|
||||||
Params.ExStyle := WS_EX_TRANSPARENT or WS_EX_TOPMOST;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TScreenForm.FormShow(Sender: TObject);
|
procedure TScreenForm.FormShow(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
@ -114,19 +110,23 @@ end;
|
|||||||
procedure TScreenForm.FormKeyDown(Sender: TObject; var Key: Word;
|
procedure TScreenForm.FormKeyDown(Sender: TObject; var Key: Word;
|
||||||
Shift: TShiftState);
|
Shift: TShiftState);
|
||||||
begin
|
begin
|
||||||
if (key = VK_ESCAPE) or (ssAlt in Shift) or (ssCtrl in Shift) then
|
if (key = VK_ESCAPE) or (ssAlt in Shift) or (ssCtrl in Shift) then
|
||||||
EndSelection(0, 0, false);
|
EndSelection(0, 0, false);
|
||||||
if Assigned(FOnKeyDown) then FOnKeyDown(Self, Key, Shift);
|
if (key = VK_RETURN) then
|
||||||
|
EndSelection(Mouse.CursorPos.X, Mouse.CursorPos.Y, true);
|
||||||
|
if Assigned(FOnKeyDown) then
|
||||||
|
FOnKeyDown(Self, Key, Shift);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TScreenForm.EndSelection(x, y: integer; ok: boolean);
|
procedure TScreenForm.EndSelection(x, y: integer; ok: boolean);
|
||||||
begin
|
begin
|
||||||
if ok then
|
if ok then
|
||||||
SelectedColor := GetDesktopColor(x, y)
|
SelectedColor := GetDesktopColor(x, y)
|
||||||
else
|
else
|
||||||
SelectedColor := clNone;
|
SelectedColor := clNone;
|
||||||
close;
|
Close;
|
||||||
if Assigned(FOnSelColorChange) then FOnSelColorChange(Self);
|
if Assigned(FOnSelColorChange) then
|
||||||
|
FOnSelColorChange(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TScreenForm.FormMouseUp(Sender: TObject; Button: TMouseButton;
|
procedure TScreenForm.FormMouseUp(Sender: TObject; Button: TMouseButton;
|
||||||
@ -138,25 +138,26 @@ end;
|
|||||||
procedure TScreenForm.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
|
procedure TScreenForm.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
|
||||||
Y: Integer);
|
Y: Integer);
|
||||||
begin
|
begin
|
||||||
SelectedColor := GetDesktopColor(x, y);
|
SelectedColor := GetDesktopColor(x, y);
|
||||||
if Assigned(FOnSelColorChange) then FOnSelColorChange(Self);
|
if Assigned(FOnSelColorChange) then FOnSelColorChange(Self);
|
||||||
|
Application.ProcessMessages;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TScreenForm.CMHintShow(var Message: TCMHintShow);
|
procedure TScreenForm.CMHintShow(var Message: TCMHintShow);
|
||||||
begin
|
begin
|
||||||
with TCMHintShow(Message) do
|
with TCMHintShow(Message) do
|
||||||
if not ShowHint then
|
if not ShowHint then
|
||||||
Message.Result := 1
|
Message.Result := 1
|
||||||
else
|
else
|
||||||
with HintInfo^ do
|
with HintInfo^ do
|
||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
ReshowTimeout := 1;
|
ReshowTimeout := 1;
|
||||||
HideTimeout := 5000;
|
HideTimeout := 5000;
|
||||||
HintPos := Point(HintPos.X + 16, HintPos.y - 16);
|
HintPos := Point(HintPos.X + 16, HintPos.y - 16);
|
||||||
HintStr := FormatHint(FHintFormat, SelectedColor);
|
HintStr := FormatHint(FHintFormat, SelectedColor);
|
||||||
end;
|
end;
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -62,11 +62,6 @@
|
|||||||
<Debugging>
|
<Debugging>
|
||||||
<UseExternalDbgSyms Value="True"/>
|
<UseExternalDbgSyms Value="True"/>
|
||||||
</Debugging>
|
</Debugging>
|
||||||
<Options>
|
|
||||||
<Win32>
|
|
||||||
<GraphicApplication Value="True"/>
|
|
||||||
</Win32>
|
|
||||||
</Options>
|
|
||||||
</Linking>
|
</Linking>
|
||||||
</CompilerOptions>
|
</CompilerOptions>
|
||||||
<Debugging>
|
<Debugging>
|
||||||
|
@ -56,7 +56,7 @@ object Form1: TForm1
|
|||||||
Height = 287
|
Height = 287
|
||||||
Top = 8
|
Top = 8
|
||||||
Width = 377
|
Width = 377
|
||||||
SelectedColor = 488198
|
SelectedColor = 488454
|
||||||
HSPickerHintFormat = 'H: %h S: %s'#13'Hex: %hex'
|
HSPickerHintFormat = 'H: %h S: %s'#13'Hex: %hex'
|
||||||
LPickerHintFormat = 'Luminance: %l'
|
LPickerHintFormat = 'Luminance: %l'
|
||||||
Anchors = [akTop, akLeft, akRight, akBottom]
|
Anchors = [akTop, akLeft, akRight, akBottom]
|
||||||
@ -691,6 +691,7 @@ object Form1: TForm1
|
|||||||
TabOrder = 0
|
TabOrder = 0
|
||||||
OnSelColorChange = mbDeskPickerButton1SelColorChange
|
OnSelColorChange = mbDeskPickerButton1SelColorChange
|
||||||
ScreenHintFormat = 'RGB(%r, %g, %b)'#13'Hex: %h'
|
ScreenHintFormat = 'RGB(%r, %g, %b)'#13'Hex: %h'
|
||||||
|
ShowScreenHint = True
|
||||||
end
|
end
|
||||||
object Button3: TButton
|
object Button3: TButton
|
||||||
Left = 8
|
Left = 8
|
||||||
|
@ -211,7 +211,7 @@ end;
|
|||||||
|
|
||||||
procedure TForm1.mbColorPalette1SelColorChange(Sender: TObject);
|
procedure TForm1.mbColorPalette1SelColorChange(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
sc.color := mbcolorpalette1.selectedcolor;
|
uc.Color := mbColorPalette1.SelectedColor;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TForm1.mbColorPalette1MouseMove(Sender: TObject;
|
procedure TForm1.mbColorPalette1MouseMove(Sender: TObject;
|
||||||
@ -401,6 +401,7 @@ procedure TForm1.CbShowHintsChange(Sender: TObject);
|
|||||||
begin
|
begin
|
||||||
PageControl1.ShowHint := CbShowHints.Checked;
|
PageControl1.ShowHint := CbShowHints.Checked;
|
||||||
mbOfficeColorDialog1.UseHints := CbShowHints.Checked;
|
mbOfficeColorDialog1.UseHints := CbShowHints.Checked;
|
||||||
|
mbDeskPickerButton1.ShowScreenHint := CbShowHints.Checked;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
@ -51,7 +51,7 @@ constructor TmbDeskPickerButton.Create(AOwner: TComponent);
|
|||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
DoubleBuffered := true;
|
DoubleBuffered := true;
|
||||||
ControlStyle := ControlStyle - [csAcceptsControls] + [csOpaque{$IFDEF DELPHI_7_UP}, csParentBackground{$ENDIF}];
|
// ControlStyle := ControlStyle - [csAcceptsControls] + [csOpaque{$IFDEF DELPHI_7_UP}, csParentBackground{$ENDIF}];
|
||||||
FHintFmt := 'RGB(%r, %g, %b)'#13'Hex: %h';
|
FHintFmt := 'RGB(%r, %g, %b)'#13'Hex: %h';
|
||||||
FShowScreenHint := false;
|
FShowScreenHint := false;
|
||||||
end;
|
end;
|
||||||
@ -80,8 +80,8 @@ end;
|
|||||||
|
|
||||||
procedure TmbDeskPickerButton.ColorPicked(Sender: TObject);
|
procedure TmbDeskPickerButton.ColorPicked(Sender: TObject);
|
||||||
begin
|
begin
|
||||||
FSelColor := ScreenFrm.SelectedColor;
|
FSelColor := ScreenFrm.SelectedColor;
|
||||||
if Assigned(FOnColorPicked) then FOnColorPicked(Self);
|
if Assigned(FOnColorPicked) then FOnColorPicked(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TmbDeskPickerButton.ScreenKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
procedure TmbDeskPickerButton.ScreenKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||||
|
Reference in New Issue
Block a user