Recent

Author Topic: Regions  (Read 4250 times)

Mando

  • Full Member
  • ***
  • Posts: 181
Regions
« on: November 15, 2010, 08:27:11 am »
Hello:

I'll go crazy. I'm writing a graphic control, and I need a clipregion to clip a bitmat drawing. I do this:

Code: [Select]

   ... drawing operations 1.....

   r:=Rect(0,0,20,ClientHeight);
   cRGN:=createRectRGN(r.left,r.top,r.Right,r.bottom);
   selectClipRGN(self.canvas.Handle,cRGN);

   .... drawing operations 2....

   selectClipRGN(self.canvas.Handle,0);
   deleteObject(cRGN);

   .... drawing operations 3....


drawing operations 1, works properly, draw at properly coordinates.
drawing operations 2, doesn't work. origin of coordinates for region is parent upper-left corner  (0,0) instead of  upper-left corner of my control. all drawing operations, including clipping, are in parent coordinates.
drawing operations 3, works again, draw at properly coordinates.
If try to offset the rectangle in step 2. Works when my control parent is a form, but not if it is, for example, a groupBox or a panel.

Can anyone help me? PLEASE!!!!!

SVN:27367

I'll try to install an older version of lazarus.

« Last Edit: November 15, 2010, 09:23:17 am by Mando »

Mando

  • Full Member
  • ***
  • Posts: 181
Re: Regions
« Reply #1 on: November 15, 2010, 09:26:04 am »
Hello:

Correction:

The solution of offsetRect, works with a form and a panel as a parent of my control, but not if the parent is a Groupbox.

I keep trying.


regards.

Mando

  • Full Member
  • ***
  • Posts: 181
Re: Regions
« Reply #2 on: November 15, 2010, 10:06:15 am »
I tried to use clipRect and clipping and it works perfectly!
the coordinates of the clipping rectangle has the origin at (0,0) of  control, not in parent.

At the moment it is sufficient, however, I want to use any region, ellipses, rounded rectangles, including my own figures ..


I keep trying.
« Last Edit: November 15, 2010, 10:39:44 am by Mando »

ivan17

  • Full Member
  • ***
  • Posts: 173
Re: Regions
« Reply #3 on: November 15, 2010, 01:45:41 pm »
The solution of offsetRect, works...
in less-elegant environments, it is common to GetClientRect right before CreateRectRgn; in delphi we'd use ClientToParent but support for that is lacking in lazarus because of other widgetsets...

 

TinyPortal © 2005-2018