?? suidbctrls.pas
字號:
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(SUI_THEME_CONTROL_BORDER_COLOR)
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;
{ 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;
if not IsWin95() then
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);
GetComboBoxInfo(Handle, pcbi);
// 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;
C.MoveTo(R.Left, R.Top - 1);
C.LineTo(R.Left, R.Bottom + 1);
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(SUI_THEME_CONTROL_BORDER_COLOR);
m_ButtonColor := m_FileTheme.GetColor(SUI_THEME_FORM_BACKGROUND_COLOR);
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;
if not IsWin95 then
DrawButton();
end;
{$IFDEF SUIPACK_D5}
procedure TsuiDBComboBox.CBNCloseUp(var Msg: TWMCommand);
begin
if Msg.NotifyCode = CBN_CLOSEUP then
CloseUp()
else
inherited;
end;
procedure TsuiDBComboBox.CloseUp;
begin
end;
{$ENDIF}
procedure TsuiDBComboBox.SetFileTheme(const Value: TsuiFileTheme);
begin
m_FileTheme := Value;
SetUIStyle(m_UIStyle);
end;
{ TsuiDBLookupListBox }
procedure TsuiDBLookupListBox.CMEnabledChanged(var Msg: TMessage);
begin
inherited;
UpdateScrollBars();
end;
constructor TsuiDBLookupListBox.Create(AOwner: TComponent);
begin
inherited;
ControlStyle := ControlStyle + [csOpaque];
BorderStyle := bsNone;
BorderWidth := 2;
m_SelfChanging := false;
m_MouseDown := false;
UIStyle := GetSUIFormStyle(AOwner);
end;
procedure TsuiDBLookupListBox.LBADDSTRING(var Msg: TMessage);
begin
inherited;
UpdateScrollBars();
end;
procedure TsuiDBLookupListBox.LBDELETESTRING(var Msg: TMessage);
begin
inherited;
UpdateScrollBars();
end;
procedure TsuiDBLookupListBox.LBINSERTSTRING(var Msg: TMessage);
begin
inherited;
UpdateScrollBars();
end;
procedure TsuiDBLookupListBox.LBNSELCHANGE(var Msg: TMessage);
begin
inherited;
UpdateScrollBars();
end;
procedure TsuiDBLookupListBox.LBNSETFOCUS(var Msg: TMessage);
begin
inherited;
UpdateScrollBars();
end;
procedure TsuiDBLookupListBox.LBSETCOUNT(var Msg: TMessage);
begin
inherited;
UpdateScrollBars();
end;
procedure TsuiDBLookupListBox.Notification(AComponent: TComponent;
Operation: TOperation);
begin
inherited;
if AComponent = nil then
Exit;
if (
(Operation = opRemove) and
(AComponent = m_VScrollBar)
)then
begin
m_VScrollBar := nil;
end;
if (
(Operation = opRemove) and
(AComponent = m_FileTheme)
)then
begin
m_FileTheme := nil;
SetUIStyle(SUI_THEME_DEFAULT);
end;
end;
procedure TsuiDBLookupListBox.OnVScrollBarChange(Sender: TObject);
begin
if m_SelfChanging then
Exit;
SendMessage(Handle, WM_VSCROLL, MakeWParam(SB_THUMBPOSITION, m_VScrollBar.Position), 0);
Invalidate;
end;
procedure TsuiDBLookupListBox.SetBorderColor(const Value: TColor);
begin
m_BorderColor := Value;
Repaint();
end;
procedure TsuiDBLookupListBox.SetFileTheme(const Value: TsuiFileTheme);
begin
m_FileTheme := Value;
if m_VScrollBar <> nil then
m_VScrollBar.FileTheme := Value;
SetUIStyle(m_UIStyle);
end;
procedure TsuiDBLookupListBox.SetUIStyle(const Value: TsuiUIStyle);
var
OutUIStyle : TsuiUIStyle;
begin
m_UIStyle := Value;
if UsingFileTheme(m_FileTheme, m_UIStyle, OutUIStyle) then
m_BorderColor := m_FileTheme.GetColor(SUI_THEME_CONTROL_BORDER_COLOR)
else
m_BorderColor := GetInsideThemeColor(OutUIStyle, SUI_THEME_CONTROL_BORDER_COLOR);
if m_VScrollBar <> nil then
m_VScrollBar.UIStyle := OutUIStyle;
Repaint();
end;
procedure TsuiDBLookupListBox.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 TsuiDBLookupListBox.UpdateScrollBars;
var
info : tagScrollInfo;
barinfo : tagScrollBarInfo;
begin
m_SelfChanging := true;
if m_VScrollBar <> nil then
begin
barinfo.cbSize := SizeOf(barinfo);
GetScrollBarInfo(Handle, Integer(OBJID_VSCROLL), barinfo);
if (barinfo.rgstate[0] = STATE_SYSTEM_INVISIBLE) or
(barinfo.rgstate[0] = STATE_SYSTEM_UNAVAILABLE) then
begin
m_VScrollBar.LineButton := 0;
m_VScrollBar.Enabled := false;
m_VScrollBar.Visible := false;
end
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;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -