Recent

Author Topic: HRgn -> clipping (again)  (Read 8068 times)

windy

  • Full Member
  • ***
  • Posts: 186
HRgn -> clipping (again)
« on: September 10, 2007, 06:05:44 am »
HI
I found the thread on clipping (old thread)
http://www.lazarus.freepascal.org/index.php?name=PNphpBB2&file=viewtopic&t=2878&highlight=clipping
thought i would stat a new one.
I am trying to get a ported comonent working correctly
I have added the LCLType
here is the code:
 ClipRgn := CreateEllipticRgn(TopLeft.x + r.Left + 1,
    TopLeft.y + r.Top + 1,
    TopLeft.x + r.Right + 1,
    TopLeft.y + r.Bottom + 1);
   
   SelectClipRgn(can.Handle,ClipRgn);


  can.CopyRect(r, Bmp.Canvas, Bmp.Canvas.Cliprect);

  DeleteObject(ClipRgn);


 ClipRgn:=CreateRectRgn(TopLeft.x + OldRect.Left,
    TopLeft.y + OldRect.Top,
    TopLeft.x + OldRect.Right,
    TopLeft.y + OldRect.Bottom);

   SelectClipRgn(can.Handle,ClipRgn );   {restore old Clip area}

  DeleteObject(ClipRgn);      



It compiles
but it does not seem to be working correctly
(i.e the region selected has not been clipped?

I also found another old thread about using widgets and example code from Troltech with a round analog clock (shaped clock)
aslos, the code samples here use setwindowRgn,but I need my code to run under linux and OSX
http://osdir.com/ml/ide.lazarus.general/2006-02/msg00718.html

Thanks for any insights
Brian

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2496
RE: HRgn -> clipping (again)
« Reply #1 on: September 10, 2007, 11:13:26 am »
IIRC clipping is not yet fully crossplatform implemented
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

windy

  • Full Member
  • ***
  • Posts: 186
HRgn -> clipping (again)
« Reply #2 on: September 10, 2007, 09:06:59 pm »
Oh
any works around I could use?
any time lines on when it will be OK in future releases of Lazarus?
( I have 9.22 beta)
thanks!

ps,if I add windows to the uses instead of LCLType the code above still does not seem to work, is that true?

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2496
HRgn -> clipping (again)
« Reply #3 on: September 11, 2007, 11:49:48 am »
if you use winapi directly it sould work.
Maybe better for restoring the old clip, you can use SaveDC/RestoreDC

Whats the value of bmp.Canvas.Cliprect ? is it a valid rectangle ?
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

windy

  • Full Member
  • ***
  • Posts: 186
HRgn -> clipping (again)
« Reply #4 on: September 11, 2007, 12:58:55 pm »
Hi
any code snippets on how to use SaveDC/RestoreDC instead of the code in use now?
:) (as this sort of thing I am not very good at!)
I would be most gratefull for help with this, as at the moment the component just looks like a big white square covering up things underneath (you can see what it should look like as its redrawn (flashes) when you move/resize the component)
the bmp.Canvas.Cliprect references from code further up not shown in the code I posted, sorry

thanks!

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2496
HRgn -> clipping (again)
« Reply #5 on: September 12, 2007, 11:42:24 am »
Code: [Select]

var
  RestoreIndex: integer;
begin
  :::
  RestoreIndex := SaveDC(ADCHandle);
  :::
  do the stuff you want
  :::
  RestoreDC(ADCHandle, RestoreIndex);
  :::
end;
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

windy

  • Full Member
  • ***
  • Posts: 186
HRgn -> clipping (again)
« Reply #6 on: September 16, 2007, 09:31:53 pm »
Hi
tried that, didnt sem to help...
one thing I have found...i have another component that also uses clipping...if I have that one on a form as well, then the first component which does clipping is looking better! (but not perfect yet)...