Recent

Author Topic: Need help with ScrollWindowEx  (Read 8355 times)

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Need help with ScrollWindowEx
« Reply #15 on: February 27, 2023, 12:16:38 pm »
Did you tried to cast to LPARAM() WPARAM() that it work on Windows? At least I do it when I call SendMessage().
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Need help with ScrollWindowEx
« Reply #16 on: February 27, 2023, 01:04:48 pm »
Martin

Quote
But then I don't understand why you don't let the memo do the job anyway?

Why do you have it in SynEdit?

I have previously used the SB_THUMBPOSITION method because it is smooth and elegant. The screen just stays where it is upon your exiting the search, instead popping to a new placement.

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Need help with ScrollWindowEx
« Reply #17 on: February 27, 2023, 01:15:17 pm »
Martin

Quote
or retrieves the WM_PAINT message from the application queue.

What is the code that used in SynEdit to do "the latter," as you cited. I would like to give it a try.

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Need help with ScrollWindowEx
« Reply #18 on: February 27, 2023, 01:27:15 pm »
KodeZwerg

Quote
Did you tried to cast to LPARAM() WPARAM() that it work on Windows?

No. It had not needed them. Can you post your code for those operations? I will try them out.

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12386
  • Debugger - SynEdit - and more
    • wiki
Re: Need help with ScrollWindowEx
« Reply #19 on: February 27, 2023, 03:05:55 pm »
Quote
or retrieves the WM_PAINT message from the application queue.

What is the code that used in SynEdit to do "the latter," as you cited. I would like to give it a try.

SynEdit simply exits from the event handler. Then the message queue is automatically processed by the LCL.

Your code normally runs in an event (OnClicked, OnIdle, On....) and as soon as your code returns (exits the event handler) the LCL continues with the message queue.

And that will include WM_Paint events. Afaik paint events are done with the lowest priority. So if you keep receiving other events, and take long enough to handle them so more can queue up, then paint can be deferred. However usually in that case you want to at least skip a handful paint events, before doing them in one combined sweep.
However if you don't run any data processing loops in your code, then there should be no speed/delay issues.

You can always check in the debugger, by setting breakpoints in the relevant paint events (unless its an OS painted widget, and there is no paint event in the LCL / though even then there should be low level lcl code that can be used to set a breakpoint / richmemo likely has its own Paint method). Make the breakpoint "not breaking" (remove the checkmark in the options of the breakpoint), and then in the breakpoint window you can watch the hitcount.

Or you can use normal breakpoints (actually pause at the breakpoint). So you can see the effect of ScrollWindowEx, and what the paint handler outputs as separate steps.
Of course for that you need to make sure nothing overlaps the richmemo, and it is **always** in view. Not hidden by the IDE, not hidden by any other app.

At least on Windows (tested Win10 64bit scrolling SynEdit): When you set a breakpoint, an step over ScrollWindowEx, the effect is immediate. You can see it happen on the screen. Of course at that time any "scrolled in" content is not yet there, and the old content still visible. The "scrolled in" is handled in the paint event.
(Just test it with a SynEdit, by finding the ScrollWindowEX in SynEdit... / and then also break in the paint method. Note that you can pause at the begin of the paint method, but the effect will only be visible when you run the app again, and it returns to "TWindowProcHelper.SendPaintMessage" in the list of callers / It may be immediate if you switch of double buffering, not tested)


rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Need help with ScrollWindowEx
« Reply #20 on: February 27, 2023, 03:16:55 pm »
Marti

Quote
SynEdit simply exits from the event handler.

I had already tried it with UpdateWindow removed ... so it just exited the handler. Did not help.

Rick
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12386
  • Debugger - SynEdit - and more
    • wiki
Re: Need help with ScrollWindowEx
« Reply #21 on: February 27, 2023, 04:23:31 pm »
Code: Pascal  [Select][+][-]
  1.        AreaRect:= rect(null,null,null,null);
  2.        SetVrtPos:= GetScrollPos(PageMemo.handle,SB_VERT); // integer
  3.  
  4.        GetVrtOK:= ScrollWindowEx (PageMemo.handle,  // RichMemo application
  5.                                   0,  // horizontal element
  6.                                   (VrtBarPos - SetVrtPos), // old and new positions
  7.                                   @AreaRect,
  8.                                   @AreaRect,
  9.                                   0,
  10.                                   @AreaRect,
  11.                                   2); // boolean
  12.  

