📄 suidbctrls.pas
字号:
SetUIStyle(SUI_THEME_DEFAULT);
end;
end;
procedure TsuiDBListBox.SetBorderColor(const Value: TColor);
begin
m_BorderColor := Value;
Repaint();
end;
procedure TsuiDBListBox.WMEARSEBKGND(var Msg: TMessage);
begin
inherited;
DrawControlBorder(self, m_BorderColor, Color);
end;
procedure TsuiDBListBox.WMPAINT(var Msg: TMessage);
begin
inherited;
DrawControlBorder(self, m_BorderColor, COlor);
end;
procedure TsuiDBListBox.CMEnabledChanged(var Msg: TMessage);
begin
inherited;
UpdateScrollBars();
end;
procedure TsuiDBListBox.LBADDSTRING(var Msg: TMessage);
begin
inherited;
UpdateScrollBars();
end;
procedure TsuiDBListBox.LBDELETESTRING(var Msg: TMessage);
begin
inherited;
UpdateScrollBars();
end;
procedure TsuiDBListBox.LBINSERTSTRING(var Msg: TMessage);
begin
inherited;
UpdateScrollBars();
end;
procedure TsuiDBListBox.LBNSELCHANGE(var Msg: TMessage);
begin
inherited;
UpdateScrollBars();
end;
procedure TsuiDBListBox.LBNSETFOCUS(var Msg: TMessage);
begin
inherited;
UpdateScrollBars();
end;
procedure TsuiDBListBox.LBSETCOUNT(var Msg: TMessage);
begin
inherited;
UpdateScrollBars();
end;
procedure TsuiDBListBox.OnVScrollBarChange(Sender: TObject);
begin
if m_SelfChanging then
Exit;
SendMessage(Handle, WM_VSCROLL, MakeWParam(SB_THUMBPOSITION, m_VScrollBar.Position), 0);
Invalidate;
end;
procedure TsuiDBListBox.SetVScrollBar(const Value: TsuiScrollBar);
begin
if m_VScrollBar = Value then
Exit;
if m_VScrollBar <> nil then
begin
m_VScrollBar.OnChange := nil;
m_VScrollBar.LineButton := 0;
m_VScrollBar.Max := 100;
m_VScrollBar.Enabled := true;
end;
m_VScrollBar := Value;
if m_VScrollBar = nil then
Exit;
m_VScrollBar.Orientation := suiVertical;
m_VScrollBar.OnChange := OnVScrollBArChange;
m_VScrollBar.BringToFront();
UpdateScrollBarsPos();
end;
procedure TsuiDBListBox.UpdateScrollBars;
var
info : tagScrollInfo;
barinfo : tagScrollBarInfo;
R : Boolean;
begin
m_SelfChanging := true;
if m_VScrollBar <> nil then
begin
barinfo.cbSize := SizeOf(barinfo);
R := SUIGetScrollBarInfo(Handle, Integer(OBJID_VSCROLL), barinfo);
if (barinfo.rgstate[0] = STATE_SYSTEM_INVISIBLE) or
(barinfo.rgstate[0] = STATE_SYSTEM_UNAVAILABLE) or
(not R) then
begin
m_VScrollBar.LineButton := 0;
m_VScrollBar.Enabled := false;
m_VScrollBar.Visible := false;
end
else if not Enabled then
m_VScrollBar.Enabled := false
else
begin
m_VScrollBar.LineButton := abs(barinfo.xyThumbBottom - barinfo.xyThumbTop);
m_VScrollBar.Enabled := true;
m_VScrollBar.Visible := true;
end;
info.cbSize := SizeOf(info);
info.fMask := SIF_ALL;
GetScrollInfo(Handle, SB_VERT, info);
m_VScrollBar.Max := info.nMax - Integer(info.nPage) + 1;
m_VScrollBar.Min := info.nMin;
m_VScrollBar.Position := info.nPos;
end;
m_SelfChanging := false;
end;
procedure TsuiDBListBox.UpdateScrollBarsPos;
var
L2R : Boolean;
begin
if m_VScrollBar <> nil then
begin
L2R := ((BidiMode = bdLeftToRight) or (BidiMode = bdRightToLeftReadingOnly)) or (not SysLocale.MiddleEast);
if L2R then
m_VScrollBar.Left := Left + Width - m_VScrollBar.Width - 2
else
m_VScrollBar.Left := Left + 2;
m_VScrollBar.Top := Top + 1;
m_VScrollBar.Height := Height - 2;
end;
UpdateScrollBars();
end;
procedure TsuiDBListBox.WMDELETEITEM(var Msg: TMessage);
begin
inherited;
UpdateScrollBars();
end;
procedure TsuiDBListBox.WMKeyDown(var Message: TWMKeyDown);
begin
inherited;
UpdateScrollBars();
end;
procedure TsuiDBListBox.WMMOUSEWHEEL(var Message: TMessage);
begin
inherited;
UpdateScrollBars();
end;
procedure TsuiDBListBox.WMMOVE(var Msg: TMessage);
begin
inherited;
UpdateScrollBarsPos();
end;
procedure TsuiDBListBox.WMSIZE(var Msg: TMessage);
begin
inherited;
UpdateScrollBarsPos();
end;
procedure TsuiDBListBox.WMHSCROLL(var Message: TWMHScroll);
begin
inherited;
UpdateScrollBars();
end;
procedure TsuiDBListBox.WMMOUSEMOVE(var Message: TMessage);
begin
inherited;
if m_MouseDown then UpdateScrollBars();
end;
procedure TsuiDBListBox.WMVSCROLL(var Message: TWMVScroll);
begin
inherited;
UpdateScrollBars();
end;
procedure TsuiDBListBox.WMLButtonUp(var Message: TMessage);
begin
inherited;
m_MouseDown := false;
end;
procedure TsuiDBListBox.SetFileTheme(const Value: TsuiFileTheme);
begin
m_FileTheme := Value;
if m_VScrollBar <> nil then
m_VScrollBar.FileTheme := Value;
SetUIStyle(m_UIStyle);
end;
procedure TsuiDBListBox.SetUIStyle(const Value: TsuiUIStyle);
var
OutUIStyle : TsuiUIStyle;
begin
m_UIStyle := Value;
if UsingFileTheme(m_FileTheme, m_UIStyle, OutUIStyle) then
m_BorderColor := m_FileTheme.GetColor(SKIN2_CONTROLBORDERCOLOR)
else
m_BorderColor := GetInsideThemeColor(OutUIStyle, SUI_THEME_CONTROL_BORDER_COLOR);
if m_VScrollBar <> nil then
m_VScrollBar.UIStyle := OutUIStyle;
Repaint();
end;
procedure TsuiDBListBox.WMLBUTTONDOWN(var Message: TMessage);
begin
inherited;
m_MouseDown := true;
UpdateScrollBars();
end;
procedure TsuiDBListBox.CMVisibleChanged(var Msg: TMEssage);
begin
inherited;
if not Visible then
begin
if m_VScrollBar <> nil then
m_VScrollBar.Visible := Visible;
end
else
UpdateScrollBarsPos();
end;
{ TsuiDBComboBox }
constructor TsuiDBComboBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ControlStyle := ControlStyle + [csOpaque];
BorderWidth := 0;
UIStyle := GetSUIFormStyle(AOwner);
end;
procedure TsuiDBComboBox.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited;
if (
(Operation = opRemove) and
(AComponent = m_FileTheme)
)then
begin
m_FileTheme := nil;
SetUIStyle(SUI_THEME_DEFAULT);
end;
end;
procedure TsuiDBComboBox.WMPaint(var Msg: TMessage);
begin
inherited;
DrawButton();
end;
procedure TsuiDBComboBox.DrawArrow(const ACanvas: TCanvas; X, Y: Integer);
begin
if not Enabled then
begin
ACanvas.Brush.Color := clWhite;
ACanvas.Pen.Color := clWhite;
ACanvas.Polygon([Point(X + 1, Y + 1), Point(X + 7, Y + 1), Point(X + 4, Y + 4)]);
ACanvas.Brush.Color := clGray;
ACanvas.Pen.Color := clGray;
end
else
begin
ACanvas.Brush.Color := m_ArrowColor;
ACanvas.Pen.Color := m_ArrowColor;
end;
ACanvas.Polygon([Point(X, Y), Point(X + 6, Y), Point(X + 3, Y + 3)]);
end;
procedure TsuiDBComboBox.DrawButton;
var
R, ListRect : TRect;
X, Y : Integer;
Btn : graphics.TBitmap;
pcbi : tagCOMBOBOXINFO;
C: TControlCanvas;
DesktopCanvas : TCanvas;
begin
pcbi.cbSize := SizeOf(pcbi);
if not SUIGetComboBoxInfo(Handle, pcbi) then
Exit;
// draw border
C := TControlCanvas.Create;
C.Control := Self;
with C do
begin
C.Brush.Color := m_BorderColor;
R := ClientRect;
FrameRect(R);
C.Brush.Color := Color;
InflateRect(R, -1, -1);
FrameRect(R);
GetWindowRect(pcbi.hwndList, ListRect);
if DroppedDown then
begin
DesktopCanvas := TCanvas.Create();
DesktopCanvas.Handle := GetWindowDC(0);
DesktopCanvas.Brush.Color := m_BorderColor;
DesktopCanvas.FrameRect(ListRect);
ReleaseDC(0, DesktopCanvas.Handle);
DesktopCanvas.Free();
end
end;
// Draw button
R := pcbi.rcButton;
if {$IFDEF RES_MACOS} (m_UIStyle = MacOS) {$ELSE} false {$ENDIF} or
{$IFDEF RES_WINXP} (m_UIStyle = WinXP){$ELSE} false {$ENDIF} then
begin
Btn := graphics.TBitmap.Create();
{$IFDEF RES_MACOS}
if m_UIStyle = MacOS then
Btn.LoadFromResourceName(hInstance, 'MACOS_COMBOBOX_BUTTON')
else
{$ENDIF}
Btn.LoadFromResourceName(hInstance, 'WINXP_COMBOBOX_BUTTON');
C.StretchDraw(R, Btn);
Btn.Free();
end
else
begin
C.Brush.Color := m_ButtonColor;
C.FillRect(R);
C.Pen.Color := m_BorderColor;
if (BidiMode = bdRightToLeft) and SysLocale.MiddleEast then
begin
C.MoveTo(R.Right, R.Top - 1);
C.LineTo(R.Right, R.Bottom + 1);
end
else
begin
C.MoveTo(R.Left, R.Top - 1);
C.LineTo(R.Left, R.Bottom + 1);
end;
end;
X := (R.Right - R.Left) div 2 + R.Left - 3;
Y := (R.Bottom - R.Top) div 2;
if {$IFDEF RES_WINXP}m_UIStyle <> WinXP{$ELSE} True {$ENDIF} then
DrawArrow(C, X, Y);
C.Free;
end;
procedure TsuiDBComboBox.SetArrowColor(const Value: TColor);
begin
m_ArrowColor := Value;
Repaint();
end;
procedure TsuiDBComboBox.SetBorderColor(const Value: TColor);
begin
m_BorderColor := Value;
Repaint();
end;
procedure TsuiDBComboBox.SetButtonColor(const Value: TColor);
begin
m_ButtonColor := Value;
Repaint();
end;
procedure TsuiDBComboBox.SetEnabled(Value: Boolean);
begin
inherited;
Repaint();
end;
procedure TsuiDBComboBox.SetUIStyle(const Value: TsuiUIStyle);
var
OutUIStyle : TsuiUIStyle;
begin
m_UIStyle := Value;
m_ArrowColor := clBlack;
if UsingFileTheme(m_FileTheme, m_UIStyle, OutUIStyle) then
begin
m_BorderColor := m_FileTheme.GetColor(SKIN2_CONTROLBORDERCOLOR);
m_ButtonColor := m_FileTheme.GetColor(SKIN2_FORMCOLOR);
end
else
begin
m_BorderColor := GetInsideThemeColor(OutUIStyle, SUI_THEME_CONTROL_BORDER_COLOR);
m_ButtonColor := GetInsideThemeColor(OutUIStyle, SUI_THEME_FORM_BACKGROUND_COLOR);
end;
Repaint();
end;
procedure TsuiDBComboBox.WMEARSEBKGND(var Msg: TMessage);
begin
inherited;
DrawButton();
end;
{$IFDEF SUIPACK_D5}
procedure TsuiDBComboBox.CBNCloseUp(var Msg: TWMCommand);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -