📄 rm_ctrls.pas
字号:
{$IFDEF USE_TB2k}
Value.Items.Add(self);
{$ELSE}
if Parent <> Value then
Parent := Value;
{$ENDIF}
end;
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{$IFDEF USE_TB2k}
function TRMToolbar.GetDockedto: TRMDock;
begin
Result := CurrentDock;
end;
procedure TRMToolbar.SetDockedto(Value: TRMDock);
begin
CurrentDock := Value;
end;
{$ENDIF}
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{TRMToolbarButton}
procedure TRMToolbarButton.SetAddTo(Value: TRMToolBar);
begin
{$IFDEF USE_TB2k}
Value.Items.Add(self);
{$ELSE}
if Parent <> Value then
Parent := Value;
{$ENDIF}
end;
{$IFDEF USE_TB2k}
function TRMToolbarButton.GetDown: Boolean;
begin
Result := Checked;
end;
procedure TRMToolbarButton.SetDown(Value: Boolean);
begin
Checked := Value;
end;
function TRMToolbarButton.GetAllowAllUp: Boolean;
begin
Result := AutoCheck;
end;
procedure TRMToolbarButton.SetAllowAllUp(Value: Boolean);
begin
AutoCheck := Value;
end;
{$ENDIF}
//dejoy added begin
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{TRMCustomMenuItem}
{$IFDEF USE_TB2k}
function TRMCustomMenuItem.GetRadioItem: boolean;
begin
Result := AutoCheck;
end;
procedure TRMCustomMenuItem.SetRadioItem(Value: boolean);
begin
AutoCheck := Value;
end;
procedure TRMCustomMenuItem.SetAddTo(Value: TRMToolBar);
begin
Value.Items.Add(self);
end;
{$ELSE}
function TRMCustomMenuItem.GetImages: TCustomImageList;
var
M: TMenu;
begin
m := GetParentMenu;
if m <> nil then
Result := m.Images
else
Result := nil;
end;
procedure TRMCustomMenuItem.SetImages(Value: TCustomImageList);
var
M: TMenu;
begin
m := GetParentMenu;
if m <> nil then
with m do
begin
if Images <> Value then
Images := Value;
end;
end;
{$ENDIF}
procedure TRMCustomMenuItem.AddToMenu(Value: TRMMenuBar);
begin
Value.Items.Add(self);
end;
procedure TRMCustomMenuItem.AddToMenu(Value: TRMCustomMenuItem);
begin
Value.Add(self);
end;
procedure TRMCustomMenuItem.AddToMenu(Value: TRMSubMenuItem);
begin
Value.Add(self);
end;
procedure TRMCustomMenuItem.AddToMenu(Value: TRMPopupMenu);
begin
Value.Items.Add(self);
end;
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{TRMSubMenuItem}
{$IFDEF USE_TB2K}
procedure TRMSubMenuItem.SetAddTo(Value: TRMToolBar);
begin
Value.Items.Add(self);
end;
procedure TRMSubMenuItem.AddToMenu(Value: TRMMenuBar);
begin
Value.Items.Add(self);
end;
procedure TRMSubMenuItem.AddToMenu(Value: TRMCustomMenuItem);
begin
Value.Add(self);
end;
procedure TRMSubMenuItem.AddToMenu(Value: TRMSubMenuItem);
begin
Value.Add(self);
end;
procedure TRMSubMenuItem.AddToMenu(Value: TRMPopupMenu);
begin
Value.Items.Add(self);
end;
{$ENDIF}
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
{ TRMSeparatorMenuItem }
{$IFDEF USE_TB2K}
procedure TRMSeparatorMenuItem.AddToMenu(Value: TRMMenuBar);
begin
Value.Items.Add(self);
end;
procedure TRMSeparatorMenuItem.AddToMenu(Value: TRMCustomMenuItem);
begin
Value.Add(self);
end;
procedure TRMSeparatorMenuItem.AddToMenu(Value: TRMSubMenuItem);
begin
Value.Add(self);
end;
procedure TRMSeparatorMenuItem.AddToMenu(Value: TRMPopupMenu);
begin
Value.Items.Add(self);
end;
{$ELSE}
constructor TRMSeparatorMenuItem.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Caption := '-';
end;
{$ENDIF}
{ TRMCustomComboBox97 }
constructor TRMCustomComboBox97.Create(AOwner: TComponent);
begin
inherited;
FButtonWidth := GetSystemMetrics(SM_CXVSCROLL) + 2;
FOldColor := inherited Color;
FOldParentColor := inherited ParentColor;
FFlat := True;
end;
procedure TRMCustomComboBox97.SetFlat(const Value: Boolean);
begin
if Value <> FFlat then
begin
FFlat := Value;
Ctl3D := not Value;
Invalidate;
end;
end;
// Verifica si el bot髇 todav韆 deba estar presionado
procedure TRMCustomComboBox97.CMEnter(var Message: TCMEnter);
begin
inherited;
if not (csDesigning in ComponentState) then
DrawBorders;
end;
procedure TRMCustomComboBox97.CMExit(var Message: TCMExit);
begin
inherited;
if not (csDesigning in ComponentState) then
DrawBorders;
end;
procedure TRMCustomComboBox97.CMMouseEnter(var Message: TMessage);
begin
inherited;
if not FMouseInControl and Enabled then
begin
FMouseInControl := True;
DrawBorders;
end;
end;
procedure TRMCustomComboBox97.CMMouseLeave(var Message: TMessage);
begin
inherited;
if FMouseInControl and Enabled then
begin
FMouseInControl := False;
DrawBorders
end;
end;
procedure TRMCustomComboBox97.CMEnabledChanged(var Msg: TMessage);
begin
inherited;
// Si se desea plano
if FFlat then
// Si se habilita se recupera su color anterior ?
// si se inhabilita se guarda su color actual y se utiliza el del contenedor,
// as?se d?la apariencia del ComboBox inhabilitado de Office97.
if Enabled then
begin
inherited Color := FOldColor;
inherited ParentColor := FOldParentColor;
end
else
begin
FOldParentColor := inherited Parentcolor;
FOldColor := inherited Color;
inherited ParentColor := True;
end;
end;
procedure TRMCustomComboBox97.WMPaint(var Message: TWMPaint);
var
DC: HDC;
PS: TPaintStruct;
procedure DrawButton;
var
ARect: TRect;
begin
// Obtiene las coordenadas de los l韒ites del bot髇
GetWindowRect(Handle, ARect);
OffsetRect(ARect, -ARect.Left, -ARect.Top);
Inc(ARect.Left, ClientWidth - FButtonWidth);
InflateRect(ARect, -1, -1);
// Dibuja el bot髇
DrawFrameControl(DC, ARect, DFC_SCROLL, DFCS_SCROLLCOMBOBOX or DFCS_FLAT);
// Notifica a Windows que ya no tiene que dibujar el bot髇
ExcludeClipRect(DC, ClientWidth - FButtonWidth - 4, 0, ClientWidth, ClientHeight);
end;
begin
// Si no es plano s髄o se hacer lo de omisi髇
if not FFlat then
begin
inherited;
Exit;
end;
// Utiliza o crea el dispositivo de contexto
if Message.DC = 0 then
DC := BeginPaint(Handle, PS)
else
DC := Message.DC;
try
// Si el estilo as?lo requiere dibuja el bot髇 y una base
if Style <> csSimple then
begin
FillRect(DC, ClientRect, Brush.Handle);
DrawButton; //(DC);
end;
// Dibuja el ComboBox
PaintWindow(DC);
finally
// Elimina el dispositivo de contexto si fu?creado aqu?
if Message.DC = 0 then
EndPaint(Handle, PS);
end;
// Dibuja los bordes del ComboBox y del bot髇 incluido
DrawBorders;
end;
function TRMCustomComboBox97.NeedDraw3DBorder: Boolean;
begin
// Se requiere dibujar el borde cuando el rat髇 esta encima
// o cuando es el control activo.
if csDesigning in ComponentState then
Result := Enabled
else
Result := FMouseInControl or (Screen.ActiveControl = Self);
end;
// Dibuja el borde del bot髇 incluido
procedure TRMCustomComboBox97.DrawButtonBorder(DC: HDC);
const
Flags: array[Boolean] of Integer = (0, BF_FLAT);
var
ARect: TRect;
BtnFaceBrush: HBRUSH;
begin
// Notifica a Windows que no tiene que dibujar sobre bot髇
ExcludeClipRect(DC, ClientWidth - FButtonWidth + 4, 4,
ClientWidth - 4, ClientHeight - 4);
// Obtiene las coordenadas de los l韒ites del bot髇
GetWindowRect(Handle, ARect);
OffsetRect(ARect, -ARect.Left, -ARect.Top);
Inc(ARect.Left, ClientWidth - FButtonWidth - 2);
InflateRect(ARect, -2, -2);
// Dibuja un borde 3D o plano seg鷑 se requiera
if NeedDraw3DBorder then
DrawEdge(DC, ARect, EDGE_RAISED, BF_RECT or Flags[csButtonPressed in FEditState])
else
begin
BtnFaceBrush := CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
try
InflateRect(ARect, -1, -1);
FillRect(DC, ARect, BtnFaceBrush);
finally
DeleteObject(BtnFaceBrush);
end;
end;
// Notifica a Windows que ya no tiene que dibujar el bot髇
ExcludeClipRect(DC, ARect.Left, ARect.Top, ARect.Right, ARect.Bottom);
end;
// Dibuja el borde del ComboBox
procedure TRMCustomComboBox97.DrawControlBorder(DC: HDC);
var
ARect: TRect;
BtnFaceBrush, WindowBrush: HBRUSH; // Brochas necesarias para el efecto 3D
begin
// Crea las brochas necesarias para el efecto 3D
BtnFaceBrush := CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
WindowBrush := CreateSolidBrush(GetSysColor(COLOR_WINDOW));
try
// Obtiene las coordenadas de los l韒ites del ComboBox
GetWindowRect(Handle, ARect);
OffsetRect(ARect, -ARect.Left, -ARect.Top);
// Dibuja un borde 3D o plano seg鷑 se requiera
if NeedDraw3DBorder then
begin
DrawEdge(DC, ARect, BDR_SUNKENOUTER, BF_RECT or BF_ADJUST);
FrameRect(DC, ARect, BtnFaceBrush);
InflateRect(ARect, -1, -1);
FrameRect(DC, ARect, WindowBrush);
end
else
begin
FrameRect(DC, ARect, BtnFaceBrush);
InflateRect(ARect, -1, -1);
FrameRect(DC, ARect, BtnFaceBrush);
InflateRect(ARect, -1, -1);
FrameRect(DC, ARect, WindowBrush);
end;
finally
// Elimina las brochas
DeleteObject(WindowBrush);
DeleteObject(BtnFaceBrush);
end;
end;
// Dibuja los bordes del ComboBox y del bot髇 incluido
procedure TRMCustomComboBox97.DrawBorders;
var
lDC: HDC;
begin
if not FFlat then Exit;
lDC := GetDC(Handle); //GetWindowDC(Handle);
try
DrawControlBorder(lDC);
if Style <> csSimple then
DrawButtonBorder(lDC);
finally
ReleaseDC(Handle, lDC);
end;
end;
procedure TRMCustomComboBox97.TrackButtonPressed(X, Y: Integer);
var
ARect: TRect;
begin
SetRect(ARect, ClientWidth - FButtonWidth, 0, ClientWidth, ClientHeight);
if (csButtonPressed in FEditState) and not PtInRect(ARect, Point(X, Y)) then
begin
Exclude(FEditState, csButtonPressed);
DrawBorders;
end;
end;
procedure TRMCustomComboBox97.MouseDown(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
begin
if DroppedDown then
begin
Include(FEditState, csButtonPressed);
Include(FEditState, csMouseCaptured);
Invalidate;
end;
inherited;
end;
procedure TRMCustomComboBox97.MouseMove(Shift: TShiftState; X, Y: Integer);
begin
if csMouseCaptured in FEditState then
TrackButtonPressed(X, Y);
inherited;
end;
procedure TRMCustomComboBox97.MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer);
begin
TrackButtonPressed(-1, -1);
inherited;
end;
procedure TRMCustomComboBox97.CMMouseWheel(var Message: TCMMouseWheel);
begin
Abort;
end;
{ TRMSpinButton }
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------}
constructor TRMSpinButton.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FUpBitmap := TBitmap.Create;
FDownBitmap := TBitmap.Create;
FUpBitmap.Handle := LoadBitmap(HInstance, sSpinUpBtn);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -