Drawing a border for a round form... 
Author Message
 Drawing a border for a round form...

Dear all,

    I've written a Sub for making a form into a round form :

Public Sub MakeRoundForm(InForm As Form)
    Dim lret As Long
    Dim dl As Long
    lret = CreateRoundRectRgn(0, 0, InForm.Width / Screen.TwipsPerPixelX,
InForm.Height / Screen.TwipsPerPixelY, 25, 25)
    dl = SetWindowRgn(InForm.hWnd, lret, True)
End Sub

    And now, I want to draw a black border around the round form... how can
I do so ?

    Thanks a lot...

Pigeon.



Wed, 28 Jun 2000 03:00:00 GMT  
 Drawing a border for a round form...

There is an API function that draws a border around a region.

The FrameRgn function draws a border around the specified region by using
the specified brush.

BOOL FrameRgn(
  HDC hdc,     // handle to device context
  HRGN hrgn,   // handle to region to be framed
  HBRUSH hbr,  // handle to brush used to draw border
  int nWidth,  // width of region frame
  int nHeight  // height of region frame
);

http://premium.microsoft.com/msdn/library/sdkdoc/regions_1y5q.htm

You can retrieve the region for the window with te GetWindowRgn function.

http://premium.microsoft.com/msdn/library/sdkdoc/pantdraw_23la.htm

The following code works, with one remark:
The frame is drawn in the Form_Paint event, which is fired when the region
inside the border must be redrawn. VB does not notify you when the border
should be redrawn, so there are some cases when the frame is not drawn.

You should subclass the form and watch for the WM_NCPAINT message and draw
the border when you get this message

Alejandro.

Pigeon escribi en mensaje

Quote:
>Dear all,

>    I've written a Sub for making a form into a round form :

>Public Sub MakeRoundForm(InForm As Form)
>    Dim lret As Long
>    Dim dl As Long
>    lret = CreateRoundRectRgn(0, 0, InForm.Width / Screen.TwipsPerPixelX,
>InForm.Height / Screen.TwipsPerPixelY, 25, 25)
>    dl = SetWindowRgn(InForm.hWnd, lret, True)
>End Sub

>    And now, I want to draw a black border around the round form... how can
>I do so ?

>    Thanks a lot...

>Pigeon.



Wed, 28 Jun 2000 03:00:00 GMT  
 Drawing a border for a round form...

I forget the code, which is:

Option Explicit
Public Function FormFrameRgn(Form As Form) As Long
    Dim hRgn As Long
    Dim hbr As Long
    Dim hDC As Long
    Dim r As Long
    hDC = GetWindowDC(Form.hwnd)    ' Get a DC for non-client area
    hRgn = CreateRectRgn(0, 0, 0, 0)    ' Create empty region
    hbr = GetStockObject(BLACK_BRUSH) ' Get black brush
    r = GetWindowRgn(Form.hwnd, hRgn) ' Get window region
    FormFrameRgn = FrameRgn(hDC, hRgn, hbr, 1, 1) ' Draw the frame
    r = ReleaseDC(Form.hwnd, hDC) ' Release DC
End Function
Public Sub MakeRoundForm(InForm As Form)
    Dim lret As Long
    Dim dl As Long
    lret = CreateRoundRectRgn(0, 0, InForm.Width / Screen.TwipsPerPixelX,
InForm.Height / Screen.TwipsPerPixelY, 25, 25)
    dl = SetWindowRgn(InForm.hwnd, lret, True)
End Sub
Private Sub Command1_Click()
    FormFrameRgn Me
End Sub
Private Sub Form_Load()
    MakeRoundForm Me
End Sub
Private Sub Form_Paint()
    'Me.Cls
    FormFrameRgn Me
End Sub



Wed, 28 Jun 2000 03:00:00 GMT  
 Drawing a border for a round form...

Have a play with:

RoundRect InForm.hdc, 0, 0, InForm.Width / Screen.TwipsPerPixelX - 1,
InForm.Height / Screen.TwipsPerPixelY - 1, 24, 24

Shane

Quote:
> -----Original Message-----

> Posted At: 10 January 1998 08:50
> Posted To: syntax
> Conversation:      Drawing a border for a round form...
> Subject:   Drawing a border for a round form...

> Dear all,

>     I've written a Sub for making a form into a round form :

> Public Sub MakeRoundForm(InForm As Form)
>     Dim lret As Long
>     Dim dl As Long
>     lret = CreateRoundRectRgn(0, 0, InForm.Width /
> Screen.TwipsPerPixelX,
> InForm.Height / Screen.TwipsPerPixelY, 25, 25)
>     dl = SetWindowRgn(InForm.hWnd, lret, True)
> End Sub

>     And now, I want to draw a black border around the round form...
> how can
> I do so ?

>     Thanks a lot...

> Pigeon.



Mon, 03 Jul 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Drawing a border for a round form...

2. draw complete border around form

3. How can I draw the windows form border ?

4. Round buttons round forms

5. drawing borders in excel 2000

6. Owner draw Menu Border

7. Drawing borders

8. how do you draw raised borders around icon?

9. Drawing Filled Polygons with a border (Outline)

10. Drawing a styalized Border

11. How to draw 3D borders around irregular shapes ?

12. Drawing a Border around a custom shaped window

 

 
Powered by phpBB® Forum Software