I assume "SetVrtPos" means "currently set/applied". IMHO misleading, maybe name it "CurrentVrtPos". But that is just a personal hint/opinion offtopic to the issue.

Where does "VrtBarPos" (the new pos to which you want to scroll?) come from?

And most important: How to you tell the memo, that it got scrolled to "VrtBarPos".
Because as I mentioned: "ScrollWindowEx" does not tell the memo (100% sure). And neither does "UpdoteWindow".



Have you single stepped the code?
Does something happen on the screen, when you call ScrollWindowEx? (When you step over (F8) it).




Mind, I don't know RichMemo. Maybe it uses child windows, and the content you want to scroll is in an altogether different childwindow, and you are passing the wrong handle?
I must say, that IMHO this is highly UNLIKELY. But when nothing works, consider the unlikely.


rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Need help with ScrollWindowEx
« Reply #22 on: February 27, 2023, 05:16:41 pm »
Martin

Here is the code:

Code: Pascal  [Select][+][-]
  1. procedure TCmdForm.btnFindExitClick(Sender: TObject);  // was BtnFndEscClick
  2. var //PageStat:boolean;
  3.     OldSelStart, OldSelLength: integer;
  4.     HrzBarPos, VrtBarPos, SetVrtPos, SetHrzPos, TmpPos: integer;
  5.     HrzBarFnd, VrtBarFnd, GetVrtOK, GetHrzOK: boolean;
  6.     AreaRect: TRect;
  7. begin
  8.   try
  9.   //PageMemo.Lines.BeginUpdate; // suspend screen update
  10.     FindPanel.visible:= false;
  11.     FindActive:= false;
  12.  
  13.     OldSelStart:= PageMemo.SelStart;
  14.     OldSelLength:= PageMemo.SelLength;
  15.  
  16.     //TmpPos:= GetScrollPos(PageMemo.handle,SB_VERT);  // for pop-up report
  17.  
  18.     VrtBarFnd:= Is_ScrollBar_Visible(PageMemo.Handle, SB_VERT); // boolean
  19.     HrzBarFnd:= Is_ScrollBar_Visible(PageMemo.Handle, SB_HORZ);
  20.  
  21.     //  *** SetScrollPos Method *** serves all methods
  22.     if VrtBarFnd then VrtBarPos:= GetScrollPos(PageMemo.handle,SB_VERT); // integer
  23.     if HrzBarFnd then HrzBarPos:= GetScrollPos(PageMemo.handle,SB_HORZ);
  24.  
  25.     if VrtBarPos>0 then GetVrtOK:= TRUE else GetVrtOK:= FALSE;
  26.     if HrzBarPos>0 then GetHrzOK:= TRUE else GetHrzOK:= FALSE;
  27.  
  28.     {  // *** ScrollInfo Method ***  // Get_Scroll_Info is identical to GetScrollInfo
  29.     if VrtBarFnd then                // being duplicated in order to make it editable
  30.        GetVrtOK:= Get_Scroll_Info(PageMemo.Handle, SB_VERT, VrtScrollData) //: Boolean;
  31.        else GetVrtOK:= false;
  32.  
  33.     if HrzBarFnd then
  34.        GetHrzOK:= Get_Scroll_Info(PageMemo.Handle, SB_HORZ, HrzScrollData) //: Boolean;
  35.        else GetHrzOK:= false;
  36.     }
  37.  
  38.     //PageStat:= PageWideStat.checked; // STORE STAT
  39.     FormResize(Self);
  40.     if AppSize=CmdForm.Width
  41.        then PageWideStat.checked:= true
  42.        else PageWideStat.checked:= false;
  43.     //PageWideStat.checked:= PageStat; // RESET STAT
  44.  
  45.     RichMemoHighlightReset(PageMemo);
  46.  
  47.     PageMemo.SelStart:= OldSelStart;
  48.     PageMemo.SelLength:= OldSelLength;   // was := OldSelLength; *or* 0
  49.  
  50. //=======================================
  51.     // *** C Code ScrollWindowEx example ***  // DO NOT ATTEMPT TO ACTIVATE THIS CODE
  52.     {
  53.     ScrollWindowEx(hwnd, -xDelta, -yDelta, (CONST RECT *) NULL,
  54.                   (CONST RECT *) NULL, (HRGN) NULL, (PRECT) NULL,
  55.                   SW_INVALIDATE);
  56.  
  57.     UpdateWindow(hwnd);
  58.     }
  59. //=======================================
  60.     // *** SB_THUMBPOSITION Method ***
  61.     (*
  62.     if GetVrtOK then
  63.        begin
  64.        SendMessage(PageMemo.handle, WM_VSCROLL, // vertical
  65.                    MakeLong(SB_THUMBPOSITION, VrtBarPos), 0);
  66.        VrtBarPos:= SetScrollPos(PageMemo.handle, SB_VERT, VrtBarPos, TRUE); //*GOOD*
  67.        end; // else showmessage('VRT-SCROLLBAR FAILED 17');
  68.  
  69.     if GetHrzOK then
  70.        begin
  71.        SendMessage(PageMemo.handle, WM_HSCROLL, // horizontal
  72.                    MakeLong(SB_THUMBPOSITION, HrzBarPos), 0);
  73.        HrzBarPos:= SetScrollPos(PageMemo.handle, SB_HORZ, HrzBarPos, TRUE); //*GOOD*
  74.        end; // else showmessage('VRT-SCROLLBAR FAILED 17');
  75.  
  76.     showmessage('SB_THUMBPOSITION DONE');
  77.     *)
  78. //=======================================
  79.     // *** ScrollWindowEx method ***
  80.     //(*
  81.     if GetVrtOK then
  82.        begin
  83.        AreaRect:= rect(0,0,0,0);
  84.        SetVrtPos:= GetScrollPos(PageMemo.handle,SB_VERT); // integer
  85.  
  86.        GetVrtOK:= ScrollWindowEx (PageMemo.handle,  // RichMemo application
  87.                                   0,  // horizontal element
  88.                                   (VrtBarPos - SetVrtPos), // old and new positions
  89.                                   @AreaRect,
  90.                                   @AreaRect,
  91.                                   0,
  92.                                   @AreaRect,
  93.                                   SW_INVALIDATE); // boolean
  94.  
  95.        GetVrtOK:= UpdateWindow(PageMemo.handle); // must execute
  96.        end else showmessage('VRT-SCROLLBAR FAILED 17');
  97.  
  98.        showmessage('ScrollWindowEx DONE');
  99.     //*)
  100. //======================================
  101.    
  102.   finally
  103.     PageMemo.SelStart:= OldSelStart;
  104.     PageMemo.SelLength:= OldSelLength;   // was := OldSelLength; *or* 0
  105.     PagePassive:= false;
  106.   //PageMemo.Lines.EndUpdate;
  107.   end;
  108. end;

The GET and SET are equivalent to READ and WRITE as they were applied prior to trying to use ScrollWindowEx.
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12386
  • Debugger - SynEdit - and more
    • wiki
Re: Need help with ScrollWindowEx
« Reply #23 on: February 27, 2023, 05:57:10 pm »
First of all:

If "VrtBarFnd" will be false, then "VrtBarPos" will not be initialized, and "GetVrtOK" will also not be initialized. So the condition at the end, may be true at random.




I might have missed something, but I assume that between
Code: Pascal  [Select][+][-]
  1.  if VrtBarFnd then VrtBarPos:= GetScrollPos(PageMemo.handle,SB_VERT);
Code: Pascal  [Select][+][-]
  1. SetVrtPos:= GetScrollPos(PageMemo.handle,SB_VERT);
The Scrollbar will actually change?
Otherwise you always scroll by 0 pixel.

I don't see what changes it. Have you debugged and checked that the 2 values are different?

Also what changes the scrollbar pos, and why does whatever that is not actually do the scrolling?

E.g. if at some point (that I have not spotted), you set the Selection to a different location, and the memo scrolls to that different location (thereby updating the scrollbars), then why would you still need to scroll it, if it already did scroll?
If of course the 2 lines that set the selection to OldSelStart/Length are undoing the scroll, then ... Well then SetVrtPos will be the same as VrtBarFnd, and DY will be 0.
... But then, even if you get SetVrtPos before you undo the scroll (reset the old selection), ScrollWindowEx will not fix the issue. It will move the pixels, but the memo will eventually get a paint event, and jump back to where it was.



In any case:
"@AreaRect" (all 3 occurrences) should be "nil".
Code: Pascal  [Select][+][-]
  1.       GetVrtOK:= ScrollWindowEx (PageMemo.handle,  // RichMemo application
  2.                                   0,  // horizontal element
  3.                                   (VrtBarPos - SetVrtPos), // old and new positions
  4.                                   NIL,
  5.                                   NIL,
  6.                                   0,
  7.                                   NIL,
  8.                                   SW_INVALIDATE); // boolean

If you hand in a pointer, then Windows will always read the rect at the pointer, and restrict scrolling to the rect given. In your case: zero pixel width, zero pixel height => nothing is scrolled).
If you pass in nil, the entire clientrect will be scrolled.

If you pass in "nil", and the 2 values from above are different (dy <> 0) and you set a breakpoint and step over the "ScrollWindowEx" call then you should see the pixels on the screen move to the new location. (This happens immediately during the call / if on Windows)


Mind, this is trying to make the ScrollWindowEx actually do something (which in order to see it, you may have to watch in the debugger). If that solves whatever needs to be solved is another question....

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Need help with ScrollWindowEx
« Reply #24 on: February 27, 2023, 06:20:10 pm »
Quote
Have you debugged and checked that the 2 values are different?
Yes, they are different, and they are absolute pixel counts.

Quote
If "VrtBarFnd" will be false, then "VrtBarPos" will not be initialized, and "GetVrtOK" will also not be initialized. So the condition at the end, may be true at random.

Good point. They had been globals, and were initiated elsewhere. Here, they are locals, and placed as such to make sure nothing is interfering with the data ... but I forgot to initiate them. I'll fix that and get back to you.
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Need help with ScrollWindowEx
« Reply #25 on: February 27, 2023, 06:37:15 pm »
This has the initiated variables.

