Using SetWindowRgn() to create a polyline window

Using SetWindowRgn() to create a polyline window

Post by Defaul » Wed, 16 Aug 2000 04:00:00



Dear expert,

How to create a polyline window with border, is it correct to use
SetWindowRgn(CRgn bdShape, BOOL reDraw)? But  the SetWindowRgn(...)
will cut the rectangle window and erase the border.
I need your help, thanks in advance!

Ping.Z

 
 
 

Using SetWindowRgn() to create a polyline window

Post by Neil J. Rubenki » Wed, 16 Aug 2000 04:00:00



Quote:> How to create a polyline window with border

Not sure exactly what you're asking, but FrameRgn() will draw a frame
that follows the region's border.
--
Neil J. Rubenking
Contributing Technical Editor
PC Magazine

 
 
 

Using SetWindowRgn() to create a polyline window

Post by Defaul » Wed, 16 Aug 2000 04:00:00


Dear Neil J. Rubenking,

I put FrameRgn(...) after SetWindowRgn(...) in the main window
constructor,
the project does not show the borders. Is  the problem from the position
of FrameRgn(...) or the member HDC of FrameRgn(..)?
Thank you very much!

Ping.Z



> > How to create a polyline window with border

> Not sure exactly what you're asking, but FrameRgn() will draw a frame
> that follows the region's border.
> --
> Neil J. Rubenking
> Contributing Technical Editor
> PC Magazine

 
 
 

Using SetWindowRgn() to create a polyline window

Post by Neil J. Rubenki » Thu, 17 Aug 2000 04:00:00



Quote:> I put FrameRgn(...) after SetWindowRgn(...) in the main window
> constructor,

The region that you pass to SetWindowRgn() belongs to the system; it's
not yours any more. So if you want to keep using the region, you need to
pass a copy. Suppose your region is named R1:

        R2 := CreateRectRgn(0, 0, 1, 1);
        CombineRgn(R2, R1, R2, RGN_COPY);
        SetWindowRgn(Self.Handle, R2, False);

Now *in your OnPaint handler*, you call FrameRgn(), e.g.

        FrameRgn(Canvas.Handle, R1, Canvas.Brush, 1, 1);

--
Neil J. Rubenking
Contributing Technical Editor
PC Magazine

 
 
 

Using SetWindowRgn() to create a polyline window

Post by Defaul » Fri, 18 Aug 2000 04:00:00


Dear Neil J. Rubenking,

According to your ideals, I wrote the following codes (using VC++ 6.0
compiler),

   CPaintDC dc(this);
   HDC hdc;
   HBRUSH brush;
   HRGN gn, gn1;
   gn=CreatePolygonRgn(points,30,ALTERNATE);
   gn1=CreateRectRgn(0,0,1,1);
   CombineRgn(gn1,gn,gn1,RGN_COPY);
   brush=CreateSolidBrush(RGN(255,0,0);
   hdc=CreateCompatibleDC(dc);
   if (!FrameRgn(hdc,gn,brush,1,1)) Beep(200,300);
   InvalidateRect(NULL,TRUE);

I can see the polyline shape window, but I still can't see the frame
borders, could you tell me what is wrong with that?

Thank you very much in advance!

Ping.Z


> The region that you pass to SetWindowRgn() belongs to the system; it's
> not yours any more. So if you want to keep using the region, you need to
> pass a copy. Suppose your region is named R1:

>         R2 := CreateRectRgn(0, 0, 1, 1);
>         CombineRgn(R2, R1, R2, RGN_COPY);
>         SetWindowRgn(Self.Handle, R2, False);

> Now *in your OnPaint handler*, you call FrameRgn(), e.g.

>         FrameRgn(Canvas.Handle, R1, Canvas.Brush, 1, 1);

> --
> Neil J. Rubenking
> Contributing Technical Editor
> PC Magazine

 
 
 

Using SetWindowRgn() to create a polyline window

Post by Neil J. Rubenki » Fri, 18 Aug 2000 04:00:00


I must admit, I got mixed up which newsgroup I was in - I thought it was
Delphi. That's where the "OnPaint event handler" comment came in. I'm
glad you managed to translare it to VC++.

You should create your region, make a copy of it, and call SetWindowRgn()
all in the method that's called when your window is created. The copy
should stored in a persistent location - a data member of your form class
(Sorry, I don't do VC++; I'm guessing at the names for things). You
should not be creating the region anew every time the window is painted.

Beyond that, I'm afraid you'll have to ask those who know VC++ why it
isn't working.
--
Neil J. Rubenking
Contributing Technical Editor
PC Magazine

 
 
 

1. Can't modify HRGN used by SetWindowRgn ( )

      I CreateElipticalRgn on WM_NCCREATE and set it to window by
SetWindowRgn ( ). This window derminates on WM_NCHITTEST where cursor is and
returns HTTOP, HTTOPLEFT etc. for resizing of itself when cursor is near to
ellipse border. Respectively, on WM_SIZE I need to:
      1) modify HRGN according to new window size or
      2) DeleteObject (hrgnOld), create new region and
SetWindowRgn(hrgnNew).
      Both of this wais return FALSE (i.e. I can do the second part of the
(2), but whith eath of WM_SIZE unused HRGN collect in memory heap -- it's
not fearfully on NT but fatally for 9x).
      Can anybody prompt me how do modify or delete used HRGN? Tricks like
SetWindowRgn(NULL) etc. do nothing and fails.

2. Acorns !Browse, error: loading web page: "Too Long"

3. Loosing XP-style when using SetWIndowRgn ?

4. Cyberstorm MKII and A3000 Memory

5. Resource leak using SetWindowRgn

6. Travis-"Why Does It Always Rain On Me"-anyone got it?

7. Avoid window/screen update while drawing Polylines?

8. RSI Expert Wanted for User Group Mtg

9. SetWindowRgn and Windows 95

10. SetWindowRgn doesn't work under Windows 95

11. Window and Button shapes - Setwindowrgn

12. Using VB5-created COM object from an MSVC++6-created DLL: