关于如何设置Form样式的简单问题,大家快来抢分(100分)

  • 主题发起人 主题发起人 烂泥
  • 开始时间 开始时间

烂泥

Unregistered / Unconfirmed
GUEST, unregistred user!
将form的borderstyle设为bsnone后窗体就无法拖动和改变大小,<br>或者有什么办法在普通窗口上放Image的时候将form的Border去掉,<br><br>小弟我查个几个API都没搞定、各位有什么办法么,热烈欢迎大侠们灌水
 
何用API如此夸张,在程序运行时是可以动态改变窗体的borderstyle属性的。在你想加载图片<br>时直接指定borderstyle:=bsnone即可。例如在窗体上放一按钮语句如下<br>form1.borderstyle:=bsnone;<br>试一下你应该会明白
 
晚了一步
 
TO: 老猫<br>&nbsp; &nbsp;用了一下,但是在Form1.borderstyle:=Bsnone时,还时无法拖动和改变大小啊。<br>&nbsp; &nbsp;如果是BsSizeable的时候,在上面放Image,但是有边框啊,<br>&nbsp; &nbsp;边框(就是边上很细的那条线) <br>&nbsp; &nbsp;哇;你删除了<br><br>TO mat <br>&nbsp; &nbsp;我知道,但是Form1.borderstyle:=Bsnone时无法拖动和改变窗体的大小啊。<br>&nbsp; &nbsp;如何不用BSnone那么就会有边框出现啊。<br><br><br>&nbsp; <br>&nbsp; &nbsp;<br>&nbsp; &nbsp;<br><br>
 
呵呵,烂泥在你发言之前我就删除我的发言了 ^_^<br>我试试也是不行的,移动你可以用欺骗系统的那套老方法,改变大小不知道了。
 
如果不怕麻烦,可以自己写过程,将拖动写在窗体的ondrop事件中,或是将放大缩小写在<br>onclick事件中(判断一下,左键放大,右键缩小)。<br>我也试了一下,去掉那条细线确实挺困难的。还是自己写过程吧。
 
public<br>&nbsp; procedure WMNCPAINT(var msg: TWMNCPaint); message WM_NCPAINT;<br><br><br>procedure TForm1.WMNCPAINT(var msg: TWMNCPaint);<br>var<br>&nbsp; &nbsp;oldHDC: HDC;<br>&nbsp; &nbsp;newDC: HDC;<br>begin<br>&nbsp; &nbsp; &nbsp;OLDHDC := Canvas.Handle;<br>&nbsp; &nbsp; &nbsp;newDC := GetWindowDC(handle);<br>&nbsp; &nbsp; &nbsp;Canvas.Handle := newDC;<br>&nbsp; &nbsp; &nbsp;Canvas.FloodFill(2,2,clRed,fsBorder);<br>&nbsp; &nbsp; &nbsp;Canvas.Handle := oldHDC;<br>&nbsp; &nbsp; &nbsp;ReleaseDC(handle, newDC);<br>end;<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>begin<br>SetWindowLong(Handle,GWL_STYLE,GetWindowLong(Handle,GWL_STYLE) and (not WS_CAPTION));<br>Height:=ClientHeight;<br>end;<br>这样写后,倒是可以实现,可惜闪烁太厉害
 
呵呵这个问题我来拣分:<br>procedure WMNCHITTEST(var Msg: TWMNCHitMessage); message WM_NCHITTEST;<br>procedure TForm1.WMNCHITTEST(var Msg: TWMNCHitMessage);<br>var<br>&nbsp; P: TPoint;<br>begin<br>&nbsp; Inherited;<br>&nbsp; with Msg do<br>&nbsp; begin<br>&nbsp; &nbsp; P.X := XCursor;<br>&nbsp; &nbsp; P.Y := YCursor;<br>&nbsp; &nbsp; Windows.ScreenToClient(Self.Handle,P);<br>&nbsp; &nbsp; if (P.X &lt; 10) and (P.Y &lt; 10) then // 这里只模拟了左上角的 Size <br>&nbsp; &nbsp; &nbsp; Result := HTTOPLEFT;<br>&nbsp; end;<br>end;<br>截获 WM_NCHITTEST 消息,可以模拟有边框窗口的点击事件。
 
