' If the creation of the region was successful then color.
If hRgn Then FillRgn UserControl.hdc, hRgn, hBrush
DeleteObject hRgn
End Sub
(I took the code from si_geek and changed it a little for my own needs, thank you, si_geek)
As you can imagine, I am trying to emulate the behavior Frontpage has with its different files.
I wonder if there is a way to get the WindowBackground color for the brush... And also how could I redraw an array... Meaning I have to have something like a ZOrder... I am just starting and I would like some help.
Thanks in advance.
We miss you, friend... Rest in Peace, we will take care of the rest of it.
[vbcode]
On Error Me.Fault = False
[/vbcode]
- Silence is the human way to share ignorance
Tec-Nico
Originally posted by Tec-Nico
...
hBrush = GetStockObject(color)
...
Hola Tec-Nico,
I'm using code similar to yours to draw a filled polygon. Do you happen to know how it could be filled with a custom colour like, for example, black border and blue inside?
Saludos desde el otro lado del Atlantico...
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
Originally posted by Tec-Nico (I took the code from si_geek and changed it a little for my own needs, thank you, si_geek)
thanks, I'm glad it helped!
Anyway, time to see if I can help some more!
From the title of this thread I guessed you wanted to know how to detect a click in a polygon, if that is the case try searching this site for PtInRegion, hopefully there will be some good examples/explantions.
No ideas about the Brush questions I'm afraid - I've neve needed to use them.
Originally posted by Tec-Nico And also how could I redraw an array... Meaning I have to have something like a ZOrder... .
If you are drawing directly onto a form you can just do formname.cls, then re-draw everything (in the new order, the shapes at the "back" first).
I think usercontrols might have the cls method too, in which case you can use the same method.
Last edited by si_the_geek; Aug 27th, 2004 at 06:08 PM.
I am so ashamed I can't help you with the brushes either... Yet I solved it in another way... I will show you how I did it.
si_the_geek, thanks for your suggestions... But I ended up making a control that would be like the shape control but that would know when you click on it... I haven't finished it yet, but so far I have done what I need so far.
I will add that control here (the code and the OCX, of course), it is still in testing mode.. For example, when it is disabled in Windows XP it won't get the colors it should... Also when you try changing the BackColor (I commented this code) it will make all of it go black.
Why? I don't know...
Anyway, here is the code...
Oh, saludos desde este lado del charco, krtxmrtz
We miss you, friend... Rest in Peace, we will take care of the rest of it.
[vbcode]
On Error Me.Fault = False
[/vbcode]
- Silence is the human way to share ignorance
Tec-Nico
I'll take a look at the control... For now I've solved it differently: I draw my polygon on a picturebox with black brush and then I use an API function to change black for another colour.
Still I'd like to know if this step could be avoided by using the SetDCBrushColor or SetDCPenColor function. The explanation in the Microsoft pages was not too informative -I couldn't set the functions to work properly- and I haven't found any references to them neither searching the forum nor in Allapi.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
What I haven't figured out yet is how to have a border colour different from the fill colour...
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
I don't have VB.NET so I'll have to make do with VB6.
I have been experimenting with various values of the parameter in GetStockObject but can't get it to plot a black border and the interior area of a different color, for example unfilled.
Further, I can't erase the polygon -which I draw in a picturebox- after I'm done with it, the picturebox.cls instruction is ignored altogether!!! Thereafter, if I draw a polygon of a different shape it overlaps with the previous image.
Would someone have pity on me and fish me out of this deadlock? Please...
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
Originally posted by Tec-Nico The trick here would be to add a quantity in the left and on the top and substract it from the right and the bottom.
And for erasing it, you could try setting the autoRedraw of the PictureBox to be False, then try .cls and then setting it to True again.
The first idea may work, probably I should add/substract one or two pixels but I thought the CreatePolygonRgn, GetStockObject and FillRgn functions would be more flexible and allow the trick directly.
As for erasing the picturebox, it didn't work. I don't know what else to try, I'm stuck.
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
if you look at the tootip text link it my sig then you will see a class called clsDraw. This class is used to simplify API drawing.
You can fill with custom cothers, you can even fill with a bitmap.
It allows you to draw text in any font or style.
All you would ned to do is add the class into your project, and away you go
Originally posted by Wokawidget if you look at the tootip text link it my sig...
You mean the Graph control, I assume... I'll take a look. What kind of bugs are those you mention in the page linked to?
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)
I am so ashamed I can't help you with the brushes either...
I finally found the answer:
VB Code:
'(In a sub...)
Dim hBrush As Long
Dim hPen As Long
hBrush = CreateSolidBrush(MyColour)
SelectObject myBuffer, hBrush
hPen = CreatePen(PS_SOLID, 1, vbBlack)
SelectObject myBuffer, hRPen
'Poly2Buffer is a sub which does exactly
'what its name suggests by means of the
'CreatePolygonRgn API function. After the
'polygon region has been created to a buffer
'this buffer is BitBlt'd to a picturebox
Poly2Buffer myBuffer, xIon, yIon, nIon
DeleteObject hBrush
DeleteObject hPen
So this plots a polygon with black border and fills it with any colour you like. I've tried this out with back buffering, don't know if it would work when plotting directly to a PictureBox (no time to check it now)
Lottery is a tax on people who are bad at maths
If only mosquitoes sucked fat instead of blood...
To do is to be (Descartes). To be is to do (Sartre). To be do be do (Sinatra)