Board index » delphi » Delphi 6 VCL bug: WM_NCPAINT and flat scroll bar
Koms Bomb
Delphi Developer |
Delphi 6 VCL bug: WM_NCPAINT and flat scroll bar2003-11-11 04:06:35 PM delphi204 Following is a piece of code in Delphi VCL Controls.pas, it's a handler of WM_NCPAINT, and paint the bevel border. procedure TWinControl.WMNCPaint(var Message: TMessage); [snip] begin [snip] if BevelKind <>bkNone then begin EdgeSize := 0; if BevelInner <>bvNone then Inc(EdgeSize, BevelWidth); if BevelOuter <>bvNone then Inc(EdgeSize, BevelWidth); with RW do begin WinStyle := GetWindowLong(Handle, GWL_STYLE); //#Note if beLeft in BevelEdges then Dec(Left, EdgeSize); if beTop in BevelEdges then Dec(Top, EdgeSize); if beRight in BevelEdges then Inc(Right, EdgeSize); if (WinStyle and WS_VSCROLL) <>0 then Inc(Right, GetSystemMetrics(SM_CYVSCROLL)); //#1 if beBottom in BevelEdges then Inc(Bottom, EdgeSize); if (WinStyle and WS_HSCROLL) <>0 then Inc(Bottom, GetSystemMetrics(SM_CXHSCROLL)); //#2 end; [snip] end; At that '#Note' line, Delphi uses GetWindowLong to see whether there is any scroll bars. How ever, flat scroll bar(in ComCtl32.dll) remove the WS_HSCROLL and WS_VSCROLL style before sending the WM_NCPAINT message, so Delphi 'think' there is no any scroll bar so it doesn't execute the lines #1 and #2. This bug causes the border seems a little strange when there is flat scroll bar. For flat scroll bars, it should use FlatSB_GetScrollProp(Handle, WSB_PROP_WINSTYLE, @WinStyle); to get the scroll bar style. *****Pardon my poor English***** --------------------- My TASM homepage, resource for assembly. Tools, articles, links. komsbomb.ols-lab.com |