📄 jvexmask.pas
字号:
{-----------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1.1.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is: JvExMask.pas, released on 2004-01-04
The Initial Developer of the Original Code is Andreas Hausladen [Andreas dott Hausladen att gmx dott de]
Portions created by Andreas Hausladen are Copyright (C) 2004 Andreas Hausladen.
All Rights Reserved.
Contributor(s): -
You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
located at http://jvcl.sourceforge.net
Known Issues:
-----------------------------------------------------------------------------}
// $Id: JvExMask.pas,v 1.56 2005/03/09 07:25:03 marquardt Exp $
unit JvExMask;
{$I jvcl.inc}
{MACROINCLUDE JvExControls.macros}
{*****************************************************************************
* WARNING: Do not edit this file.
* This file is autogenerated from the source in devtools/JvExVCL/src.
* If you do it despite this warning your changes will be discarded by the next
* update of this file. Do your changes in the template files.
****************************************************************************}
interface
uses
Windows, Messages,
{$IFDEF HAS_UNIT_TYPES}
Types,
{$ENDIF HAS_UNIT_TYPES}
SysUtils, Classes, Graphics, Controls, Forms, Mask,
{$IFDEF UNITVERSIONING}
JclUnitVersioning,
{$ENDIF UNITVERSIONING}
JvTypes, JvThemes, JVCLVer, JvExControls;
type
TJvExCustomMaskEdit = class(TCustomMaskEdit, IJvExControl)
private
FAboutJVCL: TJVCLAboutInfo;
FHintColor: TColor;
FMouseOver: Boolean;
{$IFDEF VCL}
FOnMouseEnter: TNotifyEvent;
FOnMouseLeave: TNotifyEvent;
{$ENDIF VCL}
FOnParentColorChanged: TNotifyEvent;
function BaseWndProc(Msg: Integer; WParam: Integer = 0; LParam: Integer = 0): Integer;
protected
procedure WndProc(var Msg: TMessage); override;
procedure FocusChanged(AControl: TWinControl); dynamic;
procedure VisibleChanged; reintroduce; dynamic;
procedure EnabledChanged; reintroduce; dynamic;
procedure TextChanged; reintroduce; virtual;
procedure ColorChanged; reintroduce; dynamic;
procedure FontChanged; reintroduce; dynamic;
procedure ParentFontChanged; reintroduce; dynamic;
procedure ParentColorChanged; reintroduce; dynamic;
procedure ParentShowHintChanged; reintroduce; dynamic;
function WantKey(Key: Integer; Shift: TShiftState; const KeyText: WideString): Boolean; reintroduce; virtual;
function HintShow(var HintInfo: THintInfo): Boolean; reintroduce; dynamic;
function HitTest(X, Y: Integer): Boolean; reintroduce; virtual;
procedure MouseEnter(AControl: TControl); reintroduce; dynamic;
procedure MouseLeave(AControl: TControl); reintroduce; dynamic;
{$IFDEF COMPILER5}
{$IFNDEF HASAUTOSIZE}
procedure CMSetAutoSize(var Msg: TMessage); message CM_SETAUTOSIZE;
procedure SetAutoSize(Value: Boolean); virtual;
{$ENDIF !HASAUTOSIZE}
{$ENDIF COMPILER5}
property MouseOver: Boolean read FMouseOver write FMouseOver;
property HintColor: TColor read FHintColor write FHintColor default clDefault;
{$IFDEF VCL}
property OnMouseEnter: TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
property OnMouseLeave: TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
{$ENDIF VCL}
property OnParentColorChange: TNotifyEvent read FOnParentColorChanged write FOnParentColorChanged;
public
constructor Create(AOwner: TComponent); override;
published
property AboutJVCL: TJVCLAboutInfo read FAboutJVCL write FAboutJVCL stored False;
protected
procedure BoundsChanged; reintroduce; virtual;
procedure CursorChanged; reintroduce; dynamic;
procedure ShowingChanged; reintroduce; dynamic;
procedure ShowHintChanged; reintroduce; dynamic;
procedure ControlsListChanging(Control: TControl; Inserting: Boolean); reintroduce; dynamic;
procedure ControlsListChanged(Control: TControl; Inserting: Boolean); reintroduce; dynamic;
procedure GetDlgCode(var Code: TDlgCodes); virtual;
procedure FocusSet(PrevWnd: HWND); virtual;
procedure FocusKilled(NextWnd: HWND); virtual;
function DoEraseBackground(Canvas: TCanvas; Param: Integer): Boolean; virtual;
{$IFDEF JVCLThemesEnabledD56}
private
function GetParentBackground: Boolean;
protected
procedure SetParentBackground(Value: Boolean); virtual;
property ParentBackground: Boolean read GetParentBackground write SetParentBackground;
{$ENDIF JVCLThemesEnabledD56}
private
FClipboardCommands: TJvClipboardCommands;
protected
procedure SetClipboardCommands(const Value: TJvClipboardCommands); virtual;
property ClipboardCommands: TJvClipboardCommands read FClipboardCommands write SetClipboardCommands default [caCopy..caUndo];
private
FBeepOnError: Boolean;
protected
procedure DoBeepOnError; dynamic;
procedure SetBeepOnError(Value: Boolean); virtual;
property BeepOnError: Boolean read FBeepOnError write SetBeepOnError default True;
end;
TJvExMaskEdit = class(TMaskEdit, IJvExControl)
private
FAboutJVCL: TJVCLAboutInfo;
FHintColor: TColor;
FMouseOver: Boolean;
{$IFDEF VCL}
FOnMouseEnter: TNotifyEvent;
FOnMouseLeave: TNotifyEvent;
{$ENDIF VCL}
FOnParentColorChanged: TNotifyEvent;
function BaseWndProc(Msg: Integer; WParam: Integer = 0; LParam: Integer = 0): Integer;
protected
procedure WndProc(var Msg: TMessage); override;
procedure FocusChanged(AControl: TWinControl); dynamic;
procedure VisibleChanged; reintroduce; dynamic;
procedure EnabledChanged; reintroduce; dynamic;
procedure TextChanged; reintroduce; virtual;
procedure ColorChanged; reintroduce; dynamic;
procedure FontChanged; reintroduce; dynamic;
procedure ParentFontChanged; reintroduce; dynamic;
procedure ParentColorChanged; reintroduce; dynamic;
procedure ParentShowHintChanged; reintroduce; dynamic;
function WantKey(Key: Integer; Shift: TShiftState; const KeyText: WideString): Boolean; reintroduce; virtual;
function HintShow(var HintInfo: THintInfo): Boolean; reintroduce; dynamic;
function HitTest(X, Y: Integer): Boolean; reintroduce; virtual;
procedure MouseEnter(AControl: TControl); reintroduce; dynamic;
procedure MouseLeave(AControl: TControl); reintroduce; dynamic;
{$IFDEF COMPILER5}
{$IFNDEF HASAUTOSIZE}
procedure CMSetAutoSize(var Msg: TMessage); message CM_SETAUTOSIZE;
procedure SetAutoSize(Value: Boolean); virtual;
{$ENDIF !HASAUTOSIZE}
{$ENDIF COMPILER5}
property MouseOver: Boolean read FMouseOver write FMouseOver;
property HintColor: TColor read FHintColor write FHintColor default clDefault;
{$IFDEF VCL}
property OnMouseEnter: TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
property OnMouseLeave: TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
{$ENDIF VCL}
property OnParentColorChange: TNotifyEvent read FOnParentColorChanged write FOnParentColorChanged;
public
constructor Create(AOwner: TComponent); override;
published
property AboutJVCL: TJVCLAboutInfo read FAboutJVCL write FAboutJVCL stored False;
protected
procedure BoundsChanged; reintroduce; virtual;
procedure CursorChanged; reintroduce; dynamic;
procedure ShowingChanged; reintroduce; dynamic;
procedure ShowHintChanged; reintroduce; dynamic;
procedure ControlsListChanging(Control: TControl; Inserting: Boolean); reintroduce; dynamic;
procedure ControlsListChanged(Control: TControl; Inserting: Boolean); reintroduce; dynamic;
procedure GetDlgCode(var Code: TDlgCodes); virtual;
procedure FocusSet(PrevWnd: HWND); virtual;
procedure FocusKilled(NextWnd: HWND); virtual;
function DoEraseBackground(Canvas: TCanvas; Param: Integer): Boolean; virtual;
{$IFDEF JVCLThemesEnabledD56}
private
function GetParentBackground: Boolean;
protected
procedure SetParentBackground(Value: Boolean); virtual;
property ParentBackground: Boolean read GetParentBackground write SetParentBackground;
{$ENDIF JVCLThemesEnabledD56}
private
FClipboardCommands: TJvClipboardCommands;
protected
procedure SetClipboardCommands(const Value: TJvClipboardCommands); virtual;
property ClipboardCommands: TJvClipboardCommands read FClipboardCommands write SetClipboardCommands default [caCopy..caUndo];
private
FBeepOnError: Boolean;
protected
procedure DoBeepOnError; dynamic;
procedure SetBeepOnError(Value: Boolean); virtual;
property BeepOnError: Boolean read FBeepOnError write SetBeepOnError default True;
end;
{$IFDEF UNITVERSIONING}
const
UnitVersioning: TUnitVersionInfo = (
RCSfile: '$RCSfile: JvExMask.pas,v $';
Revision: '$Revision: 1.56 $';
Date: '$Date: 2005/03/09 07:25:03 $';
LogPath: 'JVCL\run'
);
{$ENDIF UNITVERSIONING}
implementation
constructor TJvExCustomMaskEdit.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FHintColor := clDefault;
FClipboardCommands := [caCopy..caUndo];
FBeepOnError := True;
end;
function TJvExCustomMaskEdit.BaseWndProc(Msg: Integer; WParam: Integer = 0; LParam: Integer = 0): Integer;
var
Mesg: TMessage;
begin
Mesg.Msg := Msg;
Mesg.WParam := WParam;
Mesg.LParam := LParam;
Mesg.Result := 0;
inherited WndProc(Mesg);
Result := Mesg.Result;
end;
procedure TJvExCustomMaskEdit.VisibleChanged;
begin
BaseWndProc(CM_VISIBLECHANGED);
end;
procedure TJvExCustomMaskEdit.EnabledChanged;
begin
BaseWndProc(CM_ENABLEDCHANGED);
end;
procedure TJvExCustomMaskEdit.TextChanged;
begin
BaseWndProc(CM_TEXTCHANGED);
end;
procedure TJvExCustomMaskEdit.FontChanged;
begin
BaseWndProc(CM_FONTCHANGED);
end;
procedure TJvExCustomMaskEdit.ColorChanged;
begin
BaseWndProc(CM_COLORCHANGED);
end;
procedure TJvExCustomMaskEdit.ParentFontChanged;
begin
BaseWndProc(CM_PARENTFONTCHANGED);
end;
procedure TJvExCustomMaskEdit.ParentColorChanged;
begin
BaseWndProc(CM_PARENTCOLORCHANGED);
if Assigned(OnParentColorChange) then
OnParentColorChange(Self);
end;
procedure TJvExCustomMaskEdit.ParentShowHintChanged;
begin
BaseWndProc(CM_PARENTSHOWHINTCHANGED);
end;
function TJvExCustomMaskEdit.WantKey(Key: Integer; Shift: TShiftState; const KeyText: WideString): Boolean;
begin
Result := BaseWndProc(CM_DIALOGCHAR, Word(Key), ShiftStateToKeyData(Shift)) <> 0;
end;
function TJvExCustomMaskEdit.HitTest(X, Y: Integer): Boolean;
begin
Result := BaseWndProc(CM_HITTEST, 0, Integer(PointToSmallPoint(Point(X, Y)))) <> 0;
end;
function TJvExCustomMaskEdit.HintShow(var HintInfo: THintInfo): Boolean;
begin
GetHintColor(HintInfo, Self, FHintColor);
Result := BaseWndProc(CM_HINTSHOW, 0, Integer(@HintInfo)) <> 0;
end;
procedure TJvExCustomMaskEdit.MouseEnter(AControl: TControl);
begin
FMouseOver := True;
{$IFDEF VCL}
if Assigned(FOnMouseEnter) then
FOnMouseEnter(Self);
{$ENDIF VCL}
BaseWndProc(CM_MOUSEENTER, 0, Integer(AControl));
end;
procedure TJvExCustomMaskEdit.MouseLeave(AControl: TControl);
begin
FMouseOver := False;
BaseWndProc(CM_MOUSELEAVE, 0, Integer(AControl));
{$IFDEF VCL}
if Assigned(FOnMouseLeave) then
FOnMouseLeave(Self);
{$ENDIF VCL}
end;
procedure TJvExCustomMaskEdit.FocusChanged(AControl: TWinControl);
begin
BaseWndProc(CM_FOCUSCHANGED, 0, Integer(AControl));
end;
{$IFDEF COMPILER5}
{$IFNDEF HASAUTOSIZE}
procedure TJvExCustomMaskEdit.CMSetAutoSize(var Msg: TMessage);
begin
SetAutoSize(Msg.WParam <> 0);
end;
procedure TJvExCustomMaskEdit.SetAutoSize(Value: Boolean);
begin
TOpenControl_SetAutoSize(Self, Value);
end;
{$ENDIF !HASAUTOSIZE}
{$ENDIF COMPILER5}
procedure TJvExCustomMaskEdit.BoundsChanged;
begin
end;
procedure TJvExCustomMaskEdit.CursorChanged;
begin
BaseWndProc(CM_CURSORCHANGED);
end;
procedure TJvExCustomMaskEdit.ShowingChanged;
begin
BaseWndProc(CM_SHOWINGCHANGED);
end;
procedure TJvExCustomMaskEdit.ShowHintChanged;
begin
BaseWndProc(CM_SHOWHINTCHANGED);
end;
{ VCL sends CM_CONTROLLISTCHANGE and CM_CONTROLCHANGE in a different order than
the CLX methods are used. So we must correct it by evaluating "Inserting". }
procedure TJvExCustomMaskEdit.ControlsListChanging(Control: TControl; Inserting: Boolean);
begin
if Inserting then
BaseWndProc(CM_CONTROLLISTCHANGE, Integer(Control), Integer(Inserting))
else
BaseWndProc(CM_CONTROLCHANGE, Integer(Control), Integer(Inserting));
end;
procedure TJvExCustomMaskEdit.ControlsListChanged(Control: TControl; Inserting: Boolean);
begin
if not Inserting then
BaseWndProc(CM_CONTROLLISTCHANGE, Integer(Control), Integer(Inserting))
else
BaseWndProc(CM_CONTROLCHANGE, Integer(Control), Integer(Inserting));
end;
procedure TJvExCustomMaskEdit.GetDlgCode(var Code: TDlgCodes);
begin
end;
procedure TJvExCustomMaskEdit.FocusSet(PrevWnd: HWND);
begin
BaseWndProc(WM_SETFOCUS, Integer(PrevWnd), 0);
end;
procedure TJvExCustomMaskEdit.FocusKilled(NextWnd: HWND);
begin
BaseWndProc(WM_KILLFOCUS, Integer(NextWnd), 0);
end;
function TJvExCustomMaskEdit.DoEraseBackground(Canvas: TCanvas; Param: Integer): Boolean;
begin
Result := BaseWndProc(WM_ERASEBKGND, Canvas.Handle, Param) <> 0;
end;
{$IFDEF JVCLThemesEnabledD56}
function TJvExCustomMaskEdit.GetParentBackground: Boolean;
begin
Result := JvThemes.GetParentBackground(Self);
end;
procedure TJvExCustomMaskEdit.SetParentBackground(Value: Boolean);
begin
JvThemes.SetParentBackground(Self, Value);
end;
{$ENDIF JVCLThemesEnabledD56}
procedure TJvExCustomMaskEdit.SetClipboardCommands(const Value: TJvClipboardCommands);
begin
FClipboardCommands := Value;
end;
procedure TJvExCustomMaskEdit.WndProc(var Msg: TMessage);
var
IdSaveDC: Integer;
DlgCodes: TDlgCodes;
Canvas: TCanvas;
begin
case Msg.Msg of
CM_DENYSUBCLASSING:
Msg.Result := Ord(GetInterfaceEntry(IJvDenySubClassing) <> nil);
CM_DIALOGCHAR:
with TCMDialogChar(Msg) do
Result := Ord(WantKey(CharCode, KeyDataToShiftState(KeyData), WideChar(CharCode)));
CM_HINTSHOW:
with TCMHintShow(Msg) do
Result := Integer(HintShow(HintInfo^));
CM_HITTEST:
with TCMHitTest(Msg) do
Result := Integer(HitTest(XPos, YPos));
CM_MOUSEENTER:
MouseEnter(TControl(Msg.LParam));
CM_MOUSELEAVE:
MouseLeave(TControl(Msg.LParam));
CM_VISIBLECHANGED:
VisibleChanged;
CM_ENABLEDCHANGED:
EnabledChanged;
CM_TEXTCHANGED:
TextChanged;
CM_FONTCHANGED:
FontChanged;
CM_COLORCHANGED:
ColorChanged;
CM_FOCUSCHANGED:
FocusChanged(TWinControl(Msg.LParam));
CM_PARENTFONTCHANGED:
ParentFontChanged;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -