SelectClipRgn fails in Form_Paint() 
Author Message
 SelectClipRgn fails in Form_Paint()

I was experimenting with some code from Appleman's API book,
specifically Path.vbp, which illustrates using various path functions
from the GDI.

The following code is puzzling me:

'-----------------------------------------------------------------------
Private Sub Out_Paint()

Dim usepen&
Dim oldpen&
Dim dl&
Dim myRect As RECT
Dim i%

    savedDC& = SaveDC&(Out.hdc)

    Call SelectClipRgn(Out.hdc, 0)

    dl& = BeginPath&(Out.hdc)
        dl& = TextOut&(Out.hdc, 80&, 30&, "Color", 5)
        dl& = TextOut&(Out.hdc, 50&, 120&, "Circles", 7)
    dl& = EndPath&(Out.hdc)

    dl& = SelectClipPath&(Out.hdc, RGN_COPY)

    usepen = CreatePen(PS_SOLID, 1, QBColor(12))
    oldpen = SelectObject(Out.hdc, usepen)

    For i% = 0 To 40
        dl& = Ellipse&(Out.hdc, i% * Out.ScaleWidth / 80, i% * _
            Out.ScaleHeight / 80, Out.ScaleWidth - (i% * _
            Out.ScaleWidth / 80), Out.ScaleHeight - (i% *  _
            Out.ScaleHeight / 80))
    Next i%

    ' Select out the pen before deleting
    dl& = SelectObject(Out.hdc, oldpen)
    dl& = DeleteObject(usepen)

    dl& = RestoreDC&(Out.hdc, savedDC&)

End Sub

'-----------------------------------------------------------------------

In this example, Out is a picturebox, sited on a form with no other
controls.  When the form opens, the text "Color Circles" defines a path
that is filled with concentric circles.

If I move this code to Form_Paint() instead of Out_Paint(), and replace
all the references to Out with Me, and remove the PictureBox, then the
path is not defined, and all that is drawn are the concentric circles.

The return value of SelectClipRegion is 0, indicating failure, but
GetLastError also returns 0, so I am at a loss to figure out why the
function fails.

Any ideas?

Gerald

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Mon, 19 May 2003 03:00:00 GMT  
 SelectClipRgn fails in Form_Paint()

deja.com> writes

Quote:
>If I move this code to Form_Paint() instead of Out_Paint(), and replace
>all the references to Out with Me, and remove the PictureBox, then the
>path is not defined, and all that is drawn are the concentric circles.

Try it with the Form Font set to the same Font as Out

--
Richard Mason



Tue, 20 May 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. UserControl problems with DrawEdge and SelectClipRgn API - clipping custom frame control

2. Help with SelectClipRgn

3. UserControl problems with DrawEdge and SelectClipRgn API - clipping custom frame control

4. Help with SelectClipRgn or similar

5. Form_Paint gets decoupled ???

6. labels dissapear mysteriously with Form_Paint

7. Strange behavior of Form_Paint and X close button.

8. Form_Paint occurs 3 times?

9. Problem with MDI and Form_Paint

10. How to unload a form while its still busy with Form_Paint

11. Detecting WM_SYSCOLORCHANGE Message in Form_Paint

12. Connection Fail after installation - dbnmpntw write() connection fail

 

 
Powered by phpBB® Forum Software