Code: Pascal  [Select][+][-]
  1. procedure TCmdForm.btnFindExitClick(Sender: TObject);  // was BtnFndEscClick
  2. var //PageStat:boolean;
  3.     OldSelStart, OldSelLength: integer;
  4.     HrzBarPos, VrtBarPos, SetVrtPos, SetHrzPos, TmpPos: integer;
  5.     HrzBarFnd, VrtBarFnd, GetVrtOK, GetHrzOK: boolean;
  6.     AreaRect: TRect;
  7. begin
  8.   try
  9.   //PageMemo.Lines.BeginUpdate; // suspend screen update
  10.     FindPanel.visible:= false;
  11.     FindActive:= false;
  12.  
  13.     OldSelStart:= PageMemo.SelStart;
  14.     OldSelLength:= PageMemo.SelLength;
  15.  
  16.     VrtBarFnd:= false;
  17.     HrzBarFnd:= false;
  18.     VrtBarPos:= 0;
  19.     HrzBarPos:= 0;
  20.     SetVrtPos:= 0;
  21.     SetHrzPos:= 0;
  22.     GetVrtOK:= false;
  23.     GetHrzOK:= false;
  24.  
  25.     //TmpPos:= 0;
  26.     //TmpPos:= GetScrollPos(PageMemo.handle,SB_VERT);  // for pop-up report
  27.  
  28.     VrtBarFnd:= Is_ScrollBar_Visible(PageMemo.Handle, SB_VERT); // boolean
  29.     HrzBarFnd:= Is_ScrollBar_Visible(PageMemo.Handle, SB_HORZ);
  30.  
  31.     //  *** SetScrollPos Method *** serves all methods
  32.     if VrtBarFnd then VrtBarPos:= GetScrollPos(PageMemo.handle,SB_VERT); // integer
  33.     if HrzBarFnd then HrzBarPos:= GetScrollPos(PageMemo.handle,SB_HORZ);
  34.  
  35.     if VrtBarPos>0 then GetVrtOK:= TRUE else GetVrtOK:= FALSE;
  36.     if HrzBarPos>0 then GetHrzOK:= TRUE else GetHrzOK:= FALSE;
  37.  
  38.     {  // *** ScrollInfo Method ***
  39.     if VrtBarFnd then
  40.        GetVrtOK:= Get_Scroll_Info(PageMemo.Handle, SB_VERT, VrtScrollData) //: Boolean;
  41.        else GetVrtOK:= false;
  42.  
  43.     if HrzBarFnd then
  44.        GetHrzOK:= Get_Scroll_Info(PageMemo.Handle, SB_HORZ, HrzScrollData) //: Boolean;
  45.        else GetHrzOK:= false;
  46.     }
  47.  
  48.     //PageStat:= PageWideStat.checked; // STORE STAT
  49.     FormResize(Self);
  50.     if AppSize=CmdForm.Width
  51.        then PageWideStat.checked:= true
  52.        else PageWideStat.checked:= false;
  53.     //PageWideStat.checked:= PageStat; // RESET STAT
  54.  
  55.     RichMemoHighlightReset(PageMemo);
  56.  
  57.     PageMemo.SelStart:= OldSelStart;
  58.     PageMemo.SelLength:= OldSelLength;   // was := OldSelLength; *or* 0
  59.  
  60. //=======================================
  61.     // *** C Code ScrollWindowEx example ***
  62.     {
  63.     ScrollWindowEx(hwnd, -xDelta, -yDelta, (CONST RECT *) NULL,
  64.                   (CONST RECT *) NULL, (HRGN) NULL, (PRECT) NULL,
  65.                   SW_INVALIDATE);
  66.  
  67.     UpdateWindow(hwnd);
  68.     }
  69. //=======================================
  70.     // *** SB_THUMBPOSITION Method ***
  71.     (*
  72.     if GetVrtOK then
  73.        begin
  74.        SendMessage(PageMemo.handle, WM_VSCROLL, // vertical
  75.                    MakeLong(SB_THUMBPOSITION, VrtBarPos), 0);
  76.        VrtBarPos:= SetScrollPos(PageMemo.handle, SB_VERT, VrtBarPos, TRUE); //*GOOD*
  77.        end; // else showmessage('VRT-SCROLLBAR FAILED 17');
  78.  
  79.     if GetHrzOK then
  80.        begin
  81.        SendMessage(PageMemo.handle, WM_HSCROLL, // horizontal
  82.                    MakeLong(SB_THUMBPOSITION, HrzBarPos), 0);
  83.        HrzBarPos:= SetScrollPos(PageMemo.handle, SB_HORZ, HrzBarPos, TRUE); //*GOOD*
  84.        end; // else showmessage('VRT-SCROLLBAR FAILED 17');
  85.  
  86.     showmessage('SB_THUMBPOSITION DONE');
  87.     *)
  88. //=======================================
  89.     // *** ScrollWindowEx method ***
  90.     //(*
  91.     if GetVrtOK then
  92.        begin
  93.        AreaRect:= rect(0,0,0,0);
  94.        SetVrtPos:= GetScrollPos(PageMemo.handle,SB_VERT); // integer
  95.  
  96.        GetVrtOK:= ScrollWindowEx (PageMemo.handle,  // RichMemo application
  97.                                   0,  // horizontal element
  98.                                   (VrtBarPos - SetVrtPos), // old and new positions
  99.                                   @AreaRect,
  100.                                   @AreaRect,
  101.                                   0,
  102.                                   @AreaRect,
  103.                                   SW_INVALIDATE); // boolean result
  104.  
  105.        GetVrtOK:= UpdateWindow(PageMemo.handle); // must execute
  106.        end else showmessage('VRT-SCROLLBAR FAILED 17');
  107.  
  108.        showmessage('ScrollWindowEx DONE');
  109.     //*)
  110. //======================================
  111.  
  112.   finally
  113.     PageMemo.SelStart:= OldSelStart;
  114.     PageMemo.SelLength:= OldSelLength;   // was := OldSelLength; *or* 0
  115.     PagePassive:= false;
  116.   //PageMemo.Lines.EndUpdate;
  117.   end;
  118. end;
  119.  

RichMemo is a container that is placed in the Control Form. Its controls are buttons, menus, pop-ups, and short-cut key strokes. Its only children are the scrollbars and PageTabControl.

I have just made a test run, and it still has the same behaviour.
Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12386
  • Debugger - SynEdit - and more
    • wiki
Re: Need help with ScrollWindowEx
« Reply #26 on: February 27, 2023, 06:59:19 pm »
Did you try to
1) replace "@AreaRect" with "nil"
2) debug with a breakpoint before ScrollWindowEx, and then use "F8" until you stepped over it?

Debug in such a way that the RichMemo is at no time hidden, and you can always see it?

