Not really sure what you mean - but if you want to make a usercontrol to be a container - just set the ControlContainer property to be true.
To expose the hDC property - just add the following to the control:
VB Code:
Public Property Get hDc() As Long
hDc = UserControl.hDc
End Property
Does this help?
My secretary hopes that I will pay her, her landlord hopes that she will produce some rent, the Electricity Board hopes that he will settle their bill, and so on. I find it a wonderfully optimistic way of life. [Dirk Gently]
Yes that's it. But I already managed to figure that out when using the property wizard.
However, It didnt work as I planed. I need to do bltbit on the form or a picturebox. but want their background to be transparent. I used the form and put it to transparent (borderstyle=0) and added hDc, but the image didnt get printed on the form. it probably got printed, but the form is transparent. wacked!
there must be som way. because i want to move the image as It is transparent as well.
With GDI it is possible I think, but I have no idea how to do it. Have anyone here coded with GDI?
My secretary hopes that I will pay her, her landlord hopes that she will produce some rent, the Electricity Board hopes that he will settle their bill, and so on. I find it a wonderfully optimistic way of life. [Dirk Gently]
Declare Function TransparentBlt Lib "msimg32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal crTransparent As Long) As Boolean
My secretary hopes that I will pay her, her landlord hopes that she will produce some rent, the Electricity Board hopes that he will settle their bill, and so on. I find it a wonderfully optimistic way of life. [Dirk Gently]
I want to use the forma png as it is anti-aliased. I have printed a transparent anti-aliased PNG file on a PictureBox. However as the PictureBox isnt transparent the image will not be transparent on the form.
I could print it on the form directly, but then I cant use the properties on the PictureBox so I can move it with the mouse.
I have included the file here. Have a look and see what im trying to do. Press the color buttons and look what I mean with with the picturebox layer is blocking the image.
Anyone know how to use the GDI and print PNG files, that would be better. I've seen a quite messy applikation doing so.
I can't use the project because I don't have a license for the SetPNGImage
Try this set the png picture to a picture box using the setpngimage function then copy the picture from the picturebox to the form using the transparentblt function [defined above]: - use it like this:
BOOL TransparentBlt(
HDC hdcDest, // handle to destination DC
int nXOriginDest, // x-coord of destination upper-left corner
int nYOriginDest, // y-coord of destination upper-left corner
int nWidthDest, // width of destination rectangle
int hHeightDest, // height of destination rectangle
HDC hdcSrc, // handle to source DC
int nXOriginSrc, // x-coord of source upper-left corner
int nYOriginSrc, // y-coord of source upper-left corner
int nWidthSrc, // width of source rectangle
int nHeightSrc, // height of source rectangle
UINT crTransparent // color to make transparent
);
My secretary hopes that I will pay her, her landlord hopes that she will produce some rent, the Electricity Board hopes that he will settle their bill, and so on. I find it a wonderfully optimistic way of life. [Dirk Gently]
This is a very rough version - I think it will give you some pointers of what to do. I have moved the textbox and the picturebox into a usercontrol that is transparent.
Does this help
My secretary hopes that I will pay her, her landlord hopes that she will produce some rent, the Electricity Board hopes that he will settle their bill, and so on. I find it a wonderfully optimistic way of life. [Dirk Gently]
I couldnt load the ocx and ctl. it wasnt loaded automatic, so I tried browsing to it manually but it didnt showup as a file. I then tried draging it into visual basic but got a error message "it is not a registered controller".
Can you try unziping the file into a new folder and open the project from this new folder.
I have tried it here everything worked.
Try it again - if it still doesn't work I will repost.
Rob
My secretary hopes that I will pay her, her landlord hopes that she will produce some rent, the Electricity Board hopes that he will settle their bill, and so on. I find it a wonderfully optimistic way of life. [Dirk Gently]
I want to use the forma png as it is anti-aliased. I have printed a transparent anti-aliased PNG file on a PictureBox. However as the PictureBox isnt transparent the image will not be transparent on the form.
I could print it on the form directly, but then I cant use the properties on the PictureBox so I can move it with the mouse.
I have included the file here. Have a look and see what im trying to do. Press the color buttons and look what I mean with with the picturebox layer is blocking the image.
Anyone know how to use the GDI and print PNG files, that would be better. I've seen a quite messy applikation doing so.
You could move it around with the mouse using the form. The form has the same basic drawing properties of the PictureBox, aswell as the same Functions (MouseDown/Up, etc..)
This will expose the hDC - just paste it into the usercontrol. Since the usercontrol has been set to transparent it should still be transparent when the PNG file is copied to it.
My secretary hopes that I will pay her, her landlord hopes that she will produce some rent, the Electricity Board hopes that he will settle their bill, and so on. I find it a wonderfully optimistic way of life. [Dirk Gently]
I can't think of any proper way to do what you want. When you copy the image to a hdc - the transparent bits of the picture become the background of the control.
The only way I can think of is to set the image of the picture box to be the background - then copy over the png file - you will need to do this every time there is any movement - this will be very slow.
Since the only parts of the Png file that are transparent is the border - you could just cut out the border
I would suggest changing the design.
R
My secretary hopes that I will pay her, her landlord hopes that she will produce some rent, the Electricity Board hopes that he will settle their bill, and so on. I find it a wonderfully optimistic way of life. [Dirk Gently]