提问:能否直接改绘标题栏和边框,实现类似金山词霸.net 2001 这样可更换的Skin界面?(50分)

  • 主题发起人 主题发起人 JimWeaver
  • 开始时间 开始时间
J

JimWeaver

Unregistered / Unconfirmed
GUEST, unregistred user!
要实现Skin界面,现在我们在网上看到的方法一般都是隐藏窗体的标题栏和边框,然后自己用TImage、TPanel等组件“搭建”标题栏和边框,典型的是TNeoForm;或者直接使用KSDev SkinEngine套件之类的庞然大物。
但是,小弟用 Resource Hacker 检查了金山词霸.net 2001 的XDICT.exe(系 VC++ 生成),发现其主窗体上并没有放置任何用于“搭建”标题栏和边框的Image或Panel之类的控件,窗体的Style也是有最大化、最小化按钮和系统菜单的,而且,词霸的几个按钮(回退、前一词、后一词、主菜单)都是标准控件BUTTON的自绘风格。请看:
101 DIALOGEX 0, 0, 196, 152
STYLE WS_MAXIMIZEBOX | WS_MINIMIZEBOX | WS_POPUP | WS_CLIPCHILDREN | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
EXSTYLE WS_EX_APPWINDOW
CAPTION ""
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
FONT 10, "Arial"
{
CONTROL "", 1002, COMBOBOX, CBS_DROPDOWN | CBS_OWNERDRAWVARIABLE | CBS_AUTOHSCROLL | CBS_HASSTRINGS | CBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 24, 2, 86, 106
CONTROL "B", 1003, BUTTON, BS_OWNERDRAW | WS_CHILD | WS_VISIBLE, 116, 2, 18, 14
CONTROL "P", 1004, BUTTON, BS_OWNERDRAW | WS_CHILD | WS_VISIBLE, 135, 2, 18, 14
CONTROL "N", 1005, BUTTON, BS_OWNERDRAW | WS_CHILD | WS_VISIBLE, 154, 2, 18, 14
CONTROL "M", 1006, BUTTON, BS_OWNERDRAW | WS_CHILD | WS_VISIBLE, 173, 2, 18, 14
CONTROL "", 1001, "SysTreeView32", TVS_HASLINES | TVS_SHOWSELALWAYS | WS_CHILD | WS_BORDER | WS_TABSTOP, 4, 83, 20, 17
CONTROL "", 1007, "SysTreeView32", TVS_HASLINES | TVS_SHOWSELALWAYS | WS_CHILD | WS_BORDER | WS_TABSTOP, 28, 83, 20, 17
CONTROL "", 1011, "XDICT_TitleView", 0x50000000, 82, 21, 110, 14 , 0x00000004
CONTROL "", 1009, "XDICT_ExplainView", 0x50810000, 82, 41, 110, 96 , 0x00000004
CONTROL "", 1013, "XDICT_PlayView", 0x50000000, 4, 103, 70, 35
CONTROL "", 1012, "XDICT_StatusBar", 0x52000000, 4, 141, 188, 7
CONTROL "Tab1", 1018, "SysTabControl32", TCS_TABS | TCS_BOTTOM | TCS_FIXEDWIDTH | TCS_OWNERDRAWFIXED | TCS_FOCUSNEVER | WS_CHILD | WS_VISIBLE, 4, 21, 70, 58
CONTROL "", 1087, BUTTON, BS_OWNERDRAW | WS_CHILD, 4, 2, 17, 14
}
由此,我猜测,除了“另起炉灶”搭建“伪”标题栏和边框之外,还有另外的可以改变窗体、按钮的界面的方法,但是,小弟才疏学浅,上网查找也无济于事,不知哪位大虾有这方面的资料或者范例,望不吝赐教:)
jimweaver@zjgl.net.cn
 
www.51delphi.com
DynamicSkinform
 
千堆雪的程序,更改Caption字体的,不知道是否有用。思路借鉴以及实现方式。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
private
{ Private declarations }
procedure WMNCPAint(var Mes : TWMNCPaint);
message WM_NCPAINT;
procedure WMNCACTIVE(var msg: TMessage);
message WM_NCACTIVATE;
procedure Paint_Caption;
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
{$R *.DFM}
var
State:Integer;
procedure TForm1.WMNCPAint(var Mes : TWMNCPaint);
begin
inherited;
Paint_Caption;
end;

procedure TForm1.Paint_Caption;
var
ACanvas : TCanvas;
begin

ACanvas := TCanvas.Create;
try
ACanvas.Handle := GetWindowDC(Form1.Handle);
with ACanvasdo
begin
if State=1 then
Brush.Color := clActiveCaption
else
Brush.Color := clInactiveCaption;
Font.Name := 'Times New Roman';
Font.Size := 12;
Font.Color := clYellow;
Font.Style := [fsBold];
TextOut(GetSystemMetrics(SM_CYMENU) + GetSystemMetrics(SM_CXBORDER),
Round((GetSystemMetrics(SM_CYCAPTION) - Abs(Font.Height))/2) +1,
'千堆雪的程序');
end;
finally
ReleaseDC(Form1.Handle, ACanvas.Handle);
ACanvas.Free;
end;
end;

procedure TForm1.WMNCACTIVE(var msg: TMessage);
begin
inherited;
State:=msg.WParam;
Paint_Caption;
end;

end.
 
接受答案了.
 
后退
顶部