凭证控件用TstringGrid的基类PAS文件修改的.PZgrid ( 积分: 50 )

  • 主题发起人 主题发起人 dkq811230
  • 开始时间 开始时间
D

dkq811230

Unregistered / Unconfirmed
GUEST, unregistred user!
凭证控件用TstringGrid的基类PAS文件修改的.PZgrid,存在一些问题,那位兄弟可以帮忙改一下.再发上来不?下载地址www.tomore.com<br>附原码:<br><br>{*******************************************************}<br>{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Borland&nbsp;Delphi&nbsp;Visual&nbsp;Component&nbsp;Library&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>{&nbsp;&nbsp;Copyright&nbsp;(c)&nbsp;1999-2002&nbsp;Borland&nbsp;Software&nbsp;Corporation&nbsp;}<br>{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>{*******************************************************}<br><br>unit&nbsp;PZGrid;<br><br>{$R-,T-,H+,X+}<br><br>interface<br><br>uses&nbsp;Messages,&nbsp;{$IFDEF&nbsp;LINUX}&nbsp;WinUtils,&nbsp;{$ENDIF}&nbsp;Windows,&nbsp;SysUtils,&nbsp;Classes,<br>&nbsp;&nbsp;Variants,&nbsp;Graphics,&nbsp;Menus,&nbsp;Controls,&nbsp;Forms,&nbsp;StdCtrls,&nbsp;Mask;<br><br>const<br>&nbsp;&nbsp;MaxCustomExtents&nbsp;=&nbsp;MaxListSize;<br>&nbsp;&nbsp;MaxShortInt&nbsp;=&nbsp;High(ShortInt);<br>&nbsp;&nbsp;Fraction1Bit=15;<br>&nbsp;&nbsp;Fraction2Bit=16;<br>&nbsp;&nbsp;SeperatorBit=14;<br>&nbsp;&nbsp;IntegerBit=13;<br>&nbsp;&nbsp;BorderIndent=2;<br>&nbsp;&nbsp;FractionBits=&nbsp;[Fraction1Bit,&nbsp;Fraction2Bit];<br>&nbsp;&nbsp;IntegerBits=&nbsp;[1..IntegerBit];<br>&nbsp;&nbsp;ThousandBits=&nbsp;[1,&nbsp;4,&nbsp;7,&nbsp;10,&nbsp;13];<br>&nbsp;&nbsp;TextKm:array&nbsp;[0..3]&nbsp;of&nbsp;&nbsp;String=('摘要','科目','借方金额','贷方金额');<br><br>type<br>&nbsp;&nbsp;EInvalidGridOperation&nbsp;=&nbsp;class(Exception);<br><br>&nbsp;&nbsp;{&nbsp;Internal&nbsp;grid&nbsp;types&nbsp;}<br>&nbsp;&nbsp;TGetExtentsFunc&nbsp;=&nbsp;function(Index:&nbsp;Longint):&nbsp;Integer&nbsp;of&nbsp;object;<br><br>&nbsp;&nbsp;TGridAxisDrawInfo&nbsp;=&nbsp;record<br>&nbsp;&nbsp;&nbsp;&nbsp;EffectiveLineWidth:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;FixedBoundary:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;GridBoundary:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;GridExtent:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;LastFullVisibleCell:&nbsp;Longint;<br>&nbsp;&nbsp;&nbsp;&nbsp;FullVisBoundary:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;FixedCellCount:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;FirstGridCell:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;GridCellCount:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;GetExtent:&nbsp;TGetExtentsFunc;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;TGridDrawInfo&nbsp;=&nbsp;record<br>&nbsp;&nbsp;&nbsp;&nbsp;Horz,&nbsp;Vert:&nbsp;TGridAxisDrawInfo;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;TGridState&nbsp;=&nbsp;(gsNormal,&nbsp;gsSelecting,&nbsp;gsRowSizing,&nbsp;gsColSizing,<br>&nbsp;&nbsp;&nbsp;&nbsp;gsRowMoving,&nbsp;gsColMoving);<br>&nbsp;&nbsp;TGridMovement&nbsp;=&nbsp;gsRowMoving..gsColMoving;<br><br>&nbsp;&nbsp;{&nbsp;TInplaceEdit&nbsp;}<br>&nbsp;&nbsp;{&nbsp;The&nbsp;inplace&nbsp;editor&nbsp;is&nbsp;not&nbsp;intended&nbsp;to&nbsp;be&nbsp;used&nbsp;outside&nbsp;the&nbsp;grid&nbsp;}<br><br>&nbsp;&nbsp;TCustomPZGrid&nbsp;=&nbsp;class;<br><br>&nbsp;&nbsp;TInplaceEdit&nbsp;=&nbsp;class(TCustomMaskEdit)<br>&nbsp;&nbsp;private<br>&nbsp;&nbsp;&nbsp;&nbsp;FGrid:&nbsp;TCustomPZGrid;<br>&nbsp;&nbsp;&nbsp;&nbsp;FClickTime:&nbsp;Longint;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;InternalMove(const&nbsp;Loc:&nbsp;TRect;&nbsp;Redraw:&nbsp;Boolean);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetGrid(Value:&nbsp;TCustomPZGrid);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;CMShowingChanged(var&nbsp;Message:&nbsp;TMessage);&nbsp;message&nbsp;CM_SHOWINGCHANGED;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WMGetDlgCode(var&nbsp;Message:&nbsp;TWMGetDlgCode);&nbsp;message&nbsp;WM_GETDLGCODE;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WMPaste(var&nbsp;Message);&nbsp;message&nbsp;WM_PASTE;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WMCut(var&nbsp;Message);&nbsp;message&nbsp;WM_CUT;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WMClear(var&nbsp;Message);&nbsp;message&nbsp;WM_CLEAR;<br>&nbsp;&nbsp;protected<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;CreateParams(var&nbsp;Params:&nbsp;TCreateParams);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;DblClick;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;DoMouseWheel(Shift:&nbsp;TShiftState;&nbsp;WheelDelta:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MousePos:&nbsp;TPoint):&nbsp;Boolean;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;EditCanModify:&nbsp;Boolean;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;KeyDown(var&nbsp;Key:&nbsp;Word;&nbsp;Shift:&nbsp;TShiftState);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;KeyPress(var&nbsp;Key:&nbsp;Char);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;KeyUp(var&nbsp;Key:&nbsp;Word;&nbsp;Shift:&nbsp;TShiftState);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;BoundsChanged;&nbsp;virtual;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;UpdateContents;&nbsp;virtual;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WndProc(var&nbsp;Message:&nbsp;TMessage);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;&nbsp;Grid:&nbsp;TCustomPZGrid&nbsp;read&nbsp;FGrid;<br>&nbsp;&nbsp;public<br>&nbsp;&nbsp;&nbsp;&nbsp;constructor&nbsp;Create(AOwner:&nbsp;TComponent);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Deselect;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Hide;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Invalidate;&nbsp;reintroduce;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Move(const&nbsp;Loc:&nbsp;TRect);<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;PosEqual(const&nbsp;Rect:&nbsp;TRect):&nbsp;Boolean;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetFocus;&nbsp;reintroduce;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;UpdateLoc(const&nbsp;Loc:&nbsp;TRect);<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;Visible:&nbsp;Boolean;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;{&nbsp;TCustomPZGrid&nbsp;}<br><br>&nbsp;&nbsp;{&nbsp;TCustomPZGrid&nbsp;is&nbsp;an&nbsp;abstract&nbsp;base&nbsp;class&nbsp;that&nbsp;can&nbsp;be&nbsp;used&nbsp;to&nbsp;implement<br>&nbsp;&nbsp;&nbsp;&nbsp;general&nbsp;purpose&nbsp;grid&nbsp;style&nbsp;controls.&nbsp;&nbsp;The&nbsp;control&nbsp;will&nbsp;call&nbsp;DrawCell&nbsp;for<br>&nbsp;&nbsp;&nbsp;&nbsp;each&nbsp;of&nbsp;the&nbsp;cells&nbsp;allowing&nbsp;the&nbsp;derived&nbsp;class&nbsp;to&nbsp;fill&nbsp;in&nbsp;the&nbsp;contents&nbsp;of<br>&nbsp;&nbsp;&nbsp;&nbsp;the&nbsp;cell.&nbsp;&nbsp;The&nbsp;base&nbsp;class&nbsp;handles&nbsp;scrolling,&nbsp;selection,&nbsp;cursor&nbsp;keys,&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;scrollbars.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawCell<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Called&nbsp;by&nbsp;Paint.&nbsp;If&nbsp;DefaultDrawing&nbsp;is&nbsp;true&nbsp;the&nbsp;font&nbsp;and&nbsp;brush&nbsp;are<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;intialized&nbsp;to&nbsp;the&nbsp;control&nbsp;font&nbsp;and&nbsp;cell&nbsp;color.&nbsp;&nbsp;The&nbsp;cell&nbsp;is&nbsp;prepainted<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;in&nbsp;the&nbsp;cell&nbsp;color&nbsp;and&nbsp;a&nbsp;focus&nbsp;rect&nbsp;is&nbsp;drawn&nbsp;in&nbsp;the&nbsp;focused&nbsp;cell&nbsp;after<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawCell&nbsp;returns.&nbsp;&nbsp;The&nbsp;state&nbsp;passed&nbsp;will&nbsp;reflect&nbsp;whether&nbsp;the&nbsp;cell&nbsp;is<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a&nbsp;fixed&nbsp;cell,&nbsp;the&nbsp;focused&nbsp;cell&nbsp;or&nbsp;in&nbsp;the&nbsp;selection.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SizeChanged<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Called&nbsp;when&nbsp;the&nbsp;size&nbsp;of&nbsp;the&nbsp;grid&nbsp;has&nbsp;changed.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BorderStyle<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Allows&nbsp;a&nbsp;single&nbsp;line&nbsp;border&nbsp;to&nbsp;be&nbsp;drawn&nbsp;around&nbsp;the&nbsp;control.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Col<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;current&nbsp;column&nbsp;of&nbsp;the&nbsp;focused&nbsp;cell&nbsp;(runtime&nbsp;only).<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ColCount<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;number&nbsp;of&nbsp;columns&nbsp;in&nbsp;the&nbsp;grid.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ColWidths<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;width&nbsp;of&nbsp;each&nbsp;column&nbsp;(up&nbsp;to&nbsp;a&nbsp;maximum&nbsp;MaxCustomExtents,&nbsp;runtime<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;only).<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DefaultColWidth<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;default&nbsp;column&nbsp;width.&nbsp;&nbsp;Changing&nbsp;this&nbsp;value&nbsp;will&nbsp;throw&nbsp;away&nbsp;any<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;customization&nbsp;done&nbsp;either&nbsp;visually&nbsp;or&nbsp;through&nbsp;ColWidths.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DefaultDrawing<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Indicates&nbsp;whether&nbsp;the&nbsp;Paint&nbsp;should&nbsp;do&nbsp;the&nbsp;drawing&nbsp;talked&nbsp;about&nbsp;above&nbsp;in<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawCell.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DefaultRowHeight<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;default&nbsp;row&nbsp;height.&nbsp;&nbsp;Changing&nbsp;this&nbsp;value&nbsp;will&nbsp;throw&nbsp;away&nbsp;any<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;customization&nbsp;done&nbsp;either&nbsp;visually&nbsp;or&nbsp;through&nbsp;RowHeights.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FixedCols<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;number&nbsp;of&nbsp;non-scrolling&nbsp;columns.&nbsp;&nbsp;This&nbsp;value&nbsp;must&nbsp;be&nbsp;at&nbsp;least&nbsp;one<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;below&nbsp;ColCount.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FixedRows<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;number&nbsp;of&nbsp;non-scrolling&nbsp;rows.&nbsp;&nbsp;This&nbsp;value&nbsp;must&nbsp;be&nbsp;at&nbsp;least&nbsp;one<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;below&nbsp;RowCount.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GridLineWidth<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;width&nbsp;of&nbsp;the&nbsp;lines&nbsp;drawn&nbsp;between&nbsp;the&nbsp;cells.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LeftCol<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;index&nbsp;of&nbsp;the&nbsp;left&nbsp;most&nbsp;displayed&nbsp;column&nbsp;(runtime&nbsp;only).<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Options<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;following&nbsp;options&nbsp;are&nbsp;available:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goFixedHorzLine:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Draw&nbsp;horizontal&nbsp;grid&nbsp;lines&nbsp;in&nbsp;the&nbsp;fixed&nbsp;cell&nbsp;area.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goFixedVertLine:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Draw&nbsp;veritical&nbsp;grid&nbsp;lines&nbsp;in&nbsp;the&nbsp;fixed&nbsp;cell&nbsp;area.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goHorzLine:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Draw&nbsp;horizontal&nbsp;lines&nbsp;between&nbsp;cells.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goVertLine:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Draw&nbsp;vertical&nbsp;lines&nbsp;between&nbsp;cells.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goRangeSelect:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Allow&nbsp;a&nbsp;range&nbsp;of&nbsp;cells&nbsp;to&nbsp;be&nbsp;selected.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goDrawFocusSelected:&nbsp;Draw&nbsp;the&nbsp;focused&nbsp;cell&nbsp;in&nbsp;the&nbsp;selected&nbsp;color.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goRowSizing:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Allows&nbsp;rows&nbsp;to&nbsp;be&nbsp;individually&nbsp;resized.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goColSizing:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Allows&nbsp;columns&nbsp;to&nbsp;be&nbsp;individually&nbsp;resized.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goRowMoving:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Allows&nbsp;rows&nbsp;to&nbsp;be&nbsp;moved&nbsp;with&nbsp;the&nbsp;mouse<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goColMoving:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Allows&nbsp;columns&nbsp;to&nbsp;be&nbsp;moved&nbsp;with&nbsp;the&nbsp;mouse.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goEditing:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Places&nbsp;an&nbsp;edit&nbsp;control&nbsp;over&nbsp;the&nbsp;focused&nbsp;cell.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goAlwaysShowEditor:&nbsp;&nbsp;Always&nbsp;shows&nbsp;the&nbsp;editor&nbsp;in&nbsp;place&nbsp;instead&nbsp;of<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;waiting&nbsp;for&nbsp;a&nbsp;keypress&nbsp;or&nbsp;F2&nbsp;to&nbsp;display&nbsp;it.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goTabs:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Enables&nbsp;the&nbsp;tabbing&nbsp;between&nbsp;columns.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goRowSelect:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Selection&nbsp;and&nbsp;movement&nbsp;is&nbsp;done&nbsp;a&nbsp;row&nbsp;at&nbsp;a&nbsp;time.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Row<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;row&nbsp;of&nbsp;the&nbsp;focused&nbsp;cell&nbsp;(runtime&nbsp;only).<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RowCount<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;number&nbsp;of&nbsp;rows&nbsp;in&nbsp;the&nbsp;grid.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RowHeights<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;hieght&nbsp;of&nbsp;each&nbsp;row&nbsp;(up&nbsp;to&nbsp;a&nbsp;maximum&nbsp;MaxCustomExtents,&nbsp;runtime<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;only).<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ScrollBars<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Determines&nbsp;whether&nbsp;the&nbsp;control&nbsp;has&nbsp;scrollbars.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Selection<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;TGridRect&nbsp;of&nbsp;the&nbsp;current&nbsp;selection.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TopLeftChanged<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Called&nbsp;when&nbsp;the&nbsp;TopRow&nbsp;or&nbsp;LeftCol&nbsp;change.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TopRow<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;index&nbsp;of&nbsp;the&nbsp;top&nbsp;most&nbsp;row&nbsp;displayed&nbsp;(runtime&nbsp;only)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VisibleColCount<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;number&nbsp;of&nbsp;columns&nbsp;fully&nbsp;displayed.&nbsp;&nbsp;There&nbsp;could&nbsp;be&nbsp;one&nbsp;more&nbsp;column<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;partially&nbsp;displayed.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VisibleRowCount<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;number&nbsp;of&nbsp;rows&nbsp;fully&nbsp;displayed.&nbsp;&nbsp;There&nbsp;could&nbsp;be&nbsp;one&nbsp;more&nbsp;row<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;partially&nbsp;displayed.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;Protected&nbsp;members,&nbsp;for&nbsp;implementors&nbsp;of&nbsp;TCustomPZGrid&nbsp;descendents<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DesignOptionBoost<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Options&nbsp;mixed&nbsp;in&nbsp;only&nbsp;at&nbsp;design&nbsp;time&nbsp;to&nbsp;aid&nbsp;design-time&nbsp;editing.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Default&nbsp;=&nbsp;[goColSizing,&nbsp;goRowSizing],&nbsp;which&nbsp;makes&nbsp;grid&nbsp;cols&nbsp;and&nbsp;rows<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;resizeable&nbsp;at&nbsp;design&nbsp;time,&nbsp;regardless&nbsp;of&nbsp;the&nbsp;Options&nbsp;settings.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VirtualView<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Controls&nbsp;the&nbsp;use&nbsp;of&nbsp;maximum&nbsp;screen&nbsp;clipping&nbsp;optimizations&nbsp;when&nbsp;the<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;grid&nbsp;window&nbsp;changes&nbsp;size.&nbsp;&nbsp;Default&nbsp;=&nbsp;False,&nbsp;which&nbsp;means&nbsp;only&nbsp;the<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;area&nbsp;exposed&nbsp;by&nbsp;the&nbsp;size&nbsp;change&nbsp;will&nbsp;be&nbsp;redrawn,&nbsp;for&nbsp;less&nbsp;flicker.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VirtualView&nbsp;=&nbsp;True&nbsp;means&nbsp;the&nbsp;entire&nbsp;data&nbsp;area&nbsp;of&nbsp;the&nbsp;grid&nbsp;is&nbsp;redrawn<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when&nbsp;the&nbsp;size&nbsp;changes.&nbsp;&nbsp;This&nbsp;is&nbsp;required&nbsp;when&nbsp;the&nbsp;data&nbsp;displayed&nbsp;in<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the&nbsp;grid&nbsp;is&nbsp;not&nbsp;bound&nbsp;to&nbsp;the&nbsp;number&nbsp;of&nbsp;rows&nbsp;or&nbsp;columns&nbsp;in&nbsp;the&nbsp;grid,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;such&nbsp;as&nbsp;the&nbsp;dbgrid&nbsp;(a&nbsp;few&nbsp;grid&nbsp;rows&nbsp;displaying&nbsp;a&nbsp;view&nbsp;onto&nbsp;a&nbsp;million<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;row&nbsp;table).<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br><br>&nbsp;&nbsp;TGridOption&nbsp;=&nbsp;(goFixedVertLine,&nbsp;goFixedHorzLine,&nbsp;goVertLine,&nbsp;goHorzLine,<br>&nbsp;&nbsp;&nbsp;&nbsp;goRangeSelect,&nbsp;goDrawFocusSelected,&nbsp;goRowSizing,&nbsp;goColSizing,&nbsp;goRowMoving,<br>&nbsp;&nbsp;&nbsp;&nbsp;goColMoving,&nbsp;goEditing,&nbsp;goTabs,&nbsp;goRowSelect,<br>&nbsp;&nbsp;&nbsp;&nbsp;goAlwaysShowEditor,&nbsp;goThumbTracking);<br>&nbsp;&nbsp;TGridOptions&nbsp;=&nbsp;set&nbsp;of&nbsp;TGridOption;<br>&nbsp;&nbsp;TGridDrawState&nbsp;=&nbsp;set&nbsp;of&nbsp;(gdSelected,&nbsp;gdFocused,&nbsp;gdFixed);<br>&nbsp;&nbsp;TGridScrollDirection&nbsp;=&nbsp;set&nbsp;of&nbsp;(sdLeft,&nbsp;sdRight,&nbsp;sdUp,&nbsp;sdDown);<br><br>&nbsp;&nbsp;TGridCoord&nbsp;=&nbsp;record<br>&nbsp;&nbsp;&nbsp;&nbsp;X:&nbsp;Longint;<br>&nbsp;&nbsp;&nbsp;&nbsp;Y:&nbsp;Longint;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;TGridRect&nbsp;=&nbsp;record<br>&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;Integer&nbsp;of<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0:&nbsp;(Left,&nbsp;Top,&nbsp;Right,&nbsp;Bottom:&nbsp;Longint);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1:&nbsp;(TopLeft,&nbsp;BottomRight:&nbsp;TGridCoord);<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;TLineColors=class(TGraphicsObject)<br>&nbsp;&nbsp;private<br>&nbsp;&nbsp;&nbsp;&nbsp;FLineColors:&nbsp;array[1..5]&nbsp;of&nbsp;TColor;<br>&nbsp;&nbsp;protected<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;GetLineColor(Index:&nbsp;integer):&nbsp;TColor;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetLineColor(Index:&nbsp;integer;&nbsp;Value:&nbsp;TColor);<br>&nbsp;&nbsp;public<br>&nbsp;&nbsp;&nbsp;&nbsp;constructor&nbsp;Create;<br>&nbsp;&nbsp;published<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;DefaultLineColor:&nbsp;TColor&nbsp;index&nbsp;1&nbsp;read&nbsp;GetLineColor&nbsp;write&nbsp;SetLineColor;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;SeperatorLineColor:&nbsp;TColor&nbsp;index&nbsp;2&nbsp;read&nbsp;GetLineColor&nbsp;write&nbsp;SetLineColor;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;ThousandLineColor:&nbsp;TColor&nbsp;index&nbsp;3&nbsp;read&nbsp;GetLineColor&nbsp;write&nbsp;SetLineColor;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;BorderLineColor:&nbsp;TColor&nbsp;index&nbsp;4&nbsp;read&nbsp;GetLineColor&nbsp;write&nbsp;SetLineColor;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;GridLineColor:&nbsp;TColor&nbsp;index&nbsp;5&nbsp;read&nbsp;GetLineColor&nbsp;write&nbsp;SetLineColor;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;TEditStyle&nbsp;=&nbsp;&nbsp;(esSimple,&nbsp;esEllipsis,&nbsp;esPickList);<br><br>&nbsp;&nbsp;TSelectCellEvent&nbsp;=&nbsp;procedure&nbsp;(Sender:&nbsp;TObject;&nbsp;ACol,&nbsp;ARow:&nbsp;Longint;<br>&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;CanSelect:&nbsp;Boolean)&nbsp;of&nbsp;object;<br>&nbsp;&nbsp;TDrawCellEvent&nbsp;=&nbsp;procedure&nbsp;(Sender:&nbsp;TObject;&nbsp;ACol,&nbsp;ARow:&nbsp;Longint;<br>&nbsp;&nbsp;&nbsp;&nbsp;Rect:&nbsp;TRect;&nbsp;State:&nbsp;TGridDrawState)&nbsp;of&nbsp;object;<br><br>&nbsp;&nbsp;TCustomPZGrid&nbsp;=&nbsp;class(TCustomControl)<br>&nbsp;&nbsp;private<br>&nbsp;&nbsp;&nbsp;&nbsp;FAnchor:&nbsp;TGridCoord;<br>&nbsp;&nbsp;&nbsp;&nbsp;FLineColors:&nbsp;TLineColors;<br>&nbsp;&nbsp;&nbsp;&nbsp;FShowLineSeparator:Boolean;<br>&nbsp;&nbsp;&nbsp;&nbsp;FBorderStyle:&nbsp;TBorderStyle;<br>&nbsp;&nbsp;&nbsp;&nbsp;FCanEditModify:&nbsp;Boolean;<br>&nbsp;&nbsp;&nbsp;&nbsp;FColCount:&nbsp;Longint;<br>&nbsp;&nbsp;&nbsp;&nbsp;FColWidths:&nbsp;Pointer;<br>&nbsp;&nbsp;&nbsp;&nbsp;FTabStops:&nbsp;Pointer;<br>&nbsp;&nbsp;&nbsp;&nbsp;FCurrent:&nbsp;TGridCoord;<br>&nbsp;&nbsp;&nbsp;&nbsp;FDefaultColWidth:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;FDefaultRowHeight:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;FFixedCols:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;FFixedRows:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;FFixedColor:&nbsp;TColor;<br>&nbsp;&nbsp;&nbsp;&nbsp;FGridLineWidth:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;FOptions:&nbsp;TGridOptions;<br>&nbsp;&nbsp;&nbsp;&nbsp;FRowCount:&nbsp;Longint;<br>&nbsp;&nbsp;&nbsp;&nbsp;FRowHeights:&nbsp;Pointer;<br>&nbsp;&nbsp;&nbsp;&nbsp;FScrollBars:&nbsp;TScrollStyle;<br>&nbsp;&nbsp;&nbsp;&nbsp;FTopLeft:&nbsp;TGridCoord;<br>&nbsp;&nbsp;&nbsp;&nbsp;FSizingIndex:&nbsp;Longint;<br>&nbsp;&nbsp;&nbsp;&nbsp;FSizingPos,&nbsp;FSizingOfs:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;FMoveIndex,&nbsp;FMovePos:&nbsp;Longint;<br>&nbsp;&nbsp;&nbsp;&nbsp;FHitTest:&nbsp;TPoint;<br>&nbsp;&nbsp;&nbsp;&nbsp;FInplaceEdit:&nbsp;TInplaceEdit;<br>&nbsp;&nbsp;&nbsp;&nbsp;FInplaceCol,&nbsp;FInplaceRow:&nbsp;Longint;<br>&nbsp;&nbsp;&nbsp;&nbsp;FColOffset:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;FDefaultDrawing:&nbsp;Boolean;<br>&nbsp;&nbsp;&nbsp;&nbsp;FEditorMode:&nbsp;Boolean;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;CalcCoordFromPoint(X,&nbsp;Y:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;DrawInfo:&nbsp;TGridDrawInfo):&nbsp;TGridCoord;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;CalcDrawInfoXY(var&nbsp;DrawInfo:&nbsp;TGridDrawInfo;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UseWidth,&nbsp;UseHeight:&nbsp;Integer);<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;CalcMaxTopLeft(const&nbsp;Coord:&nbsp;TGridCoord;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;DrawInfo:&nbsp;TGridDrawInfo):&nbsp;TGridCoord;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;CancelMode;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;ChangeSize(NewColCount,&nbsp;NewRowCount:&nbsp;Longint);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;ClampInView(const&nbsp;Coord:&nbsp;TGridCoord);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;DrawSizingLine(const&nbsp;DrawInfo:&nbsp;TGridDrawInfo);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;DrawMove;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;GridRectToScreenRect(GridRect:&nbsp;TGridRect;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;ScreenRect:&nbsp;TRect;&nbsp;IncludeLine:&nbsp;Boolean);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Initialize;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;InvalidateRect(ARect:&nbsp;TGridRect);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;ModifyScrollBar(ScrollBar,&nbsp;ScrollCode,&nbsp;Pos:&nbsp;Cardinal;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UseRightToLeft:&nbsp;Boolean);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;MoveAdjust(var&nbsp;CellPos:&nbsp;Longint;&nbsp;FromIndex,&nbsp;ToIndex:&nbsp;Longint);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;MoveAnchor(const&nbsp;NewAnchor:&nbsp;TGridCoord);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;MoveAndScroll(Mouse,&nbsp;CellHit:&nbsp;Integer;&nbsp;var&nbsp;DrawInfo:&nbsp;TGridDrawInfo;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;Axis:&nbsp;TGridAxisDrawInfo;&nbsp;Scrollbar:&nbsp;Integer;&nbsp;const&nbsp;MousePt:&nbsp;TPoint);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;MoveCurrent(ACol,&nbsp;ARow:&nbsp;Longint;&nbsp;MoveAnchor,&nbsp;Show:&nbsp;Boolean);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;MoveTopLeft(ALeft,&nbsp;ATop:&nbsp;Longint);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;ResizeCol(Index:&nbsp;Longint;&nbsp;OldSize,&nbsp;NewSize:&nbsp;Integer);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;ResizeRow(Index:&nbsp;Longint;&nbsp;OldSize,&nbsp;NewSize:&nbsp;Integer);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SelectionMoved(const&nbsp;OldSel:&nbsp;TGridRect);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;ScrollDataInfo(DX,&nbsp;DY:&nbsp;Integer;&nbsp;var&nbsp;DrawInfo:&nbsp;TGridDrawInfo);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;TopLeftMoved(const&nbsp;OldTopLeft:&nbsp;TGridCoord);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;UpdateScrollPos;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;UpdateScrollRange;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;GetColWidths(Index:&nbsp;Longint):&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;GetRowHeights(Index:&nbsp;Longint):&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;GetSelection:&nbsp;TGridRect;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;GetTabStops(Index:&nbsp;Longint):&nbsp;Boolean;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;GetVisibleColCount:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;GetVisibleRowCount:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;IsActiveControl:&nbsp;Boolean;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;ReadColWidths(Reader:&nbsp;TReader);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;ReadRowHeights(Reader:&nbsp;TReader);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetBorderStyle(Value:&nbsp;TBorderStyle);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetCol(Value:&nbsp;Longint);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetColCount(Value:&nbsp;Longint);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetColWidths(Index:&nbsp;Longint;&nbsp;Value:&nbsp;Integer);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetDefaultColWidth(Value:&nbsp;Integer);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetDefaultRowHeight(Value:&nbsp;Integer);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetEditorMode(Value:&nbsp;Boolean);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetFixedColor(Value:&nbsp;TColor);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetFixedCols(Value:&nbsp;Integer);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetFixedRows(Value:&nbsp;Integer);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetGridLineWidth(Value:&nbsp;Integer);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetLeftCol(Value:&nbsp;Longint);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetOptions(Value:&nbsp;TGridOptions);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetRow(Value:&nbsp;Longint);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetRowCount(Value:&nbsp;Longint);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetRowHeights(Index:&nbsp;Longint;&nbsp;Value:&nbsp;Integer);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetScrollBars(Value:&nbsp;TScrollStyle);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetSelection(Value:&nbsp;TGridRect);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetTabStops(Index:&nbsp;Longint;&nbsp;Value:&nbsp;Boolean);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetTopRow(Value:&nbsp;Longint);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;UpdateEdit;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;UpdateText;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WriteColWidths(Writer:&nbsp;TWriter);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WriteRowHeights(Writer:&nbsp;TWriter);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;CMCancelMode(var&nbsp;Msg:&nbsp;TMessage);&nbsp;message&nbsp;CM_CANCELMODE;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;CMFontChanged(var&nbsp;Message:&nbsp;TMessage);&nbsp;message&nbsp;CM_FONTCHANGED;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;CMCtl3DChanged(var&nbsp;Message:&nbsp;TMessage);&nbsp;message&nbsp;CM_CTL3DCHANGED;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;CMDesignHitTest(var&nbsp;Msg:&nbsp;TCMDesignHitTest);&nbsp;message&nbsp;CM_DESIGNHITTEST;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;CMWantSpecialKey(var&nbsp;Msg:&nbsp;TCMWantSpecialKey);&nbsp;message&nbsp;CM_WANTSPECIALKEY;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;CMShowingChanged(var&nbsp;Message:&nbsp;TMessage);&nbsp;message&nbsp;CM_SHOWINGCHANGED;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WMChar(var&nbsp;Msg:&nbsp;TWMChar);&nbsp;message&nbsp;WM_CHAR;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WMCancelMode(var&nbsp;Msg:&nbsp;TWMCancelMode);&nbsp;message&nbsp;WM_CANCELMODE;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WMCommand(var&nbsp;Message:&nbsp;TWMCommand);&nbsp;message&nbsp;WM_COMMAND;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WMGetDlgCode(var&nbsp;Msg:&nbsp;TWMGetDlgCode);&nbsp;message&nbsp;WM_GETDLGCODE;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WMHScroll(var&nbsp;Msg:&nbsp;TWMHScroll);&nbsp;message&nbsp;WM_HSCROLL;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WMKillFocus(var&nbsp;Msg:&nbsp;TWMKillFocus);&nbsp;message&nbsp;WM_KILLFOCUS;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WMLButtonDown(var&nbsp;Message:&nbsp;TMessage);&nbsp;message&nbsp;WM_LBUTTONDOWN;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WMNCHitTest(var&nbsp;Msg:&nbsp;TWMNCHitTest);&nbsp;message&nbsp;WM_NCHITTEST;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WMSetCursor(var&nbsp;Msg:&nbsp;TWMSetCursor);&nbsp;message&nbsp;WM_SETCURSOR;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WMSetFocus(var&nbsp;Msg:&nbsp;TWMSetFocus);&nbsp;message&nbsp;WM_SETFOCUS;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WMSize(var&nbsp;Msg:&nbsp;TWMSize);&nbsp;message&nbsp;WM_SIZE;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WMTimer(var&nbsp;Msg:&nbsp;TWMTimer);&nbsp;message&nbsp;WM_TIMER;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WMVScroll(var&nbsp;Msg:&nbsp;TWMVScroll);&nbsp;message&nbsp;WM_VSCROLL;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;LineColorsChanged(FLineColors:&nbsp;TObject);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;PaintMoeny(Str:&nbsp;string;&nbsp;FocRect:&nbsp;TRect);<br>&nbsp;&nbsp;protected<br>&nbsp;&nbsp;&nbsp;&nbsp;FGridState:&nbsp;TGridState;<br>&nbsp;&nbsp;&nbsp;&nbsp;FSaveCellExtents:&nbsp;Boolean;<br>&nbsp;&nbsp;&nbsp;&nbsp;DesignOptionsBoost:&nbsp;TGridOptions;<br>&nbsp;&nbsp;&nbsp;&nbsp;VirtualView:&nbsp;Boolean;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;CalcDrawInfo(var&nbsp;DrawInfo:&nbsp;TGridDrawInfo);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;CalcFixedInfo(var&nbsp;DrawInfo:&nbsp;TGridDrawInfo);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;CalcSizingState(X,&nbsp;Y:&nbsp;Integer;&nbsp;var&nbsp;State:&nbsp;TGridState;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;Index:&nbsp;Longint;&nbsp;var&nbsp;SizingPos,&nbsp;SizingOfs:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;FixedInfo:&nbsp;TGridDrawInfo);&nbsp;virtual;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;ChangeGridOrientation(RightToLeftOrientation:&nbsp;Boolean);<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;CreateEditor:&nbsp;TInplaceEdit;&nbsp;virtual;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;CreateParams(var&nbsp;Params:&nbsp;TCreateParams);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;KeyDown(var&nbsp;Key:&nbsp;Word;&nbsp;Shift:&nbsp;TShiftState);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;KeyPress(var&nbsp;Key:&nbsp;Char);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;MouseDown(Button:&nbsp;TMouseButton;&nbsp;Shift:&nbsp;TShiftState;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;X,&nbsp;Y:&nbsp;Integer);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;MouseMove(Shift:&nbsp;TShiftState;&nbsp;X,&nbsp;Y:&nbsp;Integer);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;MouseUp(Button:&nbsp;TMouseButton;&nbsp;Shift:&nbsp;TShiftState;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;X,&nbsp;Y:&nbsp;Integer);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;AdjustSize(Index,&nbsp;Amount:&nbsp;Longint;&nbsp;Rows:&nbsp;Boolean);&nbsp;reintroduce;&nbsp;dynamic;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;BoxRect(ALeft,&nbsp;ATop,&nbsp;ARight,&nbsp;ABottom:&nbsp;Longint):&nbsp;TRect;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;DoExit;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;CellRect(ACol,&nbsp;ARow:&nbsp;Longint):&nbsp;TRect;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;CanEditAcceptKey(Key:&nbsp;Char):&nbsp;Boolean;&nbsp;dynamic;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;CanGridAcceptKey(Key:&nbsp;Word;&nbsp;Shift:&nbsp;TShiftState):&nbsp;Boolean;&nbsp;dynamic;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;CanEditModify:&nbsp;Boolean;&nbsp;dynamic;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;CanEditShow:&nbsp;Boolean;&nbsp;virtual;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;DoMouseWheelDown(Shift:&nbsp;TShiftState;&nbsp;MousePos:&nbsp;TPoint):&nbsp;Boolean;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;DoMouseWheelUp(Shift:&nbsp;TShiftState;&nbsp;MousePos:&nbsp;TPoint):&nbsp;Boolean;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;FocusCell(ACol,&nbsp;ARow:&nbsp;Longint;&nbsp;MoveAnchor:&nbsp;Boolean);<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;GetEditText(ACol,&nbsp;ARow:&nbsp;Longint):&nbsp;string;&nbsp;dynamic;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetEditText(ACol,&nbsp;ARow:&nbsp;Longint;&nbsp;const&nbsp;Value:&nbsp;string);&nbsp;dynamic;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;GetEditLimit:&nbsp;Integer;&nbsp;dynamic;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;GetEditMask(ACol,&nbsp;ARow:&nbsp;Longint):&nbsp;string;&nbsp;dynamic;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;GetEditStyle(ACol,&nbsp;ARow:&nbsp;Longint):&nbsp;TEditStyle;&nbsp;dynamic;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;GetGridWidth:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;GetGridHeight:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;HideEdit;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;HideEditor;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;ShowEditor;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;ShowEditorChar(Ch:&nbsp;Char);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;InvalidateEditor;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;InvalidateGrid;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;MoveColumn(FromIndex,&nbsp;ToIndex:&nbsp;Longint);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;ColumnMoved(FromIndex,&nbsp;ToIndex:&nbsp;Longint);&nbsp;dynamic;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;MoveRow(FromIndex,&nbsp;ToIndex:&nbsp;Longint);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;RowMoved(FromIndex,&nbsp;ToIndex:&nbsp;Longint);&nbsp;dynamic;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;DrawCell(ACol,&nbsp;ARow:&nbsp;Longint;&nbsp;ARect:&nbsp;TRect;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AState:&nbsp;TGridDrawState);&nbsp;virtual;&nbsp;abstract;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;DefineProperties(Filer:&nbsp;TFiler);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;MoveColRow(ACol,&nbsp;ARow:&nbsp;Longint;&nbsp;MoveAnchor,&nbsp;Show:&nbsp;Boolean);<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;SelectCell(ACol,&nbsp;ARow:&nbsp;Longint):&nbsp;Boolean;&nbsp;virtual;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SizeChanged(OldColCount,&nbsp;OldRowCount:&nbsp;Longint);&nbsp;dynamic;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;Sizing(X,&nbsp;Y:&nbsp;Integer):&nbsp;Boolean;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;ScrollData(DX,&nbsp;DY:&nbsp;Integer);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;InvalidateCell(ACol,&nbsp;ARow:&nbsp;Longint);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;InvalidateCol(ACol:&nbsp;Longint);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;InvalidateRow(ARow:&nbsp;Longint);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;TopLeftChanged;&nbsp;dynamic;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;TimedScroll(Direction:&nbsp;TGridScrollDirection);&nbsp;dynamic;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Paint;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;ColWidthsChanged;&nbsp;dynamic;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;RowHeightsChanged;&nbsp;dynamic;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;DeleteColumn(ACol:&nbsp;Longint);&nbsp;virtual;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;DeleteRow(ARow:&nbsp;Longint);&nbsp;virtual;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;UpdateDesigner;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;BeginColumnDrag(var&nbsp;Origin,&nbsp;Destination:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;MousePt:&nbsp;TPoint):&nbsp;Boolean;&nbsp;dynamic;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;BeginRowDrag(var&nbsp;Origin,&nbsp;Destination:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;MousePt:&nbsp;TPoint):&nbsp;Boolean;&nbsp;dynamic;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;CheckColumnDrag(var&nbsp;Origin,&nbsp;Destination:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;MousePt:&nbsp;TPoint):&nbsp;Boolean;&nbsp;dynamic;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;CheckRowDrag(var&nbsp;Origin,&nbsp;Destination:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;MousePt:&nbsp;TPoint):&nbsp;Boolean;&nbsp;dynamic;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;EndColumnDrag(var&nbsp;Origin,&nbsp;Destination:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;MousePt:&nbsp;TPoint):&nbsp;Boolean;&nbsp;dynamic;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;EndRowDrag(var&nbsp;Origin,&nbsp;Destination:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;MousePt:&nbsp;TPoint):&nbsp;Boolean;&nbsp;dynamic;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;BorderStyle:&nbsp;TBorderStyle&nbsp;read&nbsp;FBorderStyle&nbsp;write&nbsp;SetBorderStyle&nbsp;default&nbsp;bsSingle;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Col:&nbsp;Longint&nbsp;read&nbsp;FCurrent.X&nbsp;write&nbsp;SetCol;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Color&nbsp;default&nbsp;clWindow;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;ColCount:&nbsp;Longint&nbsp;read&nbsp;FColCount&nbsp;write&nbsp;SetColCount&nbsp;default&nbsp;5;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;ColWidths[Index:&nbsp;Longint]:&nbsp;Integer&nbsp;read&nbsp;GetColWidths&nbsp;write&nbsp;SetColWidths;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;DefaultColWidth:&nbsp;Integer&nbsp;read&nbsp;FDefaultColWidth&nbsp;write&nbsp;SetDefaultColWidth&nbsp;default&nbsp;64;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;DefaultDrawing:&nbsp;Boolean&nbsp;read&nbsp;FDefaultDrawing&nbsp;write&nbsp;FDefaultDrawing&nbsp;default&nbsp;True;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;DefaultRowHeight:&nbsp;Integer&nbsp;read&nbsp;FDefaultRowHeight&nbsp;write&nbsp;SetDefaultRowHeight&nbsp;default&nbsp;24;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;EditorMode:&nbsp;Boolean&nbsp;read&nbsp;FEditorMode&nbsp;write&nbsp;SetEditorMode;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;FixedColor:&nbsp;TColor&nbsp;read&nbsp;FFixedColor&nbsp;write&nbsp;SetFixedColor&nbsp;default&nbsp;clBtnFace;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;FixedCols:&nbsp;Integer&nbsp;read&nbsp;FFixedCols&nbsp;write&nbsp;SetFixedCols&nbsp;default&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;FixedRows:&nbsp;Integer&nbsp;read&nbsp;FFixedRows&nbsp;write&nbsp;SetFixedRows&nbsp;default&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;GridHeight:&nbsp;Integer&nbsp;read&nbsp;GetGridHeight;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;GridLineWidth:&nbsp;Integer&nbsp;read&nbsp;FGridLineWidth&nbsp;write&nbsp;SetGridLineWidth&nbsp;default&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;GridWidth:&nbsp;Integer&nbsp;read&nbsp;GetGridWidth;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;HitTest:&nbsp;TPoint&nbsp;read&nbsp;FHitTest;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;InplaceEditor:&nbsp;TInplaceEdit&nbsp;read&nbsp;FInplaceEdit;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;LeftCol:&nbsp;Longint&nbsp;read&nbsp;FTopLeft.X&nbsp;write&nbsp;SetLeftCol;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Options:&nbsp;TGridOptions&nbsp;read&nbsp;FOptions&nbsp;write&nbsp;SetOptions<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default&nbsp;[goFixedVertLine,&nbsp;goFixedHorzLine,&nbsp;goVertLine,&nbsp;goHorzLine,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goRangeSelect];<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;ParentColor&nbsp;default&nbsp;False;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Row:&nbsp;Longint&nbsp;read&nbsp;FCurrent.Y&nbsp;write&nbsp;SetRow;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;RowCount:&nbsp;Longint&nbsp;read&nbsp;FRowCount&nbsp;write&nbsp;SetRowCount&nbsp;default&nbsp;5;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;RowHeights[Index:&nbsp;Longint]:&nbsp;Integer&nbsp;read&nbsp;GetRowHeights&nbsp;write&nbsp;SetRowHeights;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;ScrollBars:&nbsp;TScrollStyle&nbsp;read&nbsp;FScrollBars&nbsp;write&nbsp;SetScrollBars&nbsp;default&nbsp;ssBoth;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Selection:&nbsp;TGridRect&nbsp;read&nbsp;GetSelection&nbsp;write&nbsp;SetSelection;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;TabStops[Index:&nbsp;Longint]:&nbsp;Boolean&nbsp;read&nbsp;GetTabStops&nbsp;write&nbsp;SetTabStops;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;TopRow:&nbsp;Longint&nbsp;read&nbsp;FTopLeft.Y&nbsp;write&nbsp;SetTopRow;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;VisibleColCount:&nbsp;Integer&nbsp;read&nbsp;GetVisibleColCount;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;VisibleRowCount:&nbsp;Integer&nbsp;read&nbsp;GetVisibleRowCount;<br>&nbsp;&nbsp;public<br>&nbsp;&nbsp;&nbsp;&nbsp;constructor&nbsp;Create(AOwner:&nbsp;TComponent);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;destructor&nbsp;Destroy;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;MouseCoord(X,&nbsp;Y:&nbsp;Integer):&nbsp;TGridCoord;<br>&nbsp;&nbsp;published<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;TabStop&nbsp;default&nbsp;True;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;ShowLineSeparator:boolean&nbsp;Read&nbsp;FShowLineSeparator&nbsp;Write<br>&nbsp;&nbsp;&nbsp;&nbsp;FShowLineSeparator&nbsp;default&nbsp;True;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;LineColors:&nbsp;TLineColors&nbsp;read&nbsp;FLineColors&nbsp;write&nbsp;FLineColors;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;{&nbsp;TCustomDrawPZGrid&nbsp;}<br><br>&nbsp;&nbsp;{&nbsp;A&nbsp;grid&nbsp;relies&nbsp;on&nbsp;the&nbsp;OnDrawCell&nbsp;event&nbsp;to&nbsp;display&nbsp;the&nbsp;cells.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CellRect<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This&nbsp;method&nbsp;returns&nbsp;control&nbsp;relative&nbsp;screen&nbsp;coordinates&nbsp;of&nbsp;the&nbsp;cell&nbsp;or<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;an&nbsp;empty&nbsp;rectangle&nbsp;if&nbsp;the&nbsp;cell&nbsp;is&nbsp;not&nbsp;visible.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EditorMode<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Setting&nbsp;to&nbsp;true&nbsp;shows&nbsp;the&nbsp;editor,&nbsp;as&nbsp;if&nbsp;the&nbsp;F2&nbsp;key&nbsp;was&nbsp;pressed,&nbsp;when<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;goEditing&nbsp;is&nbsp;turned&nbsp;on&nbsp;and&nbsp;goAlwaysShowEditor&nbsp;is&nbsp;turned&nbsp;off.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MouseToCell<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Takes&nbsp;control&nbsp;relative&nbsp;screen&nbsp;X,&nbsp;Y&nbsp;location&nbsp;and&nbsp;fills&nbsp;in&nbsp;the&nbsp;column&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;row&nbsp;that&nbsp;contain&nbsp;that&nbsp;point.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OnColumnMoved<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Called&nbsp;when&nbsp;the&nbsp;user&nbsp;request&nbsp;to&nbsp;move&nbsp;a&nbsp;column&nbsp;with&nbsp;the&nbsp;mouse&nbsp;when<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the&nbsp;goColMoving&nbsp;option&nbsp;is&nbsp;on.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OnDrawCell<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;This&nbsp;event&nbsp;is&nbsp;passed&nbsp;the&nbsp;same&nbsp;information&nbsp;as&nbsp;the&nbsp;DrawCell&nbsp;method<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;discussed&nbsp;above.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OnGetEditMask<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Called&nbsp;to&nbsp;retrieve&nbsp;edit&nbsp;mask&nbsp;in&nbsp;the&nbsp;inplace&nbsp;editor&nbsp;when&nbsp;goEditing&nbsp;is<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;turned&nbsp;on.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OnGetEditText<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Called&nbsp;to&nbsp;retrieve&nbsp;text&nbsp;to&nbsp;edit&nbsp;when&nbsp;goEditing&nbsp;is&nbsp;turned&nbsp;on.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OnRowMoved<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Called&nbsp;when&nbsp;the&nbsp;user&nbsp;request&nbsp;to&nbsp;move&nbsp;a&nbsp;row&nbsp;with&nbsp;the&nbsp;mouse&nbsp;when<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the&nbsp;goRowMoving&nbsp;option&nbsp;is&nbsp;on.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OnSetEditText<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Called&nbsp;when&nbsp;goEditing&nbsp;is&nbsp;turned&nbsp;on&nbsp;to&nbsp;reflect&nbsp;changes&nbsp;to&nbsp;the&nbsp;text<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;made&nbsp;by&nbsp;the&nbsp;editor.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OnTopLeftChanged<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Invoked&nbsp;when&nbsp;TopRow&nbsp;or&nbsp;LeftCol&nbsp;change.&nbsp;}<br><br>&nbsp;&nbsp;TGetEditEvent&nbsp;=&nbsp;procedure&nbsp;(Sender:&nbsp;TObject;&nbsp;ACol,&nbsp;ARow:&nbsp;Longint;&nbsp;var&nbsp;Value:&nbsp;string)&nbsp;of&nbsp;object;<br>&nbsp;&nbsp;TSetEditEvent&nbsp;=&nbsp;procedure&nbsp;(Sender:&nbsp;TObject;&nbsp;ACol,&nbsp;ARow:&nbsp;Longint;&nbsp;const&nbsp;Value:&nbsp;string)&nbsp;of&nbsp;object;<br>&nbsp;&nbsp;TMovedEvent&nbsp;=&nbsp;procedure&nbsp;(Sender:&nbsp;TObject;&nbsp;FromIndex,&nbsp;ToIndex:&nbsp;Longint)&nbsp;of&nbsp;object;<br><br>&nbsp;&nbsp;TCustomDrawPZGrid&nbsp;=&nbsp;class(TCustomPZGrid)<br>&nbsp;&nbsp;private<br>&nbsp;&nbsp;&nbsp;&nbsp;FOnColumnMoved:&nbsp;TMovedEvent;<br>&nbsp;&nbsp;&nbsp;&nbsp;FOnDrawCell:&nbsp;TDrawCellEvent;<br>&nbsp;&nbsp;&nbsp;&nbsp;FOnGetEditMask:&nbsp;TGetEditEvent;<br>&nbsp;&nbsp;&nbsp;&nbsp;FOnGetEditText:&nbsp;TGetEditEvent;<br>&nbsp;&nbsp;&nbsp;&nbsp;FOnRowMoved:&nbsp;TMovedEvent;<br>&nbsp;&nbsp;&nbsp;&nbsp;FOnSelectCell:&nbsp;TSelectCellEvent;<br>&nbsp;&nbsp;&nbsp;&nbsp;FOnSetEditText:&nbsp;TSetEditEvent;<br>&nbsp;&nbsp;&nbsp;&nbsp;FOnTopLeftChanged:&nbsp;TNotifyEvent;<br>&nbsp;&nbsp;protected<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;ColumnMoved(FromIndex,&nbsp;ToIndex:&nbsp;Longint);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;DrawCell(ACol,&nbsp;ARow:&nbsp;Longint;&nbsp;ARect:&nbsp;TRect;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AState:&nbsp;TGridDrawState);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;GetEditMask(ACol,&nbsp;ARow:&nbsp;Longint):&nbsp;string;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;GetEditText(ACol,&nbsp;ARow:&nbsp;Longint):&nbsp;string;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;RowMoved(FromIndex,&nbsp;ToIndex:&nbsp;Longint);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;SelectCell(ACol,&nbsp;ARow:&nbsp;Longint):&nbsp;Boolean;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetEditText(ACol,&nbsp;ARow:&nbsp;Longint;&nbsp;const&nbsp;Value:&nbsp;string);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;TopLeftChanged;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnColumnMoved:&nbsp;TMovedEvent&nbsp;read&nbsp;FOnColumnMoved&nbsp;write&nbsp;FOnColumnMoved;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnDrawCell:&nbsp;TDrawCellEvent&nbsp;read&nbsp;FOnDrawCell&nbsp;write&nbsp;FOnDrawCell;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnGetEditMask:&nbsp;TGetEditEvent&nbsp;read&nbsp;FOnGetEditMask&nbsp;write&nbsp;FOnGetEditMask;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnGetEditText:&nbsp;TGetEditEvent&nbsp;read&nbsp;FOnGetEditText&nbsp;write&nbsp;FOnGetEditText;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnRowMoved:&nbsp;TMovedEvent&nbsp;read&nbsp;FOnRowMoved&nbsp;write&nbsp;FOnRowMoved;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnSelectCell:&nbsp;TSelectCellEvent&nbsp;read&nbsp;FOnSelectCell&nbsp;write&nbsp;FOnSelectCell;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnSetEditText:&nbsp;TSetEditEvent&nbsp;read&nbsp;FOnSetEditText&nbsp;write&nbsp;FOnSetEditText;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnTopLeftChanged:&nbsp;TNotifyEvent&nbsp;read&nbsp;FOnTopLeftChanged&nbsp;write&nbsp;FOnTopLeftChanged;<br>&nbsp;&nbsp;public<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;CellRect(ACol,&nbsp;ARow:&nbsp;Longint):&nbsp;TRect;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;MouseToCell(X,&nbsp;Y:&nbsp;Integer;&nbsp;var&nbsp;ACol,&nbsp;ARow:&nbsp;Longint);<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Canvas;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Col;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;ColWidths;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;EditorMode;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;GridHeight;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;GridWidth;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;LeftCol;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Selection;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Row;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;RowHeights;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;TabStops;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;TopRow;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;{&nbsp;TDrawPZGrid&nbsp;}<br><br>&nbsp;&nbsp;TDrawPZGrid&nbsp;=&nbsp;class(TCustomDrawPZGrid)<br>&nbsp;&nbsp;published<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Align;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Anchors;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;BiDiMode;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;BorderStyle;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Color;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;ColCount;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Constraints;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Ctl3D;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;DefaultColWidth;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;DefaultRowHeight;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;DefaultDrawing;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;DragCursor;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;DragKind;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;DragMode;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Enabled;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;FixedColor;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;FixedCols;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;RowCount;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;FixedRows;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Font;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;GridLineWidth;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Options;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;ParentBiDiMode;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;ParentColor;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;ParentCtl3D;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;ParentFont;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;ParentShowHint;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;PopupMenu;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;ScrollBars;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;ShowHint;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;TabOrder;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Visible;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;VisibleColCount;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;VisibleRowCount;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnClick;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnColumnMoved;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnContextPopup;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnDblClick;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnDragDrop;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnDragOver;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnDrawCell;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnEndDock;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnEndDrag;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnEnter;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnExit;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnGetEditMask;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnGetEditText;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnKeyDown;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnKeyPress;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnKeyUp;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnMouseDown;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnMouseMove;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnMouseUp;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnMouseWheelDown;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnMouseWheelUp;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnRowMoved;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnSelectCell;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnSetEditText;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnStartDock;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnStartDrag;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnTopLeftChanged;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;{&nbsp;TPZGrid&nbsp;}<br><br>&nbsp;&nbsp;{&nbsp;TPZGrid&nbsp;adds&nbsp;to&nbsp;TDrawPZGrid&nbsp;the&nbsp;ability&nbsp;to&nbsp;save&nbsp;a&nbsp;string&nbsp;and&nbsp;associated<br>&nbsp;&nbsp;&nbsp;&nbsp;object&nbsp;(much&nbsp;like&nbsp;TListBox).&nbsp;&nbsp;It&nbsp;also&nbsp;adds&nbsp;to&nbsp;the&nbsp;DefaultDrawing&nbsp;the&nbsp;drawing<br>&nbsp;&nbsp;&nbsp;&nbsp;of&nbsp;the&nbsp;string&nbsp;associated&nbsp;with&nbsp;the&nbsp;current&nbsp;cell.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cells<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;ColCount&nbsp;by&nbsp;RowCount&nbsp;array&nbsp;of&nbsp;strings&nbsp;which&nbsp;are&nbsp;associated&nbsp;with&nbsp;each<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cell.&nbsp;&nbsp;By&nbsp;default,&nbsp;the&nbsp;string&nbsp;is&nbsp;drawn&nbsp;into&nbsp;the&nbsp;cell&nbsp;before&nbsp;OnDrawCell<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;is&nbsp;called.&nbsp;&nbsp;This&nbsp;can&nbsp;be&nbsp;turned&nbsp;off&nbsp;(along&nbsp;with&nbsp;all&nbsp;the&nbsp;other&nbsp;default<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;drawing)&nbsp;by&nbsp;setting&nbsp;DefaultDrawing&nbsp;to&nbsp;false.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cols<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;TStrings&nbsp;object&nbsp;that&nbsp;contains&nbsp;the&nbsp;strings&nbsp;and&nbsp;objects&nbsp;in&nbsp;the&nbsp;column<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;indicated&nbsp;by&nbsp;Index.&nbsp;&nbsp;The&nbsp;TStrings&nbsp;will&nbsp;always&nbsp;have&nbsp;a&nbsp;count&nbsp;of&nbsp;RowCount.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;a&nbsp;another&nbsp;TStrings&nbsp;is&nbsp;assigned&nbsp;to&nbsp;it,&nbsp;the&nbsp;strings&nbsp;and&nbsp;objects&nbsp;beyond<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RowCount&nbsp;are&nbsp;ignored.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Objects<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;ColCount&nbsp;by&nbsp;Rowcount&nbsp;array&nbsp;of&nbsp;TObject's&nbsp;associated&nbsp;with&nbsp;each&nbsp;cell.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Object&nbsp;put&nbsp;into&nbsp;this&nbsp;array&nbsp;will&nbsp;*not*&nbsp;be&nbsp;destroyed&nbsp;automatically&nbsp;when<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the&nbsp;grid&nbsp;is&nbsp;destroyed.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Rows<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A&nbsp;TStrings&nbsp;object&nbsp;that&nbsp;contains&nbsp;the&nbsp;strings&nbsp;and&nbsp;objects&nbsp;in&nbsp;the&nbsp;row<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;indicated&nbsp;by&nbsp;Index.&nbsp;&nbsp;The&nbsp;TStrings&nbsp;will&nbsp;always&nbsp;have&nbsp;a&nbsp;count&nbsp;of&nbsp;ColCount.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If&nbsp;a&nbsp;another&nbsp;TStrings&nbsp;is&nbsp;assigned&nbsp;to&nbsp;it,&nbsp;the&nbsp;strings&nbsp;and&nbsp;objects&nbsp;beyond<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ColCount&nbsp;are&nbsp;ignored.&nbsp;}<br><br>&nbsp;&nbsp;TPZGrid&nbsp;=&nbsp;class;<br><br>&nbsp;&nbsp;TPZGridStrings&nbsp;=&nbsp;class(TStrings)<br>&nbsp;&nbsp;private<br>&nbsp;&nbsp;&nbsp;&nbsp;FGrid:&nbsp;TPZGrid;<br>&nbsp;&nbsp;&nbsp;&nbsp;FIndex:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;CalcXY(Index:&nbsp;Integer;&nbsp;var&nbsp;X,&nbsp;Y:&nbsp;Integer);<br>&nbsp;&nbsp;protected<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;Get(Index:&nbsp;Integer):&nbsp;string;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;GetCount:&nbsp;Integer;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;GetObject(Index:&nbsp;Integer):&nbsp;TObject;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Put(Index:&nbsp;Integer;&nbsp;const&nbsp;S:&nbsp;string);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;PutObject(Index:&nbsp;Integer;&nbsp;AObject:&nbsp;TObject);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetUpdateState(Updating:&nbsp;Boolean);&nbsp;override;<br>&nbsp;&nbsp;public<br>&nbsp;&nbsp;&nbsp;&nbsp;constructor&nbsp;Create(AGrid:&nbsp;TPZGrid;&nbsp;AIndex:&nbsp;Longint);<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;Add(const&nbsp;S:&nbsp;string):&nbsp;Integer;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Assign(Source:&nbsp;TPersistent);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Clear;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Delete(Index:&nbsp;Integer);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Insert(Index:&nbsp;Integer;&nbsp;const&nbsp;S:&nbsp;string);&nbsp;override;<br>&nbsp;&nbsp;end;<br><br><br>&nbsp;&nbsp;TPZGrid&nbsp;=&nbsp;class(TDrawPZGrid)<br>&nbsp;&nbsp;private<br>&nbsp;&nbsp;&nbsp;&nbsp;FData:&nbsp;Pointer;<br>&nbsp;&nbsp;&nbsp;&nbsp;FRows:&nbsp;Pointer;<br>&nbsp;&nbsp;&nbsp;&nbsp;FCols:&nbsp;Pointer;<br>&nbsp;&nbsp;&nbsp;&nbsp;FUpdating:&nbsp;Boolean;<br>&nbsp;&nbsp;&nbsp;&nbsp;FNeedsUpdating:&nbsp;Boolean;<br>&nbsp;&nbsp;&nbsp;&nbsp;FEditUpdate:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;DisableEditUpdate;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;EnableEditUpdate;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Initialize;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Update(ACol,&nbsp;ARow:&nbsp;Integer);&nbsp;reintroduce;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetUpdateState(Updating:&nbsp;Boolean);<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;GetCells(ACol,&nbsp;ARow:&nbsp;Integer):&nbsp;string;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;GetCols(Index:&nbsp;Integer):&nbsp;TStrings;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;GetObjects(ACol,&nbsp;ARow:&nbsp;Integer):&nbsp;TObject;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;GetRows(Index:&nbsp;Integer):&nbsp;TStrings;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetCells(ACol,&nbsp;ARow:&nbsp;Integer;&nbsp;const&nbsp;Value:&nbsp;string);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetCols(Index:&nbsp;Integer;&nbsp;Value:&nbsp;TStrings);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetObjects(ACol,&nbsp;ARow:&nbsp;Integer;&nbsp;Value:&nbsp;TObject);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetRows(Index:&nbsp;Integer;&nbsp;Value:&nbsp;TStrings);<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;EnsureColRow(Index:&nbsp;Integer;&nbsp;IsCol:&nbsp;Boolean):&nbsp;TPZGridStrings;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;EnsureDataRow(ARow:&nbsp;Integer):&nbsp;Pointer;<br>&nbsp;&nbsp;protected<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;ColumnMoved(FromIndex,&nbsp;ToIndex:&nbsp;Longint);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;DrawCell(ACol,&nbsp;ARow:&nbsp;Longint;&nbsp;ARect:&nbsp;TRect;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AState:&nbsp;TGridDrawState);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;GetEditText(ACol,&nbsp;ARow:&nbsp;Longint):&nbsp;string;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;SetEditText(ACol,&nbsp;ARow:&nbsp;Longint;&nbsp;const&nbsp;Value:&nbsp;string);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;RowMoved(FromIndex,&nbsp;ToIndex:&nbsp;Longint);&nbsp;override;<br>&nbsp;&nbsp;public<br>&nbsp;&nbsp;&nbsp;&nbsp;constructor&nbsp;Create(AOwner:&nbsp;TComponent);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;destructor&nbsp;Destroy;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Cells[ACol,&nbsp;ARow:&nbsp;Integer]:&nbsp;string&nbsp;read&nbsp;GetCells&nbsp;write&nbsp;SetCells;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Cols[Index:&nbsp;Integer]:&nbsp;TStrings&nbsp;read&nbsp;GetCols&nbsp;write&nbsp;SetCols;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Objects[ACol,&nbsp;ARow:&nbsp;Integer]:&nbsp;TObject&nbsp;read&nbsp;GetObjects&nbsp;write&nbsp;SetObjects;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Rows[Index:&nbsp;Integer]:&nbsp;TStrings&nbsp;read&nbsp;GetRows&nbsp;write&nbsp;SetRows;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;{&nbsp;TInplaceEditList&nbsp;}<br><br>&nbsp;&nbsp;{&nbsp;TInplaceEditList&nbsp;adds&nbsp;to&nbsp;TInplaceEdit&nbsp;the&nbsp;ability&nbsp;to&nbsp;drop&nbsp;down&nbsp;a&nbsp;pick&nbsp;list<br>&nbsp;&nbsp;&nbsp;&nbsp;of&nbsp;possible&nbsp;values&nbsp;or&nbsp;to&nbsp;display&nbsp;an&nbsp;ellipsis&nbsp;button&nbsp;which&nbsp;will&nbsp;invoke<br>&nbsp;&nbsp;&nbsp;&nbsp;user&nbsp;code&nbsp;in&nbsp;an&nbsp;event&nbsp;to&nbsp;bring&nbsp;up&nbsp;a&nbsp;modal&nbsp;dialog.&nbsp;&nbsp;The&nbsp;EditStyle&nbsp;property<br>&nbsp;&nbsp;&nbsp;&nbsp;determines&nbsp;which&nbsp;type&nbsp;of&nbsp;button&nbsp;to&nbsp;draw&nbsp;(if&nbsp;any)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ActiveList<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TWinControl&nbsp;reference&nbsp;which&nbsp;typically&nbsp;points&nbsp;to&nbsp;the&nbsp;internal<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PickList.&nbsp;&nbsp;May&nbsp;be&nbsp;set&nbsp;to&nbsp;a&nbsp;different&nbsp;list&nbsp;by&nbsp;descendent&nbsp;inplace<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;editors&nbsp;which&nbsp;provide&nbsp;additional&nbsp;functionality.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ButtonWidth<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;width&nbsp;of&nbsp;the&nbsp;button&nbsp;used&nbsp;to&nbsp;drop&nbsp;down&nbsp;the&nbsp;pick&nbsp;list.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DropDownRows<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;maximum&nbsp;number&nbsp;of&nbsp;rows&nbsp;to&nbsp;display&nbsp;at&nbsp;a&nbsp;time&nbsp;in&nbsp;the&nbsp;pick&nbsp;list.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EditStyle<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Indicates&nbsp;what&nbsp;type&nbsp;of&nbsp;list&nbsp;to&nbsp;display&nbsp;(none,&nbsp;custom,&nbsp;or&nbsp;picklist).<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ListVisible<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Indicates&nbsp;if&nbsp;the&nbsp;list&nbsp;is&nbsp;currently&nbsp;dropped&nbsp;down.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PickList<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Reference&nbsp;to&nbsp;the&nbsp;internal&nbsp;PickList&nbsp;(a&nbsp;TCustomListBox).<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pressed<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Indicates&nbsp;if&nbsp;the&nbsp;button&nbsp;is&nbsp;currently&nbsp;pressed.}<br><br>&nbsp;&nbsp;TOnGetPickListItems&nbsp;=&nbsp;procedure(ACol,&nbsp;ARow:&nbsp;Integer;&nbsp;Items:&nbsp;TStrings)&nbsp;of&nbsp;Object;<br><br>&nbsp;&nbsp;TInplaceEditList&nbsp;=&nbsp;class(TInPlaceEdit)<br>&nbsp;&nbsp;private<br>&nbsp;&nbsp;&nbsp;&nbsp;FButtonWidth:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;FPickList:&nbsp;TCustomListbox;<br>&nbsp;&nbsp;&nbsp;&nbsp;FActiveList:&nbsp;TWinControl;<br>&nbsp;&nbsp;&nbsp;&nbsp;FEditStyle:&nbsp;TEditStyle;<br>&nbsp;&nbsp;&nbsp;&nbsp;FDropDownRows:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;FListVisible:&nbsp;Boolean;<br>&nbsp;&nbsp;&nbsp;&nbsp;FTracking:&nbsp;Boolean;<br>&nbsp;&nbsp;&nbsp;&nbsp;FPressed:&nbsp;Boolean;<br>&nbsp;&nbsp;&nbsp;&nbsp;FPickListLoaded:&nbsp;Boolean;<br>&nbsp;&nbsp;&nbsp;&nbsp;FOnGetPickListitems:&nbsp;TOnGetPickListItems;<br>&nbsp;&nbsp;&nbsp;&nbsp;FOnEditButtonClick:&nbsp;TNotifyEvent;<br>&nbsp;&nbsp;&nbsp;&nbsp;FMouseInControl:&nbsp;Boolean;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;GetPickList:&nbsp;TCustomListbox;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;CMCancelMode(var&nbsp;Message:&nbsp;TCMCancelMode);&nbsp;message&nbsp;CM_CancelMode;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WMCancelMode(var&nbsp;Message:&nbsp;TMessage);&nbsp;message&nbsp;WM_CancelMode;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WMKillFocus(var&nbsp;Message:&nbsp;TMessage);&nbsp;message&nbsp;WM_KillFocus;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WMLButtonDblClk(var&nbsp;Message:&nbsp;TWMLButtonDblClk);&nbsp;message&nbsp;wm_LButtonDblClk;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WMPaint(var&nbsp;Message:&nbsp;TWMPaint);&nbsp;message&nbsp;wm_Paint;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WMSetCursor(var&nbsp;Message:&nbsp;TWMSetCursor);&nbsp;message&nbsp;WM_SetCursor;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;CMMouseEnter(var&nbsp;Message:&nbsp;TMessage);&nbsp;message&nbsp;CM_MOUSEENTER;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;CMMouseLeave(var&nbsp;Message:&nbsp;TMessage);&nbsp;message&nbsp;CM_MOUSELEAVE;<br>&nbsp;&nbsp;protected<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;BoundsChanged;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;ButtonRect:&nbsp;TRect;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;CloseUp(Accept:&nbsp;Boolean);&nbsp;dynamic;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;DblClick;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;DoDropDownKeys(var&nbsp;Key:&nbsp;Word;&nbsp;Shift:&nbsp;TShiftState);&nbsp;virtual;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;DoEditButtonClick;&nbsp;virtual;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;DoGetPickListItems;&nbsp;dynamic;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;DropDown;&nbsp;dynamic;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;KeyDown(var&nbsp;Key:&nbsp;Word;&nbsp;Shift:&nbsp;TShiftState);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;ListMouseUp(Sender:&nbsp;TObject;&nbsp;Button:&nbsp;TMouseButton;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Shift:&nbsp;TShiftState;&nbsp;X,&nbsp;Y:&nbsp;Integer);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;MouseDown(Button:&nbsp;TMouseButton;&nbsp;Shift:&nbsp;TShiftState;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;X,&nbsp;Y:&nbsp;Integer);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;MouseMove(Shift:&nbsp;TShiftState;&nbsp;X,&nbsp;Y:&nbsp;Integer);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;MouseUp(Button:&nbsp;TMouseButton;&nbsp;Shift:&nbsp;TShiftState;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;X,&nbsp;Y:&nbsp;Integer);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;OverButton(const&nbsp;P:&nbsp;TPoint):&nbsp;Boolean;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;PaintWindow(DC:&nbsp;HDC);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;StopTracking;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;TrackButton(X,Y:&nbsp;Integer);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;UpdateContents;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WndProc(var&nbsp;Message:&nbsp;TMessage);&nbsp;override;<br>&nbsp;&nbsp;public<br>&nbsp;&nbsp;&nbsp;&nbsp;constructor&nbsp;Create(Owner:&nbsp;TComponent);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;RestoreContents;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;ActiveList:&nbsp;TWinControl&nbsp;read&nbsp;FActiveList&nbsp;write&nbsp;FActiveList;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;ButtonWidth:&nbsp;Integer&nbsp;read&nbsp;FButtonWidth&nbsp;write&nbsp;FButtonWidth;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;DropDownRows:&nbsp;Integer&nbsp;read&nbsp;FDropDownRows&nbsp;write&nbsp;FDropDownRows;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;EditStyle:&nbsp;TEditStyle&nbsp;read&nbsp;FEditStyle;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;ListVisible:&nbsp;Boolean&nbsp;read&nbsp;FListVisible&nbsp;write&nbsp;FListVisible;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;PickList:&nbsp;TCustomListbox&nbsp;read&nbsp;GetPickList;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;PickListLoaded:&nbsp;Boolean&nbsp;read&nbsp;FPickListLoaded&nbsp;write&nbsp;FPickListLoaded;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Pressed:&nbsp;Boolean&nbsp;read&nbsp;FPressed;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnEditButtonClick:&nbsp;TNotifyEvent&nbsp;read&nbsp;FOnEditButtonClick<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;write&nbsp;FOnEditButtonClick;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnGetPickListitems:&nbsp;TOnGetPickListItems&nbsp;read&nbsp;FOnGetPickListitems<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;write&nbsp;FOnGetPickListitems;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;procedure&nbsp;Register;<br><br>implementation<br><br>uses&nbsp;Math,&nbsp;Consts,&nbsp;RTLConsts,&nbsp;Themes;<br><br>type<br>&nbsp;&nbsp;PIntArray&nbsp;=&nbsp;^TIntArray;<br>&nbsp;&nbsp;TIntArray&nbsp;=&nbsp;array[0..MaxCustomExtents]&nbsp;of&nbsp;Integer;<br><br><br>//&nbsp;**********************************************************<br>procedure&nbsp;FmtMoney(var&nbsp;Str:&nbsp;string);<br>var<br>&nbsp;&nbsp;F:&nbsp;double;<br>begin<br>&nbsp;&nbsp;if&nbsp;Length(Trim(Str))=0&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;Exit;<br>&nbsp;&nbsp;try<br>&nbsp;&nbsp;&nbsp;&nbsp;F:=StrToFloatdef(Str,0);<br>&nbsp;&nbsp;&nbsp;&nbsp;Str:=Format('%16.2f',&nbsp;[F]);<br>&nbsp;&nbsp;except<br>&nbsp;&nbsp;&nbsp;&nbsp;Str:='0.00';<br>&nbsp;&nbsp;end;<br>end;<br><br><br>function&nbsp;GetBitPos(R:&nbsp;TRect;&nbsp;iBit,&nbsp;iInterval:&nbsp;integer;&nbsp;var&nbsp;XPos:&nbsp;integer):&nbsp;Boolean;<br>begin<br>&nbsp;&nbsp;if&nbsp;iBit&nbsp;in&nbsp;FractionBits&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;XPos:=R.Right-iInterval*(Fraction2Bit-iBit+1)<br>&nbsp;&nbsp;else&nbsp;if&nbsp;iBit&nbsp;in&nbsp;IntegerBits&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;XPos:=R.Right-iInterval*(IntegerBit-iBit+3)<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;XPos:=R.Left;<br><br>&nbsp;&nbsp;Result:=XPos&gt;R.Left;<br>end;<br><br>function&nbsp;GetBitPosComma(R:&nbsp;TRect;&nbsp;iBit,&nbsp;iInterval:&nbsp;integer;&nbsp;var&nbsp;XPos:&nbsp;integer):&nbsp;Boolean;<br>begin<br>&nbsp;&nbsp;if&nbsp;(iBit&nbsp;in&nbsp;FractionBits)or(iBit=SeperatorBit)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;XPos:=R.Right-iInterval*(Fraction2Bit-iBit+1)<br>&nbsp;&nbsp;else&nbsp;if&nbsp;iBit&nbsp;in&nbsp;IntegerBits&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;XPos:=R.Right-iInterval*(IntegerBit-iBit+4)-+((IntegerBit-iBit)div&nbsp;3)*(iInterval-BorderIndent)<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;XPos:=R.Left;<br><br>&nbsp;&nbsp;Result:=XPos&gt;R.Left;<br>end;<br><br>procedure&nbsp;DrawMoneyCell(Text:&nbsp;string;&nbsp;aCanvas:&nbsp;TCanvas;&nbsp;iInterval:&nbsp;integer;&nbsp;R:&nbsp;TRect);<br>var<br>&nbsp;&nbsp;iBit,&nbsp;iLen,&nbsp;XPos:&nbsp;integer;<br>&nbsp;&nbsp;rc:&nbsp;TRect;<br>&nbsp;&nbsp;Str:&nbsp;array[0..1]&nbsp;of&nbsp;Char;<br>&nbsp;&nbsp;tmpColor:&nbsp;TColor;<br>begin<br>&nbsp;&nbsp;iLen:=Length(Text);<br>&nbsp;&nbsp;if&nbsp;(Length(Trim(Text))&gt;0)and((StrToFloat(Text)&lt;0)or(StrToFloat(Text)=0)and(StrScan(PChar(Text),<br>&nbsp;&nbsp;&nbsp;&nbsp;'-')&lt;&gt;nil))&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;tmpColor:=aCanvas.Font.Color;<br>&nbsp;&nbsp;&nbsp;&nbsp;aCanvas.Font.Color:=clRed;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;Str[1]:=#0;<br>&nbsp;&nbsp;rc:=R;<br>&nbsp;&nbsp;with&nbsp;aCanvas&nbsp;do<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;iBit:=Fraction2Bit&nbsp;downto&nbsp;1&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;iLen-Fraction2Bit+iBit&lt;=0&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;GetBitPos(R,&nbsp;iBit,&nbsp;iInterval,&nbsp;XPos)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rc.Left:=XPos+2;&nbsp;//&nbsp;2&nbsp;is&nbsp;a&nbsp;experiance&nbsp;data&nbsp;to&nbsp;locate&nbsp;the&nbsp;digit&nbsp;just&nbsp;in&nbsp;the&nbsp;center<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rc.Right:=XPos+iInterval;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Str[0]:=Text[iLen-Fraction2Bit+iBit];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(Str[0]&lt;&gt;'-')or(StrToFloat(Text)=0)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawText(Handle,&nbsp;@Str,&nbsp;1,&nbsp;rc,&nbsp;DT_SINGLELINE&nbsp;or&nbsp;DT_VCENTER&nbsp;or&nbsp;DT_CENTER);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;if&nbsp;(Length(Trim(Text))&gt;0)and((StrToFloat(Text)&lt;0)or(StrToFloat(Text)=0)and(StrScan(PChar(Text),<br>&nbsp;&nbsp;&nbsp;&nbsp;'-')&lt;&gt;nil))&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;aCanvas.Font.Color:=tmpColor;<br>end;<br><br>procedure&nbsp;DrawMoneyCellComma(Text:&nbsp;string;&nbsp;aCanvas:&nbsp;TCanvas;&nbsp;iInterval:&nbsp;integer;&nbsp;R:&nbsp;TRect);<br>var<br>&nbsp;&nbsp;iBit,&nbsp;iLen,&nbsp;XPos:&nbsp;integer;<br>&nbsp;&nbsp;rc:&nbsp;TRect;<br>&nbsp;&nbsp;Str:&nbsp;array[0..1]&nbsp;of&nbsp;Char;<br>&nbsp;&nbsp;tmpColor:&nbsp;TColor;<br>begin<br>&nbsp;&nbsp;iLen:=Length(Text);<br>&nbsp;&nbsp;if&nbsp;(Length(Trim(Text))&gt;0)and((StrToFloat(Text)&lt;0)or(StrToFloat(Text)=0)and(StrScan(PChar(Text),<br>&nbsp;&nbsp;&nbsp;&nbsp;'-')&lt;&gt;nil))&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;tmpColor:=aCanvas.Font.Color;<br>&nbsp;&nbsp;&nbsp;&nbsp;aCanvas.Font.Color:=clRed;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;Str[1]:=#0;<br>&nbsp;&nbsp;rc:=R;<br>&nbsp;&nbsp;with&nbsp;aCanvas&nbsp;do<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;iBit:=Fraction2Bit&nbsp;downto&nbsp;1&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;iLen-Fraction2Bit+iBit&lt;=0&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;GetBitPosComma(R,&nbsp;iBit,&nbsp;iInterval,&nbsp;XPos)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rc.Left:=XPos;&nbsp;//&nbsp;+&nbsp;2; //&nbsp;2&nbsp;is&nbsp;a&nbsp;experiance&nbsp;data&nbsp;to&nbsp;locate&nbsp;the&nbsp;digit&nbsp;just&nbsp;in&nbsp;the&nbsp;center<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rc.Right:=XPos+iInterval;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Str[0]:=Text[iLen-Fraction2Bit+iBit];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(Str[0]&lt;&gt;'-')or(StrToFloat(Text)=0)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawText(Handle,&nbsp;@Str,&nbsp;1,&nbsp;rc,&nbsp;DT_SINGLELINE&nbsp;or&nbsp;DT_VCENTER&nbsp;or&nbsp;DT_CENTER);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(Str[0]&lt;&gt;'&nbsp;')and(iBit&nbsp;in&nbsp;ThousandBits)and(iBit&lt;&gt;IntegerBit)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rc.Left:=rc.Right;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rc.Right:=rc.Right+iInterval-BorderIndent;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Str[0]:=',';<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawText(Handle,&nbsp;@Str,&nbsp;1,&nbsp;rc,&nbsp;DT_SINGLELINE&nbsp;or&nbsp;DT_VCENTER&nbsp;or&nbsp;DT_CENTER);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;if&nbsp;(Length(Trim(Text))&gt;0)and((StrToFloat(Text)&lt;0)or(StrToFloat(Text)=0)and(StrScan(PChar(Text),<br>&nbsp;&nbsp;&nbsp;&nbsp;'-')&lt;&gt;nil))&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;aCanvas.Font.Color:=tmpColor;<br>end;<br><br>procedure&nbsp;DrawDigitLine(aCanvas:&nbsp;TCanvas;&nbsp;R:&nbsp;TRect;&nbsp;iInterval:&nbsp;integer;&nbsp;LineColors:&nbsp;TLineColors);<br>var<br>&nbsp;&nbsp;iBit,&nbsp;XPos:&nbsp;integer;<br>&nbsp;&nbsp;tmpColor:&nbsp;TColor;<br>begin<br>&nbsp;&nbsp;with&nbsp;aCanvas&nbsp;do<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;tmpColor:=Pen.Color;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;iBit:=Fraction1Bit&nbsp;downto&nbsp;1&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;iBit=SeperatorBit&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;continue;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;GetBitPos(R,&nbsp;iBit,&nbsp;iInterval,&nbsp;XPos)and(R.Left+iInterval&gt;0)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;iBit=IntegerBit&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pen.Color:=LineColors.SeperatorLineColor<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;iBit&nbsp;in&nbsp;ThousandBits&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pen.Color:=LineColors.ThousandLineColor<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pen.Color:=LineColors.DefaultLineColor;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MoveTo(XPos+iInterval,&nbsp;R.Top);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LineTo(XPos+iInterval,&nbsp;R.Bottom);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;Pen.Color:=tmpColor;<br>&nbsp;&nbsp;end;<br>end;<br><br><br><br>procedure&nbsp;InvalidOp(const&nbsp;id:&nbsp;string);<br>begin<br>&nbsp;&nbsp;raise&nbsp;EInvalidGridOperation.Create(id);<br>end;<br><br>function&nbsp;GridRect(Coord1,&nbsp;Coord2:&nbsp;TGridCoord):&nbsp;TGridRect;<br>begin<br>&nbsp;&nbsp;with&nbsp;Result&nbsp;do<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Left&nbsp;:=&nbsp;Coord2.X;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Coord1.X&nbsp;&lt;&nbsp;Coord2.X&nbsp;then&nbsp;Left&nbsp;:=&nbsp;Coord1.X;<br>&nbsp;&nbsp;&nbsp;&nbsp;Right&nbsp;:=&nbsp;Coord1.X;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Coord1.X&nbsp;&lt;&nbsp;Coord2.X&nbsp;then&nbsp;Right&nbsp;:=&nbsp;Coord2.X;<br>&nbsp;&nbsp;&nbsp;&nbsp;Top&nbsp;:=&nbsp;Coord2.Y;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Coord1.Y&nbsp;&lt;&nbsp;Coord2.Y&nbsp;then&nbsp;Top&nbsp;:=&nbsp;Coord1.Y;<br>&nbsp;&nbsp;&nbsp;&nbsp;Bottom&nbsp;:=&nbsp;Coord1.Y;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Coord1.Y&nbsp;&lt;&nbsp;Coord2.Y&nbsp;then&nbsp;Bottom&nbsp;:=&nbsp;Coord2.Y;<br>&nbsp;&nbsp;end;<br>end;<br><br>function&nbsp;PointInGridRect(Col,&nbsp;Row:&nbsp;Longint;&nbsp;const&nbsp;Rect:&nbsp;TGridRect):&nbsp;Boolean;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;(Col&nbsp;&gt;=&nbsp;Rect.Left)&nbsp;and&nbsp;(Col&nbsp;&lt;=&nbsp;Rect.Right)&nbsp;and&nbsp;(Row&nbsp;&gt;=&nbsp;Rect.Top)<br>&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;(Row&nbsp;&lt;=&nbsp;Rect.Bottom);<br>end;<br><br>type<br>&nbsp;&nbsp;TXorRects&nbsp;=&nbsp;array[0..3]&nbsp;of&nbsp;TRect;<br><br>procedure&nbsp;XorRects(const&nbsp;R1,&nbsp;R2:&nbsp;TRect;&nbsp;var&nbsp;XorRects:&nbsp;TXorRects);<br>var<br>&nbsp;&nbsp;Intersect,&nbsp;Union:&nbsp;TRect;<br><br>&nbsp;&nbsp;function&nbsp;PtInRect(X,&nbsp;Y:&nbsp;Integer;&nbsp;const&nbsp;Rect:&nbsp;TRect):&nbsp;Boolean;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;Rect&nbsp;do&nbsp;Result&nbsp;:=&nbsp;(X&nbsp;&gt;=&nbsp;Left)&nbsp;and&nbsp;(X&nbsp;&lt;=&nbsp;Right)&nbsp;and&nbsp;(Y&nbsp;&gt;=&nbsp;Top)&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Y&nbsp;&lt;=&nbsp;Bottom);<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;function&nbsp;Includes(const&nbsp;P1:&nbsp;TPoint;&nbsp;var&nbsp;P2:&nbsp;TPoint):&nbsp;Boolean;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;P1&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;PtInRect(X,&nbsp;Y,&nbsp;R1)&nbsp;or&nbsp;PtInRect(X,&nbsp;Y,&nbsp;R2);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Result&nbsp;then&nbsp;P2&nbsp;:=&nbsp;P1;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;function&nbsp;Build(var&nbsp;R:&nbsp;TRect;&nbsp;const&nbsp;P1,&nbsp;P2,&nbsp;P3:&nbsp;TPoint):&nbsp;Boolean;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Build&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;R&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Includes(P1,&nbsp;TopLeft)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;Includes(P3,&nbsp;BottomRight)&nbsp;then&nbsp;BottomRight&nbsp;:=&nbsp;P2;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;Includes(P2,&nbsp;TopLeft)&nbsp;then&nbsp;BottomRight&nbsp;:=&nbsp;P3<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;Build&nbsp;:=&nbsp;False;<br>&nbsp;&nbsp;end;<br><br>begin<br>&nbsp;&nbsp;FillChar(XorRects,&nbsp;SizeOf(XorRects),&nbsp;0);<br>&nbsp;&nbsp;if&nbsp;not&nbsp;Bool(IntersectRect(Intersect,&nbsp;R1,&nbsp;R2))&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Don't&nbsp;intersect&nbsp;so&nbsp;its&nbsp;simple&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;XorRects[0]&nbsp;:=&nbsp;R1;<br>&nbsp;&nbsp;&nbsp;&nbsp;XorRects[1]&nbsp;:=&nbsp;R2;<br>&nbsp;&nbsp;end<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;UnionRect(Union,&nbsp;R1,&nbsp;R2);<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Build(XorRects[0],<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Point(Union.Left,&nbsp;Union.Top),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Point(Union.Left,&nbsp;Intersect.Top),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Point(Union.Left,&nbsp;Intersect.Bottom))&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;XorRects[0].Right&nbsp;:=&nbsp;Intersect.Left;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Build(XorRects[1],<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Point(Intersect.Left,&nbsp;Union.Top),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Point(Intersect.Right,&nbsp;Union.Top),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Point(Union.Right,&nbsp;Union.Top))&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;XorRects[1].Bottom&nbsp;:=&nbsp;Intersect.Top;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Build(XorRects[2],<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Point(Union.Right,&nbsp;Intersect.Top),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Point(Union.Right,&nbsp;Intersect.Bottom),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Point(Union.Right,&nbsp;Union.Bottom))&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;XorRects[2].Left&nbsp;:=&nbsp;Intersect.Right;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Build(XorRects[3],<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Point(Union.Left,&nbsp;Union.Bottom),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Point(Intersect.Left,&nbsp;Union.Bottom),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Point(Intersect.Right,&nbsp;Union.Bottom))&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;XorRects[3].Top&nbsp;:=&nbsp;Intersect.Bottom;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;ModifyExtents(var&nbsp;Extents:&nbsp;Pointer;&nbsp;Index,&nbsp;Amount:&nbsp;Longint;<br>&nbsp;&nbsp;Default:&nbsp;Integer);<br>var<br>&nbsp;&nbsp;LongSize,&nbsp;OldSize:&nbsp;LongInt;<br>&nbsp;&nbsp;NewSize:&nbsp;Integer;<br>&nbsp;&nbsp;I:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;if&nbsp;Amount&nbsp;&lt;&gt;&nbsp;0&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;Assigned(Extents)&nbsp;then&nbsp;OldSize&nbsp;:=&nbsp;0<br>&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;OldSize&nbsp;:=&nbsp;PIntArray(Extents)^[0];<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(Index&nbsp;&lt;&nbsp;0)&nbsp;or&nbsp;(OldSize&nbsp;&lt;&nbsp;Index)&nbsp;then&nbsp;InvalidOp(SIndexOutOfRange);<br>&nbsp;&nbsp;&nbsp;&nbsp;LongSize&nbsp;:=&nbsp;OldSize&nbsp;+&nbsp;Amount;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;LongSize&nbsp;&lt;&nbsp;0&nbsp;then&nbsp;InvalidOp(STooManyDeleted)<br>&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;LongSize&nbsp;&gt;=&nbsp;MaxListSize&nbsp;-&nbsp;1&nbsp;then&nbsp;InvalidOp(SGridTooLarge);<br>&nbsp;&nbsp;&nbsp;&nbsp;NewSize&nbsp;:=&nbsp;Cardinal(LongSize);<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;NewSize&nbsp;&gt;&nbsp;0&nbsp;then&nbsp;Inc(NewSize);<br>&nbsp;&nbsp;&nbsp;&nbsp;ReallocMem(Extents,&nbsp;NewSize&nbsp;*&nbsp;SizeOf(Integer));<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Assigned(Extents)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I&nbsp;:=&nbsp;Index&nbsp;+&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;I&nbsp;&lt;&nbsp;NewSize&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PIntArray(Extents)^&nbsp;:=&nbsp;Default;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(I);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PIntArray(Extents)^[0]&nbsp;:=&nbsp;NewSize-1;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;UpdateExtents(var&nbsp;Extents:&nbsp;Pointer;&nbsp;NewSize:&nbsp;Longint;<br>&nbsp;&nbsp;Default:&nbsp;Integer);<br>var<br>&nbsp;&nbsp;OldSize:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;OldSize&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;if&nbsp;Assigned(Extents)&nbsp;then&nbsp;OldSize&nbsp;:=&nbsp;PIntArray(Extents)^[0];<br>&nbsp;&nbsp;ModifyExtents(Extents,&nbsp;OldSize,&nbsp;NewSize&nbsp;-&nbsp;OldSize,&nbsp;Default);<br>end;<br><br>procedure&nbsp;MoveExtent(var&nbsp;Extents:&nbsp;Pointer;&nbsp;FromIndex,&nbsp;ToIndex:&nbsp;Longint);<br>var<br>&nbsp;&nbsp;Extent:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;if&nbsp;Assigned(Extents)&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Extent&nbsp;:=&nbsp;PIntArray(Extents)^[FromIndex];<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;FromIndex&nbsp;&lt;&nbsp;ToIndex&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Move(PIntArray(Extents)^[FromIndex&nbsp;+&nbsp;1],&nbsp;PIntArray(Extents)^[FromIndex],<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(ToIndex&nbsp;-&nbsp;FromIndex)&nbsp;*&nbsp;SizeOf(Integer))<br>&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;FromIndex&nbsp;&gt;&nbsp;ToIndex&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Move(PIntArray(Extents)^[ToIndex],&nbsp;PIntArray(Extents)^[ToIndex&nbsp;+&nbsp;1],<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(FromIndex&nbsp;-&nbsp;ToIndex)&nbsp;*&nbsp;SizeOf(Integer));<br>&nbsp;&nbsp;&nbsp;&nbsp;PIntArray(Extents)^[ToIndex]&nbsp;:=&nbsp;Extent;<br>&nbsp;&nbsp;end;<br>end;<br><br>function&nbsp;CompareExtents(E1,&nbsp;E2:&nbsp;Pointer):&nbsp;Boolean;<br>var<br>&nbsp;&nbsp;I:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;False;<br>&nbsp;&nbsp;if&nbsp;E1&nbsp;&lt;&gt;&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;E2&nbsp;&lt;&gt;&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;I&nbsp;:=&nbsp;0&nbsp;to&nbsp;PIntArray(E1)^[0]&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;PIntArray(E1)^&nbsp;&lt;&gt;&nbsp;PIntArray(E2)^&nbsp;then&nbsp;Exit;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;end<br>&nbsp;&nbsp;else&nbsp;Result&nbsp;:=&nbsp;E2&nbsp;=&nbsp;nil;<br>end;<br><br>{&nbsp;Private.&nbsp;LongMulDiv&nbsp;multiplys&nbsp;the&nbsp;first&nbsp;two&nbsp;arguments&nbsp;and&nbsp;then<br>&nbsp;&nbsp;divides&nbsp;by&nbsp;the&nbsp;third.&nbsp;&nbsp;This&nbsp;is&nbsp;used&nbsp;so&nbsp;that&nbsp;real&nbsp;number<br>&nbsp;&nbsp;(floating&nbsp;point)&nbsp;arithmetic&nbsp;is&nbsp;not&nbsp;necessary.&nbsp;&nbsp;This&nbsp;routine&nbsp;saves<br>&nbsp;&nbsp;the&nbsp;possible&nbsp;64-bit&nbsp;value&nbsp;in&nbsp;a&nbsp;temp&nbsp;before&nbsp;doing&nbsp;the&nbsp;divide.&nbsp;&nbsp;Does<br>&nbsp;&nbsp;not&nbsp;do&nbsp;error&nbsp;checking&nbsp;like&nbsp;divide&nbsp;by&nbsp;zero.&nbsp;&nbsp;Also&nbsp;assumes&nbsp;that&nbsp;the<br>&nbsp;&nbsp;result&nbsp;is&nbsp;in&nbsp;the&nbsp;32-bit&nbsp;range&nbsp;(Actually&nbsp;31-bit,&nbsp;since&nbsp;this&nbsp;algorithm<br>&nbsp;&nbsp;is&nbsp;for&nbsp;unsigned).&nbsp;}<br><br>function&nbsp;LongMulDiv(Mult1,&nbsp;Mult2,&nbsp;Div1:&nbsp;Longint):&nbsp;Longint;&nbsp;stdcall;<br>{$IFDEF&nbsp;LINUX}<br>&nbsp;&nbsp;external&nbsp;'libwine.borland.so'&nbsp;name&nbsp;'MulDiv';<br>{$ENDIF}<br>{$IFDEF&nbsp;MSWINDOWS}<br>&nbsp;&nbsp;external&nbsp;'kernel32.dll'&nbsp;name&nbsp;'MulDiv';<br>{$ENDIF}<br><br>procedure&nbsp;KillMessage(Wnd:&nbsp;HWnd;&nbsp;Msg:&nbsp;Integer);<br>//&nbsp;Delete&nbsp;the&nbsp;requested&nbsp;message&nbsp;from&nbsp;the&nbsp;queue,&nbsp;but&nbsp;throw&nbsp;back<br>//&nbsp;any&nbsp;WM_QUIT&nbsp;msgs&nbsp;that&nbsp;PeekMessage&nbsp;may&nbsp;also&nbsp;return<br>var<br>&nbsp;&nbsp;M:&nbsp;TMsg;<br>begin<br>&nbsp;&nbsp;M.Message&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;if&nbsp;PeekMessage(M,&nbsp;Wnd,&nbsp;Msg,&nbsp;Msg,&nbsp;pm_Remove)&nbsp;and&nbsp;(M.Message&nbsp;=&nbsp;WM_QUIT)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;PostQuitMessage(M.wparam);<br>end;<br><br>type<br>&nbsp;&nbsp;TSelection&nbsp;=&nbsp;record<br>&nbsp;&nbsp;&nbsp;&nbsp;StartPos,&nbsp;EndPos:&nbsp;Integer;<br>&nbsp;&nbsp;end;<br><br>constructor&nbsp;TInplaceEdit.Create(AOwner:&nbsp;TComponent);<br>begin<br>&nbsp;&nbsp;inherited&nbsp;Create(AOwner);<br>&nbsp;&nbsp;ParentCtl3D&nbsp;:=&nbsp;False;<br>&nbsp;&nbsp;Ctl3D&nbsp;:=&nbsp;False;<br>&nbsp;&nbsp;TabStop&nbsp;:=&nbsp;False;<br>&nbsp;&nbsp;BorderStyle&nbsp;:=&nbsp;bsNone;<br>&nbsp;&nbsp;DoubleBuffered&nbsp;:=&nbsp;False;<br>end;<br><br>procedure&nbsp;TInplaceEdit.CreateParams(var&nbsp;Params:&nbsp;TCreateParams);<br>begin<br>&nbsp;&nbsp;inherited&nbsp;CreateParams(Params);<br>&nbsp;&nbsp;Params.Style&nbsp;:=&nbsp;Params.Style&nbsp;or&nbsp;ES_MULTILINE;<br>end;<br><br>procedure&nbsp;TInplaceEdit.SetGrid(Value:&nbsp;TCustomPZGrid);<br>begin<br>&nbsp;&nbsp;FGrid&nbsp;:=&nbsp;Value;<br>end;<br><br>procedure&nbsp;TInplaceEdit.CMShowingChanged(var&nbsp;Message:&nbsp;TMessage);<br>begin<br>&nbsp;&nbsp;{&nbsp;Ignore&nbsp;showing&nbsp;using&nbsp;the&nbsp;Visible&nbsp;property&nbsp;}<br>end;<br><br>procedure&nbsp;TInplaceEdit.WMGetDlgCode(var&nbsp;Message:&nbsp;TWMGetDlgCode);<br>begin<br>&nbsp;&nbsp;inherited;<br>&nbsp;&nbsp;if&nbsp;goTabs&nbsp;in&nbsp;Grid.Options&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;Message.Result&nbsp;:=&nbsp;Message.Result&nbsp;or&nbsp;DLGC_WANTTAB;<br>end;<br><br>procedure&nbsp;TInplaceEdit.WMPaste(var&nbsp;Message);<br>begin<br>&nbsp;&nbsp;if&nbsp;not&nbsp;EditCanModify&nbsp;then&nbsp;Exit;<br>&nbsp;&nbsp;inherited<br>end;<br><br>procedure&nbsp;TInplaceEdit.WMClear(var&nbsp;Message);<br>begin<br>&nbsp;&nbsp;if&nbsp;not&nbsp;EditCanModify&nbsp;then&nbsp;Exit;<br>&nbsp;&nbsp;inherited;<br>end;<br><br>procedure&nbsp;TInplaceEdit.WMCut(var&nbsp;Message);<br>begin<br>&nbsp;&nbsp;if&nbsp;not&nbsp;EditCanModify&nbsp;then&nbsp;Exit;<br>&nbsp;&nbsp;inherited;<br>end;<br><br>procedure&nbsp;TInplaceEdit.DblClick;<br>begin<br>&nbsp;&nbsp;Grid.DblClick;<br>end;<br><br>function&nbsp;TInplaceEdit.DoMouseWheel(Shift:&nbsp;TShiftState;&nbsp;WheelDelta:&nbsp;Integer;<br>&nbsp;&nbsp;MousePos:&nbsp;TPoint):&nbsp;Boolean;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;Grid.DoMouseWheel(Shift,&nbsp;WheelDelta,&nbsp;MousePos);<br>end;<br><br>function&nbsp;TInplaceEdit.EditCanModify:&nbsp;Boolean;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;Grid.CanEditModify;<br>end;<br><br>procedure&nbsp;TInplaceEdit.KeyDown(var&nbsp;Key:&nbsp;Word;&nbsp;Shift:&nbsp;TShiftState);<br><br>&nbsp;&nbsp;procedure&nbsp;SendToParent;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Grid.KeyDown(Key,&nbsp;Shift);<br>&nbsp;&nbsp;&nbsp;&nbsp;Key&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;procedure&nbsp;ParentEvent;<br>&nbsp;&nbsp;var<br>&nbsp;&nbsp;&nbsp;&nbsp;GridKeyDown:&nbsp;TKeyEvent;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;GridKeyDown&nbsp;:=&nbsp;Grid.OnKeyDown;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Assigned(GridKeyDown)&nbsp;then&nbsp;GridKeyDown(Grid,&nbsp;Key,&nbsp;Shift);<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;function&nbsp;ForwardMovement:&nbsp;Boolean;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;goAlwaysShowEditor&nbsp;in&nbsp;Grid.Options;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;function&nbsp;Ctrl:&nbsp;Boolean;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;ssCtrl&nbsp;in&nbsp;Shift;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;function&nbsp;Selection:&nbsp;TSelection;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;SendMessage(Handle,&nbsp;EM_GETSEL,&nbsp;Longint(@Result.StartPos),&nbsp;Longint(@Result.EndPos));<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;function&nbsp;CaretPos:&nbsp;Integer;<br>&nbsp;&nbsp;var<br>&nbsp;&nbsp;&nbsp;&nbsp;P:&nbsp;TPoint;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Windows.GetCaretPos(P);<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;SendMessage(Handle,&nbsp;EM_CHARFROMPOS,&nbsp;0,&nbsp;MakeLong(P.X,&nbsp;P.Y));<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;function&nbsp;RightSide:&nbsp;Boolean;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;Selection&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;(CaretPos&nbsp;=&nbsp;GetTextLen)&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;((StartPos&nbsp;=&nbsp;0)&nbsp;or&nbsp;(EndPos&nbsp;=&nbsp;StartPos))&nbsp;and&nbsp;(EndPos&nbsp;=&nbsp;GetTextLen);<br>&nbsp;&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;function&nbsp;LeftSide:&nbsp;Boolean;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;Selection&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;(CaretPos&nbsp;=&nbsp;0)&nbsp;and&nbsp;(StartPos&nbsp;=&nbsp;0)&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;((EndPos&nbsp;=&nbsp;0)&nbsp;or&nbsp;(EndPos&nbsp;=&nbsp;GetTextLen));<br>&nbsp;&nbsp;end;<br><br>begin<br>&nbsp;&nbsp;case&nbsp;Key&nbsp;of<br>&nbsp;&nbsp;&nbsp;&nbsp;VK_UP,&nbsp;VK_DOWN,&nbsp;VK_PRIOR,&nbsp;VK_NEXT,&nbsp;VK_ESCAPE:&nbsp;SendToParent;<br>&nbsp;&nbsp;&nbsp;&nbsp;VK_INSERT:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Shift&nbsp;=&nbsp;[]&nbsp;then&nbsp;SendToParent<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;(Shift&nbsp;=&nbsp;[ssShift])&nbsp;and&nbsp;not&nbsp;Grid.CanEditModify&nbsp;then&nbsp;Key&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;&nbsp;&nbsp;VK_LEFT:&nbsp;if&nbsp;ForwardMovement&nbsp;and&nbsp;(Ctrl&nbsp;or&nbsp;LeftSide)&nbsp;then&nbsp;SendToParent;<br>&nbsp;&nbsp;&nbsp;&nbsp;VK_RIGHT:&nbsp;if&nbsp;ForwardMovement&nbsp;and&nbsp;(Ctrl&nbsp;or&nbsp;RightSide)&nbsp;then&nbsp;SendToParent;<br>&nbsp;&nbsp;&nbsp;&nbsp;VK_HOME:&nbsp;if&nbsp;ForwardMovement&nbsp;and&nbsp;(Ctrl&nbsp;or&nbsp;LeftSide)&nbsp;then&nbsp;SendToParent;<br>&nbsp;&nbsp;&nbsp;&nbsp;VK_END:&nbsp;if&nbsp;ForwardMovement&nbsp;and&nbsp;(Ctrl&nbsp;or&nbsp;RightSide)&nbsp;then&nbsp;SendToParent;<br>&nbsp;&nbsp;&nbsp;&nbsp;VK_RETURN:&nbsp;if&nbsp;ForwardMovement&nbsp;and&nbsp;(Ctrl&nbsp;or&nbsp;RightSide)&nbsp;then&nbsp;SendToParent;<br>&nbsp;&nbsp;&nbsp;&nbsp;VK_F2:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ParentEvent;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Key&nbsp;=&nbsp;VK_F2&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deselect;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;VK_TAB:&nbsp;if&nbsp;not&nbsp;(ssAlt&nbsp;in&nbsp;Shift)&nbsp;then&nbsp;SendToParent;<br>&nbsp;&nbsp;&nbsp;&nbsp;VK_DELETE:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Ctrl&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SendToParent<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;Grid.CanEditModify&nbsp;then&nbsp;Key&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;if&nbsp;Key&nbsp;&lt;&gt;&nbsp;0&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;ParentEvent;<br>&nbsp;&nbsp;&nbsp;&nbsp;inherited&nbsp;KeyDown(Key,&nbsp;Shift);<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TInplaceEdit.KeyPress(var&nbsp;Key:&nbsp;Char);<br>var<br>&nbsp;&nbsp;Selection:&nbsp;TSelection;<br>begin<br>&nbsp;&nbsp;Grid.KeyPress(Key);<br>&nbsp;&nbsp;if&nbsp;(Key&nbsp;in&nbsp;[#32..#255])&nbsp;and&nbsp;not&nbsp;Grid.CanEditAcceptKey(Key)&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Key&nbsp;:=&nbsp;#0;<br>&nbsp;&nbsp;&nbsp;&nbsp;MessageBeep(0);<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;IF&nbsp;(Grid.Col=2)&nbsp;OR&nbsp;&nbsp;(Grid.Col=3)&nbsp;Then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;if&nbsp;&nbsp;not&nbsp;(Key&nbsp;in&nbsp;['0'..'9','.','-',#8,#9,#27,#13])&nbsp;then<br>&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Key&nbsp;:=&nbsp;#0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MessageBeep(0);<br>&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;case&nbsp;Key&nbsp;of<br>&nbsp;&nbsp;&nbsp;&nbsp;#9,&nbsp;#27:&nbsp;Key&nbsp;:=&nbsp;#0;<br>&nbsp;&nbsp;&nbsp;&nbsp;#13:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SendMessage(Handle,&nbsp;EM_GETSEL,&nbsp;Longint(@Selection.StartPos),&nbsp;Longint(@Selection.EndPos));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(Selection.StartPos&nbsp;=&nbsp;0)&nbsp;and&nbsp;(Selection.EndPos&nbsp;=&nbsp;GetTextLen)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Deselect&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SelectAll;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Key&nbsp;:=&nbsp;#0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;^H,&nbsp;^V,&nbsp;^X,&nbsp;#32..#255:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;Grid.CanEditModify&nbsp;then&nbsp;Key&nbsp;:=&nbsp;#0;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;if&nbsp;Key&nbsp;&lt;&gt;&nbsp;#0&nbsp;then&nbsp;inherited&nbsp;KeyPress(Key);<br>end;<br><br>procedure&nbsp;TInplaceEdit.KeyUp(var&nbsp;Key:&nbsp;Word;&nbsp;Shift:&nbsp;TShiftState);<br>begin<br>&nbsp;&nbsp;Grid.KeyUp(Key,&nbsp;Shift);<br>end;<br><br>procedure&nbsp;TInplaceEdit.WndProc(var&nbsp;Message:&nbsp;TMessage);<br>begin<br>&nbsp;&nbsp;case&nbsp;Message.Msg&nbsp;of<br>&nbsp;&nbsp;&nbsp;&nbsp;WM_SETFOCUS:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(GetParentForm(Self)&nbsp;=&nbsp;nil)&nbsp;or&nbsp;GetParentForm(Self).SetFocusedControl(Grid)&nbsp;then&nbsp;Dispatch(Message);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;WM_LBUTTONDOWN:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;UINT(GetMessageTime&nbsp;-&nbsp;FClickTime)&nbsp;&lt;&nbsp;GetDoubleClickTime&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Message.Msg&nbsp;:=&nbsp;WM_LBUTTONDBLCLK;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FClickTime&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;inherited&nbsp;WndProc(Message);<br>end;<br><br>procedure&nbsp;TInplaceEdit.Deselect;<br>begin<br>&nbsp;&nbsp;SendMessage(Handle,&nbsp;EM_SETSEL,&nbsp;$7FFFFFFF,&nbsp;Longint($FFFFFFFF));<br>end;<br><br>procedure&nbsp;TInplaceEdit.Invalidate;<br>var<br>&nbsp;&nbsp;Cur:&nbsp;TRect;<br>begin<br>&nbsp;&nbsp;ValidateRect(Handle,&nbsp;nil);<br>&nbsp;&nbsp;InvalidateRect(Handle,&nbsp;nil,&nbsp;True);<br>&nbsp;&nbsp;Windows.GetClientRect(Handle,&nbsp;Cur);<br>&nbsp;&nbsp;MapWindowPoints(Handle,&nbsp;Grid.Handle,&nbsp;Cur,&nbsp;2);<br>&nbsp;&nbsp;ValidateRect(Grid.Handle,&nbsp;@Cur);<br>&nbsp;&nbsp;InvalidateRect(Grid.Handle,&nbsp;@Cur,&nbsp;False);<br>end;<br><br>procedure&nbsp;TInplaceEdit.Hide;<br>begin<br>&nbsp;&nbsp;if&nbsp;HandleAllocated&nbsp;and&nbsp;IsWindowVisible(Handle)&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Invalidate;<br>&nbsp;&nbsp;&nbsp;&nbsp;SetWindowPos(Handle,&nbsp;0,&nbsp;0,&nbsp;0,&nbsp;0,&nbsp;0,&nbsp;SWP_HIDEWINDOW&nbsp;or&nbsp;SWP_NOZORDER&nbsp;or<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SWP_NOREDRAW);<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Focused&nbsp;then&nbsp;Windows.SetFocus(Grid.Handle);<br>&nbsp;&nbsp;end;<br>end;<br><br>function&nbsp;TInplaceEdit.PosEqual(const&nbsp;Rect:&nbsp;TRect):&nbsp;Boolean;<br>var<br>&nbsp;&nbsp;Cur:&nbsp;TRect;<br>begin<br>&nbsp;&nbsp;GetWindowRect(Handle,&nbsp;Cur);<br>&nbsp;&nbsp;MapWindowPoints(HWND_DESKTOP,&nbsp;Grid.Handle,&nbsp;Cur,&nbsp;2);<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;EqualRect(Rect,&nbsp;Cur);<br>end;<br><br>procedure&nbsp;TInplaceEdit.InternalMove(const&nbsp;Loc:&nbsp;TRect;&nbsp;Redraw:&nbsp;Boolean);<br>begin<br>&nbsp;&nbsp;if&nbsp;IsRectEmpty(Loc)&nbsp;then&nbsp;Hide<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;CreateHandle;<br>&nbsp;&nbsp;&nbsp;&nbsp;Redraw&nbsp;:=&nbsp;Redraw&nbsp;or&nbsp;not&nbsp;IsWindowVisible(Handle);<br>&nbsp;&nbsp;&nbsp;&nbsp;Invalidate;<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;Loc&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SetWindowPos(Handle,&nbsp;HWND_TOP,&nbsp;Left,&nbsp;Top,&nbsp;Right&nbsp;-&nbsp;Left,&nbsp;Bottom&nbsp;-&nbsp;Top,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SWP_SHOWWINDOW&nbsp;or&nbsp;SWP_NOREDRAW);<br>&nbsp;&nbsp;&nbsp;&nbsp;BoundsChanged;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Redraw&nbsp;then&nbsp;Invalidate;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Grid.Focused&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Windows.SetFocus(Handle);<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TInplaceEdit.BoundsChanged;<br>var<br>&nbsp;&nbsp;R:&nbsp;TRect;<br>begin<br>&nbsp;&nbsp;R&nbsp;:=&nbsp;Rect(2,&nbsp;2,&nbsp;Width&nbsp;-&nbsp;2,&nbsp;Height);<br>&nbsp;&nbsp;SendMessage(Handle,&nbsp;EM_SETRECTNP,&nbsp;0,&nbsp;LongInt(@R));<br>&nbsp;&nbsp;SendMessage(Handle,&nbsp;EM_SCROLLCARET,&nbsp;0,&nbsp;0);<br>end;<br><br>procedure&nbsp;TInplaceEdit.UpdateLoc(const&nbsp;Loc:&nbsp;TRect);<br>begin<br>&nbsp;&nbsp;InternalMove(Loc,&nbsp;False);<br>end;<br><br>function&nbsp;TInplaceEdit.Visible:&nbsp;Boolean;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;IsWindowVisible(Handle);<br>end;<br><br>procedure&nbsp;TInplaceEdit.Move(const&nbsp;Loc:&nbsp;TRect);<br>begin<br>&nbsp;&nbsp;InternalMove(Loc,&nbsp;True);<br>end;<br><br>procedure&nbsp;TInplaceEdit.SetFocus;<br>begin<br>&nbsp;&nbsp;if&nbsp;IsWindowVisible(Handle)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;Windows.SetFocus(Handle);<br>end;<br><br>procedure&nbsp;TInplaceEdit.UpdateContents;<br>begin<br>&nbsp;&nbsp;Text&nbsp;:=&nbsp;'';<br>&nbsp;&nbsp;EditMask&nbsp;:=&nbsp;Grid.GetEditMask(Grid.Col,&nbsp;Grid.Row);<br>&nbsp;&nbsp;Text&nbsp;:=&nbsp;Grid.GetEditText(Grid.Col,&nbsp;Grid.Row);<br>&nbsp;&nbsp;MaxLength&nbsp;:=&nbsp;Grid.GetEditLimit;<br>end;<br><br>{&nbsp;TCustomPZGrid&nbsp;}<br><br>constructor&nbsp;TCustomPZGrid.Create(AOwner:&nbsp;TComponent);<br>const<br>&nbsp;&nbsp;GridStyle&nbsp;=&nbsp;[csCaptureMouse,&nbsp;csOpaque,&nbsp;csDoubleClicks,&nbsp;csNeedsBorderPaint];<br>begin<br>&nbsp;&nbsp;inherited&nbsp;Create(AOwner);<br>&nbsp;&nbsp;if&nbsp;NewStyleControls&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;ControlStyle&nbsp;:=&nbsp;GridStyle<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;ControlStyle&nbsp;:=&nbsp;GridStyle&nbsp;+&nbsp;[csFramed];<br>&nbsp;&nbsp;FCanEditModify&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;FColCount&nbsp;:=&nbsp;4;<br>&nbsp;&nbsp;FRowCount&nbsp;:=&nbsp;65536;<br>&nbsp;&nbsp;FFixedCols&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;FFixedRows&nbsp;:=&nbsp;1;<br>&nbsp;&nbsp;FGridLineWidth&nbsp;:=&nbsp;1;<br>&nbsp;&nbsp;FShowLineSeparator:=True;<br>&nbsp;&nbsp;FOptions&nbsp;:=&nbsp;[goFixedVertLine,&nbsp;goFixedHorzLine,&nbsp;goVertLine,&nbsp;goHorzLine,<br>&nbsp;&nbsp;&nbsp;&nbsp;goEditing,&nbsp;goTabs,goAlwaysShowEditor,goRangeSelect];<br>&nbsp;&nbsp;DesignOptionsBoost&nbsp;:=&nbsp;[goColSizing,&nbsp;goRowSizing];<br>&nbsp;&nbsp;FFixedColor&nbsp;:=&nbsp;clSkyBlue;<br>&nbsp;&nbsp;FScrollBars&nbsp;:=&nbsp;ssBoth;<br>&nbsp;&nbsp;FBorderStyle&nbsp;:=&nbsp;bsSingle;<br>&nbsp;&nbsp;FDefaultColWidth&nbsp;:=&nbsp;150;<br>&nbsp;&nbsp;FDefaultRowHeight&nbsp;:=&nbsp;35;<br>&nbsp;&nbsp;FDefaultDrawing&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;FSaveCellExtents&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;FEditorMode&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;Color&nbsp;:=&nbsp;clWindow;<br>&nbsp;&nbsp;ParentColor&nbsp;:=&nbsp;False;<br>&nbsp;&nbsp;TabStop&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;FLineColors:=TLineColors.Create;<br>&nbsp;&nbsp;FLineColors.OnChange:=LineColorsChanged;<br>&nbsp;&nbsp;SetBounds(Left,&nbsp;Top,&nbsp;FColCount&nbsp;*&nbsp;FDefaultColWidth,<br>&nbsp;&nbsp;&nbsp;&nbsp;FRowCount&nbsp;*&nbsp;FDefaultRowHeight);<br>&nbsp;&nbsp;Initialize;<br>end;<br><br>destructor&nbsp;TCustomPZGrid.Destroy;<br>begin<br>&nbsp;&nbsp;FInplaceEdit.Free;<br>&nbsp;&nbsp;FLineColors.OnChange:=nil;<br>&nbsp;&nbsp;FLineColors.Free;<br>&nbsp;&nbsp;inherited&nbsp;Destroy;<br>&nbsp;&nbsp;FreeMem(FColWidths);<br>&nbsp;&nbsp;FreeMem(FRowHeights);<br>&nbsp;&nbsp;FreeMem(FTabStops);<br>end;<br>procedure&nbsp;TCustomPZGrid.LineColorsChanged(FLineColors:&nbsp;TObject);<br>begin<br>&nbsp;&nbsp;Invalidate;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.AdjustSize(Index,&nbsp;Amount:&nbsp;Longint;&nbsp;Rows:&nbsp;Boolean);<br>var<br>&nbsp;&nbsp;NewCur:&nbsp;TGridCoord;<br>&nbsp;&nbsp;OldRows,&nbsp;OldCols:&nbsp;Longint;<br>&nbsp;&nbsp;MovementX,&nbsp;MovementY:&nbsp;Longint;<br>&nbsp;&nbsp;MoveRect:&nbsp;TGridRect;<br>&nbsp;&nbsp;ScrollArea:&nbsp;TRect;<br>&nbsp;&nbsp;AbsAmount:&nbsp;Longint;<br><br>&nbsp;&nbsp;function&nbsp;DoSizeAdjust(var&nbsp;Count:&nbsp;Longint;&nbsp;var&nbsp;Extents:&nbsp;Pointer;<br>&nbsp;&nbsp;&nbsp;&nbsp;DefaultExtent:&nbsp;Integer;&nbsp;var&nbsp;Current:&nbsp;Longint):&nbsp;Longint;<br>&nbsp;&nbsp;var<br>&nbsp;&nbsp;&nbsp;&nbsp;I:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;NewCount:&nbsp;Longint;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;NewCount&nbsp;:=&nbsp;Count&nbsp;+&nbsp;Amount;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;NewCount&nbsp;&lt;&nbsp;Index&nbsp;then&nbsp;InvalidOp(STooManyDeleted);<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(Amount&nbsp;&lt;&nbsp;0)&nbsp;and&nbsp;Assigned(Extents)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;I&nbsp;:=&nbsp;Index&nbsp;to&nbsp;Index&nbsp;-&nbsp;Amount&nbsp;-&nbsp;1&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(Result,&nbsp;PIntArray(Extents)^);<br>&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;Amount&nbsp;*&nbsp;DefaultExtent;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Extents&nbsp;&lt;&gt;&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ModifyExtents(Extents,&nbsp;Index,&nbsp;Amount,&nbsp;DefaultExtent);<br>&nbsp;&nbsp;&nbsp;&nbsp;Count&nbsp;:=&nbsp;NewCount;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Current&nbsp;&gt;=&nbsp;Index&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(Amount&nbsp;&lt;&nbsp;0)&nbsp;and&nbsp;(Current&nbsp;&lt;&nbsp;Index&nbsp;-&nbsp;Amount)&nbsp;then&nbsp;Current&nbsp;:=&nbsp;Index<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;Inc(Current,&nbsp;Amount);<br>&nbsp;&nbsp;end;<br><br>begin<br>&nbsp;&nbsp;if&nbsp;Amount&nbsp;=&nbsp;0&nbsp;then&nbsp;Exit;<br>&nbsp;&nbsp;NewCur&nbsp;:=&nbsp;FCurrent;<br>&nbsp;&nbsp;OldCols&nbsp;:=&nbsp;ColCount;<br>&nbsp;&nbsp;OldRows&nbsp;:=&nbsp;RowCount;<br>&nbsp;&nbsp;MoveRect.Left&nbsp;:=&nbsp;FixedCols;<br>&nbsp;&nbsp;MoveRect.Right&nbsp;:=&nbsp;ColCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;MoveRect.Top&nbsp;:=&nbsp;FixedRows;<br>&nbsp;&nbsp;MoveRect.Bottom&nbsp;:=&nbsp;RowCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;MovementX&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;MovementY&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;AbsAmount&nbsp;:=&nbsp;Amount;<br>&nbsp;&nbsp;if&nbsp;AbsAmount&nbsp;&lt;&nbsp;0&nbsp;then&nbsp;AbsAmount&nbsp;:=&nbsp;-AbsAmount;<br>&nbsp;&nbsp;if&nbsp;Rows&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;MovementY&nbsp;:=&nbsp;DoSizeAdjust(FRowCount,&nbsp;FRowHeights,&nbsp;DefaultRowHeight,&nbsp;NewCur.Y);<br>&nbsp;&nbsp;&nbsp;&nbsp;MoveRect.Top&nbsp;:=&nbsp;Index;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Index&nbsp;+&nbsp;AbsAmount&nbsp;&lt;=&nbsp;TopRow&nbsp;then&nbsp;MoveRect.Bottom&nbsp;:=&nbsp;TopRow&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;end<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;MovementX&nbsp;:=&nbsp;DoSizeAdjust(FColCount,&nbsp;FColWidths,&nbsp;DefaultColWidth,&nbsp;NewCur.X);<br>&nbsp;&nbsp;&nbsp;&nbsp;MoveRect.Left&nbsp;:=&nbsp;Index;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Index&nbsp;+&nbsp;AbsAmount&nbsp;&lt;=&nbsp;LeftCol&nbsp;then&nbsp;MoveRect.Right&nbsp;:=&nbsp;LeftCol&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;GridRectToScreenRect(MoveRect,&nbsp;ScrollArea,&nbsp;True);<br>&nbsp;&nbsp;if&nbsp;not&nbsp;IsRectEmpty(ScrollArea)&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;ScrollWindow(Handle,&nbsp;MovementX,&nbsp;MovementY,&nbsp;@ScrollArea,&nbsp;@ScrollArea);<br>&nbsp;&nbsp;&nbsp;&nbsp;UpdateWindow(Handle);<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;SizeChanged(OldCols,&nbsp;OldRows);<br>&nbsp;&nbsp;if&nbsp;(NewCur.X&nbsp;&lt;&gt;&nbsp;FCurrent.X)&nbsp;or&nbsp;(NewCur.Y&nbsp;&lt;&gt;&nbsp;FCurrent.Y)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;MoveCurrent(NewCur.X,&nbsp;NewCur.Y,&nbsp;True,&nbsp;True);<br>end;<br><br>function&nbsp;TCustomPZGrid.BoxRect(ALeft,&nbsp;ATop,&nbsp;ARight,&nbsp;ABottom:&nbsp;Longint):&nbsp;TRect;<br>var<br>&nbsp;&nbsp;GridRect:&nbsp;TGridRect;<br>begin<br>&nbsp;&nbsp;GridRect.Left&nbsp;:=&nbsp;ALeft;<br>&nbsp;&nbsp;GridRect.Right&nbsp;:=&nbsp;ARight;<br>&nbsp;&nbsp;GridRect.Top&nbsp;:=&nbsp;ATop;<br>&nbsp;&nbsp;GridRect.Bottom&nbsp;:=&nbsp;ABottom;<br>&nbsp;&nbsp;GridRectToScreenRect(GridRect,&nbsp;Result,&nbsp;False);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.DoExit;<br>begin<br>&nbsp;&nbsp;inherited&nbsp;DoExit;<br>&nbsp;&nbsp;if&nbsp;not&nbsp;(goAlwaysShowEditor&nbsp;in&nbsp;Options)&nbsp;then&nbsp;HideEditor;<br>end;<br><br>function&nbsp;TCustomPZGrid.CellRect(ACol,&nbsp;ARow:&nbsp;Longint):&nbsp;TRect;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;BoxRect(ACol,&nbsp;ARow,&nbsp;ACol,&nbsp;ARow);<br>end;<br><br>function&nbsp;TCustomPZGrid.CanEditAcceptKey(Key:&nbsp;Char):&nbsp;Boolean;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;True;<br>end;<br><br>function&nbsp;TCustomPZGrid.CanGridAcceptKey(Key:&nbsp;Word;&nbsp;Shift:&nbsp;TShiftState):&nbsp;Boolean;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;True;<br>end;<br><br>function&nbsp;TCustomPZGrid.CanEditModify:&nbsp;Boolean;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;FCanEditModify;<br>end;<br><br>function&nbsp;TCustomPZGrid.CanEditShow:&nbsp;Boolean;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;([goRowSelect,&nbsp;goEditing]&nbsp;*&nbsp;Options&nbsp;=&nbsp;[goEditing])&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;FEditorMode&nbsp;and&nbsp;not&nbsp;(csDesigning&nbsp;in&nbsp;ComponentState)&nbsp;and&nbsp;HandleAllocated&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;((goAlwaysShowEditor&nbsp;in&nbsp;Options)&nbsp;or&nbsp;IsActiveControl);<br>end;<br><br>function&nbsp;TCustomPZGrid.IsActiveControl:&nbsp;Boolean;<br>var<br>&nbsp;&nbsp;H:&nbsp;Hwnd;<br>&nbsp;&nbsp;ParentForm:&nbsp;TCustomForm;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;False;<br>&nbsp;&nbsp;ParentForm&nbsp;:=&nbsp;GetParentForm(Self);<br>&nbsp;&nbsp;if&nbsp;Assigned(ParentForm)&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(ParentForm.ActiveControl&nbsp;=&nbsp;Self)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;True<br>&nbsp;&nbsp;end<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;H&nbsp;:=&nbsp;GetFocus;<br>&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;IsWindow(H)&nbsp;and&nbsp;(Result&nbsp;=&nbsp;False)&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;H&nbsp;=&nbsp;WindowHandle&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;True<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;H&nbsp;:=&nbsp;GetParent(H);<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br>end;<br><br>function&nbsp;TCustomPZGrid.GetEditMask(ACol,&nbsp;ARow:&nbsp;Longint):&nbsp;string;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;'';<br>end;<br><br>function&nbsp;TCustomPZGrid.GetEditText(ACol,&nbsp;ARow:&nbsp;Longint):&nbsp;string;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;'';<br>end;<br><br>procedure&nbsp;TCustomPZGrid.SetEditText(ACol,&nbsp;ARow:&nbsp;Longint;&nbsp;const&nbsp;Value:&nbsp;string);<br>begin<br>end;<br><br>function&nbsp;TCustomPZGrid.GetEditLimit:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;0;<br>end;<br><br>function&nbsp;TCustomPZGrid.GetEditStyle(ACol,&nbsp;ARow:&nbsp;Longint):&nbsp;TEditStyle;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;esSimple;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.HideEditor;<br>begin<br>&nbsp;&nbsp;FEditorMode&nbsp;:=&nbsp;False;<br>&nbsp;&nbsp;HideEdit;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.ShowEditor;<br>begin<br>&nbsp;&nbsp;FEditorMode&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;UpdateEdit;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.ShowEditorChar(Ch:&nbsp;Char);<br>begin<br>&nbsp;&nbsp;ShowEditor;<br>&nbsp;&nbsp;if&nbsp;FInplaceEdit&nbsp;&lt;&gt;&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;PostMessage(FInplaceEdit.Handle,&nbsp;WM_CHAR,&nbsp;Word(Ch),&nbsp;0);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.InvalidateEditor;<br>begin<br>&nbsp;&nbsp;FInplaceCol&nbsp;:=&nbsp;-1;<br>&nbsp;&nbsp;FInplaceRow&nbsp;:=&nbsp;-1;<br>&nbsp;&nbsp;UpdateEdit;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.ReadColWidths(Reader:&nbsp;TReader);<br>var<br>&nbsp;&nbsp;I:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;with&nbsp;Reader&nbsp;do<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;ReadListBegin;<br>&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;I&nbsp;:=&nbsp;0&nbsp;to&nbsp;ColCount&nbsp;-&nbsp;1&nbsp;do&nbsp;ColWidths&nbsp;:=&nbsp;ReadInteger;<br>&nbsp;&nbsp;&nbsp;&nbsp;ReadListEnd;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.ReadRowHeights(Reader:&nbsp;TReader);<br>var<br>&nbsp;&nbsp;I:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;with&nbsp;Reader&nbsp;do<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;ReadListBegin;<br>&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;I&nbsp;:=&nbsp;0&nbsp;to&nbsp;RowCount&nbsp;-&nbsp;1&nbsp;do&nbsp;RowHeights&nbsp;:=&nbsp;ReadInteger;<br>&nbsp;&nbsp;&nbsp;&nbsp;ReadListEnd;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.WriteColWidths(Writer:&nbsp;TWriter);<br>var<br>&nbsp;&nbsp;I:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;with&nbsp;Writer&nbsp;do<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;WriteListBegin;<br>&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;I&nbsp;:=&nbsp;0&nbsp;to&nbsp;ColCount&nbsp;-&nbsp;1&nbsp;do&nbsp;WriteInteger(ColWidths);<br>&nbsp;&nbsp;&nbsp;&nbsp;WriteListEnd;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.WriteRowHeights(Writer:&nbsp;TWriter);<br>var<br>&nbsp;&nbsp;I:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;with&nbsp;Writer&nbsp;do<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;WriteListBegin;<br>&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;I&nbsp;:=&nbsp;0&nbsp;to&nbsp;RowCount&nbsp;-&nbsp;1&nbsp;do&nbsp;WriteInteger(RowHeights);<br>&nbsp;&nbsp;&nbsp;&nbsp;WriteListEnd;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.DefineProperties(Filer:&nbsp;TFiler);<br><br>&nbsp;&nbsp;function&nbsp;DoColWidths:&nbsp;Boolean;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Filer.Ancestor&nbsp;&lt;&gt;&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;not&nbsp;CompareExtents(TCustomPZGrid(Filer.Ancestor).FColWidths,&nbsp;FColWidths)<br>&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;FColWidths&nbsp;&lt;&gt;&nbsp;nil;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;function&nbsp;DoRowHeights:&nbsp;Boolean;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Filer.Ancestor&nbsp;&lt;&gt;&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;not&nbsp;CompareExtents(TCustomPZGrid(Filer.Ancestor).FRowHeights,&nbsp;FRowHeights)<br>&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;FRowHeights&nbsp;&lt;&gt;&nbsp;nil;<br>&nbsp;&nbsp;end;<br><br><br>begin<br>&nbsp;&nbsp;inherited&nbsp;DefineProperties(Filer);<br>&nbsp;&nbsp;if&nbsp;FSaveCellExtents&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;Filer&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DefineProperty('ColWidths',&nbsp;ReadColWidths,&nbsp;WriteColWidths,&nbsp;DoColWidths);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DefineProperty('RowHeights',&nbsp;ReadRowHeights,&nbsp;WriteRowHeights,&nbsp;DoRowHeights);<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.MoveColumn(FromIndex,&nbsp;ToIndex:&nbsp;Longint);<br>var<br>&nbsp;&nbsp;Rect:&nbsp;TGridRect;<br>begin<br>&nbsp;&nbsp;if&nbsp;FromIndex&nbsp;=&nbsp;ToIndex&nbsp;then&nbsp;Exit;<br>&nbsp;&nbsp;if&nbsp;Assigned(FColWidths)&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;MoveExtent(FColWidths,&nbsp;FromIndex&nbsp;+&nbsp;1,&nbsp;ToIndex&nbsp;+&nbsp;1);<br>&nbsp;&nbsp;&nbsp;&nbsp;MoveExtent(FTabStops,&nbsp;FromIndex&nbsp;+&nbsp;1,&nbsp;ToIndex&nbsp;+&nbsp;1);<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;MoveAdjust(FCurrent.X,&nbsp;FromIndex,&nbsp;ToIndex);<br>&nbsp;&nbsp;MoveAdjust(FAnchor.X,&nbsp;FromIndex,&nbsp;ToIndex);<br>&nbsp;&nbsp;MoveAdjust(FInplaceCol,&nbsp;FromIndex,&nbsp;ToIndex);<br>&nbsp;&nbsp;Rect.Top&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;Rect.Bottom&nbsp;:=&nbsp;VisibleRowCount;<br>&nbsp;&nbsp;if&nbsp;FromIndex&nbsp;&lt;&nbsp;ToIndex&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Rect.Left&nbsp;:=&nbsp;FromIndex;<br>&nbsp;&nbsp;&nbsp;&nbsp;Rect.Right&nbsp;:=&nbsp;ToIndex;<br>&nbsp;&nbsp;end<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Rect.Left&nbsp;:=&nbsp;ToIndex;<br>&nbsp;&nbsp;&nbsp;&nbsp;Rect.Right&nbsp;:=&nbsp;FromIndex;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;InvalidateRect(Rect);<br>&nbsp;&nbsp;ColumnMoved(FromIndex,&nbsp;ToIndex);<br>&nbsp;&nbsp;if&nbsp;Assigned(FColWidths)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;ColWidthsChanged;<br>&nbsp;&nbsp;UpdateEdit;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.ColumnMoved(FromIndex,&nbsp;ToIndex:&nbsp;Longint);<br>begin<br>end;<br><br>procedure&nbsp;TCustomPZGrid.MoveRow(FromIndex,&nbsp;ToIndex:&nbsp;Longint);<br>begin<br>&nbsp;&nbsp;if&nbsp;Assigned(FRowHeights)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;MoveExtent(FRowHeights,&nbsp;FromIndex&nbsp;+&nbsp;1,&nbsp;ToIndex&nbsp;+&nbsp;1);<br>&nbsp;&nbsp;MoveAdjust(FCurrent.Y,&nbsp;FromIndex,&nbsp;ToIndex);<br>&nbsp;&nbsp;MoveAdjust(FAnchor.Y,&nbsp;FromIndex,&nbsp;ToIndex);<br>&nbsp;&nbsp;MoveAdjust(FInplaceRow,&nbsp;FromIndex,&nbsp;ToIndex);<br>&nbsp;&nbsp;RowMoved(FromIndex,&nbsp;ToIndex);<br>&nbsp;&nbsp;if&nbsp;Assigned(FRowHeights)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;RowHeightsChanged;<br>&nbsp;&nbsp;UpdateEdit;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.RowMoved(FromIndex,&nbsp;ToIndex:&nbsp;Longint);<br>begin<br>end;<br><br>function&nbsp;TCustomPZGrid.MouseCoord(X,&nbsp;Y:&nbsp;Integer):&nbsp;TGridCoord;<br>var<br>&nbsp;&nbsp;DrawInfo:&nbsp;TGridDrawInfo;<br>begin<br>&nbsp;&nbsp;CalcDrawInfo(DrawInfo);<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;CalcCoordFromPoint(X,&nbsp;Y,&nbsp;DrawInfo);<br>&nbsp;&nbsp;if&nbsp;Result.X&nbsp;&lt;&nbsp;0&nbsp;then&nbsp;Result.Y&nbsp;:=&nbsp;-1<br>&nbsp;&nbsp;else&nbsp;if&nbsp;Result.Y&nbsp;&lt;&nbsp;0&nbsp;then&nbsp;Result.X&nbsp;:=&nbsp;-1;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.MoveColRow(ACol,&nbsp;ARow:&nbsp;Longint;&nbsp;MoveAnchor,<br>&nbsp;&nbsp;Show:&nbsp;Boolean);<br>begin<br>&nbsp;&nbsp;MoveCurrent(ACol,&nbsp;ARow,&nbsp;MoveAnchor,&nbsp;Show);<br>end;<br><br>function&nbsp;TCustomPZGrid.SelectCell(ACol,&nbsp;ARow:&nbsp;Longint):&nbsp;Boolean;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;True;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.SizeChanged(OldColCount,&nbsp;OldRowCount:&nbsp;Longint);<br>begin<br>end;<br><br>function&nbsp;TCustomPZGrid.Sizing(X,&nbsp;Y:&nbsp;Integer):&nbsp;Boolean;<br>var<br>&nbsp;&nbsp;DrawInfo:&nbsp;TGridDrawInfo;<br>&nbsp;&nbsp;State:&nbsp;TGridState;<br>&nbsp;&nbsp;Index:&nbsp;Longint;<br>&nbsp;&nbsp;Pos,&nbsp;Ofs:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;State&nbsp;:=&nbsp;FGridState;<br>&nbsp;&nbsp;if&nbsp;State&nbsp;=&nbsp;gsNormal&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;CalcDrawInfo(DrawInfo);<br>&nbsp;&nbsp;&nbsp;&nbsp;CalcSizingState(X,&nbsp;Y,&nbsp;State,&nbsp;Index,&nbsp;Pos,&nbsp;Ofs,&nbsp;DrawInfo);<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;State&nbsp;&lt;&gt;&nbsp;gsNormal;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.TopLeftChanged;<br>begin<br>&nbsp;&nbsp;if&nbsp;FEditorMode&nbsp;and&nbsp;(FInplaceEdit&nbsp;&lt;&gt;&nbsp;nil)&nbsp;then&nbsp;FInplaceEdit.UpdateLoc(CellRect(Col,&nbsp;Row));<br>end;<br><br>procedure&nbsp;FillDWord(var&nbsp;Dest;&nbsp;Count,&nbsp;Value:&nbsp;Integer);&nbsp;register;<br>asm<br>&nbsp;&nbsp;XCHG&nbsp;&nbsp;EDX,&nbsp;ECX<br>&nbsp;&nbsp;PUSH&nbsp;&nbsp;EDI<br>&nbsp;&nbsp;MOV&nbsp;&nbsp;&nbsp;EDI,&nbsp;EAX<br>&nbsp;&nbsp;MOV&nbsp;&nbsp;&nbsp;EAX,&nbsp;EDX<br>&nbsp;&nbsp;REP&nbsp;&nbsp;&nbsp;STOSD<br>&nbsp;&nbsp;POP&nbsp;&nbsp;&nbsp;EDI<br>end;<br><br>{&nbsp;StackAlloc&nbsp;allocates&nbsp;a&nbsp;'small'&nbsp;block&nbsp;of&nbsp;memory&nbsp;from&nbsp;the&nbsp;stack&nbsp;by<br>&nbsp;&nbsp;decrementing&nbsp;SP.&nbsp;&nbsp;This&nbsp;provides&nbsp;the&nbsp;allocation&nbsp;speed&nbsp;of&nbsp;a&nbsp;local&nbsp;variable,<br>&nbsp;&nbsp;but&nbsp;the&nbsp;runtime&nbsp;size&nbsp;flexibility&nbsp;of&nbsp;heap&nbsp;allocated&nbsp;memory.&nbsp;&nbsp;}<br>function&nbsp;StackAlloc(Size:&nbsp;Integer):&nbsp;Pointer;&nbsp;register;<br>asm<br>&nbsp;&nbsp;POP&nbsp;&nbsp;&nbsp;ECX&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;return&nbsp;address&nbsp;}<br>&nbsp;&nbsp;MOV&nbsp;&nbsp;&nbsp;EDX,&nbsp;ESP<br>&nbsp;&nbsp;ADD&nbsp;&nbsp;&nbsp;EAX,&nbsp;3<br>&nbsp;&nbsp;AND&nbsp;&nbsp;&nbsp;EAX,&nbsp;not&nbsp;3&nbsp;&nbsp;&nbsp;//&nbsp;round&nbsp;up&nbsp;to&nbsp;keep&nbsp;ESP&nbsp;dword&nbsp;aligned<br>&nbsp;&nbsp;CMP&nbsp;&nbsp;&nbsp;EAX,&nbsp;4092<br>&nbsp;&nbsp;JLE&nbsp;&nbsp;&nbsp;@@2<br>@@1:<br>&nbsp;&nbsp;SUB&nbsp;&nbsp;&nbsp;ESP,&nbsp;4092<br>&nbsp;&nbsp;PUSH&nbsp;&nbsp;EAX&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;make&nbsp;sure&nbsp;we&nbsp;touch&nbsp;guard&nbsp;page,&nbsp;to&nbsp;grow&nbsp;stack&nbsp;}<br>&nbsp;&nbsp;SUB&nbsp;&nbsp;&nbsp;EAX,&nbsp;4096<br>&nbsp;&nbsp;JNS&nbsp;&nbsp;&nbsp;@@1<br>&nbsp;&nbsp;ADD&nbsp;&nbsp;&nbsp;EAX,&nbsp;4096<br>@@2:<br>&nbsp;&nbsp;SUB&nbsp;&nbsp;&nbsp;ESP,&nbsp;EAX<br>&nbsp;&nbsp;MOV&nbsp;&nbsp;&nbsp;EAX,&nbsp;ESP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;function&nbsp;result&nbsp;=&nbsp;low&nbsp;memory&nbsp;address&nbsp;of&nbsp;block&nbsp;}<br>&nbsp;&nbsp;PUSH&nbsp;&nbsp;EDX&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;save&nbsp;original&nbsp;SP,&nbsp;for&nbsp;cleanup&nbsp;}<br>&nbsp;&nbsp;MOV&nbsp;&nbsp;&nbsp;EDX,&nbsp;ESP<br>&nbsp;&nbsp;SUB&nbsp;&nbsp;&nbsp;EDX,&nbsp;4<br>&nbsp;&nbsp;PUSH&nbsp;&nbsp;EDX&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;save&nbsp;current&nbsp;SP,&nbsp;for&nbsp;sanity&nbsp;check&nbsp;&nbsp;(sp&nbsp;=&nbsp;[sp])&nbsp;}<br>&nbsp;&nbsp;PUSH&nbsp;&nbsp;ECX&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;return&nbsp;to&nbsp;caller&nbsp;}<br>end;<br><br>{&nbsp;StackFree&nbsp;pops&nbsp;the&nbsp;memory&nbsp;allocated&nbsp;by&nbsp;StackAlloc&nbsp;off&nbsp;the&nbsp;stack.<br>-&nbsp;Calling&nbsp;StackFree&nbsp;is&nbsp;optional&nbsp;-&nbsp;SP&nbsp;will&nbsp;be&nbsp;restored&nbsp;when&nbsp;the&nbsp;calling&nbsp;routine<br>&nbsp;&nbsp;exits,&nbsp;but&nbsp;it's&nbsp;a&nbsp;good&nbsp;idea&nbsp;to&nbsp;free&nbsp;the&nbsp;stack&nbsp;allocated&nbsp;memory&nbsp;ASAP&nbsp;anyway.<br>-&nbsp;StackFree&nbsp;must&nbsp;be&nbsp;called&nbsp;in&nbsp;the&nbsp;same&nbsp;stack&nbsp;context&nbsp;as&nbsp;StackAlloc&nbsp;-&nbsp;not&nbsp;in<br>&nbsp;&nbsp;a&nbsp;subroutine&nbsp;or&nbsp;finally&nbsp;block.<br>-&nbsp;Multiple&nbsp;StackFree&nbsp;calls&nbsp;must&nbsp;occur&nbsp;in&nbsp;reverse&nbsp;order&nbsp;of&nbsp;their&nbsp;corresponding<br>&nbsp;&nbsp;StackAlloc&nbsp;calls.<br>-&nbsp;Built-in&nbsp;sanity&nbsp;checks&nbsp;guarantee&nbsp;that&nbsp;an&nbsp;improper&nbsp;call&nbsp;to&nbsp;StackFree&nbsp;will&nbsp;not<br>&nbsp;&nbsp;corrupt&nbsp;the&nbsp;stack.&nbsp;Worst&nbsp;case&nbsp;is&nbsp;that&nbsp;the&nbsp;stack&nbsp;block&nbsp;is&nbsp;not&nbsp;released&nbsp;until<br>&nbsp;&nbsp;the&nbsp;calling&nbsp;routine&nbsp;exits.&nbsp;}<br>procedure&nbsp;StackFree(P:&nbsp;Pointer);&nbsp;register;<br>asm<br>&nbsp;&nbsp;POP&nbsp;&nbsp;&nbsp;ECX&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;return&nbsp;address&nbsp;}<br>&nbsp;&nbsp;MOV&nbsp;&nbsp;&nbsp;EDX,&nbsp;DWORD&nbsp;PTR&nbsp;[ESP]<br>&nbsp;&nbsp;SUB&nbsp;&nbsp;&nbsp;EAX,&nbsp;8<br>&nbsp;&nbsp;CMP&nbsp;&nbsp;&nbsp;EDX,&nbsp;ESP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;sanity&nbsp;check&nbsp;#1&nbsp;(SP&nbsp;=&nbsp;[SP])&nbsp;}<br>&nbsp;&nbsp;JNE&nbsp;&nbsp;&nbsp;@@1<br>&nbsp;&nbsp;CMP&nbsp;&nbsp;&nbsp;EDX,&nbsp;EAX&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;sanity&nbsp;check&nbsp;#2&nbsp;(P&nbsp;=&nbsp;this&nbsp;stack&nbsp;block)&nbsp;}<br>&nbsp;&nbsp;JNE&nbsp;&nbsp;&nbsp;@@1<br>&nbsp;&nbsp;MOV&nbsp;&nbsp;&nbsp;ESP,&nbsp;DWORD&nbsp;PTR&nbsp;[ESP+4]&nbsp;&nbsp;{&nbsp;restore&nbsp;previous&nbsp;SP&nbsp;&nbsp;}<br>@@1:<br>&nbsp;&nbsp;PUSH&nbsp;&nbsp;ECX&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;return&nbsp;to&nbsp;caller&nbsp;}<br>end;<br><br>procedure&nbsp;TCustomPZGrid.PaintMoeny(Str:&nbsp;string;FocRect:&nbsp;TRect);<br>var<br>&nbsp;&nbsp;clBrushColor,&nbsp;clPenColor,&nbsp;Color:&nbsp;TColor;<br>begin<br>&nbsp;&nbsp;with&nbsp;Canvas&nbsp;do<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;clBrushColor:=Brush.Color;<br>&nbsp;&nbsp;&nbsp;&nbsp;clPenColor:=Pen.Color;<br>&nbsp;&nbsp;&nbsp;&nbsp;Font.Assign(Font);<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Length(Trim(Str))&gt;0&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FmtMoney(Str);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Color:=Pen.Color;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Font.Color:=Color;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ShowLineSeparator&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawMoneyCell(Str,&nbsp;Canvas,&nbsp;TextWidth('0')+3,&nbsp;FocRect)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawMoneyCellComma(Str,&nbsp;Canvas,&nbsp;TextWidth('0'),&nbsp;FocRect);<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ShowLineSeparator&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawDigitLine(Canvas,&nbsp;FocRect,&nbsp;TextWidth('0')+3,&nbsp;LineColors);<br>&nbsp;&nbsp;&nbsp;&nbsp;Brush.Color:=clBrushColor;<br>&nbsp;&nbsp;&nbsp;&nbsp;Pen.Color:=clPenColor;<br>&nbsp;&nbsp;end;<br>end;<br><br><br>procedure&nbsp;TCustomPZGrid.Paint;<br>var<br>&nbsp;&nbsp;LineColor:&nbsp;TColor;<br>&nbsp;&nbsp;DrawInfo:&nbsp;TGridDrawInfo;<br>&nbsp;&nbsp;Sel:&nbsp;TGridRect;<br>&nbsp;&nbsp;UpdateRect:&nbsp;TRect;<br>&nbsp;&nbsp;AFocRect,&nbsp;FocRect:&nbsp;TRect;<br>&nbsp;&nbsp;PointsList:&nbsp;PIntArray;<br>&nbsp;&nbsp;StrokeList:&nbsp;PIntArray;<br>&nbsp;&nbsp;MaxStroke:&nbsp;Integer;<br>&nbsp;&nbsp;FrameFlags1,&nbsp;FrameFlags2:&nbsp;DWORD;<br><br><br>&nbsp;&nbsp;procedure&nbsp;DrawLines(DoHorz,&nbsp;DoVert:&nbsp;Boolean;&nbsp;Col,&nbsp;Row:&nbsp;Longint;<br>&nbsp;&nbsp;&nbsp;&nbsp;const&nbsp;CellBounds:&nbsp;array&nbsp;of&nbsp;Integer;&nbsp;OnColor,&nbsp;OffColor:&nbsp;TColor);<br><br>&nbsp;&nbsp;{&nbsp;Cellbounds&nbsp;is&nbsp;4&nbsp;integers:&nbsp;StartX,&nbsp;StartY,&nbsp;StopX,&nbsp;StopY<br>&nbsp;&nbsp;&nbsp;&nbsp;Horizontal&nbsp;lines:&nbsp;&nbsp;MajorIndex&nbsp;=&nbsp;0<br>&nbsp;&nbsp;&nbsp;&nbsp;Vertical&nbsp;lines:&nbsp;&nbsp;&nbsp;&nbsp;MajorIndex&nbsp;=&nbsp;1&nbsp;}<br><br>&nbsp;&nbsp;const<br>&nbsp;&nbsp;&nbsp;&nbsp;FlatPenStyle&nbsp;=&nbsp;PS_Geometric&nbsp;or&nbsp;PS_Solid&nbsp;or&nbsp;PS_EndCap_Flat&nbsp;or&nbsp;PS_Join_Miter;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;DrawAxisLines(const&nbsp;AxisInfo:&nbsp;TGridAxisDrawInfo;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cell,&nbsp;MajorIndex:&nbsp;Integer;&nbsp;UseOnColor:&nbsp;Boolean);<br>&nbsp;&nbsp;&nbsp;&nbsp;var<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Line:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LogBrush:&nbsp;TLOGBRUSH;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Index:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Points:&nbsp;PIntArray;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StopMajor,&nbsp;StartMinor,&nbsp;StopMinor,&nbsp;StopIndex:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LineIncr:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;Canvas,&nbsp;AxisInfo&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;EffectiveLineWidth&nbsp;&lt;&gt;&nbsp;0&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pen.Width&nbsp;:=&nbsp;GridLineWidth;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;UseOnColor&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pen.Color&nbsp;:=&nbsp;OnColor<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pen.Color&nbsp;:=&nbsp;OffColor;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Pen.Width&nbsp;&gt;&nbsp;1&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LogBrush.lbStyle&nbsp;:=&nbsp;BS_Solid;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LogBrush.lbColor&nbsp;:=&nbsp;Pen.Color;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LogBrush.lbHatch&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pen.Handle&nbsp;:=&nbsp;ExtCreatePen(FlatPenStyle,&nbsp;Pen.Width,&nbsp;LogBrush,&nbsp;0,&nbsp;nil);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Points&nbsp;:=&nbsp;PointsList;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Line&nbsp;:=&nbsp;CellBounds[MajorIndex]&nbsp;+&nbsp;EffectiveLineWidth&nbsp;shr&nbsp;1&nbsp;+<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GetExtent(Cell);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//!!!&nbsp;???&nbsp;Line&nbsp;needs&nbsp;to&nbsp;be&nbsp;incremented&nbsp;for&nbsp;RightToLeftAlignment&nbsp;???<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;UseRightToLeftAlignment&nbsp;and&nbsp;(MajorIndex&nbsp;=&nbsp;0)&nbsp;then&nbsp;Inc(Line);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StartMinor&nbsp;:=&nbsp;CellBounds[MajorIndex&nbsp;xor&nbsp;1];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StopMinor&nbsp;:=&nbsp;CellBounds[2&nbsp;+&nbsp;(MajorIndex&nbsp;xor&nbsp;1)];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StopMajor&nbsp;:=&nbsp;CellBounds[2&nbsp;+&nbsp;MajorIndex]&nbsp;+&nbsp;EffectiveLineWidth;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StopIndex&nbsp;:=&nbsp;MaxStroke&nbsp;*&nbsp;4;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Index&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;repeat<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Points^[Index&nbsp;+&nbsp;MajorIndex]&nbsp;:=&nbsp;Line;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;MoveTo&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Points^[Index&nbsp;+&nbsp;(MajorIndex&nbsp;xor&nbsp;1)]&nbsp;:=&nbsp;StartMinor;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(Index,&nbsp;2);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Points^[Index&nbsp;+&nbsp;MajorIndex]&nbsp;:=&nbsp;Line;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;LineTo&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Points^[Index&nbsp;+&nbsp;(MajorIndex&nbsp;xor&nbsp;1)]&nbsp;:=&nbsp;StopMinor;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(Index,&nbsp;2);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Skip&nbsp;hidden&nbsp;columns/rows.&nbsp;&nbsp;We&nbsp;don't&nbsp;have&nbsp;stroke&nbsp;slots&nbsp;for&nbsp;them<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;A&nbsp;column/row&nbsp;with&nbsp;an&nbsp;extent&nbsp;of&nbsp;-EffectiveLineWidth&nbsp;is&nbsp;hidden<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;repeat<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(Cell);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LineIncr&nbsp;:=&nbsp;GetExtent(Cell)&nbsp;+&nbsp;EffectiveLineWidth;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;until&nbsp;(LineIncr&nbsp;&gt;&nbsp;0)&nbsp;or&nbsp;(Cell&nbsp;&gt;&nbsp;LastFullVisibleCell);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(Line,&nbsp;LineIncr);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;until&nbsp;(Line&nbsp;&gt;&nbsp;StopMajor)&nbsp;or&nbsp;(Cell&nbsp;&gt;&nbsp;LastFullVisibleCell)&nbsp;or&nbsp;(Index&nbsp;&gt;&nbsp;StopIndex);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;2&nbsp;integers&nbsp;per&nbsp;point,&nbsp;2&nbsp;points&nbsp;per&nbsp;line&nbsp;-&gt;&nbsp;Index&nbsp;div&nbsp;4&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PolyPolyLine(Canvas.Handle,&nbsp;Points^,&nbsp;StrokeList^,&nbsp;Index&nbsp;shr&nbsp;2);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(CellBounds[0]&nbsp;=&nbsp;CellBounds[2])&nbsp;or&nbsp;(CellBounds[1]&nbsp;=&nbsp;CellBounds[3])&nbsp;then&nbsp;Exit;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;DoHorz&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawAxisLines(DrawInfo.Vert,&nbsp;Row,&nbsp;1,&nbsp;DoHorz);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawAxisLines(DrawInfo.Horz,&nbsp;Col,&nbsp;0,&nbsp;DoVert);<br>&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawAxisLines(DrawInfo.Horz,&nbsp;Col,&nbsp;0,&nbsp;DoVert);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawAxisLines(DrawInfo.Vert,&nbsp;Row,&nbsp;1,&nbsp;DoHorz);<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;procedure&nbsp;DrawCells(ACol,&nbsp;ARow:&nbsp;Longint;&nbsp;StartX,&nbsp;StartY,&nbsp;StopX,&nbsp;StopY:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;Color:&nbsp;TColor;&nbsp;IncludeDrawState:&nbsp;TGridDrawState);<br>&nbsp;&nbsp;var<br>&nbsp;&nbsp;&nbsp;&nbsp;CurCol,&nbsp;CurRow:&nbsp;Longint;<br>&nbsp;&nbsp;&nbsp;&nbsp;AWhere,&nbsp;Where,&nbsp;TempRect:&nbsp;TRect;<br>&nbsp;&nbsp;&nbsp;&nbsp;DrawState:&nbsp;TGridDrawState;<br>&nbsp;&nbsp;&nbsp;&nbsp;Focused:&nbsp;Boolean;<br>&nbsp;&nbsp;&nbsp;&nbsp;Str:String;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;CurRow&nbsp;:=&nbsp;ARow;<br>&nbsp;&nbsp;&nbsp;&nbsp;Where.Top&nbsp;:=&nbsp;StartY;<br>&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;(Where.Top&nbsp;&lt;&nbsp;StopY)&nbsp;and&nbsp;(CurRow&nbsp;&lt;&nbsp;RowCount)&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CurCol&nbsp;:=&nbsp;ACol;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Where.Left&nbsp;:=&nbsp;StartX;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Where.Bottom&nbsp;:=&nbsp;Where.Top&nbsp;+&nbsp;RowHeights[CurRow];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;(Where.Left&nbsp;&lt;&nbsp;StopX)&nbsp;and&nbsp;(CurCol&nbsp;&lt;&nbsp;ColCount)&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Where.Right&nbsp;:=&nbsp;Where.Left&nbsp;+&nbsp;ColWidths[CurCol];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(Where.Right&nbsp;&gt;&nbsp;Where.Left)&nbsp;and&nbsp;RectVisible(Canvas.Handle,&nbsp;Where)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawState&nbsp;:=&nbsp;IncludeDrawState;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Focused&nbsp;:=&nbsp;IsActiveControl;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Focused&nbsp;and&nbsp;(CurRow&nbsp;=&nbsp;Row)&nbsp;and&nbsp;(CurCol&nbsp;=&nbsp;Col)&nbsp;&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Include(DrawState,&nbsp;gdFocused);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;PointInGridRect(CurCol,&nbsp;CurRow,&nbsp;Sel)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Include(DrawState,&nbsp;gdSelected);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;(gdFocused&nbsp;in&nbsp;DrawState)&nbsp;or&nbsp;not&nbsp;(goEditing&nbsp;in&nbsp;Options)&nbsp;or<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;not&nbsp;FEditorMode&nbsp;or&nbsp;(csDesigning&nbsp;in&nbsp;ComponentState)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;DefaultDrawing&nbsp;or&nbsp;(csDesigning&nbsp;in&nbsp;ComponentState)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;Canvas&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Font&nbsp;:=&nbsp;Self.Font;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(gdSelected&nbsp;in&nbsp;DrawState)&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(not&nbsp;(gdFocused&nbsp;in&nbsp;DrawState)&nbsp;or<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;([goDrawFocusSelected,&nbsp;goRowSelect]&nbsp;*&nbsp;Options&nbsp;&lt;&gt;&nbsp;[]))&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Brush.Color&nbsp;:=&nbsp;clHighlight;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Font.Color&nbsp;:=&nbsp;clHighlightText;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Brush.Color&nbsp;:=&nbsp;Color;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FillRect(Where);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawCell(CurCol,&nbsp;CurRow,&nbsp;Where,&nbsp;DrawState);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//加画字<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;CurRow=0&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawText(Canvas.Handle,&nbsp;pchar(TextKm[CurCol]),&nbsp;length(TextKm[CurCol]),&nbsp;Where,&nbsp;DT_SINGLELINE&nbsp;or&nbsp;DT_VCENTER<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;or&nbsp;DT_CENTER);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;///加画金额线<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;&nbsp;&nbsp;(curRow&gt;0)&nbsp;and&nbsp;((CurCol&nbsp;=2)&nbsp;or&nbsp;(CurCol=3))&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Str:=GetEditText(CurCol,curRow);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PaintMoeny(Str,Where);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;DefaultDrawing&nbsp;and&nbsp;(gdFixed&nbsp;in&nbsp;DrawState)&nbsp;and&nbsp;Ctl3D&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;((FrameFlags1&nbsp;or&nbsp;FrameFlags2)&nbsp;&lt;&gt;&nbsp;0)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TempRect&nbsp;:=&nbsp;Where;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(FrameFlags1&nbsp;and&nbsp;BF_RIGHT)&nbsp;=&nbsp;0&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(TempRect.Right,&nbsp;DrawInfo.Horz.EffectiveLineWidth)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;(FrameFlags1&nbsp;and&nbsp;BF_BOTTOM)&nbsp;=&nbsp;0&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(TempRect.Bottom,&nbsp;DrawInfo.Vert.EffectiveLineWidth);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawEdge(Canvas.Handle,&nbsp;TempRect,&nbsp;BDR_RAISEDINNER,&nbsp;FrameFlags1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawEdge(Canvas.Handle,&nbsp;TempRect,&nbsp;BDR_RAISEDINNER,&nbsp;FrameFlags2);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;DefaultDrawing&nbsp;and&nbsp;not&nbsp;(csDesigning&nbsp;in&nbsp;ComponentState)&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(gdFocused&nbsp;in&nbsp;DrawState)&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;([goEditing,&nbsp;goAlwaysShowEditor]&nbsp;*&nbsp;Options&nbsp;&lt;&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[goEditing,&nbsp;goAlwaysShowEditor])<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;not&nbsp;(goRowSelect&nbsp;in&nbsp;Options)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;UseRightToLeftAlignment&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawFocusRect(Canvas.Handle,&nbsp;Where)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AWhere&nbsp;:=&nbsp;Where;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AWhere.Left&nbsp;:=&nbsp;Where.Right;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AWhere.Right&nbsp;:=&nbsp;Where.Left;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawFocusRect(Canvas.Handle,&nbsp;AWhere);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Where.Left&nbsp;:=&nbsp;Where.Right&nbsp;+&nbsp;DrawInfo.Horz.EffectiveLineWidth;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(CurCol);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Where.Top&nbsp;:=&nbsp;Where.Bottom&nbsp;+&nbsp;DrawInfo.Vert.EffectiveLineWidth;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(CurRow);<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br><br>begin<br>&nbsp;&nbsp;if&nbsp;UseRightToLeftAlignment&nbsp;then&nbsp;ChangeGridOrientation(True);<br><br>&nbsp;&nbsp;UpdateRect&nbsp;:=&nbsp;Canvas.ClipRect;<br>&nbsp;&nbsp;CalcDrawInfo(DrawInfo);<br>&nbsp;&nbsp;with&nbsp;DrawInfo&nbsp;do<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(Horz.EffectiveLineWidth&nbsp;&gt;&nbsp;0)&nbsp;or&nbsp;(Vert.EffectiveLineWidth&nbsp;&gt;&nbsp;0)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Draw&nbsp;the&nbsp;grid&nbsp;line&nbsp;in&nbsp;the&nbsp;four&nbsp;areas&nbsp;(fixed,&nbsp;fixed),&nbsp;(variable,&nbsp;fixed),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(fixed,&nbsp;variable)&nbsp;and&nbsp;(variable,&nbsp;variable)&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LineColor&nbsp;:=&nbsp;clBlack;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MaxStroke&nbsp;:=&nbsp;Max(Horz.LastFullVisibleCell&nbsp;-&nbsp;LeftCol&nbsp;+&nbsp;FixedCols,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Vert.LastFullVisibleCell&nbsp;-&nbsp;TopRow&nbsp;+&nbsp;FixedRows)&nbsp;+&nbsp;3;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PointsList&nbsp;:=&nbsp;StackAlloc(MaxStroke&nbsp;*&nbsp;sizeof(TPoint)&nbsp;*&nbsp;2);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StrokeList&nbsp;:=&nbsp;StackAlloc(MaxStroke&nbsp;*&nbsp;sizeof(Integer));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FillDWord(StrokeList^,&nbsp;MaxStroke,&nbsp;2);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ColorToRGB(Color)&nbsp;=&nbsp;clSilver&nbsp;then&nbsp;LineColor&nbsp;:=&nbsp;clGray;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawLines(goFixedHorzLine&nbsp;in&nbsp;Options,&nbsp;goFixedVertLine&nbsp;in&nbsp;Options,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0,&nbsp;0,&nbsp;[0,&nbsp;0,&nbsp;Horz.FixedBoundary,&nbsp;Vert.FixedBoundary],&nbsp;clBlack,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FixedColor);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawLines(goFixedHorzLine&nbsp;in&nbsp;Options,&nbsp;goFixedVertLine&nbsp;in&nbsp;Options,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LeftCol,&nbsp;0,&nbsp;[Horz.FixedBoundary,&nbsp;0,&nbsp;Horz.GridBoundary,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Vert.FixedBoundary],&nbsp;clBlack,&nbsp;FixedColor);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawLines(goFixedHorzLine&nbsp;in&nbsp;Options,&nbsp;goFixedVertLine&nbsp;in&nbsp;Options,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0,&nbsp;TopRow,&nbsp;[0,&nbsp;Vert.FixedBoundary,&nbsp;Horz.FixedBoundary,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Vert.GridBoundary],&nbsp;clBlack,&nbsp;FixedColor);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawLines(goHorzLine&nbsp;in&nbsp;Options,&nbsp;goVertLine&nbsp;in&nbsp;Options,&nbsp;LeftCol,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TopRow,&nbsp;[Horz.FixedBoundary,&nbsp;Vert.FixedBoundary,&nbsp;Horz.GridBoundary,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Vert.GridBoundary],&nbsp;LineColor,&nbsp;Color);<br><br><br><br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StackFree(StrokeList);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StackFree(PointsList);<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Draw&nbsp;the&nbsp;cells&nbsp;in&nbsp;the&nbsp;four&nbsp;areas&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;Sel&nbsp;:=&nbsp;Selection;<br>&nbsp;&nbsp;&nbsp;&nbsp;FrameFlags1&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;&nbsp;&nbsp;FrameFlags2&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;goFixedVertLine&nbsp;in&nbsp;Options&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FrameFlags1&nbsp;:=&nbsp;BF_RIGHT;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FrameFlags2&nbsp;:=&nbsp;BF_LEFT;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;goFixedHorzLine&nbsp;in&nbsp;Options&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FrameFlags1&nbsp;:=&nbsp;FrameFlags1&nbsp;or&nbsp;BF_BOTTOM;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FrameFlags2&nbsp;:=&nbsp;FrameFlags2&nbsp;or&nbsp;BF_TOP;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;//////////画固定头<br>&nbsp;&nbsp;&nbsp;&nbsp;DrawCells(0,&nbsp;0,&nbsp;0,&nbsp;0,&nbsp;Horz.FixedBoundary,&nbsp;Vert.FixedBoundary,&nbsp;FixedColor,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[gdFixed]);<br>&nbsp;&nbsp;&nbsp;&nbsp;DrawCells(LeftCol,&nbsp;0,&nbsp;Horz.FixedBoundary&nbsp;-&nbsp;FColOffset,&nbsp;0,&nbsp;Horz.GridBoundary,&nbsp;&nbsp;//!!&nbsp;clip<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Vert.FixedBoundary,&nbsp;FixedColor,&nbsp;[gdFixed]);<br>&nbsp;&nbsp;&nbsp;&nbsp;DrawCells(0,&nbsp;TopRow,&nbsp;0,&nbsp;Vert.FixedBoundary,&nbsp;Horz.FixedBoundary,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Vert.GridBoundary,&nbsp;FixedColor,&nbsp;[gdFixed]);<br>&nbsp;&nbsp;&nbsp;&nbsp;DrawCells(LeftCol,&nbsp;TopRow,&nbsp;Horz.FixedBoundary&nbsp;-&nbsp;FColOffset,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//!!&nbsp;clip<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Vert.FixedBoundary,&nbsp;Horz.GridBoundary,&nbsp;Vert.GridBoundary,&nbsp;Color,&nbsp;[]);<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;(csDesigning&nbsp;in&nbsp;ComponentState)&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(goRowSelect&nbsp;in&nbsp;Options)&nbsp;and&nbsp;DefaultDrawing&nbsp;and&nbsp;Focused&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GridRectToScreenRect(GetSelection,&nbsp;FocRect,&nbsp;False);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;UseRightToLeftAlignment&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Canvas.DrawFocusRect(FocRect)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AFocRect&nbsp;:=&nbsp;FocRect;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AFocRect.Left&nbsp;:=&nbsp;FocRect.Right;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AFocRect.Right&nbsp;:=&nbsp;FocRect.Left;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawFocusRect(Canvas.Handle,&nbsp;AFocRect);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Fill&nbsp;in&nbsp;area&nbsp;not&nbsp;occupied&nbsp;by&nbsp;cells&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Horz.GridBoundary&nbsp;&lt;&nbsp;Horz.GridExtent&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Canvas.Brush.Color&nbsp;:=&nbsp;Color;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Canvas.FillRect(Rect(Horz.GridBoundary,&nbsp;0,&nbsp;Horz.GridExtent,&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Vert.GridBoundary));<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Vert.GridBoundary&nbsp;&lt;&nbsp;Vert.GridExtent&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Canvas.Brush.Color&nbsp;:=&nbsp;Color;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Canvas.FillRect(Rect(0,&nbsp;Vert.GridBoundary,&nbsp;Horz.GridExtent,&nbsp;Vert.GridExtent));<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;if&nbsp;UseRightToLeftAlignment&nbsp;then&nbsp;ChangeGridOrientation(False);<br>end;<br><br>function&nbsp;TCustomPZGrid.CalcCoordFromPoint(X,&nbsp;Y:&nbsp;Integer;<br>&nbsp;&nbsp;const&nbsp;DrawInfo:&nbsp;TGridDrawInfo):&nbsp;TGridCoord;<br><br>&nbsp;&nbsp;function&nbsp;DoCalc(const&nbsp;AxisInfo:&nbsp;TGridAxisDrawInfo;&nbsp;N:&nbsp;Integer):&nbsp;Integer;<br>&nbsp;&nbsp;var<br>&nbsp;&nbsp;&nbsp;&nbsp;I,&nbsp;Start,&nbsp;Stop:&nbsp;Longint;<br>&nbsp;&nbsp;&nbsp;&nbsp;Line:&nbsp;Integer;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;AxisInfo&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;N&nbsp;&lt;&nbsp;FixedBoundary&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Stop&nbsp;:=&nbsp;&nbsp;FixedCellCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Line&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start&nbsp;:=&nbsp;FirstGridCell;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Stop&nbsp;:=&nbsp;GridCellCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Line&nbsp;:=&nbsp;FixedBoundary;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;-1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;I&nbsp;:=&nbsp;Start&nbsp;to&nbsp;Stop&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(Line,&nbsp;GetExtent(I)&nbsp;+&nbsp;EffectiveLineWidth);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;N&nbsp;&lt;&nbsp;Line&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;I;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;function&nbsp;DoCalcRightToLeft(const&nbsp;AxisInfo:&nbsp;TGridAxisDrawInfo;&nbsp;N:&nbsp;Integer):&nbsp;Integer;<br>&nbsp;&nbsp;var<br>&nbsp;&nbsp;&nbsp;&nbsp;I,&nbsp;Start,&nbsp;Stop:&nbsp;Longint;<br>&nbsp;&nbsp;&nbsp;&nbsp;Line:&nbsp;Integer;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;N&nbsp;:=&nbsp;ClientWidth&nbsp;-&nbsp;N;<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;AxisInfo&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;N&nbsp;&lt;&nbsp;FixedBoundary&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Stop&nbsp;:=&nbsp;&nbsp;FixedCellCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Line&nbsp;:=&nbsp;ClientWidth;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start&nbsp;:=&nbsp;FirstGridCell;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Stop&nbsp;:=&nbsp;GridCellCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Line&nbsp;:=&nbsp;FixedBoundary;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;-1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;I&nbsp;:=&nbsp;Start&nbsp;to&nbsp;Stop&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(Line,&nbsp;GetExtent(I)&nbsp;+&nbsp;EffectiveLineWidth);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;N&nbsp;&lt;&nbsp;Line&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;I;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br><br>begin<br>&nbsp;&nbsp;if&nbsp;not&nbsp;UseRightToLeftAlignment&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;Result.X&nbsp;:=&nbsp;DoCalc(DrawInfo.Horz,&nbsp;X)<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;Result.X&nbsp;:=&nbsp;DoCalcRightToLeft(DrawInfo.Horz,&nbsp;X);<br>&nbsp;&nbsp;Result.Y&nbsp;:=&nbsp;DoCalc(DrawInfo.Vert,&nbsp;Y);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.CalcDrawInfo(var&nbsp;DrawInfo:&nbsp;TGridDrawInfo);<br>begin<br>&nbsp;&nbsp;CalcDrawInfoXY(DrawInfo,&nbsp;ClientWidth,&nbsp;ClientHeight);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.CalcDrawInfoXY(var&nbsp;DrawInfo:&nbsp;TGridDrawInfo;<br>&nbsp;&nbsp;UseWidth,&nbsp;UseHeight:&nbsp;Integer);<br><br>&nbsp;&nbsp;procedure&nbsp;CalcAxis(var&nbsp;AxisInfo:&nbsp;TGridAxisDrawInfo;&nbsp;UseExtent:&nbsp;Integer);<br>&nbsp;&nbsp;var<br>&nbsp;&nbsp;&nbsp;&nbsp;I:&nbsp;Integer;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;AxisInfo&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GridExtent&nbsp;:=&nbsp;UseExtent;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GridBoundary&nbsp;:=&nbsp;FixedBoundary;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FullVisBoundary&nbsp;:=&nbsp;FixedBoundary;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LastFullVisibleCell&nbsp;:=&nbsp;FirstGridCell;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;I&nbsp;:=&nbsp;FirstGridCell&nbsp;to&nbsp;GridCellCount&nbsp;-&nbsp;1&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(GridBoundary,&nbsp;GetExtent(I)&nbsp;+&nbsp;EffectiveLineWidth);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;GridBoundary&nbsp;&gt;&nbsp;GridExtent&nbsp;+&nbsp;EffectiveLineWidth&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GridBoundary&nbsp;:=&nbsp;GridExtent;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Break;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LastFullVisibleCell&nbsp;:=&nbsp;I;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FullVisBoundary&nbsp;:=&nbsp;GridBoundary;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br><br>begin<br>&nbsp;&nbsp;CalcFixedInfo(DrawInfo);<br>&nbsp;&nbsp;CalcAxis(DrawInfo.Horz,&nbsp;UseWidth);<br>&nbsp;&nbsp;CalcAxis(DrawInfo.Vert,&nbsp;UseHeight);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.CalcFixedInfo(var&nbsp;DrawInfo:&nbsp;TGridDrawInfo);<br><br>&nbsp;&nbsp;procedure&nbsp;CalcFixedAxis(var&nbsp;Axis:&nbsp;TGridAxisDrawInfo;&nbsp;LineOptions:&nbsp;TGridOptions;<br>&nbsp;&nbsp;&nbsp;&nbsp;FixedCount,&nbsp;FirstCell,&nbsp;CellCount:&nbsp;Integer;&nbsp;GetExtentFunc:&nbsp;TGetExtentsFunc);<br>&nbsp;&nbsp;var<br>&nbsp;&nbsp;&nbsp;&nbsp;I:&nbsp;Integer;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;Axis&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;LineOptions&nbsp;*&nbsp;Options&nbsp;=&nbsp;[]&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EffectiveLineWidth&nbsp;:=&nbsp;0<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EffectiveLineWidth&nbsp;:=&nbsp;GridLineWidth;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FixedBoundary&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;I&nbsp;:=&nbsp;0&nbsp;to&nbsp;FixedCount&nbsp;-&nbsp;1&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(FixedBoundary,&nbsp;GetExtentFunc(I)&nbsp;+&nbsp;EffectiveLineWidth);<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FixedCellCount&nbsp;:=&nbsp;FixedCount;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FirstGridCell&nbsp;:=&nbsp;FirstCell;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GridCellCount&nbsp;:=&nbsp;CellCount;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GetExtent&nbsp;:=&nbsp;GetExtentFunc;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br><br>begin<br>&nbsp;&nbsp;CalcFixedAxis(DrawInfo.Horz,&nbsp;[goFixedVertLine,&nbsp;goVertLine],&nbsp;FixedCols,<br>&nbsp;&nbsp;&nbsp;&nbsp;LeftCol,&nbsp;ColCount,&nbsp;GetColWidths);<br>&nbsp;&nbsp;CalcFixedAxis(DrawInfo.Vert,&nbsp;[goFixedHorzLine,&nbsp;goHorzLine],&nbsp;FixedRows,<br>&nbsp;&nbsp;&nbsp;&nbsp;TopRow,&nbsp;RowCount,&nbsp;GetRowHeights);<br>end;<br><br>{&nbsp;Calculates&nbsp;the&nbsp;TopLeft&nbsp;that&nbsp;will&nbsp;put&nbsp;the&nbsp;given&nbsp;Coord&nbsp;in&nbsp;view&nbsp;}<br>function&nbsp;TCustomPZGrid.CalcMaxTopLeft(const&nbsp;Coord:&nbsp;TGridCoord;<br>&nbsp;&nbsp;const&nbsp;DrawInfo:&nbsp;TGridDrawInfo):&nbsp;TGridCoord;<br><br>&nbsp;&nbsp;function&nbsp;CalcMaxCell(const&nbsp;Axis:&nbsp;TGridAxisDrawInfo;&nbsp;Start:&nbsp;Integer):&nbsp;Integer;<br>&nbsp;&nbsp;var<br>&nbsp;&nbsp;&nbsp;&nbsp;Line:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;I,&nbsp;Extent:&nbsp;Longint;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;Start;<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;Axis&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Line&nbsp;:=&nbsp;GridExtent&nbsp;+&nbsp;EffectiveLineWidth;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;I&nbsp;:=&nbsp;Start&nbsp;downto&nbsp;FixedCellCount&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Extent&nbsp;:=&nbsp;GetExtent(I);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Extent&nbsp;&gt;&nbsp;0&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dec(Line,&nbsp;Extent);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dec(Line,&nbsp;EffectiveLineWidth);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Line&nbsp;&lt;&nbsp;FixedBoundary&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(Result&nbsp;=&nbsp;Start)&nbsp;and&nbsp;(GetExtent(Start)&nbsp;&lt;=&nbsp;0)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;I;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Break;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;I;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br><br>begin<br>&nbsp;&nbsp;Result.X&nbsp;:=&nbsp;CalcMaxCell(DrawInfo.Horz,&nbsp;Coord.X);<br>&nbsp;&nbsp;Result.Y&nbsp;:=&nbsp;CalcMaxCell(DrawInfo.Vert,&nbsp;Coord.Y);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.CalcSizingState(X,&nbsp;Y:&nbsp;Integer;&nbsp;var&nbsp;State:&nbsp;TGridState;<br>&nbsp;&nbsp;var&nbsp;Index:&nbsp;Longint;&nbsp;var&nbsp;SizingPos,&nbsp;SizingOfs:&nbsp;Integer;<br>&nbsp;&nbsp;var&nbsp;FixedInfo:&nbsp;TGridDrawInfo);<br><br>&nbsp;&nbsp;procedure&nbsp;CalcAxisState(const&nbsp;AxisInfo:&nbsp;TGridAxisDrawInfo;&nbsp;Pos:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;NewState:&nbsp;TGridState);<br>&nbsp;&nbsp;var<br>&nbsp;&nbsp;&nbsp;&nbsp;I,&nbsp;Line,&nbsp;Back,&nbsp;Range:&nbsp;Integer;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(NewState&nbsp;=&nbsp;gsColSizing)&nbsp;and&nbsp;UseRightToLeftAlignment&nbsp;then&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pos&nbsp;:=&nbsp;ClientWidth&nbsp;-&nbsp;Pos;<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;AxisInfo&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Line&nbsp;:=&nbsp;FixedBoundary;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Range&nbsp;:=&nbsp;EffectiveLineWidth;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Back&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Range&nbsp;&lt;&nbsp;7&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Range&nbsp;:=&nbsp;7;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Back&nbsp;:=&nbsp;(Range&nbsp;-&nbsp;EffectiveLineWidth)&nbsp;shr&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;I&nbsp;:=&nbsp;FirstGridCell&nbsp;to&nbsp;GridCellCount&nbsp;-&nbsp;1&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(Line,&nbsp;GetExtent(I));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Line&nbsp;&gt;&nbsp;GridBoundary&nbsp;then&nbsp;Break;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(Pos&nbsp;&gt;=&nbsp;Line&nbsp;-&nbsp;Back)&nbsp;and&nbsp;(Pos&nbsp;&lt;=&nbsp;Line&nbsp;-&nbsp;Back&nbsp;+&nbsp;Range)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;State&nbsp;:=&nbsp;NewState;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SizingPos&nbsp;:=&nbsp;Line;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SizingOfs&nbsp;:=&nbsp;Line&nbsp;-&nbsp;Pos;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Index&nbsp;:=&nbsp;I;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(Line,&nbsp;EffectiveLineWidth);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(GridBoundary&nbsp;=&nbsp;GridExtent)&nbsp;and&nbsp;(Pos&nbsp;&gt;=&nbsp;GridExtent&nbsp;-&nbsp;Back)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;(Pos&nbsp;&lt;=&nbsp;GridExtent)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;State&nbsp;:=&nbsp;NewState;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SizingPos&nbsp;:=&nbsp;GridExtent;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SizingOfs&nbsp;:=&nbsp;GridExtent&nbsp;-&nbsp;Pos;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Index&nbsp;:=&nbsp;LastFullVisibleCell&nbsp;+&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;function&nbsp;XOutsideHorzFixedBoundary:&nbsp;Boolean;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;FixedInfo&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;UseRightToLeftAlignment&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;X&nbsp;&gt;&nbsp;Horz.FixedBoundary<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;X&nbsp;&lt;&nbsp;ClientWidth&nbsp;-&nbsp;Horz.FixedBoundary;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;function&nbsp;XOutsideOrEqualHorzFixedBoundary:&nbsp;Boolean;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;FixedInfo&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;UseRightToLeftAlignment&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;X&nbsp;&gt;=&nbsp;Horz.FixedBoundary<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;X&nbsp;&lt;=&nbsp;ClientWidth&nbsp;-&nbsp;Horz.FixedBoundary;<br>&nbsp;&nbsp;end;<br><br><br>var<br>&nbsp;&nbsp;EffectiveOptions:&nbsp;TGridOptions;<br>begin<br>&nbsp;&nbsp;State&nbsp;:=&nbsp;gsNormal;<br>&nbsp;&nbsp;Index&nbsp;:=&nbsp;-1;<br>&nbsp;&nbsp;EffectiveOptions&nbsp;:=&nbsp;Options;<br>&nbsp;&nbsp;if&nbsp;csDesigning&nbsp;in&nbsp;ComponentState&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;EffectiveOptions&nbsp;:=&nbsp;EffectiveOptions&nbsp;+&nbsp;DesignOptionsBoost;<br>&nbsp;&nbsp;if&nbsp;[goColSizing,&nbsp;goRowSizing]&nbsp;*&nbsp;EffectiveOptions&nbsp;&lt;&gt;&nbsp;[]&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;FixedInfo&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Vert.GridExtent&nbsp;:=&nbsp;ClientHeight;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Horz.GridExtent&nbsp;:=&nbsp;ClientWidth;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(XOutsideHorzFixedBoundary)&nbsp;and&nbsp;(goColSizing&nbsp;in&nbsp;EffectiveOptions)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Y&nbsp;&gt;=&nbsp;Vert.FixedBoundary&nbsp;then&nbsp;Exit;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CalcAxisState(Horz,&nbsp;X,&nbsp;gsColSizing);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;(Y&nbsp;&gt;&nbsp;Vert.FixedBoundary)&nbsp;and&nbsp;(goRowSizing&nbsp;in&nbsp;EffectiveOptions)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;XOutsideOrEqualHorzFixedBoundary&nbsp;then&nbsp;Exit;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CalcAxisState(Vert,&nbsp;Y,&nbsp;gsRowSizing);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.ChangeGridOrientation(RightToLeftOrientation:&nbsp;Boolean);<br>var<br>&nbsp;&nbsp;Org:&nbsp;TPoint;<br>&nbsp;&nbsp;Ext:&nbsp;TPoint;<br>begin<br>&nbsp;&nbsp;if&nbsp;RightToLeftOrientation&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Org&nbsp;:=&nbsp;Point(ClientWidth,0);<br>&nbsp;&nbsp;&nbsp;&nbsp;Ext&nbsp;:=&nbsp;Point(-1,1);<br>&nbsp;&nbsp;&nbsp;&nbsp;SetMapMode(Canvas.Handle,&nbsp;mm_Anisotropic);<br>&nbsp;&nbsp;&nbsp;&nbsp;SetWindowOrgEx(Canvas.Handle,&nbsp;Org.X,&nbsp;Org.Y,&nbsp;nil);<br>&nbsp;&nbsp;&nbsp;&nbsp;SetViewportExtEx(Canvas.Handle,&nbsp;ClientWidth,&nbsp;ClientHeight,&nbsp;nil);<br>&nbsp;&nbsp;&nbsp;&nbsp;SetWindowExtEx(Canvas.Handle,&nbsp;Ext.X*ClientWidth,&nbsp;Ext.Y*ClientHeight,&nbsp;nil);<br>&nbsp;&nbsp;end<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Org&nbsp;:=&nbsp;Point(0,0);<br>&nbsp;&nbsp;&nbsp;&nbsp;Ext&nbsp;:=&nbsp;Point(1,1);<br>&nbsp;&nbsp;&nbsp;&nbsp;SetMapMode(Canvas.Handle,&nbsp;mm_Anisotropic);<br>&nbsp;&nbsp;&nbsp;&nbsp;SetWindowOrgEx(Canvas.Handle,&nbsp;Org.X,&nbsp;Org.Y,&nbsp;nil);<br>&nbsp;&nbsp;&nbsp;&nbsp;SetViewportExtEx(Canvas.Handle,&nbsp;ClientWidth,&nbsp;ClientHeight,&nbsp;nil);<br>&nbsp;&nbsp;&nbsp;&nbsp;SetWindowExtEx(Canvas.Handle,&nbsp;Ext.X*ClientWidth,&nbsp;Ext.Y*ClientHeight,&nbsp;nil);<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.ChangeSize(NewColCount,&nbsp;NewRowCount:&nbsp;Longint);<br>var<br>&nbsp;&nbsp;OldColCount,&nbsp;OldRowCount:&nbsp;Longint;<br>&nbsp;&nbsp;OldDrawInfo:&nbsp;TGridDrawInfo;<br><br>&nbsp;&nbsp;procedure&nbsp;MinRedraw(const&nbsp;OldInfo,&nbsp;NewInfo:&nbsp;TGridAxisDrawInfo;&nbsp;Axis:&nbsp;Integer);<br>&nbsp;&nbsp;var<br>&nbsp;&nbsp;&nbsp;&nbsp;R:&nbsp;TRect;<br>&nbsp;&nbsp;&nbsp;&nbsp;First:&nbsp;Integer;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;First&nbsp;:=&nbsp;Min(OldInfo.LastFullVisibleCell,&nbsp;NewInfo.LastFullVisibleCell);<br>&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Get&nbsp;the&nbsp;rectangle&nbsp;around&nbsp;the&nbsp;leftmost&nbsp;or&nbsp;topmost&nbsp;cell&nbsp;in&nbsp;the&nbsp;target&nbsp;range.<br>&nbsp;&nbsp;&nbsp;&nbsp;R&nbsp;:=&nbsp;CellRect(First&nbsp;and&nbsp;not&nbsp;Axis,&nbsp;First&nbsp;and&nbsp;Axis);<br>&nbsp;&nbsp;&nbsp;&nbsp;R.Bottom&nbsp;:=&nbsp;Height;<br>&nbsp;&nbsp;&nbsp;&nbsp;R.Right&nbsp;:=&nbsp;Width;<br>&nbsp;&nbsp;&nbsp;&nbsp;Windows.InvalidateRect(Handle,&nbsp;@R,&nbsp;False);<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;procedure&nbsp;DoChange;<br>&nbsp;&nbsp;var<br>&nbsp;&nbsp;&nbsp;&nbsp;Coord:&nbsp;TGridCoord;<br>&nbsp;&nbsp;&nbsp;&nbsp;NewDrawInfo:&nbsp;TGridDrawInfo;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;FColWidths&nbsp;&lt;&gt;&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UpdateExtents(FColWidths,&nbsp;ColCount,&nbsp;DefaultColWidth);<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;FTabStops&nbsp;&lt;&gt;&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UpdateExtents(FTabStops,&nbsp;ColCount,&nbsp;Integer(True));<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;FRowHeights&nbsp;&lt;&gt;&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UpdateExtents(FRowHeights,&nbsp;RowCount,&nbsp;DefaultRowHeight);<br>&nbsp;&nbsp;&nbsp;&nbsp;Coord&nbsp;:=&nbsp;FCurrent;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Row&nbsp;&gt;=&nbsp;RowCount&nbsp;then&nbsp;Coord.Y&nbsp;:=&nbsp;RowCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Col&nbsp;&gt;=&nbsp;ColCount&nbsp;then&nbsp;Coord.X&nbsp;:=&nbsp;ColCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(FCurrent.X&nbsp;&lt;&gt;&nbsp;Coord.X)&nbsp;or&nbsp;(FCurrent.Y&nbsp;&lt;&gt;&nbsp;Coord.Y)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MoveCurrent(Coord.X,&nbsp;Coord.Y,&nbsp;True,&nbsp;True);<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(FAnchor.X&nbsp;&lt;&gt;&nbsp;Coord.X)&nbsp;or&nbsp;(FAnchor.Y&nbsp;&lt;&gt;&nbsp;Coord.Y)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MoveAnchor(Coord);<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;VirtualView&nbsp;or<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(LeftCol&nbsp;&lt;&gt;&nbsp;OldDrawInfo.Horz.FirstGridCell)&nbsp;or<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(TopRow&nbsp;&lt;&gt;&nbsp;OldDrawInfo.Vert.FirstGridCell)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InvalidateGrid<br>&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;HandleAllocated&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CalcDrawInfo(NewDrawInfo);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MinRedraw(OldDrawInfo.Horz,&nbsp;NewDrawInfo.Horz,&nbsp;0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MinRedraw(OldDrawInfo.Vert,&nbsp;NewDrawInfo.Vert,&nbsp;-1);<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;UpdateScrollRange;<br>&nbsp;&nbsp;&nbsp;&nbsp;SizeChanged(OldColCount,&nbsp;OldRowCount);<br>&nbsp;&nbsp;end;<br><br>begin<br>&nbsp;&nbsp;if&nbsp;HandleAllocated&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;CalcDrawInfo(OldDrawInfo);<br>&nbsp;&nbsp;OldColCount&nbsp;:=&nbsp;FColCount;<br>&nbsp;&nbsp;OldRowCount&nbsp;:=&nbsp;FRowCount;<br>&nbsp;&nbsp;FColCount&nbsp;:=&nbsp;NewColCount;<br>&nbsp;&nbsp;FRowCount&nbsp;:=&nbsp;NewRowCount;<br>&nbsp;&nbsp;if&nbsp;FixedCols&nbsp;&gt;&nbsp;NewColCount&nbsp;then&nbsp;FFixedCols&nbsp;:=&nbsp;NewColCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;if&nbsp;FixedRows&nbsp;&gt;&nbsp;NewRowCount&nbsp;then&nbsp;FFixedRows&nbsp;:=&nbsp;NewRowCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;try<br>&nbsp;&nbsp;&nbsp;&nbsp;DoChange;<br>&nbsp;&nbsp;except<br>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Could&nbsp;not&nbsp;change&nbsp;size&nbsp;so&nbsp;try&nbsp;to&nbsp;clean&nbsp;up&nbsp;by&nbsp;setting&nbsp;the&nbsp;size&nbsp;back&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;FColCount&nbsp;:=&nbsp;OldColCount;<br>&nbsp;&nbsp;&nbsp;&nbsp;FRowCount&nbsp;:=&nbsp;OldRowCount;<br>&nbsp;&nbsp;&nbsp;&nbsp;DoChange;<br>&nbsp;&nbsp;&nbsp;&nbsp;InvalidateGrid;<br>&nbsp;&nbsp;&nbsp;&nbsp;raise;<br>&nbsp;&nbsp;end;<br>end;<br><br>{&nbsp;Will&nbsp;move&nbsp;TopLeft&nbsp;so&nbsp;that&nbsp;Coord&nbsp;is&nbsp;in&nbsp;view&nbsp;}<br>procedure&nbsp;TCustomPZGrid.ClampInView(const&nbsp;Coord:&nbsp;TGridCoord);<br>var<br>&nbsp;&nbsp;DrawInfo:&nbsp;TGridDrawInfo;<br>&nbsp;&nbsp;MaxTopLeft:&nbsp;TGridCoord;<br>&nbsp;&nbsp;OldTopLeft:&nbsp;TGridCoord;<br>begin<br>&nbsp;&nbsp;if&nbsp;not&nbsp;HandleAllocated&nbsp;then&nbsp;Exit;<br>&nbsp;&nbsp;CalcDrawInfo(DrawInfo);<br>&nbsp;&nbsp;with&nbsp;DrawInfo,&nbsp;Coord&nbsp;do<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(X&nbsp;&gt;&nbsp;Horz.LastFullVisibleCell)&nbsp;or<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(Y&nbsp;&gt;&nbsp;Vert.LastFullVisibleCell)&nbsp;or&nbsp;(X&nbsp;&lt;&nbsp;LeftCol)&nbsp;or&nbsp;(Y&nbsp;&lt;&nbsp;TopRow)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OldTopLeft&nbsp;:=&nbsp;FTopLeft;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MaxTopLeft&nbsp;:=&nbsp;CalcMaxTopLeft(Coord,&nbsp;DrawInfo);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Update;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;X&nbsp;&lt;&nbsp;LeftCol&nbsp;then&nbsp;FTopLeft.X&nbsp;:=&nbsp;X<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;X&nbsp;&gt;&nbsp;Horz.LastFullVisibleCell&nbsp;then&nbsp;FTopLeft.X&nbsp;:=&nbsp;MaxTopLeft.X;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Y&nbsp;&lt;&nbsp;TopRow&nbsp;then&nbsp;FTopLeft.Y&nbsp;:=&nbsp;Y<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;Y&nbsp;&gt;&nbsp;Vert.LastFullVisibleCell&nbsp;then&nbsp;FTopLeft.Y&nbsp;:=&nbsp;MaxTopLeft.Y;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TopLeftMoved(OldTopLeft);<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.DrawSizingLine(const&nbsp;DrawInfo:&nbsp;TGridDrawInfo);<br>var<br>&nbsp;&nbsp;OldPen:&nbsp;TPen;<br>begin<br>&nbsp;&nbsp;OldPen&nbsp;:=&nbsp;TPen.Create;<br>&nbsp;&nbsp;try<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;Canvas,&nbsp;DrawInfo&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OldPen.Assign(Pen);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pen.Style&nbsp;:=&nbsp;psDot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pen.Mode&nbsp;:=&nbsp;pmXor;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pen.Width&nbsp;:=&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;FGridState&nbsp;=&nbsp;gsRowSizing&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;UseRightToLeftAlignment&nbsp;then&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MoveTo(Horz.GridExtent,&nbsp;FSizingPos);&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LineTo(Horz.GridExtent&nbsp;-&nbsp;Horz.GridBoundary,&nbsp;FSizingPos);&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MoveTo(0,&nbsp;FSizingPos);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LineTo(Horz.GridBoundary,&nbsp;FSizingPos);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MoveTo(FSizingPos,&nbsp;0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LineTo(FSizingPos,&nbsp;Vert.GridBoundary);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;finally<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pen&nbsp;:=&nbsp;OldPen;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;finally<br>&nbsp;&nbsp;&nbsp;&nbsp;OldPen.Free;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.DrawMove;<br>var<br>&nbsp;&nbsp;OldPen:&nbsp;TPen;<br>&nbsp;&nbsp;Pos:&nbsp;Integer;<br>&nbsp;&nbsp;R:&nbsp;TRect;<br>begin<br>&nbsp;&nbsp;OldPen&nbsp;:=&nbsp;TPen.Create;<br>&nbsp;&nbsp;try<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;Canvas&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OldPen.Assign(Pen);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pen.Style&nbsp;:=&nbsp;psDot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pen.Mode&nbsp;:=&nbsp;pmXor;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pen.Width&nbsp;:=&nbsp;5;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;FGridState&nbsp;=&nbsp;gsRowMoving&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;R&nbsp;:=&nbsp;CellRect(0,&nbsp;FMovePos);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;FMovePos&nbsp;&gt;&nbsp;FMoveIndex&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pos&nbsp;:=&nbsp;R.Bottom&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pos&nbsp;:=&nbsp;R.Top;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MoveTo(0,&nbsp;Pos);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LineTo(ClientWidth,&nbsp;Pos);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;R&nbsp;:=&nbsp;CellRect(FMovePos,&nbsp;0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;FMovePos&nbsp;&gt;&nbsp;FMoveIndex&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;UseRightToLeftAlignment&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pos&nbsp;:=&nbsp;R.Right<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pos&nbsp;:=&nbsp;R.Left<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;UseRightToLeftAlignment&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pos&nbsp;:=&nbsp;R.Left<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Pos&nbsp;:=&nbsp;R.Right;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MoveTo(Pos,&nbsp;0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LineTo(Pos,&nbsp;ClientHeight);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;finally<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Canvas.Pen&nbsp;:=&nbsp;OldPen;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;finally<br>&nbsp;&nbsp;&nbsp;&nbsp;OldPen.Free;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.FocusCell(ACol,&nbsp;ARow:&nbsp;Longint;&nbsp;MoveAnchor:&nbsp;Boolean);<br>begin<br>&nbsp;&nbsp;MoveCurrent(ACol,&nbsp;ARow,&nbsp;MoveAnchor,&nbsp;True);<br>&nbsp;&nbsp;UpdateEdit;<br>&nbsp;&nbsp;Click;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.GridRectToScreenRect(GridRect:&nbsp;TGridRect;<br>&nbsp;&nbsp;var&nbsp;ScreenRect:&nbsp;TRect;&nbsp;IncludeLine:&nbsp;Boolean);<br><br>&nbsp;&nbsp;function&nbsp;LinePos(const&nbsp;AxisInfo:&nbsp;TGridAxisDrawInfo;&nbsp;Line:&nbsp;Integer):&nbsp;Integer;<br>&nbsp;&nbsp;var<br>&nbsp;&nbsp;&nbsp;&nbsp;Start,&nbsp;I:&nbsp;Longint;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;AxisInfo&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Line&nbsp;&lt;&nbsp;FixedCellCount&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start&nbsp;:=&nbsp;0<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Line&nbsp;&gt;=&nbsp;FirstGridCell&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;FixedBoundary;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start&nbsp;:=&nbsp;FirstGridCell;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;I&nbsp;:=&nbsp;Start&nbsp;to&nbsp;Line&nbsp;-&nbsp;1&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(Result,&nbsp;GetExtent(I)&nbsp;+&nbsp;EffectiveLineWidth);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Result&nbsp;&gt;&nbsp;GridExtent&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;function&nbsp;CalcAxis(const&nbsp;AxisInfo:&nbsp;TGridAxisDrawInfo;<br>&nbsp;&nbsp;&nbsp;&nbsp;GridRectMin,&nbsp;GridRectMax:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;var&nbsp;ScreenRectMin,&nbsp;ScreenRectMax:&nbsp;Integer):&nbsp;Boolean;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;False;<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;AxisInfo&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(GridRectMin&nbsp;&gt;=&nbsp;FixedCellCount)&nbsp;and&nbsp;(GridRectMin&nbsp;&lt;&nbsp;FirstGridCell)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;GridRectMax&nbsp;&lt;&nbsp;FirstGridCell&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FillChar(ScreenRect,&nbsp;SizeOf(ScreenRect),&nbsp;0);&nbsp;{&nbsp;erase&nbsp;partial&nbsp;results&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GridRectMin&nbsp;:=&nbsp;FirstGridCell;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;GridRectMax&nbsp;&gt;&nbsp;LastFullVisibleCell&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GridRectMax&nbsp;:=&nbsp;LastFullVisibleCell;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;GridRectMax&nbsp;&lt;&nbsp;GridCellCount&nbsp;-&nbsp;1&nbsp;then&nbsp;Inc(GridRectMax);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;LinePos(AxisInfo,&nbsp;GridRectMax)&nbsp;=&nbsp;0&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dec(GridRectMax);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ScreenRectMin&nbsp;:=&nbsp;LinePos(AxisInfo,&nbsp;GridRectMin);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ScreenRectMax&nbsp;:=&nbsp;LinePos(AxisInfo,&nbsp;GridRectMax);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ScreenRectMax&nbsp;=&nbsp;0&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ScreenRectMax&nbsp;:=&nbsp;ScreenRectMin&nbsp;+&nbsp;GetExtent(GridRectMin)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(ScreenRectMax,&nbsp;GetExtent(GridRectMax));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ScreenRectMax&nbsp;&gt;&nbsp;GridExtent&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ScreenRectMax&nbsp;:=&nbsp;GridExtent;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;IncludeLine&nbsp;then&nbsp;Inc(ScreenRectMax,&nbsp;EffectiveLineWidth);<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;end;<br><br>var<br>&nbsp;&nbsp;DrawInfo:&nbsp;TGridDrawInfo;<br>&nbsp;&nbsp;Hold:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;FillChar(ScreenRect,&nbsp;SizeOf(ScreenRect),&nbsp;0);<br>&nbsp;&nbsp;if&nbsp;(GridRect.Left&nbsp;&gt;&nbsp;GridRect.Right)&nbsp;or&nbsp;(GridRect.Top&nbsp;&gt;&nbsp;GridRect.Bottom)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;Exit;<br>&nbsp;&nbsp;CalcDrawInfo(DrawInfo);<br>&nbsp;&nbsp;with&nbsp;DrawInfo&nbsp;do<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;GridRect.Left&nbsp;&gt;&nbsp;Horz.LastFullVisibleCell&nbsp;+&nbsp;1&nbsp;then&nbsp;Exit;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;GridRect.Top&nbsp;&gt;&nbsp;Vert.LastFullVisibleCell&nbsp;+&nbsp;1&nbsp;then&nbsp;Exit;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;CalcAxis(Horz,&nbsp;GridRect.Left,&nbsp;GridRect.Right,&nbsp;ScreenRect.Left,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ScreenRect.Right)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CalcAxis(Vert,&nbsp;GridRect.Top,&nbsp;GridRect.Bottom,&nbsp;ScreenRect.Top,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ScreenRect.Bottom);<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;if&nbsp;UseRightToLeftAlignment&nbsp;and&nbsp;(Canvas.CanvasOrientation&nbsp;=&nbsp;coLeftToRight)&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Hold&nbsp;:=&nbsp;ScreenRect.Left;<br>&nbsp;&nbsp;&nbsp;&nbsp;ScreenRect.Left&nbsp;:=&nbsp;ClientWidth&nbsp;-&nbsp;ScreenRect.Right;<br>&nbsp;&nbsp;&nbsp;&nbsp;ScreenRect.Right&nbsp;:=&nbsp;ClientWidth&nbsp;-&nbsp;Hold;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.Initialize;<br>begin<br>&nbsp;&nbsp;FTopLeft.X&nbsp;:=&nbsp;FixedCols;<br>&nbsp;&nbsp;FTopLeft.Y&nbsp;:=&nbsp;FixedRows;<br>&nbsp;&nbsp;FCurrent&nbsp;:=&nbsp;FTopLeft;<br>&nbsp;&nbsp;FAnchor&nbsp;:=&nbsp;FCurrent;<br>&nbsp;&nbsp;if&nbsp;goRowSelect&nbsp;in&nbsp;Options&nbsp;then&nbsp;FAnchor.X&nbsp;:=&nbsp;ColCount&nbsp;-&nbsp;1;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.InvalidateCell(ACol,&nbsp;ARow:&nbsp;Longint);<br>var<br>&nbsp;&nbsp;Rect:&nbsp;TGridRect;<br>begin<br>&nbsp;&nbsp;Rect.Top&nbsp;:=&nbsp;ARow;<br>&nbsp;&nbsp;Rect.Left&nbsp;:=&nbsp;ACol;<br>&nbsp;&nbsp;Rect.Bottom&nbsp;:=&nbsp;ARow;<br>&nbsp;&nbsp;Rect.Right&nbsp;:=&nbsp;ACol;<br>&nbsp;&nbsp;InvalidateRect(Rect);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.InvalidateCol(ACol:&nbsp;Longint);<br>var<br>&nbsp;&nbsp;Rect:&nbsp;TGridRect;<br>begin<br>&nbsp;&nbsp;if&nbsp;not&nbsp;HandleAllocated&nbsp;then&nbsp;Exit;<br>&nbsp;&nbsp;Rect.Top&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;Rect.Left&nbsp;:=&nbsp;ACol;<br>&nbsp;&nbsp;Rect.Bottom&nbsp;:=&nbsp;VisibleRowCount+1;<br>&nbsp;&nbsp;Rect.Right&nbsp;:=&nbsp;ACol;<br>&nbsp;&nbsp;InvalidateRect(Rect);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.InvalidateRow(ARow:&nbsp;Longint);<br>var<br>&nbsp;&nbsp;Rect:&nbsp;TGridRect;<br>begin<br>&nbsp;&nbsp;if&nbsp;not&nbsp;HandleAllocated&nbsp;then&nbsp;Exit;<br>&nbsp;&nbsp;Rect.Top&nbsp;:=&nbsp;ARow;<br>&nbsp;&nbsp;Rect.Left&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;Rect.Bottom&nbsp;:=&nbsp;ARow;<br>&nbsp;&nbsp;Rect.Right&nbsp;:=&nbsp;VisibleColCount+1;<br>&nbsp;&nbsp;InvalidateRect(Rect);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.InvalidateGrid;<br>begin<br>&nbsp;&nbsp;Invalidate;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.InvalidateRect(ARect:&nbsp;TGridRect);<br>var<br>&nbsp;&nbsp;InvalidRect:&nbsp;TRect;<br>begin<br>&nbsp;&nbsp;if&nbsp;not&nbsp;HandleAllocated&nbsp;then&nbsp;Exit;<br>&nbsp;&nbsp;GridRectToScreenRect(ARect,&nbsp;InvalidRect,&nbsp;True);<br>&nbsp;&nbsp;Windows.InvalidateRect(Handle,&nbsp;@InvalidRect,&nbsp;False);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.ModifyScrollBar(ScrollBar,&nbsp;ScrollCode,&nbsp;Pos:&nbsp;Cardinal;<br>&nbsp;&nbsp;UseRightToLeft:&nbsp;Boolean);<br>var<br>&nbsp;&nbsp;NewTopLeft,&nbsp;MaxTopLeft:&nbsp;TGridCoord;<br>&nbsp;&nbsp;DrawInfo:&nbsp;TGridDrawInfo;<br>&nbsp;&nbsp;RTLFactor:&nbsp;Integer;<br><br>&nbsp;&nbsp;function&nbsp;Min:&nbsp;Longint;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ScrollBar&nbsp;=&nbsp;SB_HORZ&nbsp;then&nbsp;Result&nbsp;:=&nbsp;FixedCols<br>&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;Result&nbsp;:=&nbsp;FixedRows;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;function&nbsp;Max:&nbsp;Longint;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ScrollBar&nbsp;=&nbsp;SB_HORZ&nbsp;then&nbsp;Result&nbsp;:=&nbsp;MaxTopLeft.X<br>&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;Result&nbsp;:=&nbsp;MaxTopLeft.Y;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;function&nbsp;PageUp:&nbsp;Longint;<br>&nbsp;&nbsp;var<br>&nbsp;&nbsp;&nbsp;&nbsp;MaxTopLeft:&nbsp;TGridCoord;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;MaxTopLeft&nbsp;:=&nbsp;CalcMaxTopLeft(FTopLeft,&nbsp;DrawInfo);<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ScrollBar&nbsp;=&nbsp;SB_HORZ&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;FTopLeft.X&nbsp;-&nbsp;MaxTopLeft.X&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;FTopLeft.Y&nbsp;-&nbsp;MaxTopLeft.Y;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Result&nbsp;&lt;&nbsp;1&nbsp;then&nbsp;Result&nbsp;:=&nbsp;1;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;function&nbsp;PageDown:&nbsp;Longint;<br>&nbsp;&nbsp;var<br>&nbsp;&nbsp;&nbsp;&nbsp;DrawInfo:&nbsp;TGridDrawInfo;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;CalcDrawInfo(DrawInfo);<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;DrawInfo&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ScrollBar&nbsp;=&nbsp;SB_HORZ&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;Horz.LastFullVisibleCell&nbsp;-&nbsp;FTopLeft.X&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;Vert.LastFullVisibleCell&nbsp;-&nbsp;FTopLeft.Y;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Result&nbsp;&lt;&nbsp;1&nbsp;then&nbsp;Result&nbsp;:=&nbsp;1;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;function&nbsp;CalcScrollBar(Value,&nbsp;ARTLFactor:&nbsp;Longint):&nbsp;Longint;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;Value;<br>&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;ScrollCode&nbsp;of<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SB_LINEUP:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dec(Result,&nbsp;ARTLFactor);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SB_LINEDOWN:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(Result,&nbsp;ARTLFactor);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SB_PAGEUP:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dec(Result,&nbsp;PageUp&nbsp;*&nbsp;ARTLFactor);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SB_PAGEDOWN:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(Result,&nbsp;PageDown&nbsp;*&nbsp;ARTLFactor);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SB_THUMBPOSITION,&nbsp;SB_THUMBTRACK:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(goThumbTracking&nbsp;in&nbsp;Options)&nbsp;or&nbsp;(ScrollCode&nbsp;=&nbsp;SB_THUMBPOSITION)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(not&nbsp;UseRightToLeftAlignment)&nbsp;or&nbsp;(ARTLFactor&nbsp;=&nbsp;1)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;Min&nbsp;+&nbsp;LongMulDiv(Pos,&nbsp;Max&nbsp;-&nbsp;Min,&nbsp;MaxShortInt)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;Max&nbsp;-&nbsp;LongMulDiv(Pos,&nbsp;Max&nbsp;-&nbsp;Min,&nbsp;MaxShortInt);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SB_BOTTOM:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;Max;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SB_TOP:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;Min;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;procedure&nbsp;ModifyPixelScrollBar(Code,&nbsp;Pos:&nbsp;Cardinal);<br>&nbsp;&nbsp;var<br>&nbsp;&nbsp;&nbsp;&nbsp;NewOffset:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;OldOffset:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;R:&nbsp;TGridRect;<br>&nbsp;&nbsp;&nbsp;&nbsp;GridSpace,&nbsp;ColWidth:&nbsp;Integer;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;NewOffset&nbsp;:=&nbsp;FColOffset;<br>&nbsp;&nbsp;&nbsp;&nbsp;ColWidth&nbsp;:=&nbsp;ColWidths[DrawInfo.Horz.FirstGridCell];<br>&nbsp;&nbsp;&nbsp;&nbsp;GridSpace&nbsp;:=&nbsp;ClientWidth&nbsp;-&nbsp;DrawInfo.Horz.FixedBoundary;<br>&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;Code&nbsp;of<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SB_LINEUP:&nbsp;Dec(NewOffset,&nbsp;Canvas.TextWidth('0')&nbsp;*&nbsp;RTLFactor);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SB_LINEDOWN:&nbsp;Inc(NewOffset,&nbsp;Canvas.TextWidth('0')&nbsp;*&nbsp;RTLFactor);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SB_PAGEUP:&nbsp;Dec(NewOffset,&nbsp;GridSpace&nbsp;*&nbsp;RTLFactor);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SB_PAGEDOWN:&nbsp;Inc(NewOffset,&nbsp;GridSpace&nbsp;*&nbsp;RTLFactor);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SB_THUMBPOSITION,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SB_THUMBTRACK:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(goThumbTracking&nbsp;in&nbsp;Options)&nbsp;or&nbsp;(Code&nbsp;=&nbsp;SB_THUMBPOSITION)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;UseRightToLeftAlignment&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewOffset&nbsp;:=&nbsp;Pos<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewOffset&nbsp;:=&nbsp;Max&nbsp;-&nbsp;Integer(Pos);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SB_BOTTOM:&nbsp;NewOffset&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SB_TOP:&nbsp;NewOffset&nbsp;:=&nbsp;ColWidth&nbsp;-&nbsp;GridSpace;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;NewOffset&nbsp;&lt;&nbsp;0&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewOffset&nbsp;:=&nbsp;0<br>&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;NewOffset&nbsp;&gt;=&nbsp;ColWidth&nbsp;-&nbsp;GridSpace&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewOffset&nbsp;:=&nbsp;ColWidth&nbsp;-&nbsp;GridSpace;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;NewOffset&nbsp;&lt;&gt;&nbsp;FColOffset&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OldOffset&nbsp;:=&nbsp;FColOffset;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FColOffset&nbsp;:=&nbsp;NewOffset;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ScrollData(OldOffset&nbsp;-&nbsp;NewOffset,&nbsp;0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FillChar(R,&nbsp;SizeOf(R),&nbsp;0);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;R.Bottom&nbsp;:=&nbsp;FixedRows;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InvalidateRect(R);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Update;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UpdateScrollPos;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br><br>var<br>&nbsp;&nbsp;Temp:&nbsp;Longint;<br>begin<br>&nbsp;&nbsp;if&nbsp;(not&nbsp;UseRightToLeftAlignment)&nbsp;or&nbsp;(not&nbsp;UseRightToLeft)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;RTLFactor&nbsp;:=&nbsp;1<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;RTLFactor&nbsp;:=&nbsp;-1;<br>&nbsp;&nbsp;if&nbsp;Visible&nbsp;and&nbsp;CanFocus&nbsp;and&nbsp;TabStop&nbsp;and&nbsp;not&nbsp;(csDesigning&nbsp;in&nbsp;ComponentState)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;SetFocus;<br>&nbsp;&nbsp;CalcDrawInfo(DrawInfo);<br>&nbsp;&nbsp;if&nbsp;(ScrollBar&nbsp;=&nbsp;SB_HORZ)&nbsp;and&nbsp;(ColCount&nbsp;=&nbsp;1)&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;ModifyPixelScrollBar(ScrollCode,&nbsp;Pos);<br>&nbsp;&nbsp;&nbsp;&nbsp;Exit;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;MaxTopLeft.X&nbsp;:=&nbsp;ColCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;MaxTopLeft.Y&nbsp;:=&nbsp;RowCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;MaxTopLeft&nbsp;:=&nbsp;CalcMaxTopLeft(MaxTopLeft,&nbsp;DrawInfo);<br>&nbsp;&nbsp;NewTopLeft&nbsp;:=&nbsp;FTopLeft;<br>&nbsp;&nbsp;if&nbsp;ScrollBar&nbsp;=&nbsp;SB_HORZ&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;repeat<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Temp&nbsp;:=&nbsp;NewTopLeft.X;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewTopLeft.X&nbsp;:=&nbsp;CalcScrollBar(NewTopLeft.X,&nbsp;RTLFactor);<br>&nbsp;&nbsp;&nbsp;&nbsp;until&nbsp;(NewTopLeft.X&nbsp;&lt;=&nbsp;FixedCols)&nbsp;or&nbsp;(NewTopLeft.X&nbsp;&gt;=&nbsp;MaxTopLeft.X)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;or&nbsp;(ColWidths[NewTopLeft.X]&nbsp;&gt;&nbsp;0)&nbsp;or&nbsp;(Temp&nbsp;=&nbsp;NewTopLeft.X)<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;repeat<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Temp&nbsp;:=&nbsp;NewTopLeft.Y;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewTopLeft.Y&nbsp;:=&nbsp;CalcScrollBar(NewTopLeft.Y,&nbsp;1);<br>&nbsp;&nbsp;&nbsp;&nbsp;until&nbsp;(NewTopLeft.Y&nbsp;&lt;=&nbsp;FixedRows)&nbsp;or&nbsp;(NewTopLeft.Y&nbsp;&gt;=&nbsp;MaxTopLeft.Y)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;or&nbsp;(RowHeights[NewTopLeft.Y]&nbsp;&gt;&nbsp;0)&nbsp;or&nbsp;(Temp&nbsp;=&nbsp;NewTopLeft.Y);<br>&nbsp;&nbsp;NewTopLeft.X&nbsp;:=&nbsp;Math.Max(FixedCols,&nbsp;Math.Min(MaxTopLeft.X,&nbsp;NewTopLeft.X));<br>&nbsp;&nbsp;NewTopLeft.Y&nbsp;:=&nbsp;Math.Max(FixedRows,&nbsp;Math.Min(MaxTopLeft.Y,&nbsp;NewTopLeft.Y));<br>&nbsp;&nbsp;if&nbsp;(NewTopLeft.X&nbsp;&lt;&gt;&nbsp;FTopLeft.X)&nbsp;or&nbsp;(NewTopLeft.Y&nbsp;&lt;&gt;&nbsp;FTopLeft.Y)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;MoveTopLeft(NewTopLeft.X,&nbsp;NewTopLeft.Y);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.MoveAdjust(var&nbsp;CellPos:&nbsp;Longint;&nbsp;FromIndex,&nbsp;ToIndex:&nbsp;Longint);<br>var<br>&nbsp;&nbsp;Min,&nbsp;Max:&nbsp;Longint;<br>begin<br>&nbsp;&nbsp;if&nbsp;CellPos&nbsp;=&nbsp;FromIndex&nbsp;then&nbsp;CellPos&nbsp;:=&nbsp;ToIndex<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Min&nbsp;:=&nbsp;FromIndex;<br>&nbsp;&nbsp;&nbsp;&nbsp;Max&nbsp;:=&nbsp;ToIndex;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;FromIndex&nbsp;&gt;&nbsp;ToIndex&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Min&nbsp;:=&nbsp;ToIndex;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Max&nbsp;:=&nbsp;FromIndex;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(CellPos&nbsp;&gt;=&nbsp;Min)&nbsp;and&nbsp;(CellPos&nbsp;&lt;=&nbsp;Max)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;FromIndex&nbsp;&gt;&nbsp;ToIndex&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(CellPos)&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dec(CellPos);<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.MoveAnchor(const&nbsp;NewAnchor:&nbsp;TGridCoord);<br>var<br>&nbsp;&nbsp;OldSel:&nbsp;TGridRect;<br>begin<br>&nbsp;&nbsp;if&nbsp;[goRangeSelect,&nbsp;goEditing]&nbsp;*&nbsp;Options&nbsp;=&nbsp;[goRangeSelect]&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;OldSel&nbsp;:=&nbsp;Selection;<br>&nbsp;&nbsp;&nbsp;&nbsp;FAnchor&nbsp;:=&nbsp;NewAnchor;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;goRowSelect&nbsp;in&nbsp;Options&nbsp;then&nbsp;FAnchor.X&nbsp;:=&nbsp;ColCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;ClampInView(NewAnchor);<br>&nbsp;&nbsp;&nbsp;&nbsp;SelectionMoved(OldSel);<br>&nbsp;&nbsp;end<br>&nbsp;&nbsp;else&nbsp;MoveCurrent(NewAnchor.X,&nbsp;NewAnchor.Y,&nbsp;True,&nbsp;True);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.MoveCurrent(ACol,&nbsp;ARow:&nbsp;Longint;&nbsp;MoveAnchor,<br>&nbsp;&nbsp;Show:&nbsp;Boolean);<br>var<br>&nbsp;&nbsp;OldSel:&nbsp;TGridRect;<br>&nbsp;&nbsp;OldCurrent:&nbsp;TGridCoord;<br>begin<br>&nbsp;&nbsp;if&nbsp;(ACol&nbsp;&lt;&nbsp;0)&nbsp;or&nbsp;(ARow&nbsp;&lt;&nbsp;0)&nbsp;or&nbsp;(ACol&nbsp;&gt;=&nbsp;ColCount)&nbsp;or&nbsp;(ARow&nbsp;&gt;=&nbsp;RowCount)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;InvalidOp(SIndexOutOfRange);<br>&nbsp;&nbsp;if&nbsp;SelectCell(ACol,&nbsp;ARow)&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;OldSel&nbsp;:=&nbsp;Selection;<br>&nbsp;&nbsp;&nbsp;&nbsp;OldCurrent&nbsp;:=&nbsp;FCurrent;<br>&nbsp;&nbsp;&nbsp;&nbsp;FCurrent.X&nbsp;:=&nbsp;ACol;<br>&nbsp;&nbsp;&nbsp;&nbsp;FCurrent.Y&nbsp;:=&nbsp;ARow;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;(goAlwaysShowEditor&nbsp;in&nbsp;Options)&nbsp;then&nbsp;HideEditor;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;MoveAnchor&nbsp;or&nbsp;not&nbsp;(goRangeSelect&nbsp;in&nbsp;Options)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FAnchor&nbsp;:=&nbsp;FCurrent;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;goRowSelect&nbsp;in&nbsp;Options&nbsp;then&nbsp;FAnchor.X&nbsp;:=&nbsp;ColCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;goRowSelect&nbsp;in&nbsp;Options&nbsp;then&nbsp;FCurrent.X&nbsp;:=&nbsp;FixedCols;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Show&nbsp;then&nbsp;ClampInView(FCurrent);<br>&nbsp;&nbsp;&nbsp;&nbsp;SelectionMoved(OldSel);<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;OldCurrent&nbsp;do&nbsp;InvalidateCell(X,&nbsp;Y);<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;FCurrent&nbsp;do&nbsp;InvalidateCell(ACol,&nbsp;ARow);<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.MoveTopLeft(ALeft,&nbsp;ATop:&nbsp;Longint);<br>var<br>&nbsp;&nbsp;OldTopLeft:&nbsp;TGridCoord;<br>begin<br>&nbsp;&nbsp;if&nbsp;(ALeft&nbsp;=&nbsp;FTopLeft.X)&nbsp;and&nbsp;(ATop&nbsp;=&nbsp;FTopLeft.Y)&nbsp;then&nbsp;Exit;<br>&nbsp;&nbsp;Update;<br>&nbsp;&nbsp;OldTopLeft&nbsp;:=&nbsp;FTopLeft;<br>&nbsp;&nbsp;FTopLeft.X&nbsp;:=&nbsp;ALeft;<br>&nbsp;&nbsp;FTopLeft.Y&nbsp;:=&nbsp;ATop;<br>&nbsp;&nbsp;TopLeftMoved(OldTopLeft);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.ResizeCol(Index:&nbsp;Longint;&nbsp;OldSize,&nbsp;NewSize:&nbsp;Integer);<br>begin<br>&nbsp;&nbsp;InvalidateGrid;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.ResizeRow(Index:&nbsp;Longint;&nbsp;OldSize,&nbsp;NewSize:&nbsp;Integer);<br>begin<br>&nbsp;&nbsp;InvalidateGrid;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.SelectionMoved(const&nbsp;OldSel:&nbsp;TGridRect);<br>var<br>&nbsp;&nbsp;OldRect,&nbsp;NewRect:&nbsp;TRect;<br>&nbsp;&nbsp;AXorRects:&nbsp;TXorRects;<br>&nbsp;&nbsp;I:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;if&nbsp;not&nbsp;HandleAllocated&nbsp;then&nbsp;Exit;<br>&nbsp;&nbsp;GridRectToScreenRect(OldSel,&nbsp;OldRect,&nbsp;True);<br>&nbsp;&nbsp;GridRectToScreenRect(Selection,&nbsp;NewRect,&nbsp;True);<br>&nbsp;&nbsp;XorRects(OldRect,&nbsp;NewRect,&nbsp;AXorRects);<br>&nbsp;&nbsp;for&nbsp;I&nbsp;:=&nbsp;Low(AXorRects)&nbsp;to&nbsp;High(AXorRects)&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;Windows.InvalidateRect(Handle,&nbsp;@AXorRects,&nbsp;False);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.ScrollDataInfo(DX,&nbsp;DY:&nbsp;Integer;<br>&nbsp;&nbsp;var&nbsp;DrawInfo:&nbsp;TGridDrawInfo);<br>var<br>&nbsp;&nbsp;ScrollArea:&nbsp;TRect;<br>&nbsp;&nbsp;ScrollFlags:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;with&nbsp;DrawInfo&nbsp;do<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;ScrollFlags&nbsp;:=&nbsp;SW_INVALIDATE;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;DefaultDrawing&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ScrollFlags&nbsp;:=&nbsp;ScrollFlags&nbsp;or&nbsp;SW_ERASE;<br>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Scroll&nbsp;the&nbsp;area&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;DY&nbsp;=&nbsp;0&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Scroll&nbsp;both&nbsp;the&nbsp;column&nbsp;titles&nbsp;and&nbsp;data&nbsp;area&nbsp;at&nbsp;the&nbsp;same&nbsp;time&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;UseRightToLeftAlignment&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ScrollArea&nbsp;:=&nbsp;Rect(Horz.FixedBoundary,&nbsp;0,&nbsp;Horz.GridExtent,&nbsp;Vert.GridExtent)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ScrollArea&nbsp;:=&nbsp;Rect(ClientWidth&nbsp;-&nbsp;Horz.GridExtent,&nbsp;0,&nbsp;ClientWidth&nbsp;-&nbsp;Horz.FixedBoundary,&nbsp;Vert.GridExtent);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DX&nbsp;:=&nbsp;-DX;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ScrollWindowEx(Handle,&nbsp;DX,&nbsp;0,&nbsp;@ScrollArea,&nbsp;@ScrollArea,&nbsp;0,&nbsp;nil,&nbsp;ScrollFlags);<br>&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;DX&nbsp;=&nbsp;0&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Scroll&nbsp;both&nbsp;the&nbsp;row&nbsp;titles&nbsp;and&nbsp;data&nbsp;area&nbsp;at&nbsp;the&nbsp;same&nbsp;time&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ScrollArea&nbsp;:=&nbsp;Rect(0,&nbsp;Vert.FixedBoundary,&nbsp;Horz.GridExtent,&nbsp;Vert.GridExtent);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ScrollWindowEx(Handle,&nbsp;0,&nbsp;DY,&nbsp;@ScrollArea,&nbsp;@ScrollArea,&nbsp;0,&nbsp;nil,&nbsp;ScrollFlags);<br>&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Scroll&nbsp;titles&nbsp;and&nbsp;data&nbsp;area&nbsp;separately&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Column&nbsp;titles&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ScrollArea&nbsp;:=&nbsp;Rect(Horz.FixedBoundary,&nbsp;0,&nbsp;Horz.GridExtent,&nbsp;Vert.FixedBoundary);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ScrollWindowEx(Handle,&nbsp;DX,&nbsp;0,&nbsp;@ScrollArea,&nbsp;@ScrollArea,&nbsp;0,&nbsp;nil,&nbsp;ScrollFlags);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Row&nbsp;titles&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ScrollArea&nbsp;:=&nbsp;Rect(0,&nbsp;Vert.FixedBoundary,&nbsp;Horz.FixedBoundary,&nbsp;Vert.GridExtent);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ScrollWindowEx(Handle,&nbsp;0,&nbsp;DY,&nbsp;@ScrollArea,&nbsp;@ScrollArea,&nbsp;0,&nbsp;nil,&nbsp;ScrollFlags);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Data&nbsp;area&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ScrollArea&nbsp;:=&nbsp;Rect(Horz.FixedBoundary,&nbsp;Vert.FixedBoundary,&nbsp;Horz.GridExtent,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Vert.GridExtent);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ScrollWindowEx(Handle,&nbsp;DX,&nbsp;DY,&nbsp;@ScrollArea,&nbsp;@ScrollArea,&nbsp;0,&nbsp;nil,&nbsp;ScrollFlags);<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;if&nbsp;goRowSelect&nbsp;in&nbsp;Options&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;InvalidateRect(Selection);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.ScrollData(DX,&nbsp;DY:&nbsp;Integer);<br>var<br>&nbsp;&nbsp;DrawInfo:&nbsp;TGridDrawInfo;<br>begin<br>&nbsp;&nbsp;CalcDrawInfo(DrawInfo);<br>&nbsp;&nbsp;ScrollDataInfo(DX,&nbsp;DY,&nbsp;DrawInfo);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.TopLeftMoved(const&nbsp;OldTopLeft:&nbsp;TGridCoord);<br><br>&nbsp;&nbsp;function&nbsp;CalcScroll(const&nbsp;AxisInfo:&nbsp;TGridAxisDrawInfo;<br>&nbsp;&nbsp;&nbsp;&nbsp;OldPos,&nbsp;CurrentPos:&nbsp;Integer;&nbsp;var&nbsp;Amount:&nbsp;Longint):&nbsp;Boolean;<br>&nbsp;&nbsp;var<br>&nbsp;&nbsp;&nbsp;&nbsp;Start,&nbsp;Stop:&nbsp;Longint;<br>&nbsp;&nbsp;&nbsp;&nbsp;I:&nbsp;Longint;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;False;<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;AxisInfo&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;OldPos&nbsp;&lt;&nbsp;CurrentPos&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start&nbsp;:=&nbsp;OldPos;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Stop&nbsp;:=&nbsp;CurrentPos;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Start&nbsp;:=&nbsp;CurrentPos;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Stop&nbsp;:=&nbsp;OldPos;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Amount&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;I&nbsp;:=&nbsp;Start&nbsp;to&nbsp;Stop&nbsp;-&nbsp;1&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(Amount,&nbsp;GetExtent(I)&nbsp;+&nbsp;EffectiveLineWidth);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Amount&nbsp;&gt;&nbsp;(GridBoundary&nbsp;-&nbsp;FixedBoundary)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Scroll&nbsp;amount&nbsp;too&nbsp;big,&nbsp;redraw&nbsp;the&nbsp;whole&nbsp;thing&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InvalidateGrid;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;OldPos&nbsp;&lt;&nbsp;CurrentPos&nbsp;then&nbsp;Amount&nbsp;:=&nbsp;-Amount;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;end;<br><br>var<br>&nbsp;&nbsp;DrawInfo:&nbsp;TGridDrawInfo;<br>&nbsp;&nbsp;Delta:&nbsp;TGridCoord;<br>begin<br>&nbsp;&nbsp;UpdateScrollPos;<br>&nbsp;&nbsp;CalcDrawInfo(DrawInfo);<br>&nbsp;&nbsp;if&nbsp;CalcScroll(DrawInfo.Horz,&nbsp;OldTopLeft.X,&nbsp;FTopLeft.X,&nbsp;Delta.X)&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;CalcScroll(DrawInfo.Vert,&nbsp;OldTopLeft.Y,&nbsp;FTopLeft.Y,&nbsp;Delta.Y)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;ScrollDataInfo(Delta.X,&nbsp;Delta.Y,&nbsp;DrawInfo);<br>&nbsp;&nbsp;TopLeftChanged;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.UpdateScrollPos;<br>var<br>&nbsp;&nbsp;DrawInfo:&nbsp;TGridDrawInfo;<br>&nbsp;&nbsp;MaxTopLeft:&nbsp;TGridCoord;<br>&nbsp;&nbsp;GridSpace,&nbsp;ColWidth:&nbsp;Integer;<br><br>&nbsp;&nbsp;procedure&nbsp;SetScroll(Code:&nbsp;Word;&nbsp;Value:&nbsp;Integer);<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;UseRightToLeftAlignment&nbsp;and&nbsp;(Code&nbsp;=&nbsp;SB_HORZ)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ColCount&nbsp;&lt;&gt;&nbsp;1&nbsp;then&nbsp;Value&nbsp;:=&nbsp;MaxShortInt&nbsp;-&nbsp;Value<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Value&nbsp;:=&nbsp;(ColWidth&nbsp;-&nbsp;GridSpace)&nbsp;-&nbsp;Value;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;GetScrollPos(Handle,&nbsp;Code)&nbsp;&lt;&gt;&nbsp;Value&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SetScrollPos(Handle,&nbsp;Code,&nbsp;Value,&nbsp;True);<br>&nbsp;&nbsp;end;<br><br>begin<br>&nbsp;&nbsp;if&nbsp;(not&nbsp;HandleAllocated)&nbsp;or&nbsp;(ScrollBars&nbsp;=&nbsp;ssNone)&nbsp;then&nbsp;Exit;<br>&nbsp;&nbsp;CalcDrawInfo(DrawInfo);<br>&nbsp;&nbsp;MaxTopLeft.X&nbsp;:=&nbsp;ColCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;MaxTopLeft.Y&nbsp;:=&nbsp;RowCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;MaxTopLeft&nbsp;:=&nbsp;CalcMaxTopLeft(MaxTopLeft,&nbsp;DrawInfo);<br>&nbsp;&nbsp;if&nbsp;ScrollBars&nbsp;in&nbsp;[ssHorizontal,&nbsp;ssBoth]&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ColCount&nbsp;=&nbsp;1&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ColWidth&nbsp;:=&nbsp;ColWidths[DrawInfo.Horz.FirstGridCell];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GridSpace&nbsp;:=&nbsp;ClientWidth&nbsp;-&nbsp;DrawInfo.Horz.FixedBoundary;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(FColOffset&nbsp;&gt;&nbsp;0)&nbsp;and&nbsp;(GridSpace&nbsp;&gt;&nbsp;(ColWidth&nbsp;-&nbsp;FColOffset))&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ModifyScrollbar(SB_HORZ,&nbsp;SB_THUMBPOSITION,&nbsp;ColWidth&nbsp;-&nbsp;GridSpace,&nbsp;True)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SetScroll(SB_HORZ,&nbsp;FColOffset)<br>&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SetScroll(SB_HORZ,&nbsp;LongMulDiv(FTopLeft.X&nbsp;-&nbsp;FixedCols,&nbsp;MaxShortInt,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MaxTopLeft.X&nbsp;-&nbsp;FixedCols));<br>&nbsp;&nbsp;if&nbsp;ScrollBars&nbsp;in&nbsp;[ssVertical,&nbsp;ssBoth]&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;SetScroll(SB_VERT,&nbsp;LongMulDiv(FTopLeft.Y&nbsp;-&nbsp;FixedRows,&nbsp;MaxShortInt,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MaxTopLeft.Y&nbsp;-&nbsp;FixedRows));<br>end;<br><br>procedure&nbsp;TCustomPZGrid.UpdateScrollRange;<br>var<br>&nbsp;&nbsp;MaxTopLeft,&nbsp;OldTopLeft:&nbsp;TGridCoord;<br>&nbsp;&nbsp;DrawInfo:&nbsp;TGridDrawInfo;<br>&nbsp;&nbsp;OldScrollBars:&nbsp;TScrollStyle;<br>&nbsp;&nbsp;Updated:&nbsp;Boolean;<br><br>&nbsp;&nbsp;procedure&nbsp;DoUpdate;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;Updated&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Update;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Updated&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;function&nbsp;ScrollBarVisible(Code:&nbsp;Word):&nbsp;Boolean;<br>&nbsp;&nbsp;var<br>&nbsp;&nbsp;&nbsp;&nbsp;Min,&nbsp;Max:&nbsp;Integer;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;False;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(ScrollBars&nbsp;=&nbsp;ssBoth)&nbsp;or<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;((Code&nbsp;=&nbsp;SB_HORZ)&nbsp;and&nbsp;(ScrollBars&nbsp;=&nbsp;ssHorizontal))&nbsp;or<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;((Code&nbsp;=&nbsp;SB_VERT)&nbsp;and&nbsp;(ScrollBars&nbsp;=&nbsp;ssVertical))&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GetScrollRange(Handle,&nbsp;Code,&nbsp;Min,&nbsp;Max);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;Min&nbsp;&lt;&gt;&nbsp;Max;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;procedure&nbsp;CalcSizeInfo;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;CalcDrawInfoXY(DrawInfo,&nbsp;DrawInfo.Horz.GridExtent,&nbsp;DrawInfo.Vert.GridExtent);<br>&nbsp;&nbsp;&nbsp;&nbsp;MaxTopLeft.X&nbsp;:=&nbsp;ColCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;MaxTopLeft.Y&nbsp;:=&nbsp;RowCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;MaxTopLeft&nbsp;:=&nbsp;CalcMaxTopLeft(MaxTopLeft,&nbsp;DrawInfo);<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;procedure&nbsp;SetAxisRange(var&nbsp;Max,&nbsp;Old,&nbsp;Current:&nbsp;Longint;&nbsp;Code:&nbsp;Word;<br>&nbsp;&nbsp;&nbsp;&nbsp;Fixeds:&nbsp;Integer);<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;CalcSizeInfo;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Fixeds&nbsp;&lt;&nbsp;Max&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SetScrollRange(Handle,&nbsp;Code,&nbsp;0,&nbsp;MaxShortInt,&nbsp;True)<br>&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SetScrollRange(Handle,&nbsp;Code,&nbsp;0,&nbsp;0,&nbsp;True);<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Old&nbsp;&gt;&nbsp;Max&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DoUpdate;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Current&nbsp;:=&nbsp;Max;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;procedure&nbsp;SetHorzRange;<br>&nbsp;&nbsp;var<br>&nbsp;&nbsp;&nbsp;&nbsp;Range:&nbsp;Integer;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;OldScrollBars&nbsp;in&nbsp;[ssHorizontal,&nbsp;ssBoth]&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ColCount&nbsp;=&nbsp;1&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Range&nbsp;:=&nbsp;ColWidths[0]&nbsp;-&nbsp;ClientWidth;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Range&nbsp;&lt;&nbsp;0&nbsp;then&nbsp;Range&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SetScrollRange(Handle,&nbsp;SB_HORZ,&nbsp;0,&nbsp;Range,&nbsp;True);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SetAxisRange(MaxTopLeft.X,&nbsp;OldTopLeft.X,&nbsp;FTopLeft.X,&nbsp;SB_HORZ,&nbsp;FixedCols);<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;procedure&nbsp;SetVertRange;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;OldScrollBars&nbsp;in&nbsp;[ssVertical,&nbsp;ssBoth]&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SetAxisRange(MaxTopLeft.Y,&nbsp;OldTopLeft.Y,&nbsp;FTopLeft.Y,&nbsp;SB_VERT,&nbsp;FixedRows);<br>&nbsp;&nbsp;end;<br><br>begin<br>&nbsp;&nbsp;if&nbsp;(ScrollBars&nbsp;=&nbsp;ssNone)&nbsp;or&nbsp;not&nbsp;HandleAllocated&nbsp;or&nbsp;not&nbsp;Showing&nbsp;then&nbsp;Exit;<br>&nbsp;&nbsp;with&nbsp;DrawInfo&nbsp;do<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Horz.GridExtent&nbsp;:=&nbsp;ClientWidth;<br>&nbsp;&nbsp;&nbsp;&nbsp;Vert.GridExtent&nbsp;:=&nbsp;ClientHeight;<br>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Ignore&nbsp;scroll&nbsp;bars&nbsp;for&nbsp;initial&nbsp;calculation&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ScrollBarVisible(SB_HORZ)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(Vert.GridExtent,&nbsp;GetSystemMetrics(SM_CYHSCROLL));<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ScrollBarVisible(SB_VERT)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(Horz.GridExtent,&nbsp;GetSystemMetrics(SM_CXVSCROLL));<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;OldTopLeft&nbsp;:=&nbsp;FTopLeft;<br>&nbsp;&nbsp;{&nbsp;Temporarily&nbsp;mark&nbsp;us&nbsp;as&nbsp;not&nbsp;having&nbsp;scroll&nbsp;bars&nbsp;to&nbsp;avoid&nbsp;recursion&nbsp;}<br>&nbsp;&nbsp;OldScrollBars&nbsp;:=&nbsp;FScrollBars;<br>&nbsp;&nbsp;FScrollBars&nbsp;:=&nbsp;ssNone;<br>&nbsp;&nbsp;Updated&nbsp;:=&nbsp;False;<br>&nbsp;&nbsp;try<br>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Update&nbsp;scrollbars&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;SetHorzRange;<br>&nbsp;&nbsp;&nbsp;&nbsp;DrawInfo.Vert.GridExtent&nbsp;:=&nbsp;ClientHeight;<br>&nbsp;&nbsp;&nbsp;&nbsp;SetVertRange;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;DrawInfo.Horz.GridExtent&nbsp;&lt;&gt;&nbsp;ClientWidth&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawInfo.Horz.GridExtent&nbsp;:=&nbsp;ClientWidth;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SetHorzRange;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;finally<br>&nbsp;&nbsp;&nbsp;&nbsp;FScrollBars&nbsp;:=&nbsp;OldScrollBars;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;UpdateScrollPos;<br>&nbsp;&nbsp;if&nbsp;(FTopLeft.X&nbsp;&lt;&gt;&nbsp;OldTopLeft.X)&nbsp;or&nbsp;(FTopLeft.Y&nbsp;&lt;&gt;&nbsp;OldTopLeft.Y)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;TopLeftMoved(OldTopLeft);<br>end;<br><br>function&nbsp;TCustomPZGrid.CreateEditor:&nbsp;TInplaceEdit;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;TInplaceEdit.Create(Self);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.CreateParams(var&nbsp;Params:&nbsp;TCreateParams);<br>begin<br>&nbsp;&nbsp;inherited&nbsp;CreateParams(Params);<br>&nbsp;&nbsp;with&nbsp;Params&nbsp;do<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Style&nbsp;:=&nbsp;Style&nbsp;or&nbsp;WS_TABSTOP;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;FScrollBars&nbsp;in&nbsp;[ssVertical,&nbsp;ssBoth]&nbsp;then&nbsp;Style&nbsp;:=&nbsp;Style&nbsp;or&nbsp;WS_VSCROLL;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;FScrollBars&nbsp;in&nbsp;[ssHorizontal,&nbsp;ssBoth]&nbsp;then&nbsp;Style&nbsp;:=&nbsp;Style&nbsp;or&nbsp;WS_HSCROLL;<br>&nbsp;&nbsp;&nbsp;&nbsp;WindowClass.style&nbsp;:=&nbsp;CS_DBLCLKS;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;FBorderStyle&nbsp;=&nbsp;bsSingle&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;NewStyleControls&nbsp;and&nbsp;Ctl3D&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Style&nbsp;:=&nbsp;Style&nbsp;and&nbsp;not&nbsp;WS_BORDER;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ExStyle&nbsp;:=&nbsp;ExStyle&nbsp;or&nbsp;WS_EX_CLIENTEDGE;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Style&nbsp;:=&nbsp;Style&nbsp;or&nbsp;WS_BORDER;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.KeyDown(var&nbsp;Key:&nbsp;Word;&nbsp;Shift:&nbsp;TShiftState);<br>var<br>&nbsp;&nbsp;NewTopLeft,&nbsp;NewCurrent,&nbsp;MaxTopLeft:&nbsp;TGridCoord;<br>&nbsp;&nbsp;DrawInfo:&nbsp;TGridDrawInfo;<br>&nbsp;&nbsp;PageWidth,&nbsp;PageHeight:&nbsp;Integer;<br>&nbsp;&nbsp;RTLFactor:&nbsp;Integer;<br>&nbsp;&nbsp;NeedsInvalidating:&nbsp;Boolean;<br><br>&nbsp;&nbsp;procedure&nbsp;CalcPageExtents;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;CalcDrawInfo(DrawInfo);<br>&nbsp;&nbsp;&nbsp;&nbsp;PageWidth&nbsp;:=&nbsp;DrawInfo.Horz.LastFullVisibleCell&nbsp;-&nbsp;LeftCol;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;PageWidth&nbsp;&lt;&nbsp;1&nbsp;then&nbsp;PageWidth&nbsp;:=&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;PageHeight&nbsp;:=&nbsp;DrawInfo.Vert.LastFullVisibleCell&nbsp;-&nbsp;TopRow;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;PageHeight&nbsp;&lt;&nbsp;1&nbsp;then&nbsp;PageHeight&nbsp;:=&nbsp;1;<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;procedure&nbsp;Restrict(var&nbsp;Coord:&nbsp;TGridCoord;&nbsp;MinX,&nbsp;MinY,&nbsp;MaxX,&nbsp;MaxY:&nbsp;Longint);<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;Coord&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;X&nbsp;&gt;&nbsp;MaxX&nbsp;then&nbsp;X&nbsp;:=&nbsp;MaxX<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;X&nbsp;&lt;&nbsp;MinX&nbsp;then&nbsp;X&nbsp;:=&nbsp;MinX;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Y&nbsp;&gt;&nbsp;MaxY&nbsp;then&nbsp;Y&nbsp;:=&nbsp;MaxY<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;Y&nbsp;&lt;&nbsp;MinY&nbsp;then&nbsp;Y&nbsp;:=&nbsp;MinY;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br><br>begin<br>&nbsp;&nbsp;inherited&nbsp;KeyDown(Key,&nbsp;Shift);<br>&nbsp;&nbsp;NeedsInvalidating&nbsp;:=&nbsp;False;<br>&nbsp;&nbsp;if&nbsp;not&nbsp;CanGridAcceptKey(Key,&nbsp;Shift)&nbsp;then&nbsp;Key&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;if&nbsp;not&nbsp;UseRightToLeftAlignment&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;RTLFactor&nbsp;:=&nbsp;1<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;RTLFactor&nbsp;:=&nbsp;-1;<br>&nbsp;&nbsp;NewCurrent&nbsp;:=&nbsp;FCurrent;<br>&nbsp;&nbsp;NewTopLeft&nbsp;:=&nbsp;FTopLeft;<br>&nbsp;&nbsp;CalcPageExtents;<br>&nbsp;&nbsp;if&nbsp;ssCtrl&nbsp;in&nbsp;Shift&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;Key&nbsp;of<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VK_UP:&nbsp;Dec(NewTopLeft.Y);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VK_DOWN:&nbsp;Inc(NewTopLeft.Y);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VK_LEFT:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;(goRowSelect&nbsp;in&nbsp;Options)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dec(NewCurrent.X,&nbsp;PageWidth&nbsp;*&nbsp;RTLFactor);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dec(NewTopLeft.X,&nbsp;PageWidth&nbsp;*&nbsp;RTLFactor);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VK_RIGHT:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;(goRowSelect&nbsp;in&nbsp;Options)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(NewCurrent.X,&nbsp;PageWidth&nbsp;*&nbsp;RTLFactor);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(NewTopLeft.X,&nbsp;PageWidth&nbsp;*&nbsp;RTLFactor);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VK_RETURN:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;(goRowSelect&nbsp;in&nbsp;Options)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(NewCurrent.X,&nbsp;PageWidth&nbsp;*&nbsp;RTLFactor);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(NewTopLeft.X,&nbsp;PageWidth&nbsp;*&nbsp;RTLFactor);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VK_PRIOR:&nbsp;NewCurrent.Y&nbsp;:=&nbsp;TopRow;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VK_NEXT:&nbsp;NewCurrent.Y&nbsp;:=&nbsp;DrawInfo.Vert.LastFullVisibleCell;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VK_HOME:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewCurrent.X&nbsp;:=&nbsp;FixedCols;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewCurrent.Y&nbsp;:=&nbsp;FixedRows;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NeedsInvalidating&nbsp;:=&nbsp;UseRightToLeftAlignment;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VK_END:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewCurrent.X&nbsp;:=&nbsp;ColCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewCurrent.Y&nbsp;:=&nbsp;RowCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NeedsInvalidating&nbsp;:=&nbsp;UseRightToLeftAlignment;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;Key&nbsp;of<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VK_UP:&nbsp;Dec(NewCurrent.Y);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VK_DOWN:&nbsp;Inc(NewCurrent.Y);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VK_LEFT:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;goRowSelect&nbsp;in&nbsp;Options&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dec(NewCurrent.Y,&nbsp;RTLFactor)&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dec(NewCurrent.X,&nbsp;RTLFactor);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VK_RIGHT:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;goRowSelect&nbsp;in&nbsp;Options&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(NewCurrent.Y,&nbsp;RTLFactor)&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(NewCurrent.X=3)&nbsp;and&nbsp;(NewCurrent.Y&lt;65536)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewCurrent.X:=0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewCurrent.Y:=NewCurrent.Y+1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(NewCurrent.X,&nbsp;RTLFactor);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VK_RETURN:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;goRowSelect&nbsp;in&nbsp;Options&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(NewCurrent.Y,&nbsp;RTLFactor)&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(NewCurrent.X=3)&nbsp;and&nbsp;(NewCurrent.Y&lt;65536)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewCurrent.X:=0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewCurrent.Y:=NewCurrent.Y+1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(NewCurrent.X,&nbsp;RTLFactor);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VK_NEXT:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(NewCurrent.Y,&nbsp;PageHeight);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(NewTopLeft.Y,&nbsp;PageHeight);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VK_PRIOR:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dec(NewCurrent.Y,&nbsp;PageHeight);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dec(NewTopLeft.Y,&nbsp;PageHeight);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VK_HOME:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;goRowSelect&nbsp;in&nbsp;Options&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewCurrent.Y&nbsp;:=&nbsp;FixedRows&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewCurrent.X&nbsp;:=&nbsp;FixedCols;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VK_END:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;goRowSelect&nbsp;in&nbsp;Options&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewCurrent.Y&nbsp;:=&nbsp;RowCount&nbsp;-&nbsp;1&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewCurrent.X&nbsp;:=&nbsp;ColCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VK_TAB:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;(ssAlt&nbsp;in&nbsp;Shift)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;repeat<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ssShift&nbsp;in&nbsp;Shift&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dec(NewCurrent.X);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;NewCurrent.X&nbsp;&lt;&nbsp;FixedCols&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewCurrent.X&nbsp;:=&nbsp;ColCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dec(NewCurrent.Y);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;NewCurrent.Y&nbsp;&lt;&nbsp;FixedRows&nbsp;then&nbsp;NewCurrent.Y&nbsp;:=&nbsp;RowCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Shift&nbsp;:=&nbsp;[];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(NewCurrent.X);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;NewCurrent.X&nbsp;&gt;=&nbsp;ColCount&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewCurrent.X&nbsp;:=&nbsp;FixedCols;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(NewCurrent.Y);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;NewCurrent.Y&nbsp;&gt;=&nbsp;RowCount&nbsp;then&nbsp;NewCurrent.Y&nbsp;:=&nbsp;FixedRows;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;until&nbsp;TabStops[NewCurrent.X]&nbsp;or&nbsp;(NewCurrent.X&nbsp;=&nbsp;FCurrent.X);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VK_F2:&nbsp;EditorMode&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;MaxTopLeft.X&nbsp;:=&nbsp;ColCount&nbsp;;<br>&nbsp;&nbsp;//MaxTopLeft.X&nbsp;:=&nbsp;ColCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;MaxTopLeft.Y&nbsp;:=&nbsp;RowCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;MaxTopLeft&nbsp;:=&nbsp;CalcMaxTopLeft(MaxTopLeft,&nbsp;DrawInfo);<br>&nbsp;&nbsp;Restrict(NewTopLeft,&nbsp;FixedCols,&nbsp;FixedRows,&nbsp;MaxTopLeft.X,&nbsp;MaxTopLeft.Y);<br>&nbsp;&nbsp;if&nbsp;(NewTopLeft.X&nbsp;&lt;&gt;&nbsp;LeftCol)&nbsp;or&nbsp;(NewTopLeft.Y&nbsp;&lt;&gt;&nbsp;TopRow)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;MoveTopLeft(NewTopLeft.X,&nbsp;NewTopLeft.Y);<br>&nbsp;&nbsp;Restrict(NewCurrent,&nbsp;FixedCols,&nbsp;FixedRows,&nbsp;ColCount&nbsp;-&nbsp;1,&nbsp;RowCount&nbsp;-&nbsp;1);<br>&nbsp;&nbsp;if&nbsp;(NewCurrent.X&nbsp;&lt;&gt;&nbsp;Col)&nbsp;or&nbsp;(NewCurrent.Y&nbsp;&lt;&gt;&nbsp;Row)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;FocusCell(NewCurrent.X,&nbsp;NewCurrent.Y,&nbsp;not&nbsp;(ssShift&nbsp;in&nbsp;Shift));<br>&nbsp;&nbsp;if&nbsp;NeedsInvalidating&nbsp;then&nbsp;Invalidate;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.KeyPress(var&nbsp;Key:&nbsp;Char);<br>begin<br>&nbsp;&nbsp;inherited&nbsp;KeyPress(Key);<br>&nbsp;&nbsp;if&nbsp;not&nbsp;(goAlwaysShowEditor&nbsp;in&nbsp;Options)&nbsp;and&nbsp;(Key&nbsp;=&nbsp;#13)&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;FEditorMode&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HideEditor&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ShowEditor;<br>&nbsp;&nbsp;&nbsp;&nbsp;Key&nbsp;:=&nbsp;#0;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.MouseDown(Button:&nbsp;TMouseButton;&nbsp;Shift:&nbsp;TShiftState;<br>&nbsp;&nbsp;X,&nbsp;Y:&nbsp;Integer);<br>var<br>&nbsp;&nbsp;CellHit:&nbsp;TGridCoord;<br>&nbsp;&nbsp;DrawInfo:&nbsp;TGridDrawInfo;<br>&nbsp;&nbsp;MoveDrawn:&nbsp;Boolean;<br>begin<br>&nbsp;&nbsp;MoveDrawn&nbsp;:=&nbsp;False;<br>&nbsp;&nbsp;HideEdit;<br>&nbsp;&nbsp;if&nbsp;not&nbsp;(csDesigning&nbsp;in&nbsp;ComponentState)&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;(CanFocus&nbsp;or&nbsp;(GetParentForm(Self)&nbsp;=&nbsp;nil))&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;SetFocus;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;IsActiveControl&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MouseCapture&nbsp;:=&nbsp;False;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;if&nbsp;(Button&nbsp;=&nbsp;mbLeft)&nbsp;and&nbsp;(ssDouble&nbsp;in&nbsp;Shift)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;DblClick<br>&nbsp;&nbsp;else&nbsp;if&nbsp;Button&nbsp;=&nbsp;mbLeft&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;CalcDrawInfo(DrawInfo);<br>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Check&nbsp;grid&nbsp;sizing&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;CalcSizingState(X,&nbsp;Y,&nbsp;FGridState,&nbsp;FSizingIndex,&nbsp;FSizingPos,&nbsp;FSizingOfs,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawInfo);<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;FGridState&nbsp;&lt;&gt;&nbsp;gsNormal&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(FGridState&nbsp;=&nbsp;gsColSizing)&nbsp;and&nbsp;UseRightToLeftAlignment&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FSizingPos&nbsp;:=&nbsp;ClientWidth&nbsp;-&nbsp;FSizingPos;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawSizingLine(DrawInfo);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;CellHit&nbsp;:=&nbsp;CalcCoordFromPoint(X,&nbsp;Y,&nbsp;DrawInfo);<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(CellHit.X&nbsp;&gt;=&nbsp;FixedCols)&nbsp;and&nbsp;(CellHit.Y&nbsp;&gt;=&nbsp;FixedRows)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;goEditing&nbsp;in&nbsp;Options&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(CellHit.X&nbsp;=&nbsp;FCurrent.X)&nbsp;and&nbsp;(CellHit.Y&nbsp;=&nbsp;FCurrent.Y)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ShowEditor<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MoveCurrent(CellHit.X,&nbsp;CellHit.Y,&nbsp;True,&nbsp;True);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UpdateEdit;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Click;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FGridState&nbsp;:=&nbsp;gsSelecting;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SetTimer(Handle,&nbsp;1,&nbsp;60,&nbsp;nil);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ssShift&nbsp;in&nbsp;Shift&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MoveAnchor(CellHit)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MoveCurrent(CellHit.X,&nbsp;CellHit.Y,&nbsp;True,&nbsp;True);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;(goRowMoving&nbsp;in&nbsp;Options)&nbsp;and&nbsp;(CellHit.X&nbsp;&gt;=&nbsp;0)&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(CellHit.X&nbsp;&lt;&nbsp;FixedCols)&nbsp;and&nbsp;(CellHit.Y&nbsp;&gt;=&nbsp;FixedRows)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FMoveIndex&nbsp;:=&nbsp;CellHit.Y;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FMovePos&nbsp;:=&nbsp;FMoveIndex;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;BeginRowDrag(FMoveIndex,&nbsp;FMovePos,&nbsp;Point(X,Y))&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FGridState&nbsp;:=&nbsp;gsRowMoving;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Update;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawMove;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MoveDrawn&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SetTimer(Handle,&nbsp;1,&nbsp;60,&nbsp;nil);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;(goColMoving&nbsp;in&nbsp;Options)&nbsp;and&nbsp;(CellHit.Y&nbsp;&gt;=&nbsp;0)&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(CellHit.Y&nbsp;&lt;&nbsp;FixedRows)&nbsp;and&nbsp;(CellHit.X&nbsp;&gt;=&nbsp;FixedCols)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FMoveIndex&nbsp;:=&nbsp;CellHit.X;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FMovePos&nbsp;:=&nbsp;FMoveIndex;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;BeginColumnDrag(FMoveIndex,&nbsp;FMovePos,&nbsp;Point(X,Y))&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FGridState&nbsp;:=&nbsp;gsColMoving;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Update;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawMove;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MoveDrawn&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SetTimer(Handle,&nbsp;1,&nbsp;60,&nbsp;nil);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;try<br>&nbsp;&nbsp;&nbsp;&nbsp;inherited&nbsp;MouseDown(Button,&nbsp;Shift,&nbsp;X,&nbsp;Y);<br>&nbsp;&nbsp;except<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;MoveDrawn&nbsp;then&nbsp;DrawMove;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.MouseMove(Shift:&nbsp;TShiftState;&nbsp;X,&nbsp;Y:&nbsp;Integer);<br>var<br>&nbsp;&nbsp;DrawInfo:&nbsp;TGridDrawInfo;<br>&nbsp;&nbsp;CellHit:&nbsp;TGridCoord;<br>begin<br>&nbsp;&nbsp;CalcDrawInfo(DrawInfo);<br>&nbsp;&nbsp;case&nbsp;FGridState&nbsp;of<br>&nbsp;&nbsp;&nbsp;&nbsp;gsSelecting,&nbsp;gsColMoving,&nbsp;gsRowMoving:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CellHit&nbsp;:=&nbsp;CalcCoordFromPoint(X,&nbsp;Y,&nbsp;DrawInfo);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(CellHit.X&nbsp;&gt;=&nbsp;FixedCols)&nbsp;and&nbsp;(CellHit.Y&nbsp;&gt;=&nbsp;FixedRows)&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(CellHit.X&nbsp;&lt;=&nbsp;DrawInfo.Horz.LastFullVisibleCell+1)&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(CellHit.Y&nbsp;&lt;=&nbsp;DrawInfo.Vert.LastFullVisibleCell+1)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;FGridState&nbsp;of<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gsSelecting:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;((CellHit.X&nbsp;&lt;&gt;&nbsp;FAnchor.X)&nbsp;or&nbsp;(CellHit.Y&nbsp;&lt;&gt;&nbsp;FAnchor.Y))&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MoveAnchor(CellHit);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gsColMoving:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MoveAndScroll(X,&nbsp;CellHit.X,&nbsp;DrawInfo,&nbsp;DrawInfo.Horz,&nbsp;SB_HORZ,&nbsp;Point(X,Y));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gsRowMoving:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MoveAndScroll(Y,&nbsp;CellHit.Y,&nbsp;DrawInfo,&nbsp;DrawInfo.Vert,&nbsp;SB_VERT,&nbsp;Point(X,Y));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;gsRowSizing,&nbsp;gsColSizing:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawSizingLine(DrawInfo);&nbsp;{&nbsp;XOR&nbsp;it&nbsp;out&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;FGridState&nbsp;=&nbsp;gsRowSizing&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FSizingPos&nbsp;:=&nbsp;Y&nbsp;+&nbsp;FSizingOfs&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FSizingPos&nbsp;:=&nbsp;X&nbsp;+&nbsp;FSizingOfs;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawSizingLine(DrawInfo);&nbsp;{&nbsp;XOR&nbsp;it&nbsp;back&nbsp;in&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;inherited&nbsp;MouseMove(Shift,&nbsp;X,&nbsp;Y);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.MouseUp(Button:&nbsp;TMouseButton;&nbsp;Shift:&nbsp;TShiftState;<br>&nbsp;&nbsp;X,&nbsp;Y:&nbsp;Integer);<br>var<br>&nbsp;&nbsp;DrawInfo:&nbsp;TGridDrawInfo;<br>&nbsp;&nbsp;NewSize:&nbsp;Integer;<br><br>&nbsp;&nbsp;function&nbsp;ResizeLine(const&nbsp;AxisInfo:&nbsp;TGridAxisDrawInfo):&nbsp;Integer;<br>&nbsp;&nbsp;var<br>&nbsp;&nbsp;&nbsp;&nbsp;I:&nbsp;Integer;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;AxisInfo&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;FixedBoundary;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;I&nbsp;:=&nbsp;FirstGridCell&nbsp;to&nbsp;FSizingIndex&nbsp;-&nbsp;1&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(Result,&nbsp;GetExtent(I)&nbsp;+&nbsp;EffectiveLineWidth);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;FSizingPos&nbsp;-&nbsp;Result;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br><br>begin<br>&nbsp;&nbsp;try<br>&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;FGridState&nbsp;of<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gsSelecting:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MouseMove(Shift,&nbsp;X,&nbsp;Y);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;KillTimer(Handle,&nbsp;1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UpdateEdit;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Click;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gsRowSizing,&nbsp;gsColSizing:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CalcDrawInfo(DrawInfo);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawSizingLine(DrawInfo);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(FGridState&nbsp;=&nbsp;gsColSizing)&nbsp;and&nbsp;UseRightToLeftAlignment&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FSizingPos&nbsp;:=&nbsp;ClientWidth&nbsp;-&nbsp;FSizingPos;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;FGridState&nbsp;=&nbsp;gsColSizing&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewSize&nbsp;:=&nbsp;ResizeLine(DrawInfo.Horz);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;NewSize&nbsp;&gt;&nbsp;1&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ColWidths[FSizingIndex]&nbsp;:=&nbsp;NewSize;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UpdateDesigner;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NewSize&nbsp;:=&nbsp;ResizeLine(DrawInfo.Vert);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;NewSize&nbsp;&gt;&nbsp;1&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RowHeights[FSizingIndex]&nbsp;:=&nbsp;NewSize;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UpdateDesigner;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gsColMoving:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawMove;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;KillTimer(Handle,&nbsp;1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;EndColumnDrag(FMoveIndex,&nbsp;FMovePos,&nbsp;Point(X,Y))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;(FMoveIndex&nbsp;&lt;&gt;&nbsp;FMovePos)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MoveColumn(FMoveIndex,&nbsp;FMovePos);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UpdateDesigner;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UpdateEdit;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gsRowMoving:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawMove;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;KillTimer(Handle,&nbsp;1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;EndRowDrag(FMoveIndex,&nbsp;FMovePos,&nbsp;Point(X,Y))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;(FMoveIndex&nbsp;&lt;&gt;&nbsp;FMovePos)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MoveRow(FMoveIndex,&nbsp;FMovePos);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UpdateDesigner;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UpdateEdit;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UpdateEdit;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;inherited&nbsp;MouseUp(Button,&nbsp;Shift,&nbsp;X,&nbsp;Y);<br>&nbsp;&nbsp;finally<br>&nbsp;&nbsp;&nbsp;&nbsp;FGridState&nbsp;:=&nbsp;gsNormal;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.MoveAndScroll(Mouse,&nbsp;CellHit:&nbsp;Integer;<br>&nbsp;&nbsp;var&nbsp;DrawInfo:&nbsp;TGridDrawInfo;&nbsp;var&nbsp;Axis:&nbsp;TGridAxisDrawInfo;<br>&nbsp;&nbsp;ScrollBar:&nbsp;Integer;&nbsp;const&nbsp;MousePt:&nbsp;TPoint);<br>begin<br>&nbsp;&nbsp;if&nbsp;UseRightToLeftAlignment&nbsp;and&nbsp;(ScrollBar&nbsp;=&nbsp;SB_HORZ)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;Mouse&nbsp;:=&nbsp;ClientWidth&nbsp;-&nbsp;Mouse;<br>&nbsp;&nbsp;if&nbsp;(CellHit&nbsp;&lt;&gt;&nbsp;FMovePos)&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;not((FMovePos&nbsp;=&nbsp;Axis.FixedCellCount)&nbsp;and&nbsp;(Mouse&nbsp;&lt;&nbsp;Axis.FixedBoundary))&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;not((FMovePos&nbsp;=&nbsp;Axis.GridCellCount-1)&nbsp;and&nbsp;(Mouse&nbsp;&gt;&nbsp;Axis.GridBoundary))&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;DrawMove;&nbsp;&nbsp;&nbsp;//&nbsp;hide&nbsp;the&nbsp;drag&nbsp;line<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(Mouse&nbsp;&lt;&nbsp;Axis.FixedBoundary)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(FMovePos&nbsp;&gt;&nbsp;Axis.FixedCellCount)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ModifyScrollbar(ScrollBar,&nbsp;SB_LINEUP,&nbsp;0,&nbsp;False);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Update;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CalcDrawInfo(DrawInfo);&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;this&nbsp;changes&nbsp;contents&nbsp;of&nbsp;Axis&nbsp;var<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CellHit&nbsp;:=&nbsp;Axis.FirstGridCell;<br>&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;(Mouse&nbsp;&gt;=&nbsp;Axis.FullVisBoundary)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(FMovePos&nbsp;=&nbsp;Axis.LastFullVisibleCell)&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(FMovePos&nbsp;&lt;&nbsp;Axis.GridCellCount&nbsp;-1)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ModifyScrollBar(Scrollbar,&nbsp;SB_LINEDOWN,&nbsp;0,&nbsp;False);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Update;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CalcDrawInfo(DrawInfo);&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;this&nbsp;changes&nbsp;contents&nbsp;of&nbsp;Axis&nbsp;var<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CellHit&nbsp;:=&nbsp;Axis.LastFullVisibleCell;<br>&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;CellHit&nbsp;&lt;&nbsp;0&nbsp;then&nbsp;CellHit&nbsp;:=&nbsp;FMovePos;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;((FGridState&nbsp;=&nbsp;gsColMoving)&nbsp;and&nbsp;CheckColumnDrag(FMoveIndex,&nbsp;CellHit,&nbsp;MousePt))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;or&nbsp;((FGridState&nbsp;=&nbsp;gsRowMoving)&nbsp;and&nbsp;CheckRowDrag(FMoveIndex,&nbsp;CellHit,&nbsp;MousePt))&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FMovePos&nbsp;:=&nbsp;CellHit;<br>&nbsp;&nbsp;&nbsp;&nbsp;DrawMove;<br>&nbsp;&nbsp;end;<br>end;<br><br>function&nbsp;TCustomPZGrid.GetColWidths(Index:&nbsp;Longint):&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;if&nbsp;(FColWidths&nbsp;=&nbsp;nil)&nbsp;or&nbsp;(Index&nbsp;&gt;=&nbsp;ColCount)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;DefaultColWidth<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;PIntArray(FColWidths)^[Index&nbsp;+&nbsp;1];<br>end;<br><br>function&nbsp;TCustomPZGrid.GetRowHeights(Index:&nbsp;Longint):&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;if&nbsp;(FRowHeights&nbsp;=&nbsp;nil)&nbsp;or&nbsp;(Index&nbsp;&gt;=&nbsp;RowCount)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;DefaultRowHeight<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;PIntArray(FRowHeights)^[Index&nbsp;+&nbsp;1];<br>end;<br><br>function&nbsp;TCustomPZGrid.GetGridWidth:&nbsp;Integer;<br>var<br>&nbsp;&nbsp;DrawInfo:&nbsp;TGridDrawInfo;<br>begin<br>&nbsp;&nbsp;CalcDrawInfo(DrawInfo);<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;DrawInfo.Horz.GridBoundary;<br>end;<br><br>function&nbsp;TCustomPZGrid.GetGridHeight:&nbsp;Integer;<br>var<br>&nbsp;&nbsp;DrawInfo:&nbsp;TGridDrawInfo;<br>begin<br>&nbsp;&nbsp;CalcDrawInfo(DrawInfo);<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;DrawInfo.Vert.GridBoundary;<br>end;<br><br>function&nbsp;TCustomPZGrid.GetSelection:&nbsp;TGridRect;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;GridRect(FCurrent,&nbsp;FAnchor);<br>end;<br><br>function&nbsp;TCustomPZGrid.GetTabStops(Index:&nbsp;Longint):&nbsp;Boolean;<br>begin<br>&nbsp;&nbsp;if&nbsp;FTabStops&nbsp;=&nbsp;nil&nbsp;then&nbsp;Result&nbsp;:=&nbsp;True<br>&nbsp;&nbsp;else&nbsp;Result&nbsp;:=&nbsp;Boolean(PIntArray(FTabStops)^[Index&nbsp;+&nbsp;1]);<br>end;<br><br>function&nbsp;TCustomPZGrid.GetVisibleColCount:&nbsp;Integer;<br>var<br>&nbsp;&nbsp;DrawInfo:&nbsp;TGridDrawInfo;<br>begin<br>&nbsp;&nbsp;CalcDrawInfo(DrawInfo);<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;DrawInfo.Horz.LastFullVisibleCell&nbsp;-&nbsp;LeftCol&nbsp;+&nbsp;1;<br>end;<br><br>function&nbsp;TCustomPZGrid.GetVisibleRowCount:&nbsp;Integer;<br>var<br>&nbsp;&nbsp;DrawInfo:&nbsp;TGridDrawInfo;<br>begin<br>&nbsp;&nbsp;CalcDrawInfo(DrawInfo);<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;DrawInfo.Vert.LastFullVisibleCell&nbsp;-&nbsp;TopRow&nbsp;+&nbsp;1;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.SetBorderStyle(Value:&nbsp;TBorderStyle);<br>begin<br>&nbsp;&nbsp;if&nbsp;FBorderStyle&nbsp;&lt;&gt;&nbsp;Value&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;FBorderStyle&nbsp;:=&nbsp;Value;<br>&nbsp;&nbsp;&nbsp;&nbsp;RecreateWnd;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.SetCol(Value:&nbsp;Longint);<br>begin<br>&nbsp;&nbsp;if&nbsp;Col&nbsp;&lt;&gt;&nbsp;Value&nbsp;then&nbsp;FocusCell(Value,&nbsp;Row,&nbsp;True);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.SetColCount(Value:&nbsp;Longint);<br>begin<br>&nbsp;&nbsp;if&nbsp;FColCount&nbsp;&lt;&gt;&nbsp;Value&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Value&nbsp;&lt;&nbsp;1&nbsp;then&nbsp;Value&nbsp;:=&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Value&nbsp;&lt;=&nbsp;FixedCols&nbsp;then&nbsp;FixedCols&nbsp;:=&nbsp;Value&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;ChangeSize(Value,&nbsp;RowCount);<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;goRowSelect&nbsp;in&nbsp;Options&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FAnchor.X&nbsp;:=&nbsp;ColCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Invalidate;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.SetColWidths(Index:&nbsp;Longint;&nbsp;Value:&nbsp;Integer);<br>begin<br>&nbsp;&nbsp;if&nbsp;FColWidths&nbsp;=&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;UpdateExtents(FColWidths,&nbsp;ColCount,&nbsp;DefaultColWidth);<br>&nbsp;&nbsp;if&nbsp;Index&nbsp;&gt;=&nbsp;ColCount&nbsp;then&nbsp;InvalidOp(SIndexOutOfRange);<br>&nbsp;&nbsp;if&nbsp;Value&nbsp;&lt;&gt;&nbsp;PIntArray(FColWidths)^[Index&nbsp;+&nbsp;1]&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;ResizeCol(Index,&nbsp;PIntArray(FColWidths)^[Index&nbsp;+&nbsp;1],&nbsp;Value);<br>&nbsp;&nbsp;&nbsp;&nbsp;PIntArray(FColWidths)^[Index&nbsp;+&nbsp;1]&nbsp;:=&nbsp;Value;<br>&nbsp;&nbsp;&nbsp;&nbsp;ColWidthsChanged;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.SetDefaultColWidth(Value:&nbsp;Integer);<br>begin<br>&nbsp;&nbsp;if&nbsp;FColWidths&nbsp;&lt;&gt;&nbsp;nil&nbsp;then&nbsp;UpdateExtents(FColWidths,&nbsp;0,&nbsp;0);<br>&nbsp;&nbsp;FDefaultColWidth&nbsp;:=&nbsp;Value;<br>&nbsp;&nbsp;ColWidthsChanged;<br>&nbsp;&nbsp;InvalidateGrid;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.SetDefaultRowHeight(Value:&nbsp;Integer);<br>begin<br>&nbsp;&nbsp;if&nbsp;FRowHeights&nbsp;&lt;&gt;&nbsp;nil&nbsp;then&nbsp;UpdateExtents(FRowHeights,&nbsp;0,&nbsp;0);<br>&nbsp;&nbsp;FDefaultRowHeight&nbsp;:=&nbsp;Value;<br>&nbsp;&nbsp;RowHeightsChanged;<br>&nbsp;&nbsp;InvalidateGrid;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.SetFixedColor(Value:&nbsp;TColor);<br>begin<br>&nbsp;&nbsp;if&nbsp;FFixedColor&nbsp;&lt;&gt;&nbsp;Value&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;FFixedColor&nbsp;:=&nbsp;Value;<br>&nbsp;&nbsp;&nbsp;&nbsp;InvalidateGrid;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.SetFixedCols(Value:&nbsp;Integer);<br>begin<br>&nbsp;&nbsp;if&nbsp;FFixedCols&nbsp;&lt;&gt;&nbsp;Value&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Value&nbsp;&lt;&nbsp;0&nbsp;then&nbsp;InvalidOp(SIndexOutOfRange);<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Value&nbsp;&gt;=&nbsp;ColCount&nbsp;then&nbsp;InvalidOp(SFixedColTooBig);<br>&nbsp;&nbsp;&nbsp;&nbsp;FFixedCols&nbsp;:=&nbsp;Value;<br>&nbsp;&nbsp;&nbsp;&nbsp;Initialize;<br>&nbsp;&nbsp;&nbsp;&nbsp;InvalidateGrid;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.SetFixedRows(Value:&nbsp;Integer);<br>begin<br>&nbsp;&nbsp;if&nbsp;FFixedRows&nbsp;&lt;&gt;&nbsp;Value&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Value&nbsp;&lt;&nbsp;0&nbsp;then&nbsp;InvalidOp(SIndexOutOfRange);<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Value&nbsp;&gt;=&nbsp;RowCount&nbsp;then&nbsp;InvalidOp(SFixedRowTooBig);<br>&nbsp;&nbsp;&nbsp;&nbsp;FFixedRows&nbsp;:=&nbsp;Value;<br>&nbsp;&nbsp;&nbsp;&nbsp;Initialize;<br>&nbsp;&nbsp;&nbsp;&nbsp;InvalidateGrid;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.SetEditorMode(Value:&nbsp;Boolean);<br>begin<br>&nbsp;&nbsp;if&nbsp;not&nbsp;Value&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;HideEditor<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;ShowEditor;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;FInplaceEdit&nbsp;&lt;&gt;&nbsp;nil&nbsp;then&nbsp;FInplaceEdit.Deselect;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.SetGridLineWidth(Value:&nbsp;Integer);<br>begin<br>&nbsp;&nbsp;if&nbsp;FGridLineWidth&nbsp;&lt;&gt;&nbsp;Value&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;FGridLineWidth&nbsp;:=&nbsp;Value;<br>&nbsp;&nbsp;&nbsp;&nbsp;InvalidateGrid;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.SetLeftCol(Value:&nbsp;Longint);<br>begin<br>&nbsp;&nbsp;if&nbsp;FTopLeft.X&nbsp;&lt;&gt;&nbsp;Value&nbsp;then&nbsp;MoveTopLeft(Value,&nbsp;TopRow);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.SetOptions(Value:&nbsp;TGridOptions);<br>begin<br>&nbsp;&nbsp;if&nbsp;FOptions&nbsp;&lt;&gt;&nbsp;Value&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;goRowSelect&nbsp;in&nbsp;Value&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exclude(Value,&nbsp;goAlwaysShowEditor);<br>&nbsp;&nbsp;&nbsp;&nbsp;FOptions&nbsp;:=&nbsp;Value;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;FEditorMode&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;goAlwaysShowEditor&nbsp;in&nbsp;Value&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ShowEditor&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HideEditor;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;goRowSelect&nbsp;in&nbsp;Value&nbsp;then&nbsp;MoveCurrent(Col,&nbsp;Row,&nbsp;&nbsp;True,&nbsp;False);<br>&nbsp;&nbsp;&nbsp;&nbsp;InvalidateGrid;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.SetRow(Value:&nbsp;Longint);<br>begin<br>&nbsp;&nbsp;if&nbsp;Row&nbsp;&lt;&gt;&nbsp;Value&nbsp;then&nbsp;FocusCell(Col,&nbsp;Value,&nbsp;True);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.SetRowCount(Value:&nbsp;Longint);<br>begin<br>&nbsp;&nbsp;if&nbsp;FRowCount&nbsp;&lt;&gt;&nbsp;Value&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Value&nbsp;&lt;&nbsp;1&nbsp;then&nbsp;Value&nbsp;:=&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Value&nbsp;&lt;=&nbsp;FixedRows&nbsp;then&nbsp;FixedRows&nbsp;:=&nbsp;Value&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;ChangeSize(ColCount,&nbsp;Value);<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.SetRowHeights(Index:&nbsp;Longint;&nbsp;Value:&nbsp;Integer);<br>begin<br>&nbsp;&nbsp;if&nbsp;FRowHeights&nbsp;=&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;UpdateExtents(FRowHeights,&nbsp;RowCount,&nbsp;DefaultRowHeight);<br>&nbsp;&nbsp;if&nbsp;Index&nbsp;&gt;=&nbsp;RowCount&nbsp;then&nbsp;InvalidOp(SIndexOutOfRange);<br>&nbsp;&nbsp;if&nbsp;Value&nbsp;&lt;&gt;&nbsp;PIntArray(FRowHeights)^[Index&nbsp;+&nbsp;1]&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;ResizeRow(Index,&nbsp;PIntArray(FRowHeights)^[Index&nbsp;+&nbsp;1],&nbsp;Value);<br>&nbsp;&nbsp;&nbsp;&nbsp;PIntArray(FRowHeights)^[Index&nbsp;+&nbsp;1]&nbsp;:=&nbsp;Value;<br>&nbsp;&nbsp;&nbsp;&nbsp;RowHeightsChanged;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.SetScrollBars(Value:&nbsp;TScrollStyle);<br>begin<br>&nbsp;&nbsp;if&nbsp;FScrollBars&nbsp;&lt;&gt;&nbsp;Value&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;FScrollBars&nbsp;:=&nbsp;Value;<br>&nbsp;&nbsp;&nbsp;&nbsp;RecreateWnd;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.SetSelection(Value:&nbsp;TGridRect);<br>var<br>&nbsp;&nbsp;OldSel:&nbsp;TGridRect;<br>begin<br>&nbsp;&nbsp;OldSel&nbsp;:=&nbsp;Selection;<br>&nbsp;&nbsp;FAnchor&nbsp;:=&nbsp;Value.TopLeft;<br>&nbsp;&nbsp;FCurrent&nbsp;:=&nbsp;Value.BottomRight;<br>&nbsp;&nbsp;SelectionMoved(OldSel);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.SetTabStops(Index:&nbsp;Longint;&nbsp;Value:&nbsp;Boolean);<br>begin<br>&nbsp;&nbsp;if&nbsp;FTabStops&nbsp;=&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;UpdateExtents(FTabStops,&nbsp;ColCount,&nbsp;Integer(True));<br>&nbsp;&nbsp;if&nbsp;Index&nbsp;&gt;=&nbsp;ColCount&nbsp;then&nbsp;InvalidOp(SIndexOutOfRange);<br>&nbsp;&nbsp;PIntArray(FTabStops)^[Index&nbsp;+&nbsp;1]&nbsp;:=&nbsp;Integer(Value);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.SetTopRow(Value:&nbsp;Longint);<br>begin<br>&nbsp;&nbsp;if&nbsp;FTopLeft.Y&nbsp;&lt;&gt;&nbsp;Value&nbsp;then&nbsp;MoveTopLeft(LeftCol,&nbsp;Value);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.HideEdit;<br>begin<br>&nbsp;&nbsp;if&nbsp;FInplaceEdit&nbsp;&lt;&gt;&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;try<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UpdateText;<br>&nbsp;&nbsp;&nbsp;&nbsp;finally<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FInplaceCol&nbsp;:=&nbsp;-1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FInplaceRow&nbsp;:=&nbsp;-1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FInplaceEdit.Hide;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.UpdateEdit;<br><br>&nbsp;&nbsp;procedure&nbsp;UpdateEditor;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;FInplaceCol&nbsp;:=&nbsp;Col;<br>&nbsp;&nbsp;&nbsp;&nbsp;FInplaceRow&nbsp;:=&nbsp;Row;<br>&nbsp;&nbsp;&nbsp;&nbsp;FInplaceEdit.UpdateContents;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;FInplaceEdit.MaxLength&nbsp;=&nbsp;-1&nbsp;then&nbsp;FCanEditModify&nbsp;:=&nbsp;False<br>&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;FCanEditModify&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;&nbsp;&nbsp;FInplaceEdit.SelectAll;<br>&nbsp;&nbsp;end;<br><br>begin<br>&nbsp;&nbsp;if&nbsp;CanEditShow&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;FInplaceEdit&nbsp;=&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FInplaceEdit&nbsp;:=&nbsp;CreateEditor;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FInplaceEdit.SetGrid(Self);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FInplaceEdit.Parent&nbsp;:=&nbsp;Self;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UpdateEditor;<br>&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(Col&nbsp;&lt;&gt;&nbsp;FInplaceCol)&nbsp;or&nbsp;(Row&nbsp;&lt;&gt;&nbsp;FInplaceRow)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HideEdit;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;UpdateEditor;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;CanEditShow&nbsp;then&nbsp;FInplaceEdit.Move(CellRect(Col,&nbsp;Row));<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.UpdateText;<br>begin<br>&nbsp;&nbsp;if&nbsp;(FInplaceCol&nbsp;&lt;&gt;&nbsp;-1)&nbsp;and&nbsp;(FInplaceRow&nbsp;&lt;&gt;&nbsp;-1)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;SetEditText(FInplaceCol,&nbsp;FInplaceRow,&nbsp;FInplaceEdit.Text);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.WMChar(var&nbsp;Msg:&nbsp;TWMChar);<br>begin<br>&nbsp;&nbsp;if&nbsp;(goEditing&nbsp;in&nbsp;Options)&nbsp;and&nbsp;(Char(Msg.CharCode)&nbsp;in&nbsp;[^H,&nbsp;#32..#255])&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;ShowEditorChar(Char(Msg.CharCode))<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;inherited;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.WMCommand(var&nbsp;Message:&nbsp;TWMCommand);<br>begin<br>&nbsp;&nbsp;with&nbsp;Message&nbsp;do<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(FInplaceEdit&nbsp;&lt;&gt;&nbsp;nil)&nbsp;and&nbsp;(Ctl&nbsp;=&nbsp;FInplaceEdit.Handle)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;NotifyCode&nbsp;of<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EN_CHANGE:&nbsp;UpdateText;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.WMGetDlgCode(var&nbsp;Msg:&nbsp;TWMGetDlgCode);<br>begin<br>&nbsp;&nbsp;Msg.Result&nbsp;:=&nbsp;DLGC_WANTARROWS;<br>&nbsp;&nbsp;if&nbsp;goRowSelect&nbsp;in&nbsp;Options&nbsp;then&nbsp;Exit;<br>&nbsp;&nbsp;if&nbsp;goTabs&nbsp;in&nbsp;Options&nbsp;then&nbsp;Msg.Result&nbsp;:=&nbsp;Msg.Result&nbsp;or&nbsp;DLGC_WANTTAB;<br>&nbsp;&nbsp;if&nbsp;goEditing&nbsp;in&nbsp;Options&nbsp;then&nbsp;Msg.Result&nbsp;:=&nbsp;Msg.Result&nbsp;or&nbsp;DLGC_WANTCHARS;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.WMKillFocus(var&nbsp;Msg:&nbsp;TWMKillFocus);<br>begin<br>&nbsp;&nbsp;inherited;<br>&nbsp;&nbsp;InvalidateRect(Selection);<br>&nbsp;&nbsp;if&nbsp;(FInplaceEdit&nbsp;&lt;&gt;&nbsp;nil)&nbsp;and&nbsp;(Msg.FocusedWnd&nbsp;&lt;&gt;&nbsp;FInplaceEdit.Handle)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;HideEdit;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.WMLButtonDown(var&nbsp;Message:&nbsp;TMessage);<br>begin<br>&nbsp;&nbsp;inherited;<br>&nbsp;&nbsp;if&nbsp;FInplaceEdit&nbsp;&lt;&gt;&nbsp;nil&nbsp;then&nbsp;FInplaceEdit.FClickTime&nbsp;:=&nbsp;GetMessageTime;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.WMNCHitTest(var&nbsp;Msg:&nbsp;TWMNCHitTest);<br>begin<br>&nbsp;&nbsp;DefaultHandler(Msg);<br>&nbsp;&nbsp;FHitTest&nbsp;:=&nbsp;ScreenToClient(SmallPointToPoint(Msg.Pos));<br>end;<br><br>procedure&nbsp;TCustomPZGrid.WMSetCursor(var&nbsp;Msg:&nbsp;TWMSetCursor);<br>var<br>&nbsp;&nbsp;DrawInfo:&nbsp;TGridDrawInfo;<br>&nbsp;&nbsp;State:&nbsp;TGridState;<br>&nbsp;&nbsp;Index:&nbsp;Longint;<br>&nbsp;&nbsp;Pos,&nbsp;Ofs:&nbsp;Integer;<br>&nbsp;&nbsp;Cur:&nbsp;HCURSOR;<br>begin<br>&nbsp;&nbsp;Cur&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;with&nbsp;Msg&nbsp;do<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;HitTest&nbsp;=&nbsp;HTCLIENT&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;FGridState&nbsp;=&nbsp;gsNormal&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CalcDrawInfo(DrawInfo);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CalcSizingState(FHitTest.X,&nbsp;FHitTest.Y,&nbsp;State,&nbsp;Index,&nbsp;Pos,&nbsp;Ofs,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawInfo);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end&nbsp;else&nbsp;State&nbsp;:=&nbsp;FGridState;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;State&nbsp;=&nbsp;gsRowSizing&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cur&nbsp;:=&nbsp;Screen.Cursors[crVSplit]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;State&nbsp;=&nbsp;gsColSizing&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cur&nbsp;:=&nbsp;Screen.Cursors[crHSplit]<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;if&nbsp;Cur&nbsp;&lt;&gt;&nbsp;0&nbsp;then&nbsp;SetCursor(Cur)<br>&nbsp;&nbsp;else&nbsp;inherited;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.WMSetFocus(var&nbsp;Msg:&nbsp;TWMSetFocus);<br>begin<br>&nbsp;&nbsp;inherited;<br>&nbsp;&nbsp;if&nbsp;(FInplaceEdit&nbsp;=&nbsp;nil)&nbsp;or&nbsp;(Msg.FocusedWnd&nbsp;&lt;&gt;&nbsp;FInplaceEdit.Handle)&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;InvalidateRect(Selection);<br>&nbsp;&nbsp;&nbsp;&nbsp;UpdateEdit;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.WMSize(var&nbsp;Msg:&nbsp;TWMSize);<br>begin<br>&nbsp;&nbsp;inherited;<br>&nbsp;&nbsp;UpdateScrollRange;<br>&nbsp;&nbsp;if&nbsp;UseRightToLeftAlignment&nbsp;then&nbsp;Invalidate;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.WMVScroll(var&nbsp;Msg:&nbsp;TWMVScroll);<br>begin<br>&nbsp;&nbsp;ModifyScrollBar(SB_VERT,&nbsp;Msg.ScrollCode,&nbsp;Msg.Pos,&nbsp;True);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.WMHScroll(var&nbsp;Msg:&nbsp;TWMHScroll);<br>begin<br>&nbsp;&nbsp;ModifyScrollBar(SB_HORZ,&nbsp;Msg.ScrollCode,&nbsp;Msg.Pos,&nbsp;True);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.CancelMode;<br>var<br>&nbsp;&nbsp;DrawInfo:&nbsp;TGridDrawInfo;<br>begin<br>&nbsp;&nbsp;try<br>&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;FGridState&nbsp;of<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gsSelecting:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;KillTimer(Handle,&nbsp;1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gsRowSizing,&nbsp;gsColSizing:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CalcDrawInfo(DrawInfo);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawSizingLine(DrawInfo);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gsColMoving,&nbsp;gsRowMoving:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawMove;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;KillTimer(Handle,&nbsp;1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;finally<br>&nbsp;&nbsp;&nbsp;&nbsp;FGridState&nbsp;:=&nbsp;gsNormal;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.WMCancelMode(var&nbsp;Msg:&nbsp;TWMCancelMode);<br>begin<br>&nbsp;&nbsp;inherited;<br>&nbsp;&nbsp;CancelMode;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.CMCancelMode(var&nbsp;Msg:&nbsp;TMessage);<br>begin<br>&nbsp;&nbsp;if&nbsp;Assigned(FInplaceEdit)&nbsp;then&nbsp;FInplaceEdit.WndProc(Msg);<br>&nbsp;&nbsp;inherited;<br>&nbsp;&nbsp;CancelMode;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.CMFontChanged(var&nbsp;Message:&nbsp;TMessage);<br>begin<br>&nbsp;&nbsp;if&nbsp;FInplaceEdit&nbsp;&lt;&gt;&nbsp;nil&nbsp;then&nbsp;FInplaceEdit.Font&nbsp;:=&nbsp;Font;<br>&nbsp;&nbsp;inherited;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.CMCtl3DChanged(var&nbsp;Message:&nbsp;TMessage);<br>begin<br>&nbsp;&nbsp;inherited;<br>&nbsp;&nbsp;RecreateWnd;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.CMDesignHitTest(var&nbsp;Msg:&nbsp;TCMDesignHitTest);<br>begin<br>&nbsp;&nbsp;Msg.Result&nbsp;:=&nbsp;Longint(BOOL(Sizing(Msg.Pos.X,&nbsp;Msg.Pos.Y)));<br>end;<br><br>procedure&nbsp;TCustomPZGrid.CMWantSpecialKey(var&nbsp;Msg:&nbsp;TCMWantSpecialKey);<br>begin<br>&nbsp;&nbsp;inherited;<br>&nbsp;&nbsp;if&nbsp;(goEditing&nbsp;in&nbsp;Options)&nbsp;and&nbsp;(Char(Msg.CharCode)&nbsp;=&nbsp;#13)&nbsp;then&nbsp;Msg.Result&nbsp;:=&nbsp;1;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.TimedScroll(Direction:&nbsp;TGridScrollDirection);<br>var<br>&nbsp;&nbsp;MaxAnchor,&nbsp;NewAnchor:&nbsp;TGridCoord;<br>begin<br>&nbsp;&nbsp;NewAnchor&nbsp;:=&nbsp;FAnchor;<br>&nbsp;&nbsp;MaxAnchor.X&nbsp;:=&nbsp;ColCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;MaxAnchor.Y&nbsp;:=&nbsp;RowCount&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;if&nbsp;(sdLeft&nbsp;in&nbsp;Direction)&nbsp;and&nbsp;(FAnchor.X&nbsp;&gt;&nbsp;FixedCols)&nbsp;then&nbsp;Dec(NewAnchor.X);<br>&nbsp;&nbsp;if&nbsp;(sdRight&nbsp;in&nbsp;Direction)&nbsp;and&nbsp;(FAnchor.X&nbsp;&lt;&nbsp;MaxAnchor.X)&nbsp;then&nbsp;Inc(NewAnchor.X);<br>&nbsp;&nbsp;if&nbsp;(sdUp&nbsp;in&nbsp;Direction)&nbsp;and&nbsp;(FAnchor.Y&nbsp;&gt;&nbsp;FixedRows)&nbsp;then&nbsp;Dec(NewAnchor.Y);<br>&nbsp;&nbsp;if&nbsp;(sdDown&nbsp;in&nbsp;Direction)&nbsp;and&nbsp;(FAnchor.Y&nbsp;&lt;&nbsp;MaxAnchor.Y)&nbsp;then&nbsp;Inc(NewAnchor.Y);<br>&nbsp;&nbsp;if&nbsp;(FAnchor.X&nbsp;&lt;&gt;&nbsp;NewAnchor.X)&nbsp;or&nbsp;(FAnchor.Y&nbsp;&lt;&gt;&nbsp;NewAnchor.Y)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;MoveAnchor(NewAnchor);<br>end;<br><br>procedure&nbsp;TCustomPZGrid.WMTimer(var&nbsp;Msg:&nbsp;TWMTimer);<br>var<br>&nbsp;&nbsp;Point:&nbsp;TPoint;<br>&nbsp;&nbsp;DrawInfo:&nbsp;TGridDrawInfo;<br>&nbsp;&nbsp;ScrollDirection:&nbsp;TGridScrollDirection;<br>&nbsp;&nbsp;CellHit:&nbsp;TGridCoord;<br>&nbsp;&nbsp;LeftSide:&nbsp;Integer;<br>&nbsp;&nbsp;RightSide:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;if&nbsp;not&nbsp;(FGridState&nbsp;in&nbsp;[gsSelecting,&nbsp;gsRowMoving,&nbsp;gsColMoving])&nbsp;then&nbsp;Exit;<br>&nbsp;&nbsp;GetCursorPos(Point);<br>&nbsp;&nbsp;Point&nbsp;:=&nbsp;ScreenToClient(Point);<br>&nbsp;&nbsp;CalcDrawInfo(DrawInfo);<br>&nbsp;&nbsp;ScrollDirection&nbsp;:=&nbsp;[];<br>&nbsp;&nbsp;with&nbsp;DrawInfo&nbsp;do<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;CellHit&nbsp;:=&nbsp;CalcCoordFromPoint(Point.X,&nbsp;Point.Y,&nbsp;DrawInfo);<br>&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;FGridState&nbsp;of<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gsColMoving:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MoveAndScroll(Point.X,&nbsp;CellHit.X,&nbsp;DrawInfo,&nbsp;Horz,&nbsp;SB_HORZ,&nbsp;Point);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gsRowMoving:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MoveAndScroll(Point.Y,&nbsp;CellHit.Y,&nbsp;DrawInfo,&nbsp;Vert,&nbsp;SB_VERT,&nbsp;Point);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;gsSelecting:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;UseRightToLeftAlignment&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Point.X&nbsp;&lt;&nbsp;Horz.FixedBoundary&nbsp;then&nbsp;Include(ScrollDirection,&nbsp;sdLeft)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;Point.X&nbsp;&gt;&nbsp;Horz.FullVisBoundary&nbsp;then&nbsp;Include(ScrollDirection,&nbsp;sdRight);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LeftSide&nbsp;:=&nbsp;ClientWidth&nbsp;-&nbsp;Horz.FullVisBoundary;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RightSide&nbsp;:=&nbsp;ClientWidth&nbsp;-&nbsp;Horz.FixedBoundary;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Point.X&nbsp;&lt;&nbsp;LeftSide&nbsp;then&nbsp;Include(ScrollDirection,&nbsp;sdRight)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;Point.X&nbsp;&gt;&nbsp;RightSide&nbsp;then&nbsp;Include(ScrollDirection,&nbsp;sdLeft);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Point.Y&nbsp;&lt;&nbsp;Vert.FixedBoundary&nbsp;then&nbsp;Include(ScrollDirection,&nbsp;sdUp)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;Point.Y&nbsp;&gt;&nbsp;Vert.FullVisBoundary&nbsp;then&nbsp;Include(ScrollDirection,&nbsp;sdDown);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ScrollDirection&nbsp;&lt;&gt;&nbsp;[]&nbsp;then&nbsp;&nbsp;TimedScroll(ScrollDirection);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.ColWidthsChanged;<br>begin<br>&nbsp;&nbsp;UpdateScrollRange;<br>&nbsp;&nbsp;UpdateEdit;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.RowHeightsChanged;<br>begin<br>&nbsp;&nbsp;UpdateScrollRange;<br>&nbsp;&nbsp;UpdateEdit;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.DeleteColumn(ACol:&nbsp;Longint);<br>begin<br>&nbsp;&nbsp;MoveColumn(ACol,&nbsp;ColCount-1);<br>&nbsp;&nbsp;ColCount&nbsp;:=&nbsp;ColCount&nbsp;-&nbsp;1;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.DeleteRow(ARow:&nbsp;Longint);<br>begin<br>&nbsp;&nbsp;MoveRow(ARow,&nbsp;RowCount&nbsp;-&nbsp;1);<br>&nbsp;&nbsp;RowCount&nbsp;:=&nbsp;RowCount&nbsp;-&nbsp;1;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.UpdateDesigner;<br>var<br>&nbsp;&nbsp;ParentForm:&nbsp;TCustomForm;<br>begin<br>&nbsp;&nbsp;if&nbsp;(csDesigning&nbsp;in&nbsp;ComponentState)&nbsp;and&nbsp;HandleAllocated&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;not&nbsp;(csUpdating&nbsp;in&nbsp;ComponentState)&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;ParentForm&nbsp;:=&nbsp;GetParentForm(Self);<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Assigned(ParentForm)&nbsp;and&nbsp;Assigned(ParentForm.Designer)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ParentForm.Designer.Modified;<br>&nbsp;&nbsp;end;<br>end;<br><br>function&nbsp;TCustomPZGrid.DoMouseWheelDown(Shift:&nbsp;TShiftState;&nbsp;MousePos:&nbsp;TPoint):&nbsp;Boolean;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;inherited&nbsp;DoMouseWheelDown(Shift,&nbsp;MousePos);<br>&nbsp;&nbsp;if&nbsp;not&nbsp;Result&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Row&nbsp;&lt;&nbsp;RowCount&nbsp;-&nbsp;1&nbsp;then&nbsp;Row&nbsp;:=&nbsp;Row&nbsp;+&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;end;<br>end;<br><br>function&nbsp;TCustomPZGrid.DoMouseWheelUp(Shift:&nbsp;TShiftState;&nbsp;MousePos:&nbsp;TPoint):&nbsp;Boolean;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;inherited&nbsp;DoMouseWheelUp(Shift,&nbsp;MousePos);<br>&nbsp;&nbsp;if&nbsp;not&nbsp;Result&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Row&nbsp;&gt;&nbsp;FixedRows&nbsp;then&nbsp;Row&nbsp;:=&nbsp;Row&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;end;<br>end;<br><br>function&nbsp;TCustomPZGrid.CheckColumnDrag(var&nbsp;Origin,<br>&nbsp;&nbsp;Destination:&nbsp;Integer;&nbsp;const&nbsp;MousePt:&nbsp;TPoint):&nbsp;Boolean;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;True;<br>end;<br><br>function&nbsp;TCustomPZGrid.CheckRowDrag(var&nbsp;Origin,<br>&nbsp;&nbsp;Destination:&nbsp;Integer;&nbsp;const&nbsp;MousePt:&nbsp;TPoint):&nbsp;Boolean;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;True;<br>end;<br><br>function&nbsp;TCustomPZGrid.BeginColumnDrag(var&nbsp;Origin,&nbsp;Destination:&nbsp;Integer;&nbsp;const&nbsp;MousePt:&nbsp;TPoint):&nbsp;Boolean;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;True;<br>end;<br><br>function&nbsp;TCustomPZGrid.BeginRowDrag(var&nbsp;Origin,&nbsp;Destination:&nbsp;Integer;&nbsp;const&nbsp;MousePt:&nbsp;TPoint):&nbsp;Boolean;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;True;<br>end;<br><br>function&nbsp;TCustomPZGrid.EndColumnDrag(var&nbsp;Origin,&nbsp;Destination:&nbsp;Integer;&nbsp;const&nbsp;MousePt:&nbsp;TPoint):&nbsp;Boolean;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;True;<br>end;<br><br>function&nbsp;TCustomPZGrid.EndRowDrag(var&nbsp;Origin,&nbsp;Destination:&nbsp;Integer;&nbsp;const&nbsp;MousePt:&nbsp;TPoint):&nbsp;Boolean;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;True;<br>end;<br><br>procedure&nbsp;TCustomPZGrid.CMShowingChanged(var&nbsp;Message:&nbsp;TMessage);<br>begin<br>&nbsp;&nbsp;inherited;<br>&nbsp;&nbsp;if&nbsp;Showing&nbsp;then&nbsp;UpdateScrollRange;<br>end;<br><br><br><br>{&nbsp;TCustomDrawPZGrid&nbsp;}<br><br>function&nbsp;TCustomDrawPZGrid.CellRect(ACol,&nbsp;ARow:&nbsp;Longint):&nbsp;TRect;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;inherited&nbsp;CellRect(ACol,&nbsp;ARow);<br>end;<br><br>procedure&nbsp;TCustomDrawPZGrid.MouseToCell(X,&nbsp;Y:&nbsp;Integer;&nbsp;var&nbsp;ACol,&nbsp;ARow:&nbsp;Longint);<br>var<br>&nbsp;&nbsp;Coord:&nbsp;TGridCoord;<br>begin<br>&nbsp;&nbsp;Coord&nbsp;:=&nbsp;MouseCoord(X,&nbsp;Y);<br>&nbsp;&nbsp;ACol&nbsp;:=&nbsp;Coord.X;<br>&nbsp;&nbsp;ARow&nbsp;:=&nbsp;Coord.Y;<br>end;<br><br>procedure&nbsp;TCustomDrawPZGrid.ColumnMoved(FromIndex,&nbsp;ToIndex:&nbsp;Longint);<br>begin<br>&nbsp;&nbsp;if&nbsp;Assigned(FOnColumnMoved)&nbsp;then&nbsp;FOnColumnMoved(Self,&nbsp;FromIndex,&nbsp;ToIndex);<br>end;<br><br>function&nbsp;TCustomDrawPZGrid.GetEditMask(ACol,&nbsp;ARow:&nbsp;Longint):&nbsp;string;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;'';<br>&nbsp;&nbsp;if&nbsp;Assigned(FOnGetEditMask)&nbsp;then&nbsp;FOnGetEditMask(Self,&nbsp;ACol,&nbsp;ARow,&nbsp;Result);<br>end;<br><br>function&nbsp;TCustomDrawPZGrid.GetEditText(ACol,&nbsp;ARow:&nbsp;Longint):&nbsp;string;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;'';<br>&nbsp;&nbsp;if&nbsp;Assigned(FOnGetEditText)&nbsp;then&nbsp;FOnGetEditText(Self,&nbsp;ACol,&nbsp;ARow,&nbsp;Result);<br>end;<br><br>procedure&nbsp;TCustomDrawPZGrid.RowMoved(FromIndex,&nbsp;ToIndex:&nbsp;Longint);<br>begin<br>&nbsp;&nbsp;if&nbsp;Assigned(FOnRowMoved)&nbsp;then&nbsp;FOnRowMoved(Self,&nbsp;FromIndex,&nbsp;ToIndex);<br>end;<br><br>function&nbsp;TCustomDrawPZGrid.SelectCell(ACol,&nbsp;ARow:&nbsp;Longint):&nbsp;Boolean;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;if&nbsp;Assigned(FOnSelectCell)&nbsp;then&nbsp;FOnSelectCell(Self,&nbsp;ACol,&nbsp;ARow,&nbsp;Result);<br>end;<br><br>procedure&nbsp;TCustomDrawPZGrid.SetEditText(ACol,&nbsp;ARow:&nbsp;Longint;&nbsp;const&nbsp;Value:&nbsp;string);<br>begin<br>&nbsp;&nbsp;if&nbsp;Assigned(FOnSetEditText)&nbsp;then&nbsp;FOnSetEditText(Self,&nbsp;ACol,&nbsp;ARow,&nbsp;Value);<br>end;<br><br>procedure&nbsp;TCustomDrawPZGrid.DrawCell(ACol,&nbsp;ARow:&nbsp;Longint;&nbsp;ARect:&nbsp;TRect;<br>&nbsp;&nbsp;AState:&nbsp;TGridDrawState);<br>var<br>&nbsp;&nbsp;Hold:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;if&nbsp;Assigned(FOnDrawCell)&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;UseRightToLeftAlignment&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ARect.Left&nbsp;:=&nbsp;ClientWidth&nbsp;-&nbsp;ARect.Left;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ARect.Right&nbsp;:=&nbsp;ClientWidth&nbsp;-&nbsp;ARect.Right;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Hold&nbsp;:=&nbsp;ARect.Left;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ARect.Left&nbsp;:=&nbsp;ARect.Right;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ARect.Right&nbsp;:=&nbsp;Hold;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ChangeGridOrientation(False);<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;FOnDrawCell(Self,&nbsp;ACol,&nbsp;ARow,&nbsp;ARect,&nbsp;AState);<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;UseRightToLeftAlignment&nbsp;then&nbsp;ChangeGridOrientation(True);&nbsp;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TCustomDrawPZGrid.TopLeftChanged;<br>begin<br>&nbsp;&nbsp;inherited&nbsp;TopLeftChanged;<br>&nbsp;&nbsp;if&nbsp;Assigned(FOnTopLeftChanged)&nbsp;then&nbsp;FOnTopLeftChanged(Self);<br>end;<br><br>{&nbsp;StrItem&nbsp;management&nbsp;for&nbsp;TStringSparseList&nbsp;}<br><br>type<br>&nbsp;&nbsp;PStrItem&nbsp;=&nbsp;^TStrItem;<br>&nbsp;&nbsp;TStrItem&nbsp;=&nbsp;record<br>&nbsp;&nbsp;&nbsp;&nbsp;FObject:&nbsp;TObject;<br>&nbsp;&nbsp;&nbsp;&nbsp;FString:&nbsp;string;<br>&nbsp;&nbsp;end;<br><br>function&nbsp;NewStrItem(const&nbsp;AString:&nbsp;string;&nbsp;AObject:&nbsp;TObject):&nbsp;PStrItem;<br>begin<br>&nbsp;&nbsp;New(Result);<br>&nbsp;&nbsp;Result^.FObject&nbsp;:=&nbsp;AObject;<br>&nbsp;&nbsp;Result^.FString&nbsp;:=&nbsp;AString;<br>end;<br><br>procedure&nbsp;DisposeStrItem(P:&nbsp;PStrItem);<br>begin<br>&nbsp;&nbsp;Dispose(P);<br>end;<br><br>{&nbsp;Sparse&nbsp;array&nbsp;classes&nbsp;for&nbsp;TPZGrid&nbsp;}<br><br>type<br>{&nbsp;Exception&nbsp;classes&nbsp;}<br><br>&nbsp;&nbsp;EStringSparseListError&nbsp;=&nbsp;class(Exception);<br><br>{&nbsp;TSparsePointerArray&nbsp;class}<br><br>{&nbsp;Used&nbsp;by&nbsp;TSparseList.&nbsp;&nbsp;Based&nbsp;on&nbsp;Sparse1Array,&nbsp;but&nbsp;has&nbsp;Pointer&nbsp;elements<br>&nbsp;&nbsp;and&nbsp;Integer&nbsp;index,&nbsp;just&nbsp;like&nbsp;TPointerList/TList,&nbsp;and&nbsp;less&nbsp;indirection&nbsp;}<br><br>&nbsp;&nbsp;{&nbsp;Apply&nbsp;function&nbsp;for&nbsp;the&nbsp;applicator:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TheIndex&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Index&nbsp;of&nbsp;item&nbsp;in&nbsp;array<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TheItem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Value&nbsp;of&nbsp;item&nbsp;(i.e&nbsp;pointer&nbsp;element)&nbsp;in&nbsp;section<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Returns:&nbsp;0&nbsp;if&nbsp;success,&nbsp;else&nbsp;error&nbsp;code.&nbsp;}<br>&nbsp;&nbsp;TSPAApply&nbsp;=&nbsp;function(TheIndex:&nbsp;Integer;&nbsp;TheItem:&nbsp;Pointer):&nbsp;Integer;<br><br>&nbsp;&nbsp;TSecDir&nbsp;=&nbsp;array[0..4095]&nbsp;of&nbsp;Pointer;&nbsp;&nbsp;{&nbsp;Enough&nbsp;for&nbsp;up&nbsp;to&nbsp;12&nbsp;bits&nbsp;of&nbsp;sec&nbsp;}<br>&nbsp;&nbsp;PSecDir&nbsp;=&nbsp;^TSecDir;<br>&nbsp;&nbsp;TSPAQuantum&nbsp;=&nbsp;(SPASmall,&nbsp;SPALarge);&nbsp;&nbsp;&nbsp;{&nbsp;Section&nbsp;size&nbsp;}<br><br>&nbsp;&nbsp;TSparsePointerArray&nbsp;=&nbsp;class(TObject)<br>&nbsp;&nbsp;private<br>&nbsp;&nbsp;&nbsp;&nbsp;secDir:&nbsp;PSecDir;<br>&nbsp;&nbsp;&nbsp;&nbsp;slotsInDir:&nbsp;Word;<br>&nbsp;&nbsp;&nbsp;&nbsp;indexMask,&nbsp;secShift:&nbsp;Word;<br>&nbsp;&nbsp;&nbsp;&nbsp;FHighBound:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;FSectionSize:&nbsp;Word;<br>&nbsp;&nbsp;&nbsp;&nbsp;cachedIndex:&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;cachedPointer:&nbsp;Pointer;<br>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Return&nbsp;item,&nbsp;nil&nbsp;if&nbsp;slot&nbsp;outside&nbsp;defined&nbsp;section.&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;&nbsp;GetAt(Index:&nbsp;Integer):&nbsp;Pointer;<br>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Return&nbsp;address&nbsp;of&nbsp;item,&nbsp;creating&nbsp;slot&nbsp;if&nbsp;necessary.&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;&nbsp;MakeAt(Index:&nbsp;Integer):&nbsp;PPointer;<br>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Store&nbsp;item&nbsp;at&nbsp;item,&nbsp;creating&nbsp;slot&nbsp;if&nbsp;necessary.&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;PutAt(Index:&nbsp;Integer;&nbsp;Item:&nbsp;Pointer);<br>&nbsp;&nbsp;public<br>&nbsp;&nbsp;&nbsp;&nbsp;constructor&nbsp;Create(Quantum:&nbsp;TSPAQuantum);<br>&nbsp;&nbsp;&nbsp;&nbsp;destructor&nbsp;&nbsp;Destroy;&nbsp;override;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Traverse&nbsp;SPA,&nbsp;calling&nbsp;apply&nbsp;function&nbsp;for&nbsp;each&nbsp;defined&nbsp;non-nil<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;item.&nbsp;&nbsp;The&nbsp;traversal&nbsp;terminates&nbsp;if&nbsp;the&nbsp;apply&nbsp;function&nbsp;returns<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a&nbsp;value&nbsp;other&nbsp;than&nbsp;0.&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;NOTE:&nbsp;must&nbsp;be&nbsp;static&nbsp;method&nbsp;so&nbsp;that&nbsp;we&nbsp;can&nbsp;take&nbsp;its&nbsp;address&nbsp;in<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TSparseList.ForAll&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;&nbsp;ForAll(ApplyFunction:&nbsp;Pointer&nbsp;{TSPAApply}):&nbsp;Integer;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Ratchet&nbsp;down&nbsp;HighBound&nbsp;after&nbsp;a&nbsp;deletion&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;ResetHighBound;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;HighBound:&nbsp;Integer&nbsp;read&nbsp;FHighBound;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;SectionSize:&nbsp;Word&nbsp;read&nbsp;FSectionSize;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Items[Index:&nbsp;Integer]:&nbsp;Pointer&nbsp;read&nbsp;GetAt&nbsp;write&nbsp;PutAt;&nbsp;default;<br>&nbsp;&nbsp;end;<br><br>{&nbsp;TSparseList&nbsp;class&nbsp;}<br><br>&nbsp;&nbsp;TSparseList&nbsp;=&nbsp;class(TObject)<br>&nbsp;&nbsp;private<br>&nbsp;&nbsp;&nbsp;&nbsp;FList:&nbsp;TSparsePointerArray;<br>&nbsp;&nbsp;&nbsp;&nbsp;FCount:&nbsp;Integer;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;1&nbsp;+&nbsp;HighBound,&nbsp;adjusted&nbsp;for&nbsp;Insert/Delete&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;FQuantum:&nbsp;TSPAQuantum;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;NewList(Quantum:&nbsp;TSPAQuantum);<br>&nbsp;&nbsp;protected<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;&nbsp;Get(Index:&nbsp;Integer):&nbsp;Pointer;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Put(Index:&nbsp;Integer;&nbsp;Item:&nbsp;Pointer);<br>&nbsp;&nbsp;public<br>&nbsp;&nbsp;&nbsp;&nbsp;constructor&nbsp;Create(Quantum:&nbsp;TSPAQuantum);<br>&nbsp;&nbsp;&nbsp;&nbsp;destructor&nbsp;&nbsp;Destroy;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Clear;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Delete(Index:&nbsp;Integer);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Exchange(Index1,&nbsp;Index2:&nbsp;Integer);<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;ForAll(ApplyFunction:&nbsp;Pointer&nbsp;{TSPAApply}):&nbsp;Integer;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Insert(Index:&nbsp;Integer;&nbsp;Item:&nbsp;Pointer);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Move(CurIndex,&nbsp;NewIndex:&nbsp;Integer);<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Count:&nbsp;Integer&nbsp;read&nbsp;FCount;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;Items[Index:&nbsp;Integer]:&nbsp;Pointer&nbsp;read&nbsp;Get&nbsp;write&nbsp;Put;&nbsp;default;<br>&nbsp;&nbsp;end;<br><br>{&nbsp;TStringSparseList&nbsp;class&nbsp;}<br><br>&nbsp;&nbsp;TStringSparseList&nbsp;=&nbsp;class(TStrings)<br>&nbsp;&nbsp;private<br>&nbsp;&nbsp;&nbsp;&nbsp;FList:&nbsp;TSparseList;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;of&nbsp;StrItems&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;FOnChange:&nbsp;TNotifyEvent;<br>&nbsp;&nbsp;protected<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;&nbsp;Get(Index:&nbsp;Integer):&nbsp;String;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;&nbsp;GetCount:&nbsp;Integer;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;&nbsp;GetObject(Index:&nbsp;Integer):&nbsp;TObject;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Put(Index:&nbsp;Integer;&nbsp;const&nbsp;S:&nbsp;String);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;PutObject(Index:&nbsp;Integer;&nbsp;AObject:&nbsp;TObject);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Changed;<br>&nbsp;&nbsp;public<br>&nbsp;&nbsp;&nbsp;&nbsp;constructor&nbsp;Create(Quantum:&nbsp;TSPAQuantum);<br>&nbsp;&nbsp;&nbsp;&nbsp;destructor&nbsp;&nbsp;Destroy;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;ReadData(Reader:&nbsp;TReader);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;WriteData(Writer:&nbsp;TWriter);<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;DefineProperties(Filer:&nbsp;TFiler);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Delete(Index:&nbsp;Integer);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Exchange(Index1,&nbsp;Index2:&nbsp;Integer);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Insert(Index:&nbsp;Integer;&nbsp;const&nbsp;S:&nbsp;String);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;Clear;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;List:&nbsp;TSparseList&nbsp;read&nbsp;FList;<br>&nbsp;&nbsp;&nbsp;&nbsp;property&nbsp;OnChange:&nbsp;TNotifyEvent&nbsp;read&nbsp;FOnChange&nbsp;write&nbsp;FOnChange;<br>&nbsp;&nbsp;end;<br><br>{&nbsp;TSparsePointerArray&nbsp;}<br><br>const<br>&nbsp;&nbsp;SPAIndexMask:&nbsp;array[TSPAQuantum]&nbsp;of&nbsp;Byte&nbsp;=&nbsp;(15,&nbsp;255);<br>&nbsp;&nbsp;SPASecShift:&nbsp;array[TSPAQuantum]&nbsp;of&nbsp;Byte&nbsp;=&nbsp;(4,&nbsp;8);<br><br>{&nbsp;Expand&nbsp;Section&nbsp;Directory&nbsp;to&nbsp;cover&nbsp;at&nbsp;least&nbsp;`newSlots'&nbsp;slots.&nbsp;Returns:&nbsp;Possibly<br>&nbsp;&nbsp;updated&nbsp;pointer&nbsp;to&nbsp;the&nbsp;Section&nbsp;Directory.&nbsp;}<br>function&nbsp;&nbsp;ExpandDir(secDir:&nbsp;PSecDir;&nbsp;var&nbsp;slotsInDir:&nbsp;Word;<br>&nbsp;&nbsp;newSlots:&nbsp;Word):&nbsp;PSecDir;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;secDir;<br>&nbsp;&nbsp;ReallocMem(Result,&nbsp;newSlots&nbsp;*&nbsp;SizeOf(Pointer));<br>&nbsp;&nbsp;FillChar(Result^[slotsInDir],&nbsp;(newSlots&nbsp;-&nbsp;slotsInDir)&nbsp;*&nbsp;SizeOf(Pointer),&nbsp;0);<br>&nbsp;&nbsp;slotsInDir&nbsp;:=&nbsp;newSlots;<br>end;<br><br>{&nbsp;Allocate&nbsp;a&nbsp;section&nbsp;and&nbsp;set&nbsp;all&nbsp;its&nbsp;items&nbsp;to&nbsp;nil.&nbsp;Returns:&nbsp;Pointer&nbsp;to&nbsp;start&nbsp;of<br>&nbsp;&nbsp;section.&nbsp;}<br>function&nbsp;&nbsp;MakeSec(SecIndex:&nbsp;Integer;&nbsp;SectionSize:&nbsp;Word):&nbsp;Pointer;<br>var<br>&nbsp;&nbsp;SecP:&nbsp;Pointer;<br>&nbsp;&nbsp;Size:&nbsp;Word;<br>begin<br>&nbsp;&nbsp;Size&nbsp;:=&nbsp;SectionSize&nbsp;*&nbsp;SizeOf(Pointer);<br>&nbsp;&nbsp;GetMem(secP,&nbsp;size);<br>&nbsp;&nbsp;FillChar(secP^,&nbsp;size,&nbsp;0);<br>&nbsp;&nbsp;MakeSec&nbsp;:=&nbsp;SecP<br>end;<br><br>constructor&nbsp;TSparsePointerArray.Create(Quantum:&nbsp;TSPAQuantum);<br>begin<br>&nbsp;&nbsp;SecDir&nbsp;:=&nbsp;nil;<br>&nbsp;&nbsp;SlotsInDir&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;FHighBound&nbsp;:=&nbsp;-1;<br>&nbsp;&nbsp;FSectionSize&nbsp;:=&nbsp;Word(SPAIndexMask[Quantum])&nbsp;+&nbsp;1;<br>&nbsp;&nbsp;IndexMask&nbsp;:=&nbsp;Word(SPAIndexMask[Quantum]);<br>&nbsp;&nbsp;SecShift&nbsp;:=&nbsp;Word(SPASecShift[Quantum]);<br>&nbsp;&nbsp;CachedIndex&nbsp;:=&nbsp;-1<br>end;<br><br>destructor&nbsp;TSparsePointerArray.Destroy;<br>var<br>&nbsp;&nbsp;i:&nbsp;&nbsp;Integer;<br>&nbsp;&nbsp;size:&nbsp;Word;<br>begin<br>&nbsp;&nbsp;{&nbsp;Scan&nbsp;section&nbsp;directory&nbsp;and&nbsp;free&nbsp;each&nbsp;section&nbsp;that&nbsp;exists.&nbsp;}<br>&nbsp;&nbsp;i&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;size&nbsp;:=&nbsp;FSectionSize&nbsp;*&nbsp;SizeOf(Pointer);<br>&nbsp;&nbsp;while&nbsp;i&nbsp;&lt;&nbsp;slotsInDir&nbsp;do&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;secDir^&nbsp;&lt;&gt;&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FreeMem(secDir^,&nbsp;size);<br>&nbsp;&nbsp;&nbsp;&nbsp;Inc(i)<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;{&nbsp;Free&nbsp;section&nbsp;directory.&nbsp;}<br>&nbsp;&nbsp;if&nbsp;secDir&nbsp;&lt;&gt;&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;FreeMem(secDir,&nbsp;slotsInDir&nbsp;*&nbsp;SizeOf(Pointer));<br>end;<br><br>function&nbsp;&nbsp;TSparsePointerArray.GetAt(Index:&nbsp;Integer):&nbsp;Pointer;<br>var<br>&nbsp;&nbsp;byteP:&nbsp;PChar;<br>&nbsp;&nbsp;secIndex:&nbsp;Cardinal;<br>begin<br>&nbsp;&nbsp;{&nbsp;Index&nbsp;into&nbsp;Section&nbsp;Directory&nbsp;using&nbsp;high&nbsp;order&nbsp;part&nbsp;of<br>&nbsp;&nbsp;&nbsp;&nbsp;index.&nbsp;&nbsp;Get&nbsp;pointer&nbsp;to&nbsp;Section.&nbsp;If&nbsp;not&nbsp;null,&nbsp;index&nbsp;into<br>&nbsp;&nbsp;&nbsp;&nbsp;Section&nbsp;using&nbsp;low&nbsp;order&nbsp;part&nbsp;of&nbsp;index.&nbsp;}<br>&nbsp;&nbsp;if&nbsp;Index&nbsp;=&nbsp;cachedIndex&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;cachedPointer<br>&nbsp;&nbsp;else&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;secIndex&nbsp;:=&nbsp;Index&nbsp;shr&nbsp;secShift;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;secIndex&nbsp;&gt;=&nbsp;slotsInDir&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;byteP&nbsp;:=&nbsp;nil<br>&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;byteP&nbsp;:=&nbsp;secDir^[secIndex];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;byteP&nbsp;&lt;&gt;&nbsp;nil&nbsp;then&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(byteP,&nbsp;(Index&nbsp;and&nbsp;indexMask)&nbsp;*&nbsp;SizeOf(Pointer));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;byteP&nbsp;=&nbsp;nil&nbsp;then&nbsp;Result&nbsp;:=&nbsp;nil&nbsp;else&nbsp;Result&nbsp;:=&nbsp;PPointer(byteP)^;<br>&nbsp;&nbsp;&nbsp;&nbsp;cachedIndex&nbsp;:=&nbsp;Index;<br>&nbsp;&nbsp;&nbsp;&nbsp;cachedPointer&nbsp;:=&nbsp;Result<br>&nbsp;&nbsp;end<br>end;<br><br>function&nbsp;&nbsp;TSparsePointerArray.MakeAt(Index:&nbsp;Integer):&nbsp;PPointer;<br>var<br>&nbsp;&nbsp;dirP:&nbsp;PSecDir;<br>&nbsp;&nbsp;p:&nbsp;Pointer;<br>&nbsp;&nbsp;byteP:&nbsp;PChar;<br>&nbsp;&nbsp;secIndex:&nbsp;Word;<br>begin<br>&nbsp;&nbsp;{&nbsp;Expand&nbsp;Section&nbsp;Directory&nbsp;if&nbsp;necessary.&nbsp;}<br>&nbsp;&nbsp;secIndex&nbsp;:=&nbsp;Index&nbsp;shr&nbsp;secShift;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Unsigned&nbsp;shift&nbsp;}<br>&nbsp;&nbsp;if&nbsp;secIndex&nbsp;&gt;=&nbsp;slotsInDir&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;dirP&nbsp;:=&nbsp;expandDir(secDir,&nbsp;slotsInDir,&nbsp;secIndex&nbsp;+&nbsp;1)<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;dirP&nbsp;:=&nbsp;secDir;<br><br>&nbsp;&nbsp;{&nbsp;Index&nbsp;into&nbsp;Section&nbsp;Directory&nbsp;using&nbsp;high&nbsp;order&nbsp;part&nbsp;of<br>&nbsp;&nbsp;&nbsp;&nbsp;index.&nbsp;&nbsp;Get&nbsp;pointer&nbsp;to&nbsp;Section.&nbsp;If&nbsp;null,&nbsp;create&nbsp;new<br>&nbsp;&nbsp;&nbsp;&nbsp;Section.&nbsp;&nbsp;Index&nbsp;into&nbsp;Section&nbsp;using&nbsp;low&nbsp;order&nbsp;part&nbsp;of&nbsp;index.&nbsp;}<br>&nbsp;&nbsp;secDir&nbsp;:=&nbsp;dirP;<br>&nbsp;&nbsp;p&nbsp;:=&nbsp;dirP^[secIndex];<br>&nbsp;&nbsp;if&nbsp;p&nbsp;=&nbsp;nil&nbsp;then&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;p&nbsp;:=&nbsp;makeSec(secIndex,&nbsp;FSectionSize);<br>&nbsp;&nbsp;&nbsp;&nbsp;dirP^[secIndex]&nbsp;:=&nbsp;p<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;byteP&nbsp;:=&nbsp;p;<br>&nbsp;&nbsp;Inc(byteP,&nbsp;(Index&nbsp;and&nbsp;indexMask)&nbsp;*&nbsp;SizeOf(Pointer));<br>&nbsp;&nbsp;if&nbsp;Index&nbsp;&gt;&nbsp;FHighBound&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;FHighBound&nbsp;:=&nbsp;Index;<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;PPointer(byteP);<br>&nbsp;&nbsp;cachedIndex&nbsp;:=&nbsp;-1<br>end;<br><br>procedure&nbsp;TSparsePointerArray.PutAt(Index:&nbsp;Integer;&nbsp;Item:&nbsp;Pointer);<br>begin<br>&nbsp;&nbsp;if&nbsp;(Item&nbsp;&lt;&gt;&nbsp;nil)&nbsp;or&nbsp;(GetAt(Index)&nbsp;&lt;&gt;&nbsp;nil)&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;MakeAt(Index)^&nbsp;:=&nbsp;Item;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Item&nbsp;=&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ResetHighBound<br>&nbsp;&nbsp;end<br>end;<br><br>function&nbsp;&nbsp;TSparsePointerArray.ForAll(ApplyFunction:&nbsp;Pointer&nbsp;{TSPAApply}):<br>&nbsp;&nbsp;Integer;<br>var<br>&nbsp;&nbsp;itemP:&nbsp;PChar;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Pointer&nbsp;to&nbsp;item&nbsp;in&nbsp;section&nbsp;}<br>&nbsp;&nbsp;item:&nbsp;Pointer;<br>&nbsp;&nbsp;i,&nbsp;callerBP:&nbsp;Cardinal;<br>&nbsp;&nbsp;j,&nbsp;index:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;{&nbsp;Scan&nbsp;section&nbsp;directory&nbsp;and&nbsp;scan&nbsp;each&nbsp;section&nbsp;that&nbsp;exists,<br>&nbsp;&nbsp;&nbsp;&nbsp;calling&nbsp;the&nbsp;apply&nbsp;function&nbsp;for&nbsp;each&nbsp;non-nil&nbsp;item.<br>&nbsp;&nbsp;&nbsp;&nbsp;The&nbsp;apply&nbsp;function&nbsp;must&nbsp;be&nbsp;a&nbsp;far&nbsp;local&nbsp;function&nbsp;in&nbsp;the&nbsp;scope&nbsp;of<br>&nbsp;&nbsp;&nbsp;&nbsp;the&nbsp;procedure&nbsp;P&nbsp;calling&nbsp;ForAll.&nbsp;&nbsp;The&nbsp;trick&nbsp;of&nbsp;setting&nbsp;up&nbsp;the&nbsp;stack<br>&nbsp;&nbsp;&nbsp;&nbsp;frame&nbsp;(taken&nbsp;from&nbsp;TurboVision's&nbsp;TCollection.ForEach)&nbsp;allows&nbsp;the<br>&nbsp;&nbsp;&nbsp;&nbsp;apply&nbsp;function&nbsp;access&nbsp;to&nbsp;P's&nbsp;arguments&nbsp;and&nbsp;local&nbsp;variables&nbsp;and,<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;P&nbsp;is&nbsp;a&nbsp;method,&nbsp;the&nbsp;instance&nbsp;variables&nbsp;and&nbsp;methods&nbsp;of&nbsp;P's&nbsp;class&nbsp;}<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;i&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;asm<br>&nbsp;&nbsp;&nbsp;&nbsp;mov&nbsp;&nbsp;&nbsp;eax,[ebp]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Set&nbsp;up&nbsp;stack&nbsp;frame&nbsp;for&nbsp;local&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;mov&nbsp;&nbsp;&nbsp;callerBP,eax<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;while&nbsp;(i&nbsp;&lt;&nbsp;slotsInDir)&nbsp;and&nbsp;(Result&nbsp;=&nbsp;0)&nbsp;do&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;itemP&nbsp;:=&nbsp;secDir^;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;itemP&nbsp;&lt;&gt;&nbsp;nil&nbsp;then&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;j&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;index&nbsp;:=&nbsp;i&nbsp;shl&nbsp;SecShift;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;(j&nbsp;&lt;&nbsp;FSectionSize)&nbsp;and&nbsp;(Result&nbsp;=&nbsp;0)&nbsp;do&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;item&nbsp;:=&nbsp;PPointer(itemP)^;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;item&nbsp;&lt;&gt;&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;ret&nbsp;:=&nbsp;ApplyFunction(index,&nbsp;item.Ptr);&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;asm<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mov&nbsp;&nbsp;&nbsp;eax,index<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mov&nbsp;&nbsp;&nbsp;edx,item<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;push&nbsp;&nbsp;callerBP<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;call&nbsp;&nbsp;ApplyFunction<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pop&nbsp;&nbsp;&nbsp;ecx<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;mov&nbsp;&nbsp;&nbsp;@Result,eax<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(itemP,&nbsp;SizeOf(Pointer));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(j);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(index)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;Inc(i)<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TSparsePointerArray.ResetHighBound;<br>var<br>&nbsp;&nbsp;NewHighBound:&nbsp;Integer;<br><br>&nbsp;&nbsp;function&nbsp;&nbsp;Detector(TheIndex:&nbsp;Integer;&nbsp;TheItem:&nbsp;Pointer):&nbsp;Integer;&nbsp;far;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;TheIndex&nbsp;&gt;&nbsp;FHighBound&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;1<br>&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;TheItem&nbsp;&lt;&gt;&nbsp;nil&nbsp;then&nbsp;NewHighBound&nbsp;:=&nbsp;TheIndex<br>&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;end;<br><br>begin<br>&nbsp;&nbsp;NewHighBound&nbsp;:=&nbsp;-1;<br>&nbsp;&nbsp;ForAll(@Detector);<br>&nbsp;&nbsp;FHighBound&nbsp;:=&nbsp;NewHighBound<br>end;<br><br>{&nbsp;TSparseList&nbsp;}<br><br>constructor&nbsp;TSparseList.Create(Quantum:&nbsp;TSPAQuantum);<br>begin<br>&nbsp;&nbsp;NewList(Quantum)<br>end;<br><br>destructor&nbsp;TSparseList.Destroy;<br>begin<br>&nbsp;&nbsp;if&nbsp;FList&nbsp;&lt;&gt;&nbsp;nil&nbsp;then&nbsp;FList.Destroy<br>end;<br><br>procedure&nbsp;TSparseList.Clear;<br>begin<br>&nbsp;&nbsp;FList.Destroy;<br>&nbsp;&nbsp;NewList(FQuantum);<br>&nbsp;&nbsp;FCount&nbsp;:=&nbsp;0<br>end;<br><br>procedure&nbsp;TSparseList.Delete(Index:&nbsp;Integer);<br>var<br>&nbsp;&nbsp;I:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;if&nbsp;(Index&nbsp;&lt;&nbsp;0)&nbsp;or&nbsp;(Index&nbsp;&gt;=&nbsp;FCount)&nbsp;then&nbsp;Exit;<br>&nbsp;&nbsp;for&nbsp;I&nbsp;:=&nbsp;Index&nbsp;to&nbsp;FCount&nbsp;-&nbsp;1&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;FList&nbsp;:=&nbsp;FList[I&nbsp;+&nbsp;1];<br>&nbsp;&nbsp;FList[FCount]&nbsp;:=&nbsp;nil;<br>&nbsp;&nbsp;Dec(FCount);<br>end;<br><br>procedure&nbsp;TSparseList.Exchange(Index1,&nbsp;Index2:&nbsp;Integer);<br>var<br>&nbsp;&nbsp;temp:&nbsp;Pointer;<br>begin<br>&nbsp;&nbsp;temp&nbsp;:=&nbsp;Get(Index1);<br>&nbsp;&nbsp;Put(Index1,&nbsp;Get(Index2));<br>&nbsp;&nbsp;Put(Index2,&nbsp;temp);<br>end;<br><br>{&nbsp;Jump&nbsp;to&nbsp;TSparsePointerArray.ForAll&nbsp;so&nbsp;that&nbsp;it&nbsp;looks&nbsp;like&nbsp;it&nbsp;was&nbsp;called<br>&nbsp;&nbsp;from&nbsp;our&nbsp;caller,&nbsp;so&nbsp;that&nbsp;the&nbsp;BP&nbsp;trick&nbsp;works.&nbsp;}<br><br>function&nbsp;TSparseList.ForAll(ApplyFunction:&nbsp;Pointer&nbsp;{TSPAApply}):&nbsp;Integer;&nbsp;assembler;<br>asm<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MOV&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EAX,[EAX].TSparseList.FList<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;JMP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TSparsePointerArray.ForAll<br>end;<br><br>function&nbsp;&nbsp;TSparseList.Get(Index:&nbsp;Integer):&nbsp;Pointer;<br>begin<br>&nbsp;&nbsp;if&nbsp;Index&nbsp;&lt;&nbsp;0&nbsp;then&nbsp;TList.Error(SListIndexError,&nbsp;Index);<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;FList[Index]<br>end;<br><br>procedure&nbsp;TSparseList.Insert(Index:&nbsp;Integer;&nbsp;Item:&nbsp;Pointer);<br>var<br>&nbsp;&nbsp;i:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;if&nbsp;Index&nbsp;&lt;&nbsp;0&nbsp;then&nbsp;TList.Error(SListIndexError,&nbsp;Index);<br>&nbsp;&nbsp;I&nbsp;:=&nbsp;FCount;<br>&nbsp;&nbsp;while&nbsp;I&nbsp;&gt;&nbsp;Index&nbsp;do<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;FList&nbsp;:=&nbsp;FList[i&nbsp;-&nbsp;1];<br>&nbsp;&nbsp;&nbsp;&nbsp;Dec(i)<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;FList[Index]&nbsp;:=&nbsp;Item;<br>&nbsp;&nbsp;if&nbsp;Index&nbsp;&gt;&nbsp;FCount&nbsp;then&nbsp;FCount&nbsp;:=&nbsp;Index;<br>&nbsp;&nbsp;Inc(FCount)<br>end;<br><br>procedure&nbsp;TSparseList.Move(CurIndex,&nbsp;NewIndex:&nbsp;Integer);<br>var<br>&nbsp;&nbsp;Item:&nbsp;Pointer;<br>begin<br>&nbsp;&nbsp;if&nbsp;CurIndex&nbsp;&lt;&gt;&nbsp;NewIndex&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Item&nbsp;:=&nbsp;Get(CurIndex);<br>&nbsp;&nbsp;&nbsp;&nbsp;Delete(CurIndex);<br>&nbsp;&nbsp;&nbsp;&nbsp;Insert(NewIndex,&nbsp;Item);<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TSparseList.NewList(Quantum:&nbsp;TSPAQuantum);<br>begin<br>&nbsp;&nbsp;FQuantum&nbsp;:=&nbsp;Quantum;<br>&nbsp;&nbsp;FList&nbsp;:=&nbsp;TSparsePointerArray.Create(Quantum)<br>end;<br><br>procedure&nbsp;TSparseList.Put(Index:&nbsp;Integer;&nbsp;Item:&nbsp;Pointer);<br>begin<br>&nbsp;&nbsp;if&nbsp;Index&nbsp;&lt;&nbsp;0&nbsp;then&nbsp;TList.Error(SListIndexError,&nbsp;Index);<br>&nbsp;&nbsp;FList[Index]&nbsp;:=&nbsp;Item;<br>&nbsp;&nbsp;FCount&nbsp;:=&nbsp;FList.HighBound&nbsp;+&nbsp;1<br>end;<br><br>{&nbsp;TStringSparseList&nbsp;}<br><br>constructor&nbsp;TStringSparseList.Create(Quantum:&nbsp;TSPAQuantum);<br>begin<br>&nbsp;&nbsp;inherited&nbsp;Create;<br>&nbsp;&nbsp;FList&nbsp;:=&nbsp;TSparseList.Create(Quantum)<br>end;<br><br>destructor&nbsp;&nbsp;TStringSparseList.Destroy;<br>begin<br>&nbsp;&nbsp;if&nbsp;FList&nbsp;&lt;&gt;&nbsp;nil&nbsp;then&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Clear;<br>&nbsp;&nbsp;&nbsp;&nbsp;FList.Destroy<br>&nbsp;&nbsp;end<br>end;<br><br>procedure&nbsp;TStringSparseList.ReadData(Reader:&nbsp;TReader);<br>var<br>&nbsp;&nbsp;i:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;with&nbsp;Reader&nbsp;do&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;i&nbsp;:=&nbsp;Integer(ReadInteger);<br>&nbsp;&nbsp;&nbsp;&nbsp;while&nbsp;i&nbsp;&gt;&nbsp;0&nbsp;do&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InsertObject(Integer(ReadInteger),&nbsp;ReadString,&nbsp;nil);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dec(i)<br>&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;end<br>end;<br><br>procedure&nbsp;TStringSparseList.WriteData(Writer:&nbsp;TWriter);<br>var<br>&nbsp;&nbsp;itemCount:&nbsp;Integer;<br><br>&nbsp;&nbsp;function&nbsp;&nbsp;CountItem(TheIndex:&nbsp;Integer;&nbsp;TheItem:&nbsp;Pointer):&nbsp;Integer;&nbsp;far;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Inc(itemCount);<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;0<br>&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;function&nbsp;&nbsp;StoreItem(TheIndex:&nbsp;Integer;&nbsp;TheItem:&nbsp;Pointer):&nbsp;Integer;&nbsp;far;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;Writer&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WriteInteger(TheIndex);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Item&nbsp;index&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WriteString(PStrItem(TheItem)^.FString);<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;0<br>&nbsp;&nbsp;end;<br><br>begin<br>&nbsp;&nbsp;with&nbsp;Writer&nbsp;do<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;itemCount&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;&nbsp;&nbsp;FList.ForAll(@CountItem);<br>&nbsp;&nbsp;&nbsp;&nbsp;WriteInteger(itemCount);<br>&nbsp;&nbsp;&nbsp;&nbsp;FList.ForAll(@StoreItem);<br>&nbsp;&nbsp;end<br>end;<br><br>procedure&nbsp;TStringSparseList.DefineProperties(Filer:&nbsp;TFiler);<br>begin<br>&nbsp;&nbsp;Filer.DefineProperty('List',&nbsp;ReadData,&nbsp;WriteData,&nbsp;True);<br>end;<br><br>function&nbsp;&nbsp;TStringSparseList.Get(Index:&nbsp;Integer):&nbsp;String;<br>var<br>&nbsp;&nbsp;p:&nbsp;PStrItem;<br>begin<br>&nbsp;&nbsp;p&nbsp;:=&nbsp;PStrItem(FList[Index]);<br>&nbsp;&nbsp;if&nbsp;p&nbsp;=&nbsp;nil&nbsp;then&nbsp;Result&nbsp;:=&nbsp;''&nbsp;else&nbsp;Result&nbsp;:=&nbsp;p^.FString<br>end;<br><br>function&nbsp;&nbsp;TStringSparseList.GetCount:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;FList.Count<br>end;<br><br>function&nbsp;&nbsp;TStringSparseList.GetObject(Index:&nbsp;Integer):&nbsp;TObject;<br>var<br>&nbsp;&nbsp;p:&nbsp;PStrItem;<br>begin<br>&nbsp;&nbsp;p&nbsp;:=&nbsp;PStrItem(FList[Index]);<br>&nbsp;&nbsp;if&nbsp;p&nbsp;=&nbsp;nil&nbsp;then&nbsp;Result&nbsp;:=&nbsp;nil&nbsp;else&nbsp;Result&nbsp;:=&nbsp;p^.FObject<br>end;<br><br>procedure&nbsp;TStringSparseList.Put(Index:&nbsp;Integer;&nbsp;const&nbsp;S:&nbsp;String);<br>var<br>&nbsp;&nbsp;p:&nbsp;PStrItem;<br>&nbsp;&nbsp;obj:&nbsp;TObject;<br>begin<br>&nbsp;&nbsp;p&nbsp;:=&nbsp;PStrItem(FList[Index]);<br>&nbsp;&nbsp;if&nbsp;p&nbsp;=&nbsp;nil&nbsp;then&nbsp;obj&nbsp;:=&nbsp;nil&nbsp;else&nbsp;obj&nbsp;:=&nbsp;p^.FObject;<br>&nbsp;&nbsp;if&nbsp;(S&nbsp;=&nbsp;'')&nbsp;and&nbsp;(obj&nbsp;=&nbsp;nil)&nbsp;then&nbsp;&nbsp;&nbsp;{&nbsp;Nothing&nbsp;left&nbsp;to&nbsp;store&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;FList[Index]&nbsp;:=&nbsp;nil<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;FList[Index]&nbsp;:=&nbsp;NewStrItem(S,&nbsp;obj);<br>&nbsp;&nbsp;if&nbsp;p&nbsp;&lt;&gt;&nbsp;nil&nbsp;then&nbsp;DisposeStrItem(p);<br>&nbsp;&nbsp;Changed<br>end;<br><br>procedure&nbsp;TStringSparseList.PutObject(Index:&nbsp;Integer;&nbsp;AObject:&nbsp;TObject);<br>var<br>&nbsp;&nbsp;p:&nbsp;PStrItem;<br>begin<br>&nbsp;&nbsp;p&nbsp;:=&nbsp;PStrItem(FList[Index]);<br>&nbsp;&nbsp;if&nbsp;p&nbsp;&lt;&gt;&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;p^.FObject&nbsp;:=&nbsp;AObject<br>&nbsp;&nbsp;else&nbsp;if&nbsp;AObject&nbsp;&lt;&gt;&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;FList[Index]&nbsp;:=&nbsp;NewStrItem('',AObject);<br>&nbsp;&nbsp;Changed<br>end;<br><br>procedure&nbsp;TStringSparseList.Changed;<br>begin<br>&nbsp;&nbsp;if&nbsp;Assigned(FOnChange)&nbsp;then&nbsp;FOnChange(Self)<br>end;<br><br>procedure&nbsp;TStringSparseList.Delete(Index:&nbsp;Integer);<br>var<br>&nbsp;&nbsp;p:&nbsp;PStrItem;<br>begin<br>&nbsp;&nbsp;p&nbsp;:=&nbsp;PStrItem(FList[Index]);<br>&nbsp;&nbsp;if&nbsp;p&nbsp;&lt;&gt;&nbsp;nil&nbsp;then&nbsp;DisposeStrItem(p);<br>&nbsp;&nbsp;FList.Delete(Index);<br>&nbsp;&nbsp;Changed<br>end;<br><br>procedure&nbsp;TStringSparseList.Exchange(Index1,&nbsp;Index2:&nbsp;Integer);<br>begin<br>&nbsp;&nbsp;FList.Exchange(Index1,&nbsp;Index2);<br>end;<br><br>procedure&nbsp;TStringSparseList.Insert(Index:&nbsp;Integer;&nbsp;const&nbsp;S:&nbsp;String);<br>begin<br>&nbsp;&nbsp;FList.Insert(Index,&nbsp;NewStrItem(S,&nbsp;nil));<br>&nbsp;&nbsp;Changed<br>end;<br><br>procedure&nbsp;TStringSparseList.Clear;<br><br>&nbsp;&nbsp;function&nbsp;&nbsp;ClearItem(TheIndex:&nbsp;Integer;&nbsp;TheItem:&nbsp;Pointer):&nbsp;Integer;&nbsp;far;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;DisposeStrItem(PStrItem(TheItem));&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Item&nbsp;guaranteed&nbsp;non-nil&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;0<br>&nbsp;&nbsp;end;<br><br>begin<br>&nbsp;&nbsp;FList.ForAll(@ClearItem);<br>&nbsp;&nbsp;FList.Clear;<br>&nbsp;&nbsp;Changed<br>end;<br><br>{&nbsp;TPZGridStrings&nbsp;}<br><br>{&nbsp;AIndex&nbsp;&lt;&nbsp;0&nbsp;is&nbsp;a&nbsp;column&nbsp;(for&nbsp;column&nbsp;-AIndex&nbsp;-&nbsp;1)<br>&nbsp;&nbsp;AIndex&nbsp;&gt;&nbsp;0&nbsp;is&nbsp;a&nbsp;row&nbsp;(for&nbsp;row&nbsp;AIndex&nbsp;-&nbsp;1)<br>&nbsp;&nbsp;AIndex&nbsp;=&nbsp;0&nbsp;denotes&nbsp;an&nbsp;empty&nbsp;row&nbsp;or&nbsp;column&nbsp;}<br><br>constructor&nbsp;TPZGridStrings.Create(AGrid:&nbsp;TPZGrid;&nbsp;AIndex:&nbsp;Longint);<br>begin<br>&nbsp;&nbsp;inherited&nbsp;Create;<br>&nbsp;&nbsp;FGrid&nbsp;:=&nbsp;AGrid;<br>&nbsp;&nbsp;FIndex&nbsp;:=&nbsp;AIndex;<br>end;<br><br>procedure&nbsp;TPZGridStrings.Assign(Source:&nbsp;TPersistent);<br>var<br>&nbsp;&nbsp;I,&nbsp;Max:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;if&nbsp;Source&nbsp;is&nbsp;TStrings&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;BeginUpdate;<br>&nbsp;&nbsp;&nbsp;&nbsp;Max&nbsp;:=&nbsp;TStrings(Source).Count&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Max&nbsp;&gt;=&nbsp;Count&nbsp;then&nbsp;Max&nbsp;:=&nbsp;Count&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;try<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;I&nbsp;:=&nbsp;0&nbsp;to&nbsp;Max&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Put(I,&nbsp;TStrings(Source).Strings);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PutObject(I,&nbsp;TStrings(Source).Objects);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;finally<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;EndUpdate;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;Exit;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;inherited&nbsp;Assign(Source);<br>end;<br><br>procedure&nbsp;TPZGridStrings.CalcXY(Index:&nbsp;Integer;&nbsp;var&nbsp;X,&nbsp;Y:&nbsp;Integer);<br>begin<br>&nbsp;&nbsp;if&nbsp;FIndex&nbsp;=&nbsp;0&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;X&nbsp;:=&nbsp;-1;&nbsp;Y&nbsp;:=&nbsp;-1;<br>&nbsp;&nbsp;end&nbsp;else&nbsp;if&nbsp;FIndex&nbsp;&gt;&nbsp;0&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;X&nbsp;:=&nbsp;Index;<br>&nbsp;&nbsp;&nbsp;&nbsp;Y&nbsp;:=&nbsp;FIndex&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;end&nbsp;else<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;X&nbsp;:=&nbsp;-FIndex&nbsp;-&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;Y&nbsp;:=&nbsp;Index;<br>&nbsp;&nbsp;end;<br>end;<br><br>{&nbsp;Changes&nbsp;the&nbsp;meaning&nbsp;of&nbsp;Add&nbsp;to&nbsp;mean&nbsp;copy&nbsp;to&nbsp;the&nbsp;first&nbsp;empty&nbsp;string&nbsp;}<br>function&nbsp;TPZGridStrings.Add(const&nbsp;S:&nbsp;string):&nbsp;Integer;<br>var<br>&nbsp;&nbsp;I:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;for&nbsp;I&nbsp;:=&nbsp;0&nbsp;to&nbsp;Count&nbsp;-&nbsp;1&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Strings&nbsp;=&nbsp;''&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;S&nbsp;=&nbsp;''&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Strings&nbsp;:=&nbsp;'&nbsp;'<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Strings&nbsp;:=&nbsp;S;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;I;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;-1;<br>end;<br><br>procedure&nbsp;TPZGridStrings.Clear;<br>var<br>&nbsp;&nbsp;SSList:&nbsp;TStringSparseList;<br>&nbsp;&nbsp;I:&nbsp;Integer;<br><br>&nbsp;&nbsp;function&nbsp;BlankStr(TheIndex:&nbsp;Integer;&nbsp;TheItem:&nbsp;Pointer):&nbsp;Integer;&nbsp;far;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Objects[TheIndex]&nbsp;:=&nbsp;nil;<br>&nbsp;&nbsp;&nbsp;&nbsp;Strings[TheIndex]&nbsp;:=&nbsp;'';<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;end;<br><br>begin<br>&nbsp;&nbsp;if&nbsp;FIndex&nbsp;&gt;&nbsp;0&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;SSList&nbsp;:=&nbsp;TStringSparseList(TSparseList(FGrid.FData)[FIndex&nbsp;-&nbsp;1]);<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;SSList&nbsp;&lt;&gt;&nbsp;nil&nbsp;then&nbsp;SSList.List.ForAll(@BlankStr);<br>&nbsp;&nbsp;end<br>&nbsp;&nbsp;else&nbsp;if&nbsp;FIndex&nbsp;&lt;&nbsp;0&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;I&nbsp;:=&nbsp;Count&nbsp;-&nbsp;1&nbsp;downto&nbsp;0&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Objects&nbsp;:=&nbsp;nil;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Strings&nbsp;:=&nbsp;'';<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TPZGridStrings.Delete(Index:&nbsp;Integer);<br>begin<br>&nbsp;&nbsp;InvalidOp(sInvalidStringGridOp);<br>end;<br><br>function&nbsp;TPZGridStrings.Get(Index:&nbsp;Integer):&nbsp;string;<br>var<br>&nbsp;&nbsp;X,&nbsp;Y:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;CalcXY(Index,&nbsp;X,&nbsp;Y);<br>&nbsp;&nbsp;if&nbsp;X&nbsp;&lt;&nbsp;0&nbsp;then&nbsp;Result&nbsp;:=&nbsp;''&nbsp;else&nbsp;Result&nbsp;:=&nbsp;FGrid.Cells[X,&nbsp;Y];<br>end;<br><br>function&nbsp;TPZGridStrings.GetCount:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;{&nbsp;Count&nbsp;of&nbsp;a&nbsp;row&nbsp;is&nbsp;the&nbsp;column&nbsp;count,&nbsp;and&nbsp;vice&nbsp;versa&nbsp;}<br>&nbsp;&nbsp;if&nbsp;FIndex&nbsp;=&nbsp;0&nbsp;then&nbsp;Result&nbsp;:=&nbsp;0<br>&nbsp;&nbsp;else&nbsp;if&nbsp;FIndex&nbsp;&gt;&nbsp;0&nbsp;then&nbsp;Result&nbsp;:=&nbsp;Integer(FGrid.ColCount)<br>&nbsp;&nbsp;else&nbsp;Result&nbsp;:=&nbsp;Integer(FGrid.RowCount);<br>end;<br><br>function&nbsp;TPZGridStrings.GetObject(Index:&nbsp;Integer):&nbsp;TObject;<br>var<br>&nbsp;&nbsp;X,&nbsp;Y:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;CalcXY(Index,&nbsp;X,&nbsp;Y);<br>&nbsp;&nbsp;if&nbsp;X&nbsp;&lt;&nbsp;0&nbsp;then&nbsp;Result&nbsp;:=&nbsp;nil&nbsp;else&nbsp;Result&nbsp;:=&nbsp;FGrid.Objects[X,&nbsp;Y];<br>end;<br><br>procedure&nbsp;TPZGridStrings.Insert(Index:&nbsp;Integer;&nbsp;const&nbsp;S:&nbsp;string);<br>begin<br>&nbsp;&nbsp;InvalidOp(sInvalidStringGridOp);<br>end;<br><br>procedure&nbsp;TPZGridStrings.Put(Index:&nbsp;Integer;&nbsp;const&nbsp;S:&nbsp;string);<br>var<br>&nbsp;&nbsp;X,&nbsp;Y:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;CalcXY(Index,&nbsp;X,&nbsp;Y);<br>&nbsp;&nbsp;FGrid.Cells[X,&nbsp;Y]&nbsp;:=&nbsp;S;<br>end;<br><br>procedure&nbsp;TPZGridStrings.PutObject(Index:&nbsp;Integer;&nbsp;AObject:&nbsp;TObject);<br>var<br>&nbsp;&nbsp;X,&nbsp;Y:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;CalcXY(Index,&nbsp;X,&nbsp;Y);<br>&nbsp;&nbsp;FGrid.Objects[X,&nbsp;Y]&nbsp;:=&nbsp;AObject;<br>end;<br><br>procedure&nbsp;TPZGridStrings.SetUpdateState(Updating:&nbsp;Boolean);<br>begin<br>&nbsp;&nbsp;FGrid.SetUpdateState(Updating);<br>end;<br><br>{&nbsp;TPZGrid&nbsp;}<br><br>constructor&nbsp;TPZGrid.Create(AOwner:&nbsp;TComponent);<br>begin<br>&nbsp;&nbsp;inherited&nbsp;Create(AOwner);<br>&nbsp;&nbsp;Initialize;<br>end;<br><br>destructor&nbsp;TPZGrid.Destroy;<br>&nbsp;&nbsp;function&nbsp;FreeItem(TheIndex:&nbsp;Integer;&nbsp;TheItem:&nbsp;Pointer):&nbsp;Integer;&nbsp;far;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;TObject(TheItem).Free;<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;end;<br><br>begin<br>&nbsp;&nbsp;if&nbsp;FRows&nbsp;&lt;&gt;&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;TSparseList(FRows).ForAll(@FreeItem);<br>&nbsp;&nbsp;&nbsp;&nbsp;TSparseList(FRows).Free;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;if&nbsp;FCols&nbsp;&lt;&gt;&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;TSparseList(FCols).ForAll(@FreeItem);<br>&nbsp;&nbsp;&nbsp;&nbsp;TSparseList(FCols).Free;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;if&nbsp;FData&nbsp;&lt;&gt;&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;TSparseList(FData).ForAll(@FreeItem);<br>&nbsp;&nbsp;&nbsp;&nbsp;TSparseList(FData).Free;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;inherited&nbsp;Destroy;<br>end;<br><br>procedure&nbsp;TPZGrid.ColumnMoved(FromIndex,&nbsp;ToIndex:&nbsp;Longint);<br><br>&nbsp;&nbsp;function&nbsp;MoveColData(Index:&nbsp;Integer;&nbsp;ARow:&nbsp;TStringSparseList):&nbsp;Integer;&nbsp;far;<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;ARow.Move(FromIndex,&nbsp;ToIndex);<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;end;<br><br>begin<br>&nbsp;&nbsp;TSparseList(FData).ForAll(@MoveColData);<br>&nbsp;&nbsp;Invalidate;<br>&nbsp;&nbsp;inherited&nbsp;ColumnMoved(FromIndex,&nbsp;ToIndex);<br>end;<br><br>procedure&nbsp;TPZGrid.RowMoved(FromIndex,&nbsp;ToIndex:&nbsp;Longint);<br>begin<br>&nbsp;&nbsp;TSparseList(FData).Move(FromIndex,&nbsp;ToIndex);<br>&nbsp;&nbsp;Invalidate;<br>&nbsp;&nbsp;inherited&nbsp;RowMoved(FromIndex,&nbsp;ToIndex);<br>end;<br><br>function&nbsp;TPZGrid.GetEditText(ACol,&nbsp;ARow:&nbsp;Longint):&nbsp;string;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;Cells[ACol,&nbsp;ARow];<br>&nbsp;&nbsp;if&nbsp;Assigned(FOnGetEditText)&nbsp;then&nbsp;FOnGetEditText(Self,&nbsp;ACol,&nbsp;ARow,&nbsp;Result);<br>end;<br><br>procedure&nbsp;TPZGrid.SetEditText(ACol,&nbsp;ARow:&nbsp;Longint;&nbsp;const&nbsp;Value:&nbsp;string);<br>begin<br>&nbsp;&nbsp;DisableEditUpdate;<br>&nbsp;&nbsp;try<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Value&nbsp;&lt;&gt;&nbsp;Cells[ACol,&nbsp;ARow]&nbsp;then&nbsp;Cells[ACol,&nbsp;ARow]&nbsp;:=&nbsp;Value;<br>&nbsp;&nbsp;finally<br>&nbsp;&nbsp;&nbsp;&nbsp;EnableEditUpdate;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;inherited&nbsp;SetEditText(ACol,&nbsp;ARow,&nbsp;Value);<br>end;<br><br>procedure&nbsp;TPZGrid.DrawCell(ACol,&nbsp;ARow:&nbsp;Longint;&nbsp;ARect:&nbsp;TRect;<br>&nbsp;&nbsp;AState:&nbsp;TGridDrawState);<br>begin<br>&nbsp;&nbsp;if&nbsp;DefaultDrawing&nbsp;then<br>&nbsp;&nbsp;&nbsp;Canvas.TextRect(ARect,&nbsp;ARect.Left+2,&nbsp;ARect.Top+2,&nbsp;Cells[ACol,&nbsp;ARow]);<br>&nbsp;&nbsp;&nbsp;inherited&nbsp;DrawCell(ACol,&nbsp;ARow,&nbsp;ARect,&nbsp;AState);<br>end;<br><br>procedure&nbsp;TPZGrid.DisableEditUpdate;<br>begin<br>&nbsp;&nbsp;Inc(FEditUpdate);<br>end;<br><br>procedure&nbsp;TPZGrid.EnableEditUpdate;<br>begin<br>&nbsp;&nbsp;Dec(FEditUpdate);<br>end;<br><br>procedure&nbsp;TPZGrid.Initialize;<br>var<br>&nbsp;&nbsp;quantum:&nbsp;TSPAQuantum;<br>begin<br>&nbsp;&nbsp;if&nbsp;FCols&nbsp;=&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ColCount&nbsp;&gt;&nbsp;512&nbsp;then&nbsp;quantum&nbsp;:=&nbsp;SPALarge&nbsp;else&nbsp;quantum&nbsp;:=&nbsp;SPASmall;<br>&nbsp;&nbsp;&nbsp;&nbsp;FCols&nbsp;:=&nbsp;TSparseList.Create(quantum);<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;if&nbsp;RowCount&nbsp;&gt;&nbsp;256&nbsp;then&nbsp;quantum&nbsp;:=&nbsp;SPALarge&nbsp;else&nbsp;quantum&nbsp;:=&nbsp;SPASmall;<br>&nbsp;&nbsp;if&nbsp;FRows&nbsp;=&nbsp;nil&nbsp;then&nbsp;FRows&nbsp;:=&nbsp;TSparseList.Create(quantum);<br>&nbsp;&nbsp;if&nbsp;FData&nbsp;=&nbsp;nil&nbsp;then&nbsp;FData&nbsp;:=&nbsp;TSparseList.Create(quantum);<br>end;<br><br>procedure&nbsp;TPZGrid.SetUpdateState(Updating:&nbsp;Boolean);<br>begin<br>&nbsp;&nbsp;FUpdating&nbsp;:=&nbsp;Updating;&nbsp;<br>&nbsp;&nbsp;if&nbsp;not&nbsp;Updating&nbsp;and&nbsp;FNeedsUpdating&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;InvalidateGrid;<br>&nbsp;&nbsp;&nbsp;&nbsp;FNeedsUpdating&nbsp;:=&nbsp;False;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TPZGrid.Update(ACol,&nbsp;ARow:&nbsp;Integer);<br>begin<br>&nbsp;&nbsp;if&nbsp;not&nbsp;FUpdating&nbsp;then&nbsp;InvalidateCell(ACol,&nbsp;ARow)<br>&nbsp;&nbsp;else&nbsp;FNeedsUpdating&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;if&nbsp;(ACol&nbsp;=&nbsp;Col)&nbsp;and&nbsp;(ARow&nbsp;=&nbsp;Row)&nbsp;and&nbsp;(FEditUpdate&nbsp;=&nbsp;0)&nbsp;then&nbsp;InvalidateEditor;<br>end;<br><br>function&nbsp;&nbsp;TPZGrid.EnsureColRow(Index:&nbsp;Integer;&nbsp;IsCol:&nbsp;Boolean):<br>&nbsp;&nbsp;TPZGridStrings;<br>var<br>&nbsp;&nbsp;RCIndex:&nbsp;Integer;<br>&nbsp;&nbsp;PList:&nbsp;^TSparseList;<br>begin<br>&nbsp;&nbsp;if&nbsp;IsCol&nbsp;then&nbsp;PList&nbsp;:=&nbsp;@FCols&nbsp;else&nbsp;PList&nbsp;:=&nbsp;@FRows;<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;TPZGridStrings(PList^[Index]);<br>&nbsp;&nbsp;if&nbsp;Result&nbsp;=&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;IsCol&nbsp;then&nbsp;RCIndex&nbsp;:=&nbsp;-Index&nbsp;-&nbsp;1&nbsp;else&nbsp;RCIndex&nbsp;:=&nbsp;Index&nbsp;+&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;TPZGridStrings.Create(Self,&nbsp;RCIndex);<br>&nbsp;&nbsp;&nbsp;&nbsp;PList^[Index]&nbsp;:=&nbsp;Result;<br>&nbsp;&nbsp;end;<br>end;<br><br>function&nbsp;&nbsp;TPZGrid.EnsureDataRow(ARow:&nbsp;Integer):&nbsp;Pointer;<br>var<br>&nbsp;&nbsp;quantum:&nbsp;TSPAQuantum;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;TStringSparseList(TSparseList(FData)[ARow]);<br>&nbsp;&nbsp;if&nbsp;Result&nbsp;=&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ColCount&nbsp;&gt;&nbsp;512&nbsp;then&nbsp;quantum&nbsp;:=&nbsp;SPALarge&nbsp;else&nbsp;quantum&nbsp;:=&nbsp;SPASmall;<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;TStringSparseList.Create(quantum);<br>&nbsp;&nbsp;&nbsp;&nbsp;TSparseList(FData)[ARow]&nbsp;:=&nbsp;Result;<br>&nbsp;&nbsp;end;<br>end;<br><br>function&nbsp;TPZGrid.GetCells(ACol,&nbsp;ARow:&nbsp;Integer):&nbsp;string;<br>var<br>&nbsp;&nbsp;ssl:&nbsp;TStringSparseList;<br>begin<br>&nbsp;&nbsp;ssl&nbsp;:=&nbsp;TStringSparseList(TSparseList(FData)[ARow]);<br>&nbsp;&nbsp;if&nbsp;ssl&nbsp;=&nbsp;nil&nbsp;then&nbsp;Result&nbsp;:=&nbsp;''&nbsp;else&nbsp;Result&nbsp;:=&nbsp;ssl[ACol];<br>end;<br><br>function&nbsp;TPZGrid.GetCols(Index:&nbsp;Integer):&nbsp;TStrings;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;EnsureColRow(Index,&nbsp;True);<br>end;<br><br>function&nbsp;TPZGrid.GetObjects(ACol,&nbsp;ARow:&nbsp;Integer):&nbsp;TObject;<br>var<br>&nbsp;&nbsp;ssl:&nbsp;TStringSparseList;<br>begin<br>&nbsp;&nbsp;ssl&nbsp;:=&nbsp;TStringSparseList(TSparseList(FData)[ARow]);<br>&nbsp;&nbsp;if&nbsp;ssl&nbsp;=&nbsp;nil&nbsp;then&nbsp;Result&nbsp;:=&nbsp;nil&nbsp;else&nbsp;Result&nbsp;:=&nbsp;ssl.Objects[ACol];<br>end;<br><br>function&nbsp;TPZGrid.GetRows(Index:&nbsp;Integer):&nbsp;TStrings;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;EnsureColRow(Index,&nbsp;False);<br>end;<br><br>procedure&nbsp;TPZGrid.SetCells(ACol,&nbsp;ARow:&nbsp;Integer;&nbsp;const&nbsp;Value:&nbsp;string);<br>begin<br>&nbsp;&nbsp;TPZGridStrings(EnsureDataRow(ARow))[ACol]&nbsp;:=&nbsp;Value;<br>&nbsp;&nbsp;EnsureColRow(ACol,&nbsp;True);<br>&nbsp;&nbsp;EnsureColRow(ARow,&nbsp;False);<br>&nbsp;&nbsp;Update(ACol,&nbsp;ARow);<br>end;<br><br>procedure&nbsp;TPZGrid.SetCols(Index:&nbsp;Integer;&nbsp;Value:&nbsp;TStrings);<br>begin<br>&nbsp;&nbsp;EnsureColRow(Index,&nbsp;True).Assign(Value);<br>end;<br><br>procedure&nbsp;TPZGrid.SetObjects(ACol,&nbsp;ARow:&nbsp;Integer;&nbsp;Value:&nbsp;TObject);<br>begin<br>&nbsp;&nbsp;TPZGridStrings(EnsureDataRow(ARow)).Objects[ACol]&nbsp;:=&nbsp;Value;<br>&nbsp;&nbsp;EnsureColRow(ACol,&nbsp;True);<br>&nbsp;&nbsp;EnsureColRow(ARow,&nbsp;False);<br>&nbsp;&nbsp;Update(ACol,&nbsp;ARow);<br>end;<br><br>procedure&nbsp;TPZGrid.SetRows(Index:&nbsp;Integer;&nbsp;Value:&nbsp;TStrings);<br>begin<br>&nbsp;&nbsp;EnsureColRow(Index,&nbsp;False).Assign(Value);<br>end;<br><br>type<br><br>{&nbsp;TPopupListbox&nbsp;}<br><br>&nbsp;&nbsp;TPopupListbox&nbsp;=&nbsp;class(TCustomListbox)<br>&nbsp;&nbsp;private<br>&nbsp;&nbsp;&nbsp;&nbsp;FSearchText:&nbsp;String;<br>&nbsp;&nbsp;&nbsp;&nbsp;FSearchTickCount:&nbsp;Longint;<br>&nbsp;&nbsp;protected<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;CreateParams(var&nbsp;Params:&nbsp;TCreateParams);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;CreateWnd;&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;KeyPress(var&nbsp;Key:&nbsp;Char);&nbsp;override;<br>&nbsp;&nbsp;&nbsp;&nbsp;procedure&nbsp;MouseUp(Button:&nbsp;TMouseButton;&nbsp;Shift:&nbsp;TShiftState;&nbsp;X,&nbsp;Y:&nbsp;Integer);&nbsp;override;<br>&nbsp;&nbsp;end;<br><br>procedure&nbsp;TPopupListBox.CreateParams(var&nbsp;Params:&nbsp;TCreateParams);<br>begin<br>&nbsp;&nbsp;inherited&nbsp;CreateParams(Params);<br>&nbsp;&nbsp;with&nbsp;Params&nbsp;do<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;Style&nbsp;:=&nbsp;Style&nbsp;or&nbsp;WS_BORDER;<br>&nbsp;&nbsp;&nbsp;&nbsp;ExStyle&nbsp;:=&nbsp;WS_EX_TOOLWINDOW&nbsp;or&nbsp;WS_EX_TOPMOST;<br>&nbsp;&nbsp;&nbsp;&nbsp;AddBiDiModeExStyle(ExStyle);<br>&nbsp;&nbsp;&nbsp;&nbsp;WindowClass.Style&nbsp;:=&nbsp;CS_SAVEBITS;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TPopupListbox.CreateWnd;<br>begin<br>&nbsp;&nbsp;inherited&nbsp;CreateWnd;<br>&nbsp;&nbsp;Windows.SetParent(Handle,&nbsp;0);<br>&nbsp;&nbsp;CallWindowProc(DefWndProc,&nbsp;Handle,&nbsp;wm_SetFocus,&nbsp;0,&nbsp;0);<br>end;<br><br>procedure&nbsp;TPopupListbox.Keypress(var&nbsp;Key:&nbsp;Char);<br>var<br>&nbsp;&nbsp;TickCount:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;case&nbsp;Key&nbsp;of<br>&nbsp;&nbsp;&nbsp;&nbsp;#8,&nbsp;#27:&nbsp;FSearchText&nbsp;:=&nbsp;'';<br>&nbsp;&nbsp;&nbsp;&nbsp;#32..#255:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TickCount&nbsp;:=&nbsp;GetTickCount;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;TickCount&nbsp;-&nbsp;FSearchTickCount&nbsp;&gt;&nbsp;2000&nbsp;then&nbsp;FSearchText&nbsp;:=&nbsp;'';<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FSearchTickCount&nbsp;:=&nbsp;TickCount;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Length(FSearchText)&nbsp;&lt;&nbsp;32&nbsp;then&nbsp;FSearchText&nbsp;:=&nbsp;FSearchText&nbsp;+&nbsp;Key;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SendMessage(Handle,&nbsp;LB_SelectString,&nbsp;WORD(-1),&nbsp;Longint(PChar(FSearchText)));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Key&nbsp;:=&nbsp;#0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;inherited&nbsp;Keypress(Key);<br>end;<br><br>procedure&nbsp;TPopupListbox.MouseUp(Button:&nbsp;TMouseButton;&nbsp;Shift:&nbsp;TShiftState;<br>&nbsp;&nbsp;X,&nbsp;Y:&nbsp;Integer);<br>begin<br>&nbsp;&nbsp;inherited&nbsp;MouseUp(Button,&nbsp;Shift,&nbsp;X,&nbsp;Y);<br>&nbsp;&nbsp;TInplaceEditList(Owner).CloseUp((X&nbsp;&gt;=&nbsp;0)&nbsp;and&nbsp;(Y&nbsp;&gt;=&nbsp;0)&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(X&nbsp;&lt;&nbsp;Width)&nbsp;and&nbsp;(Y&nbsp;&lt;&nbsp;Height));<br>end;<br><br>{&nbsp;TInplaceEditList&nbsp;}<br><br>constructor&nbsp;TInplaceEditList.Create(Owner:&nbsp;TComponent);<br>begin<br>&nbsp;&nbsp;inherited&nbsp;Create(Owner);<br>&nbsp;&nbsp;FButtonWidth&nbsp;:=&nbsp;GetSystemMetrics(SM_CXVSCROLL);<br>&nbsp;&nbsp;FEditStyle&nbsp;:=&nbsp;esSimple;<br>end;<br><br>procedure&nbsp;TInplaceEditList.BoundsChanged;<br>var<br>&nbsp;&nbsp;R:&nbsp;TRect;<br>begin<br>&nbsp;&nbsp;SetRect(R,&nbsp;2,&nbsp;2,&nbsp;Width&nbsp;-&nbsp;2,&nbsp;Height);<br>&nbsp;&nbsp;if&nbsp;EditStyle&nbsp;&lt;&gt;&nbsp;esSimple&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;not&nbsp;Grid.UseRightToLeftAlignment&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dec(R.Right,&nbsp;ButtonWidth)<br>&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Inc(R.Left,&nbsp;ButtonWidth&nbsp;-&nbsp;2);<br>&nbsp;&nbsp;SendMessage(Handle,&nbsp;EM_SETRECTNP,&nbsp;0,&nbsp;LongInt(@R));<br>&nbsp;&nbsp;SendMessage(Handle,&nbsp;EM_SCROLLCARET,&nbsp;0,&nbsp;0);<br>&nbsp;&nbsp;if&nbsp;SysLocale.FarEast&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;SetImeCompositionWindow(Font,&nbsp;R.Left,&nbsp;R.Top);<br>end;<br><br>procedure&nbsp;TInplaceEditList.CloseUp(Accept:&nbsp;Boolean);<br>var<br>&nbsp;&nbsp;ListValue:&nbsp;Variant;<br>begin<br>&nbsp;&nbsp;if&nbsp;ListVisible&nbsp;and&nbsp;(ActiveList&nbsp;=&nbsp;FPickList)&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;GetCapture&nbsp;&lt;&gt;&nbsp;0&nbsp;then&nbsp;SendMessage(GetCapture,&nbsp;WM_CANCELMODE,&nbsp;0,&nbsp;0);<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;PickList.ItemIndex&nbsp;&lt;&gt;&nbsp;-1&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ListValue&nbsp;:=&nbsp;PickList.Items[PickList.ItemIndex];<br>&nbsp;&nbsp;&nbsp;&nbsp;SetWindowPos(ActiveList.Handle,&nbsp;0,&nbsp;0,&nbsp;0,&nbsp;0,&nbsp;0,&nbsp;SWP_NOZORDER&nbsp;or<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SWP_NOMOVE&nbsp;or&nbsp;SWP_NOSIZE&nbsp;or&nbsp;SWP_NOACTIVATE&nbsp;or&nbsp;SWP_HIDEWINDOW);<br>&nbsp;&nbsp;&nbsp;&nbsp;FListVisible&nbsp;:=&nbsp;False;<br>&nbsp;&nbsp;&nbsp;&nbsp;Invalidate;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Accept&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(not&nbsp;VarIsEmpty(ListValue)&nbsp;or&nbsp;VarIsNull(ListValue))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;and&nbsp;(ListValue&nbsp;&lt;&gt;&nbsp;Text)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;Here&nbsp;we&nbsp;store&nbsp;the&nbsp;new&nbsp;value&nbsp;directly&nbsp;in&nbsp;the&nbsp;edit&nbsp;control&nbsp;so&nbsp;that<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;we&nbsp;bypass&nbsp;the&nbsp;CMTextChanged&nbsp;method&nbsp;on&nbsp;TCustomMaskedEdit.&nbsp;&nbsp;This<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;preserves&nbsp;the&nbsp;old&nbsp;value&nbsp;so&nbsp;that&nbsp;we&nbsp;can&nbsp;restore&nbsp;it&nbsp;later&nbsp;by&nbsp;calling<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;the&nbsp;Reset&nbsp;method.&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Perform(WM_SETTEXT,&nbsp;0,&nbsp;Longint(string(ListValue)));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Modified&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;Grid&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SetEditText(Col,&nbsp;Row,&nbsp;ListValue);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TInplaceEditList.DoDropDownKeys(var&nbsp;Key:&nbsp;Word;&nbsp;Shift:&nbsp;TShiftState);<br>begin<br>&nbsp;&nbsp;case&nbsp;Key&nbsp;of<br>&nbsp;&nbsp;&nbsp;&nbsp;VK_UP,&nbsp;VK_DOWN:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ssAlt&nbsp;in&nbsp;Shift&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ListVisible&nbsp;then&nbsp;CloseUp(True)&nbsp;else&nbsp;DropDown;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Key&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;VK_RETURN,&nbsp;VK_ESCAPE:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ListVisible&nbsp;and&nbsp;not&nbsp;(ssAlt&nbsp;in&nbsp;Shift)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CloseUp(Key&nbsp;=&nbsp;VK_RETURN);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Key&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TInplaceEditList.DoEditButtonClick;<br>begin<br>&nbsp;&nbsp;if&nbsp;Assigned(FOnEditButtonClick)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;FOnEditButtonClick(Grid);<br>end;<br><br>procedure&nbsp;TInplaceEditList.DoGetPickListItems;<br>begin<br>&nbsp;&nbsp;if&nbsp;not&nbsp;PickListLoaded&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Assigned(OnGetPickListItems)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;OnGetPickListItems(Grid.Col,&nbsp;Grid.Row,&nbsp;PickList.Items);<br>&nbsp;&nbsp;&nbsp;&nbsp;PickListLoaded&nbsp;:=&nbsp;(PickList.Items.Count&nbsp;&gt;&nbsp;0);<br>&nbsp;&nbsp;end;<br>end;<br><br>function&nbsp;TInplaceEditList.GetPickList:&nbsp;TCustomListbox;<br>var<br>&nbsp;&nbsp;PopupListbox:&nbsp;TPopupListbox;<br>begin<br>&nbsp;&nbsp;if&nbsp;not&nbsp;Assigned(FPickList)&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;PopupListbox&nbsp;:=&nbsp;TPopupListbox.Create(Self);<br>&nbsp;&nbsp;&nbsp;&nbsp;PopupListbox.Visible&nbsp;:=&nbsp;False;<br>&nbsp;&nbsp;&nbsp;&nbsp;PopupListbox.Parent&nbsp;:=&nbsp;Self;<br>&nbsp;&nbsp;&nbsp;&nbsp;PopupListbox.OnMouseUp&nbsp;:=&nbsp;ListMouseUp;<br>&nbsp;&nbsp;&nbsp;&nbsp;PopupListbox.IntegralHeight&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;&nbsp;&nbsp;PopupListbox.ItemHeight&nbsp;:=&nbsp;11;<br>&nbsp;&nbsp;&nbsp;&nbsp;FPickList&nbsp;:=&nbsp;PopupListBox;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;FPickList;<br>end;<br><br>procedure&nbsp;TInplaceEditList.DropDown;<br>var<br>&nbsp;&nbsp;P:&nbsp;TPoint;<br>&nbsp;&nbsp;I,J,Y:&nbsp;Integer;<br>begin<br>&nbsp;&nbsp;if&nbsp;not&nbsp;ListVisible&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;ActiveList.Width&nbsp;:=&nbsp;Width;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ActiveList&nbsp;=&nbsp;FPickList&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DoGetPickListItems;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TPopupListbox(PickList).Color&nbsp;:=&nbsp;Color;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TPopupListbox(PickList).Font&nbsp;:=&nbsp;Font;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(DropDownRows&nbsp;&gt;&nbsp;0)&nbsp;and&nbsp;(PickList.Items.Count&nbsp;&gt;=&nbsp;DropDownRows)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PickList.Height&nbsp;:=&nbsp;DropDownRows&nbsp;*&nbsp;TPopupListbox(PickList).ItemHeight&nbsp;+&nbsp;4<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PickList.Height&nbsp;:=&nbsp;PickList.Items.Count&nbsp;*&nbsp;TPopupListbox(PickList).ItemHeight&nbsp;+&nbsp;4;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Text&nbsp;=&nbsp;''&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PickList.ItemIndex&nbsp;:=&nbsp;-1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PickList.ItemIndex&nbsp;:=&nbsp;PickList.Items.IndexOf(Text);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;J&nbsp;:=&nbsp;PickList.ClientWidth;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for&nbsp;I&nbsp;:=&nbsp;0&nbsp;to&nbsp;PickList.Items.Count&nbsp;-&nbsp;1&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Y&nbsp;:=&nbsp;PickList.Canvas.TextWidth(PickList.Items);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Y&nbsp;&gt;&nbsp;J&nbsp;then&nbsp;J&nbsp;:=&nbsp;Y;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PickList.ClientWidth&nbsp;:=&nbsp;J;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;P&nbsp;:=&nbsp;Parent.ClientToScreen(Point(Left,&nbsp;Top));<br>&nbsp;&nbsp;&nbsp;&nbsp;Y&nbsp;:=&nbsp;P.Y&nbsp;+&nbsp;Height;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Y&nbsp;+&nbsp;ActiveList.Height&nbsp;&gt;&nbsp;Screen.Height&nbsp;then&nbsp;Y&nbsp;:=&nbsp;P.Y&nbsp;-&nbsp;ActiveList.Height;<br>&nbsp;&nbsp;&nbsp;&nbsp;SetWindowPos(ActiveList.Handle,&nbsp;HWND_TOP,&nbsp;P.X,&nbsp;Y,&nbsp;0,&nbsp;0,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SWP_NOSIZE&nbsp;or&nbsp;SWP_NOACTIVATE&nbsp;or&nbsp;SWP_SHOWWINDOW);<br>&nbsp;&nbsp;&nbsp;&nbsp;FListVisible&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;&nbsp;&nbsp;Invalidate;<br>&nbsp;&nbsp;&nbsp;&nbsp;Windows.SetFocus(Handle);<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TInplaceEditList.KeyDown(var&nbsp;Key:&nbsp;Word;&nbsp;Shift:&nbsp;TShiftState);<br>begin<br>&nbsp;&nbsp;if&nbsp;(EditStyle&nbsp;=&nbsp;esEllipsis)&nbsp;and&nbsp;(Key&nbsp;=&nbsp;VK_RETURN)&nbsp;and&nbsp;(Shift&nbsp;=&nbsp;[ssCtrl])&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;DoEditButtonClick;<br>&nbsp;&nbsp;&nbsp;&nbsp;KillMessage(Handle,&nbsp;WM_CHAR);<br>&nbsp;&nbsp;end<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;inherited&nbsp;KeyDown(Key,&nbsp;Shift);<br>end;<br><br>procedure&nbsp;TInplaceEditList.ListMouseUp(Sender:&nbsp;TObject;&nbsp;Button:&nbsp;TMouseButton;<br>&nbsp;&nbsp;Shift:&nbsp;TShiftState;&nbsp;X,&nbsp;Y:&nbsp;Integer);<br>begin<br>&nbsp;&nbsp;if&nbsp;Button&nbsp;=&nbsp;mbLeft&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;CloseUp(PtInRect(ActiveList.ClientRect,&nbsp;Point(X,&nbsp;Y)));<br>end;<br><br>procedure&nbsp;TInplaceEditList.MouseDown(Button:&nbsp;TMouseButton;&nbsp;Shift:&nbsp;TShiftState;<br>&nbsp;&nbsp;X,&nbsp;Y:&nbsp;Integer);<br>begin<br>&nbsp;&nbsp;if&nbsp;(Button&nbsp;=&nbsp;mbLeft)&nbsp;and&nbsp;(EditStyle&nbsp;&lt;&gt;&nbsp;esSimple)&nbsp;and<br>&nbsp;&nbsp;&nbsp;&nbsp;OverButton(Point(X,Y))&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ListVisible&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CloseUp(False)<br>&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MouseCapture&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FTracking&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TrackButton(X,&nbsp;Y);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Assigned(ActiveList)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DropDown;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;inherited&nbsp;MouseDown(Button,&nbsp;Shift,&nbsp;X,&nbsp;Y);<br>end;<br><br>procedure&nbsp;TInplaceEditList.MouseMove(Shift:&nbsp;TShiftState;&nbsp;X,&nbsp;Y:&nbsp;Integer);<br>var<br>&nbsp;&nbsp;ListPos:&nbsp;TPoint;<br>&nbsp;&nbsp;MousePos:&nbsp;TSmallPoint;<br>begin<br>&nbsp;&nbsp;if&nbsp;FTracking&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;TrackButton(X,&nbsp;Y);<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ListVisible&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ListPos&nbsp;:=&nbsp;ActiveList.ScreenToClient(ClientToScreen(Point(X,&nbsp;Y)));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;PtInRect(ActiveList.ClientRect,&nbsp;ListPos)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StopTracking;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MousePos&nbsp;:=&nbsp;PointToSmallPoint(ListPos);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SendMessage(ActiveList.Handle,&nbsp;WM_LBUTTONDOWN,&nbsp;0,&nbsp;Integer(MousePos));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;inherited&nbsp;MouseMove(Shift,&nbsp;X,&nbsp;Y);<br>end;<br><br>procedure&nbsp;TInplaceEditList.MouseUp(Button:&nbsp;TMouseButton;&nbsp;Shift:&nbsp;TShiftState;<br>&nbsp;&nbsp;X,&nbsp;Y:&nbsp;Integer);<br>var<br>&nbsp;&nbsp;WasPressed:&nbsp;Boolean;<br>begin<br>&nbsp;&nbsp;WasPressed&nbsp;:=&nbsp;Pressed;<br>&nbsp;&nbsp;StopTracking;<br>&nbsp;&nbsp;if&nbsp;(Button&nbsp;=&nbsp;mbLeft)&nbsp;and&nbsp;(EditStyle&nbsp;=&nbsp;esEllipsis)&nbsp;and&nbsp;WasPressed&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;DoEditButtonClick;<br>&nbsp;&nbsp;inherited&nbsp;MouseUp(Button,&nbsp;Shift,&nbsp;X,&nbsp;Y);<br>end;<br><br>procedure&nbsp;TInplaceEditList.PaintWindow(DC:&nbsp;HDC);<br>var<br>&nbsp;&nbsp;R:&nbsp;TRect;<br>&nbsp;&nbsp;Flags:&nbsp;Integer;<br>&nbsp;&nbsp;W,&nbsp;X,&nbsp;Y:&nbsp;Integer;<br>&nbsp;&nbsp;Details:&nbsp;TThemedElementDetails;<br>begin<br>&nbsp;&nbsp;if&nbsp;EditStyle&nbsp;&lt;&gt;&nbsp;esSimple&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;R&nbsp;:=&nbsp;ButtonRect;<br>&nbsp;&nbsp;&nbsp;&nbsp;Flags&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;&nbsp;&nbsp;case&nbsp;EditStyle&nbsp;of<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;esPickList:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ThemeServices.ThemesEnabled&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ActiveList&nbsp;=&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Details&nbsp;:=&nbsp;ThemeServices.GetElementDetails(tcDropDownButtonDisabled)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Pressed&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Details&nbsp;:=&nbsp;ThemeServices.GetElementDetails(tcDropDownButtonPressed)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;FMouseInControl&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Details&nbsp;:=&nbsp;ThemeServices.GetElementDetails(tcDropDownButtonHot)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Details&nbsp;:=&nbsp;ThemeServices.GetElementDetails(tcDropDownButtonNormal);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ThemeServices.DrawElement(DC,&nbsp;Details,&nbsp;R);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ActiveList&nbsp;=&nbsp;nil&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Flags&nbsp;:=&nbsp;DFCS_INACTIVE<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else&nbsp;if&nbsp;Pressed&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Flags&nbsp;:=&nbsp;DFCS_FLAT&nbsp;or&nbsp;DFCS_PUSHED;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawFrameControl(DC,&nbsp;R,&nbsp;DFC_SCROLL,&nbsp;Flags&nbsp;or&nbsp;DFCS_SCROLLCOMBOBOX);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;esEllipsis:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;ThemeServices.ThemesEnabled&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Pressed&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Details&nbsp;:=&nbsp;ThemeServices.GetElementDetails(tbPushButtonPressed)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;FMouseInControl&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Details&nbsp;:=&nbsp;ThemeServices.GetElementDetails(tbPushButtonHot)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Details&nbsp;:=&nbsp;ThemeServices.GetElementDetails(tbPushButtonNormal);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ThemeServices.DrawElement(DC,&nbsp;Details,&nbsp;R);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Pressed&nbsp;then&nbsp;Flags&nbsp;:=&nbsp;BF_FLAT;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DrawEdge(DC,&nbsp;R,&nbsp;EDGE_RAISED,&nbsp;BF_RECT&nbsp;or&nbsp;BF_MIDDLE&nbsp;or&nbsp;Flags);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;X&nbsp;:=&nbsp;R.Left&nbsp;+&nbsp;((R.Right&nbsp;-&nbsp;R.Left)&nbsp;shr&nbsp;1)&nbsp;-&nbsp;1&nbsp;+&nbsp;Ord(Pressed);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Y&nbsp;:=&nbsp;R.Top&nbsp;+&nbsp;((R.Bottom&nbsp;-&nbsp;R.Top)&nbsp;shr&nbsp;1)&nbsp;-&nbsp;1&nbsp;+&nbsp;Ord(Pressed);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;W&nbsp;:=&nbsp;ButtonWidth&nbsp;shr&nbsp;3;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;W&nbsp;=&nbsp;0&nbsp;then&nbsp;W&nbsp;:=&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PatBlt(DC,&nbsp;X,&nbsp;Y,&nbsp;W,&nbsp;W,&nbsp;BLACKNESS);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PatBlt(DC,&nbsp;X&nbsp;-&nbsp;(W&nbsp;*&nbsp;2),&nbsp;Y,&nbsp;W,&nbsp;W,&nbsp;BLACKNESS);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PatBlt(DC,&nbsp;X&nbsp;+&nbsp;(W&nbsp;*&nbsp;2),&nbsp;Y,&nbsp;W,&nbsp;W,&nbsp;BLACKNESS);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;ExcludeClipRect(DC,&nbsp;R.Left,&nbsp;R.Top,&nbsp;R.Right,&nbsp;R.Bottom);<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;inherited&nbsp;PaintWindow(DC);<br>end;<br><br>procedure&nbsp;TInplaceEditList.StopTracking;<br>begin<br>&nbsp;&nbsp;if&nbsp;FTracking&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;TrackButton(-1,&nbsp;-1);<br>&nbsp;&nbsp;&nbsp;&nbsp;FTracking&nbsp;:=&nbsp;False;<br>&nbsp;&nbsp;&nbsp;&nbsp;MouseCapture&nbsp;:=&nbsp;False;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TInplaceEditList.TrackButton(X,Y:&nbsp;Integer);<br>var<br>&nbsp;&nbsp;NewState:&nbsp;Boolean;<br>&nbsp;&nbsp;R:&nbsp;TRect;<br>begin<br>&nbsp;&nbsp;R&nbsp;:=&nbsp;ButtonRect;<br>&nbsp;&nbsp;NewState&nbsp;:=&nbsp;PtInRect(R,&nbsp;Point(X,&nbsp;Y));<br>&nbsp;&nbsp;if&nbsp;Pressed&nbsp;&lt;&gt;&nbsp;NewState&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;FPressed&nbsp;:=&nbsp;NewState;<br>&nbsp;&nbsp;&nbsp;&nbsp;InvalidateRect(Handle,&nbsp;@R,&nbsp;False);<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TInplaceEditList.UpdateContents;<br>begin<br>&nbsp;&nbsp;ActiveList&nbsp;:=&nbsp;nil;<br>&nbsp;&nbsp;PickListLoaded&nbsp;:=&nbsp;False;<br>&nbsp;&nbsp;FEditStyle&nbsp;:=&nbsp;Grid.GetEditStyle(Grid.Col,&nbsp;Grid.Row);<br>&nbsp;&nbsp;if&nbsp;EditStyle&nbsp;=&nbsp;esPickList&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;ActiveList&nbsp;:=&nbsp;PickList;<br>&nbsp;&nbsp;inherited&nbsp;UpdateContents;<br>end;<br><br>procedure&nbsp;TInplaceEditList.RestoreContents;<br>begin<br>&nbsp;&nbsp;Reset;<br>&nbsp;&nbsp;Grid.UpdateText;<br>end;<br><br>procedure&nbsp;TInplaceEditList.CMCancelMode(var&nbsp;Message:&nbsp;TCMCancelMode);<br>begin<br>&nbsp;&nbsp;if&nbsp;(Message.Sender&nbsp;&lt;&gt;&nbsp;Self)&nbsp;and&nbsp;(Message.Sender&nbsp;&lt;&gt;&nbsp;ActiveList)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;CloseUp(False);<br>end;<br><br>procedure&nbsp;TInplaceEditList.WMCancelMode(var&nbsp;Message:&nbsp;TMessage);<br>begin<br>&nbsp;&nbsp;StopTracking;<br>&nbsp;&nbsp;inherited;<br>end;<br><br>procedure&nbsp;TInplaceEditList.WMKillFocus(var&nbsp;Message:&nbsp;TMessage);<br>begin<br>&nbsp;&nbsp;if&nbsp;not&nbsp;SysLocale.FarEast&nbsp;then&nbsp;inherited<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;ImeName&nbsp;:=&nbsp;Screen.DefaultIme;<br>&nbsp;&nbsp;&nbsp;&nbsp;ImeMode&nbsp;:=&nbsp;imDontCare;<br>&nbsp;&nbsp;&nbsp;&nbsp;inherited;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;HWND(Message.WParam)&nbsp;&lt;&gt;&nbsp;Grid.Handle&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ActivateKeyboardLayout(Screen.DefaultKbLayout,&nbsp;KLF_ACTIVATE);<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;CloseUp(False);<br>end;<br><br>function&nbsp;TInplaceEditList.ButtonRect:&nbsp;TRect;<br>begin<br>&nbsp;&nbsp;if&nbsp;not&nbsp;Grid.UseRightToLeftAlignment&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;Rect(Width&nbsp;-&nbsp;ButtonWidth,&nbsp;0,&nbsp;Width,&nbsp;Height)<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;Result&nbsp;:=&nbsp;Rect(0,&nbsp;0,&nbsp;ButtonWidth,&nbsp;Height);<br>end;<br><br>function&nbsp;TInplaceEditList.OverButton(const&nbsp;P:&nbsp;TPoint):&nbsp;Boolean;<br>begin<br>&nbsp;&nbsp;Result&nbsp;:=&nbsp;PtInRect(ButtonRect,&nbsp;P);<br>end;<br><br>procedure&nbsp;TInplaceEditList.WMLButtonDblClk(var&nbsp;Message:&nbsp;TWMLButtonDblClk);<br>begin<br>&nbsp;&nbsp;with&nbsp;Message&nbsp;do<br>&nbsp;&nbsp;if&nbsp;(EditStyle&nbsp;&lt;&gt;&nbsp;esSimple)&nbsp;and&nbsp;OverButton(Point(XPos,&nbsp;YPos))&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;Exit;<br>&nbsp;&nbsp;inherited;<br>end;<br><br>procedure&nbsp;TInplaceEditList.WMPaint(var&nbsp;Message:&nbsp;TWMPaint);<br>begin<br>&nbsp;&nbsp;PaintHandler(Message);<br>end;<br><br>procedure&nbsp;TInplaceEditList.WMSetCursor(var&nbsp;Message:&nbsp;TWMSetCursor);<br>var<br>&nbsp;&nbsp;P:&nbsp;TPoint;<br>begin<br>&nbsp;&nbsp;GetCursorPos(P);<br>&nbsp;&nbsp;P&nbsp;:=&nbsp;ScreenToClient(P);<br>&nbsp;&nbsp;if&nbsp;(EditStyle&nbsp;&lt;&gt;&nbsp;esSimple)&nbsp;and&nbsp;OverButton(P)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;Windows.SetCursor(LoadCursor(0,&nbsp;idc_Arrow))<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;inherited;<br>end;<br><br>procedure&nbsp;TInplaceEditList.WndProc(var&nbsp;Message:&nbsp;TMessage);<br>begin<br>&nbsp;&nbsp;case&nbsp;Message.Msg&nbsp;of<br>&nbsp;&nbsp;&nbsp;&nbsp;wm_KeyDown,&nbsp;wm_SysKeyDown,&nbsp;wm_Char:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;EditStyle&nbsp;=&nbsp;esPickList&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;TWMKey(Message)&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DoDropDownKeys(CharCode,&nbsp;KeyDataToShiftState(KeyData));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(CharCode&nbsp;&lt;&gt;&nbsp;0)&nbsp;and&nbsp;ListVisible&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;TMessage(Message)&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SendMessage(ActiveList.Handle,&nbsp;Msg,&nbsp;WParam,&nbsp;LParam);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Exit;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end<br>&nbsp;&nbsp;end;<br>&nbsp;&nbsp;inherited;<br>end;<br><br>procedure&nbsp;TInplaceEditList.DblClick;<br>var<br>&nbsp;&nbsp;Index:&nbsp;Integer;<br>&nbsp;&nbsp;ListValue:&nbsp;string;<br>begin<br>&nbsp;&nbsp;if&nbsp;(EditStyle&nbsp;=&nbsp;esSimple)&nbsp;or&nbsp;Assigned(Grid.OnDblClick)&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;inherited<br>&nbsp;&nbsp;else&nbsp;if&nbsp;(EditStyle&nbsp;=&nbsp;esPickList)&nbsp;and&nbsp;(ActiveList&nbsp;=&nbsp;PickList)&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;DoGetPickListItems;<br>&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;PickList.Items.Count&nbsp;&gt;&nbsp;0&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Index&nbsp;:=&nbsp;PickList.ItemIndex&nbsp;+&nbsp;1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;Index&nbsp;&gt;=&nbsp;PickList.Items.Count&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Index&nbsp;:=&nbsp;0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PickList.ItemIndex&nbsp;:=&nbsp;Index;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ListValue&nbsp;:=&nbsp;PickList.Items[PickList.ItemIndex];<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Perform(WM_SETTEXT,&nbsp;0,&nbsp;Longint(ListValue));<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Modified&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with&nbsp;Grid&nbsp;do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SetEditText(Col,&nbsp;Row,&nbsp;ListValue);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;SelectAll;<br>&nbsp;&nbsp;&nbsp;&nbsp;end;<br>&nbsp;&nbsp;end<br>&nbsp;&nbsp;else&nbsp;if&nbsp;EditStyle&nbsp;=&nbsp;esEllipsis&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;DoEditButtonClick;<br>end;<br><br>procedure&nbsp;TInplaceEditList.CMMouseEnter(var&nbsp;Message:&nbsp;TMessage);<br>begin<br>&nbsp;&nbsp;inherited;<br><br>&nbsp;&nbsp;if&nbsp;ThemeServices.ThemesEnabled&nbsp;and&nbsp;not&nbsp;FMouseInControl&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;FMouseInControl&nbsp;:=&nbsp;True;<br>&nbsp;&nbsp;&nbsp;&nbsp;Invalidate;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;TInplaceEditList.CMMouseLeave(var&nbsp;Message:&nbsp;TMessage);<br>begin<br>&nbsp;&nbsp;inherited;<br>&nbsp;&nbsp;if&nbsp;ThemeServices.ThemesEnabled&nbsp;and&nbsp;FMouseInControl&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;FMouseInControl&nbsp;:=&nbsp;False;<br>&nbsp;&nbsp;&nbsp;&nbsp;Invalidate;<br>&nbsp;&nbsp;end;<br>end;<br><br>procedure&nbsp;Register;<br>begin<br>&nbsp;&nbsp;RegisterComponents('PZGrid',&nbsp;[TPZGrid]);<br>end;<br><br>{&nbsp;TLineColors&nbsp;}<br><br>//&nbsp;************************************************<br>constructor&nbsp;TLineColors.Create;<br>begin<br>&nbsp;&nbsp;DefaultLineColor:=clGray;<br>&nbsp;&nbsp;SeperatorLineColor:=clRed;<br>&nbsp;&nbsp;ThousandLineColor:=clBlue;<br>end;<br><br>function&nbsp;TLineColors.GetLineColor(Index:&nbsp;integer):&nbsp;TColor;<br>begin<br>&nbsp;&nbsp;if&nbsp;Index&nbsp;in&nbsp;[1..5]&nbsp;then<br>&nbsp;&nbsp;&nbsp;&nbsp;Result:=FLineColors[Index]<br>&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;Result:=0;<br>end;<br><br>procedure&nbsp;TLineColors.SetLineColor(Index:&nbsp;integer;&nbsp;Value:&nbsp;TColor);<br>begin<br>&nbsp;&nbsp;if&nbsp;(Index&nbsp;in&nbsp;[1..5])and(Value&lt;&gt;FLineColors[Index])&nbsp;then<br>&nbsp;&nbsp;begin<br>&nbsp;&nbsp;&nbsp;&nbsp;FLineColors[Index]:=Value;<br>&nbsp;&nbsp;&nbsp;&nbsp;Changed;&nbsp;//&nbsp;Cause&nbsp;to&nbsp;call&nbsp;OnChange<br>&nbsp;&nbsp;end;<br>end;<br><br>end.
 

Similar threads

A
回复
0
查看
992
Andreas Hausladen
A
S
回复
0
查看
589
SUNSTONE的Delphi笔记
S
S
回复
0
查看
686
SUNSTONE的Delphi笔记
S
S
回复
0
查看
906
SUNSTONE的Delphi笔记
S
S
回复
0
查看
884
SUNSTONE的Delphi笔记
S
后退
顶部