Recent

Author Topic: Setting canvas offset without scrollbars  (Read 187 times)

jamie

  • Hero Member
  • *****
  • Posts: 7772
Setting canvas offset without scrollbars
« on: May 08, 2026, 06:28:13 pm »
So i looked into how to create an offset origin for the canvas instead of using SetWindowsOrgEx and the Copilet tells me that i can use "Canvas.SetOrigin", which would be great except it dont seem to exist?

I dont want to use builtin scrollbars, i an using my own and i may want to make this xcompilable.

Is there some othe function for this in the LCL?
Jamie
The only true wisdom is knowing you know nothing

zeljko

  • Hero Member
  • *****
  • Posts: 1958
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Setting canvas offset without scrollbars
« Reply #1 on: May 08, 2026, 09:00:32 pm »
IMO, SetViewportOrgEx() is correct, not SetWindowOrgEx() ? That is what Canvas.SetOrigin does afair.

VisualLab

  • Hero Member
  • *****
  • Posts: 742
Re: Setting canvas offset without scrollbars
« Reply #2 on: May 08, 2026, 10:54:25 pm »
That is what Canvas.SetOrigin does afair.

Hmm... I've searched the documentation and there's no mention of SetOrigin. I've also looked through the Lazarus 4.6 sources (Graphics and FPCanvas modules) and there's no SetOrigin there either. In which version of LCL is this implemented?

jamie

  • Hero Member
  • *****
  • Posts: 7772
Re: Setting canvas offset without scrollbars
« Reply #3 on: May 08, 2026, 11:58:58 pm »
That is what Canvas.SetOrigin does afair.

Hmm... I've searched the documentation and there's no mention of SetOrigin. I've also looked through the Lazarus 4.6 sources (Graphics and FPCanvas modules) and there's no SetOrigin there either. In which version of LCL is this implemented?

Yeah, what he said!  :D

Jamie
The only true wisdom is knowing you know nothing

zeljko

  • Hero Member
  • *****
  • Posts: 1958
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Setting canvas offset without scrollbars
« Reply #4 on: May 09, 2026, 12:40:52 am »
Actually what TCanvas.SetOrigin should do. I thought that it really exists in Delphi, but now I see it does not exist at all :), anyway if I correctly understood you, setViewportOrgEx() is what you need.

jamie

  • Hero Member
  • *****
  • Posts: 7772
Re: Setting canvas offset without scrollbars
« Reply #5 on: May 09, 2026, 02:00:22 am »
Actually what TCanvas.SetOrigin should do. I thought that it really exists in Delphi, but now I see it does not exist at all :), anyway if I correctly understood you, setViewportOrgEx() is what you need.

My point was that "Copilot" presented an example of offsetting the origin of the canvas that was suppose to be a Lazaruas (LCL) example and this method for the canvas was used in the posted example, but It also state I could use the raw level method of doing it.

 Copilot must of corrected itself because that example no longer appears showing the use of Canvas.SetOrigin.

 
 I suppose it could of took a partial example from another language and assumed the LCL could do it and went for it.

 You know what they say about assuming!  :o

Jamie

 
The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 7772
Re: Setting canvas offset without scrollbars
« Reply #6 on: May 09, 2026, 03:14:04 pm »
I was just thinking, that is why I keep a fire extinguisher in here  :o, I could make a helper for the canvas to include that!

Jamie
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018