Results 1 to 20 of 20

Thread: Help!!!!! Anyone!

  1. #1

    Thread Starter
    Lively Member haruki's Avatar
    Join Date
    Mar 2005
    Location
    Shibuya / Japan
    Posts
    118

    Angry Help!!!!! Anyone!

    I need a controller to be transparent and a container. Nothing more.

    The controller is transparent as start, but how do I also add property hDC to it? In that way calling it like "usercontrol1.hCd x, y"

    Anyone?
    Last edited by haruki; Apr 5th, 2005 at 08:01 AM.

  2. #2
    Fanatic Member THEROB's Avatar
    Join Date
    Oct 2000
    Location
    I'm cold and there are wolves after me
    Posts
    575

    Re: Help!!!!! Anyone!

    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:
    1. Public Property Get hDc() As Long
    2.     hDc = UserControl.hDc
    3. 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]

  3. #3

    Thread Starter
    Lively Member haruki's Avatar
    Join Date
    Mar 2005
    Location
    Shibuya / Japan
    Posts
    118

    Re: Help!!!!! Anyone!

    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?

  4. #4
    Fanatic Member THEROB's Avatar
    Join Date
    Oct 2000
    Location
    I'm cold and there are wolves after me
    Posts
    575

    Re: Help!!!!! Anyone!

    Have you tried TransparentBlt to copy the image??
    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]

  5. #5
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Help!!!!! Anyone!

    Isn't TransparentBlt an function found on the internet? I don't think it's an actual API, in which case, Planet Source Code or Google can help.

    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  6. #6
    Fanatic Member THEROB's Avatar
    Join Date
    Oct 2000
    Location
    I'm cold and there are wolves after me
    Posts
    575

    Re: Help!!!!! Anyone!

    No No - its a real function

    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]

  7. #7
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Help!!!!! Anyone!

    Oh my god. I searched for ages long ago and had to come up with my own! Then I got told there was one on the internet...

    /me slaps myself..

    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  8. #8

    Thread Starter
    Lively Member haruki's Avatar
    Join Date
    Mar 2005
    Location
    Shibuya / Japan
    Posts
    118

    Re: Help!!!!! Anyone!

    Okey, I have no idea what you mean. Anyway....

    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.
    Attached Files Attached Files

  9. #9
    Fanatic Member THEROB's Avatar
    Join Date
    Oct 2000
    Location
    I'm cold and there are wolves after me
    Posts
    575

    Re: Help!!!!! Anyone!

    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]

  10. #10

    Thread Starter
    Lively Member haruki's Avatar
    Join Date
    Mar 2005
    Location
    Shibuya / Japan
    Posts
    118

    Re: Help!!!!! Anyone!

    If you were referring to to the PNGlib then just register it in the command prompt. SetPNGImage is just a function to load the image.

    to register it type:
    "regsvr32 pnglib.dll"

    to unregister it type:
    "regsvr32 pnglib.dll /u"

    I guess you already know that. Anyway, it wont work until you register the dll.


    Try it, then you will know what im trying to do.

  11. #11
    Fanatic Member THEROB's Avatar
    Join Date
    Oct 2000
    Location
    I'm cold and there are wolves after me
    Posts
    575

    Re: Help!!!!! Anyone!

    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
    Attached Files Attached Files
    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]

  12. #12

    Thread Starter
    Lively Member haruki's Avatar
    Join Date
    Mar 2005
    Location
    Shibuya / Japan
    Posts
    118

    Re: Help!!!!! Anyone!

    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".

  13. #13
    Fanatic Member THEROB's Avatar
    Join Date
    Oct 2000
    Location
    I'm cold and there are wolves after me
    Posts
    575

    Re: Help!!!!! Anyone!

    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]

  14. #14

    Thread Starter
    Lively Member haruki's Avatar
    Join Date
    Mar 2005
    Location
    Shibuya / Japan
    Posts
    118

    Re: Help!!!!! Anyone!

    Ok, got it to load. But how can I make this work?? I dont undestand the point with it? Hmm, explain or better show me what you mean.

  15. #15
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246

    Re: Help!!!!! Anyone!

    Quote Originally Posted by haruki
    Okey, I have no idea what you mean. Anyway....

    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..)

    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  16. #16

    Thread Starter
    Lively Member haruki's Avatar
    Join Date
    Mar 2005
    Location
    Shibuya / Japan
    Posts
    118

    Re: Help!!!!! Anyone!

    The controller needs hDc to function. It doesnt have that, how do I add that to the customized controller?

    So I can test print on it.

  17. #17
    Fanatic Member THEROB's Avatar
    Join Date
    Oct 2000
    Location
    I'm cold and there are wolves after me
    Posts
    575

    Re: Help!!!!! Anyone!

    Quote Originally Posted by THEROB
    VB Code:
    1. Public Property Get hDc() As Long
    2.     hDc = UserControl.hDc
    3. End Property


    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]

  18. #18

    Thread Starter
    Lively Member haruki's Avatar
    Join Date
    Mar 2005
    Location
    Shibuya / Japan
    Posts
    118

    Re: Help!!!!! Anyone!

    Ok, I've added that then refresh and autodraw that is needed. The projects starts and the images doesnt show. Have you tested it?

    Anyway, I think it is because the background is transparent, than the print will be that too. As the print is a part of the bakground, not a layer.

  19. #19
    Fanatic Member THEROB's Avatar
    Join Date
    Oct 2000
    Location
    I'm cold and there are wolves after me
    Posts
    575

    Re: Help!!!!! Anyone!

    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]

  20. #20

    Thread Starter
    Lively Member haruki's Avatar
    Join Date
    Mar 2005
    Location
    Shibuya / Japan
    Posts
    118

    Re: Help!!!!! Anyone!

    I've seen other use png files with movement, transparent and anti-aliased.

    Here's one code I found doing so, but its messy. So I dont really get any information from it as it has few comments if any at all.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width