干脆把返回值帮你查出来算了。<br>Return Values<br><br>The return value of the DefWindowProc function is one of the following values, indicating the position of the cursor hot spot: <br><br>Value Location of hot spot<br>HTBORDER In the border of a window that does not have a sizing border<br>HTBOTTOM In the lower horizontal border of a window<br>HTBOTTOMLEFT In the lower-left corner of a window border<br>HTBOTTOMRIGHT In the lower-right corner of a window border<br>HTCAPTION In a title bar<br>HTCLIENT In a client area<br>HTERROR On the screen background or on a dividing line between windows (same as HTNOWHERE, except that the DefWindowProc function produces a system beep to indicate an error)<br>HTGROWBOX In a size box (same as HTSIZE)<br>HTHSCROLL In a horizontal scroll bar<br>HTLEFT In the left border of a window<br>HTMENU In a menu<br>HTNOWHERE On the screen background or on a dividing line between windows<br>HTREDUCE In a Minimize button<br>HTRIGHT In the right border of a window<br>HTSIZE In a size box (same as HTGROWBOX)<br>HTSYSMENU In a System menu or in a Close button in a child window<br>HTTOP In the upper horizontal border of a window<br>HTTOPLEFT In the upper-left corner of a window border<br>HTTOPRIGHT In the upper right corner of a window border<br>HTTRANSPARENT In a window currently covered by another window<br>HTVSCROLL In the vertical scroll bar<br>HTZOOM In a Maximize button
 
还想知道如何重画窗体的边框?
 
烂泥大虾真贪心哦!<br>DrawFrameControl 函数,你想画什么?按钮、菜单、边框、滚动条、Sizing Grip ...<br><br>BOOL DrawFrameControl(<br>&nbsp; &nbsp; HDC hdc, // handle to device context<br>&nbsp; &nbsp; LPRECT lprc, // pointer to bounding rectangle<br>&nbsp; &nbsp; UINT uType, // frame-control type<br>&nbsp; &nbsp; UINT uState // frame-control state<br>&nbsp; &nbsp;);<br><br>uType<br><br>Specifies the type of frame control to draw. This parameter can be one of the following values:<br><br>Value Meaning<br>DFC_BUTTON Standard button<br>DFC_CAPTION Title bar<br>DCF_MENU Menu<br>DFC_SCROLL Scroll bar<br><br>uState<br><br>Specifies the initial state of the frame control. If uType is DFC_BUTTON, uState can be one of the following values:<br><br>Value Meaning<br>DFCS_BUTTON3STATE Three-state button<br>DFCS_BUTTONCHECK Check box <br>DFCS_BUTTONPUSH Push button<br>DFCS_BUTTONRADIO Radio button<br>DFCS_BUTTONRADIOIMAGE Image for radio button (nonsquare needs image)<br>DFCS_BUTTONRADIOMASK Mask for radio button (nonsquare needs mask)<br>&nbsp;<br><br>If uType is DFC_CAPTION, uState can be one of the following values:<br><br>Value Meaning<br>DFCS_CAPTIONCLOSE Close button<br>DFCS_CAPTIONHELP Windows 95 only: Help button<br>DFCS_CAPTIONMAX Maximize button<br>DFCS_CAPTIONMIN Minimize button<br>DFCS_CAPTIONRESTORE Restore button<br>&nbsp;<br><br>If uType is DFC_MENU, uState can be one of the following values:<br><br>Value Meaning<br>DFCS_MENUARROW Submenu arrow<br>DFCS_MENUBULLET Bullet<br>DFCS_MENUCHECK Check mark<br>&nbsp;<br><br>If uType is DFC_SCROLL, uState can be one of the following values:<br><br>Value Meaning<br>DFCS_SCROLLCOMBOBOX Combo box scroll bar<br>DFCS_SCROLLDOWN Down arrow of scroll bar<br>DFCS_SCROLLLEFT Left arrow of scroll bar<br>DFCS_SCROLLRIGHT Right arrow of scroll bar<br>DFCS_SCROLLSIZEGRIP Size grip in bottom-right corner of window<br>DFCS_SCROLLUP Up arrow of scroll bar<br>&nbsp;<br><br>The following style can be used to adjust the bounding rectangle of the push button:<br><br>Value Meaning<br>DFCS_ADJUSTRECT Bounding rectangle is adjusted to exclude the surrounding edge of the push button.<br>&nbsp;<br><br>One or more of the following values can be used to set the state of the control to be drawn:<br><br>Value Meaning<br>DFCS_CHECKED Button is checked.<br>DFCS_FLAT Button has a flat border.<br>DFCS_INACTIVE Button is inactive (grayed).<br>DFCS_MONO Button has a monochrome border.<br>DFCS_PUSHED Button is pushed.<br><br>满意了吗?
 
错了错了,几位都错了,根本没必要这么麻烦的。<br>如下:<br><br>procedure CreateParams(var Params :TCreateParams);Override;<br><br>procedure TForm1.CreateParams(var Params :TCreateParams);<br>begin<br>inherited CreateParams(Params);<br>with Params do<br>&nbsp; begin<br>&nbsp; Style:=Style and (not WS_CAPTION);<br>&nbsp; Style:=Style or WS_POPUP or WS_THICKFRAME or WS_CLIPCHILDREN;<br>&nbsp; end;<br>end;<br><br>这样可以生成一个没有标题栏,但是可以改变窗体大小的窗体。
 
烂泥大虾要的是没有边框,但是能改变大小。
 
虾哥BaKuBaKu说的是
 
截获 WM_NCPAINT 消息,使用 DrawFrameControl ,是比较好的办法。
 
接受答案了.
 
后退
顶部