窗体样式的问题(100分)

  • 主题发起人 主题发起人 fatBaby
  • 开始时间 开始时间
F

fatBaby

Unregistered / Unconfirmed
GUEST, unregistred user!
我需要一个没有标题,但能Resize尺寸的窗体,于是我这样:<br><br>void __fastcall TFmLanPad::CreateParams(Controls::TCreateParams &amp;Params)<br>{<br>&nbsp; &nbsp; &nbsp;TForm::CreateParams(Params);<br>&nbsp; &nbsp; &nbsp;//去掉窗口标题区<br>&nbsp; &nbsp; &nbsp;Params.Style &amp;= ~WS_CAPTION;<br>&nbsp; &nbsp; &nbsp;Params.Style |= &nbsp;WS_POPUP;<br><br>&nbsp; &nbsp; &nbsp;Params.WndParent = GetDesktopWindow();<br>}<br>// --------------------------------------------------------------------------------------------------------<br><br>结果边框太粗了,暴难看。怎么让边框极细?但仍能Resize ??
 
这样?<br>Style &amp;= WS_POPUP;<br>Style &amp;= ~WS_DLGFRAME;
 
难不难看?
 
呀<br>吐血啦<br>我不要标题<br>你比我写的还烂。<br>有更好的吗<br>我等着<br>嗯
 
我这边用Delphi实现的没有标题,而且能 Resize 啊?<br>C++的我又实践不了。然后我只好直接写成 C++ 的语句了。没想到不对?<br>我这边的是这样:<br>TForm1 = class(TForm)<br>public<br>&nbsp; procedure CreateParams(var Params: TCreateParams); override;<br>end;<br><br>procedure CreateParams(var Params: TCreateParams);<br>begin<br>&nbsp; inherited(Params);<br>&nbsp; with Params do<br>&nbsp; begin<br>&nbsp; &nbsp; Style := Style or WS_POPUP;<br>&nbsp; &nbsp; Style := Style and not WS_DLGFRAME; &nbsp;<br>&nbsp; end;<br>end;<br>
 
上面的你改为这样看看,是我写错了:<br>Style |= WS_POPUP;<br>Style &amp;= ~WS_DLGFRAME;
 
我也等着。:P
 
跟我上面代码的效果一样,不是我要的,<br>我要求的是外框看不见,但仍要能改变尺寸。<br><br>你我的效果看上去这个窗口是立体的,我希望最好是平面的。
 
一个窗口要是可以 Resize,那么其 Style 就一定包含 WS_THICKFRAME<br>但是拥有 WS_THICKFRAME 样式的窗口的边框是粗的,没法改变。<br>如果你想要平面的话,你可以自己处理 WM_NCPAINT,<br>但是窗口仍然拥有 WS_THICKFRAME 样式<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>var<br>&nbsp; dwStyle: DWORD;<br>begin<br>&nbsp; dwStyle := GetWindowLong(Handle, GWL_STYLE);<br>&nbsp; SetWindowLong(Handle, GWL_STYLE, dwStyle xor WS_THICKFRAME);<br>end;<br>
 
unit Unit1;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br>&nbsp; Dialogs;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; procedure FormCreate(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; &nbsp; procedure WMNCPaint(var Msg: TWMNCPaint); message WM_NCPAINT;<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>{ TForm1 }<br><br>procedure TForm1.WMNCPaint(var Msg: TWMNCPaint);<br>var<br>&nbsp; hDC: DWORD;<br>&nbsp; hBr: DWORD;<br>&nbsp; rc: &nbsp;TRect;<br>begin<br>&nbsp; hDC := GetDCEx(Handle, 0, DCX_WINDOW);<br>&nbsp; hBr := GetStockObject(GRAY_BRUSH);<br>&nbsp; GetWindowRect(Handle, rc);<br>&nbsp; FillRect(hDC, rc, hBr);<br>&nbsp; ReleaseDC(Handle, hDC);<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>var<br>&nbsp; dwStyle: DWORD;<br>begin<br>&nbsp; dwStyle := GetWindowLong(Handle, GWL_STYLE);<br>&nbsp; SetWindowLong(Handle, GWL_STYLE, dwStyle xor WS_CAPTION xor WS_SYSMENU);<br>end;<br><br>end.<br>
 
不对不对,扯远了,你没明白我的意思.
 
多谢楼上的。
 

Similar threads

I
回复
0
查看
606
import
I
I
回复
0
查看
734
import
I
S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
后退
顶部