procedure TCmdForm.btnFindExitClick(Sender: TObject); // was BtnFndEscClick
var //PageStat:boolean;
OldSelStart, OldSelLength: integer;
HrzBarPos, VrtBarPos, SetVrtPos, SetHrzPos, TmpPos: integer;
HrzBarFnd, VrtBarFnd, GetVrtOK, GetHrzOK: boolean;
AreaRect: TRect;
begin
try
//PageMemo.Lines.BeginUpdate; // suspend screen update
FindPanel.visible:= false;
FindActive:= false;
OldSelStart:= PageMemo.SelStart;
OldSelLength:= PageMemo.SelLength;
//TmpPos:= GetScrollPos(PageMemo.handle,SB_VERT); // for pop-up report
VrtBarFnd:= Is_ScrollBar_Visible(PageMemo.Handle, SB_VERT); // boolean
HrzBarFnd:= Is_ScrollBar_Visible(PageMemo.Handle, SB_HORZ);
// *** SetScrollPos Method *** serves all methods
if VrtBarFnd then VrtBarPos:= GetScrollPos(PageMemo.handle,SB_VERT); // integer
if HrzBarFnd then HrzBarPos:= GetScrollPos(PageMemo.handle,SB_HORZ);
if VrtBarPos>0 then GetVrtOK:= TRUE else GetVrtOK:= FALSE;
if HrzBarPos>0 then GetHrzOK:= TRUE else GetHrzOK:= FALSE;
{ // *** ScrollInfo Method *** // Get_Scroll_Info is identical to GetScrollInfo
if VrtBarFnd then // being duplicated in order to make it editable
GetVrtOK:= Get_Scroll_Info(PageMemo.Handle, SB_VERT, VrtScrollData) //: Boolean;
else GetVrtOK:= false;
if HrzBarFnd then
GetHrzOK:= Get_Scroll_Info(PageMemo.Handle, SB_HORZ, HrzScrollData) //: Boolean;
else GetHrzOK:= false;
}
//PageStat:= PageWideStat.checked; // STORE STAT
FormResize(Self);
if AppSize=CmdForm.Width
then PageWideStat.checked:= true
else PageWideStat.checked:= false;
//PageWideStat.checked:= PageStat; // RESET STAT
RichMemoHighlightReset(PageMemo);
PageMemo.SelStart:= OldSelStart;
PageMemo.SelLength:= OldSelLength; // was := OldSelLength; *or* 0
//=======================================
// *** C Code ScrollWindowEx example *** // DO NOT ATTEMPT TO ACTIVATE THIS CODE
{
ScrollWindowEx(hwnd, -xDelta, -yDelta, (CONST RECT *) NULL,
(CONST RECT *) NULL, (HRGN) NULL, (PRECT) NULL,
SW_INVALIDATE);
UpdateWindow(hwnd);
}
//=======================================
// *** SB_THUMBPOSITION Method ***
(*
if GetVrtOK then
begin
SendMessage(PageMemo.handle, WM_VSCROLL, // vertical
MakeLong(SB_THUMBPOSITION, VrtBarPos), 0);
VrtBarPos:= SetScrollPos(PageMemo.handle, SB_VERT, VrtBarPos, TRUE); //*GOOD*
end; // else showmessage('VRT-SCROLLBAR FAILED 17');
if GetHrzOK then
begin
SendMessage(PageMemo.handle, WM_HSCROLL, // horizontal
MakeLong(SB_THUMBPOSITION, HrzBarPos), 0);
HrzBarPos:= SetScrollPos(PageMemo.handle, SB_HORZ, HrzBarPos, TRUE); //*GOOD*
end; // else showmessage('VRT-SCROLLBAR FAILED 17');
showmessage('SB_THUMBPOSITION DONE');
*)
//=======================================
// *** ScrollWindowEx method ***
//(*
if GetVrtOK then
begin
AreaRect:= rect(0,0,0,0);
SetVrtPos:= GetScrollPos(PageMemo.handle,SB_VERT); // integer
GetVrtOK:= ScrollWindowEx (PageMemo.handle, // RichMemo application
0, // horizontal element
(VrtBarPos - SetVrtPos), // old and new positions
@AreaRect,
@AreaRect,
0,
@AreaRect,
SW_INVALIDATE); // boolean
GetVrtOK:= UpdateWindow(PageMemo.handle); // must execute
end else showmessage('VRT-SCROLLBAR FAILED 17');
showmessage('ScrollWindowEx DONE');
//*)
//======================================
finally
PageMemo.SelStart:= OldSelStart;
PageMemo.SelLength:= OldSelLength; // was := OldSelLength; *or* 0
PagePassive:= false;
//PageMemo.Lines.EndUpdate;
end;
end;