If in that case, at the end of stepping the content in the memo moved, then ScrollWindowEx did work. (It does not solve your issue, but it works as documented / You asked, just to make ScrollWindowEx work....).

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Need help with ScrollWindowEx
« Reply #27 on: February 27, 2023, 07:10:49 pm »
Martin

Quote
I might have missed something, but I assume that between

     if VrtBarFnd then VrtBarPos:= GetScrollPos(PageMemo.handle,SB_VERT);

    SetVrtPos:= GetScrollPos(PageMemo.handle,SB_VERT);

The Scrollbar will actually change?
Otherwise you always scroll by 0 pixel.


It does a form resize (FormResize), and clears highlighting (RichMemoHighlightReset) from the document.

FormResize checks to see if you have manually changed the size of the form. If you have, it resizes all the panels, toolbars, and pop-ups so they can seen and accessed when they become active.

I have not been changing the form size.

RichMemoHighlightReset iterates through document and removes any highlighting that the word search would have generated.

Yes, highlighting has been properly removed, and both functions are finished before I have hit the EXIT button that activates this section of code.

Rick


Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

rick2691

  • Sr. Member
  • ****
  • Posts: 444
Re: Need help with ScrollWindowEx
« Reply #28 on: February 27, 2023, 07:25:16 pm »
Martin

Quote
1) replace "@AreaRect" with "nil"

We have answered this issue before ... Lazarus will not accept the word "nil" for a Pointer RECT function.

Quote
2) debug with a breakpoint before ScrollWindowEx, and then use "F8" until you stepped over it?

No. I have never used the debugger. I have forgotten all of the "machine code" I had ever learned, so I can't read its reports.

I just layout a bunch of showmessage('STAGE 1'); 2, 3, etc. to watch what happens. But I have not done that exhaustively, as you are suggesting. But I can attempt that, and get back to you.

I was typing while you had sent those questions, so I have posted an updated procedure just prior to this post. You should look at it.

Rick

Windows 11, LAZ 2.0.10, FPC 3.2.0, SVN 63526, i386-win32-win32/win64, using windows unit

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 12386
  • Debugger - SynEdit - and more
    • wiki
Re: Need help with ScrollWindowEx
« Reply #29 on: February 27, 2023, 07:43:46 pm »
Quote
1) replace "@AreaRect" with "nil"
We have answered this issue before ... Lazarus will not accept the word "nil" for a Pointer RECT function.

Code: Pascal  [Select][+][-]
  1. uses windows, LCLIntf;
  2.  
  3. procedure TForm1.FormCreate(Sender: TObject);
  4. begin
  5.   windows.ScrollWindowEx(Handle, 0, 10, nil, nil, 0, nil, SW_INVALIDATE);
  6.   LCLIntf.ScrollWindowEx(Handle, 0, 10, nil, nil, 0, nil, SW_INVALIDATE);
  7. end;
  8.  

There is a ScrollWindowEx in unit LCLIntf (which has compatible implementation for other Widgedsets; and in unit windows (which goes directly to the win API).

Both of them compile with nil, as given above.


Quote
Quote
2) debug with a breakpoint before ScrollWindowEx, and then use "F8" until you stepped over it?

No. I have never used the debugger. I have forgotten all of the "machine code" I had ever learned, so I can't read its reports.

I just layout a bunch of showmessage('STAGE 1'); 2, 3, etc. to watch what happens. But I have not done that exhaustively, as you are suggesting. But I can attempt that, and get back to you.

I was typing while you had sent those questions, so I have posted an updated procedure just prior to this post. You should look at it.

The debugger in Lazarus works directly with Pascal code.

Menu: Project > Project Options
- Compilation and linking: set optimization to either "none" or "O1"
- Debugging: Enable "Generate info for debugger" and set the "type of debug info" to "dwarf with sets"

In the source-editor either click (left mouse button) the empty space before the line-number to set a breakpoint (a red dot should appear).
Or use F5 to set the breakpoint while the text cursor is at that line.

Then run with F9.
The debugger should pause at the breakpoint (a green arrow in the breakpoint appears).
Now use F8 (several times), it will go to each line with the arguments, and in between to the line with "ScrollWindowEx".
Eventually it goes to the statement after.
At that time the scrolling should have happened.


While paused you can hover over variables, or use "view > debug windows > ..." for much more info.


 

TinyPortal © 2005-2018