Solved

Graphics On Invisible Form

Posted on 2004-10-30
244 Views
Last Modified: 2013-12-04
If there's a graphics on a Form,is it possible to make the Form invisible at run-time but only display the graphics & any control on it?
0
Question by:EXwithRaj
    14 Comments
     
    LVL 3

    Expert Comment

    by:vippx
    Hi

    What programming language are you talking about??

    In .NET this can be done by setting the transparency key property to some wierd color (say pink, or one that you wont use on ur graphics or controls) then setr the background color of the form to that color. This would have the form go invisible if thats what you need.
    0
     
    LVL 3

    Expert Comment

    by:vippx
    for additional effects, make the form border style property as "none"
    0
     
    LVL 1

    Expert Comment

    by:baggaabhishek
    Thats ok vippx

    But what if i need to display only the image and not the square of the picture box
    Is that possible. e.g i have a circular image and i insert it on the form and set the properties u suggest , but in this case it will not show onl the image it will show as a complete square
    0
     
    LVL 3

    Expert Comment

    by:vippx
    hi

    it will show up.. while designing the imageset the background and any part of the image that u need invisibel to the color of the transperancy key that you set for the form. then make the form of the same color... and if u run the app u can see all the parts on ur form that had the color of the transperancy key would have dissapeared.
    0
     
    LVL 1

    Expert Comment

    by:baggaabhishek
    I am not talking about the image , i am talking about the picturebox in which i am including the image.
    Even if i set the backcolor property to the same as that of the form it still displays the square of the picturebox
    or even if i set the backcolor to transparent even then it displays
    0
     
    LVL 3

    Expert Comment

    by:vippx
    Well im trying it out on my machine.. the form back color is also set to be transparent, the picturebox border is set to none. the picture property is set to strech image and now when i run the form, i dont see the frame of the pivture box. i created a simple cricle using "paint" program and set the unwanted background of the picture to the same color as my transperancy key and only that is visible.
    0
     
    LVL 3

    Expert Comment

    by:vippx
    and not back color of the picture box... et the background of ur image too to the color that is transparent as set on the property of the form.
    0
     

    Author Comment

    by:EXwithRaj
    I am using VB 6 - not VB .Net.I guess now you've to reframe & rethink your suggestions.
    0
     
    LVL 3

    Expert Comment

    by:vippx
    Hi

    For visual studio 6, you need to invoke some gdi 32 APIs to do the same. here is a  was to do it

    http://juicystudio.com/tutorial/vb/transparentform.asp

    http://juicystudio.com/tutorial/vb/transparentregion.asp

    for a tranparent picturebox, check this:

    http://www.freevbcode.com/ShowCode.Asp?ID=1903

    hope this helps

    0
     

    Author Comment

    by:EXwithRaj
    The code in the 2nd link(for "transparentregion") is working partly.The inside of the form is invisible & you can see the borders & caption - but the controls are all invisible.
       What I want is that only the  picture in a PictureBox or Image must be visible & the rest invisible.
    0
     
    LVL 3

    Expert Comment

    by:vippx
    Hi

    Could u give some more information on the application of the code that you are trying to do? Are you trying to create a custom shaped form or do some image manipulation. If you are looking to create custom shaped forms( like Windows media player in skinned mode) then picturebox is not the way to go about it.

    <quote>
    The inside of the form is invisible & you can see the borders & caption - but the controls are all invisible.
    </quote>

    if you want the titlebar to be invisible then just set the borderstyle poperty of the form to "none"

    if u are trying to create a custom shaped form try this :

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchShapedWindowsFormsControlsInVisualStudioNET.asp

    hope this is what you are looking for, if not, let me know
    0
     

    Author Comment

    by:EXwithRaj
    vippx,I've already informed you that I am not using VB .Net.Therefore,your link to a .Net solution is of no use to me.
    Besides,you may look at my requirements from 2 angles:
    a) custom-shaped Form(or Windows skins)
    b) if a Form is displaying an image,thru Image or PictureBox or any other control,I want only the graphic to display - and not the Form.
       In your previous reply,there was a link for the "transparentregion" technique.As per this,only the Form's body will be invisible - but not the controls in it & the Form's borders & title-bar.But my experience,as I'd already stated,is that all the controls,along with the Form's body, become invisible.
    0
     
    LVL 3

    Expert Comment

    by:vippx
    Hi Raj

    Sorry for my eagerness to replyi posted this link as i had worked on it previously.

    However i think i have replied in part that you can make the form borders and the titlebar disappear using the forms "Border Style" Property = none

    and i was looking into option and use of these API functions should work like a charm ( atleast does so for me!)

    Public Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
    Public Declare Function CreateRoundRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long) As Long
    Public Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
    Public Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
    Public Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long

    Public Type POINTAPI
            X As Long
            Y As Long
    End Type


    The use the SetWindowRgn with these 3 arguments

    1.  pass the control's handle ( hwnd) u need to shape
    2. pass a handle to the shape that you have created using any of the create region function API that we have declared above. It should allow u to create a lot of shapes, if not you can always use other create region API to create the shape of your choice.

    3. Boolean value for redraw set as true.


    here is a link to a step by step tutorial

    http://www.onlytools.com/edgetracer/irregular_windows_vb.htm


    And once again, i say if u need to get rid of the frame border and the titlebar, use borderstyle = none and not any APIs

    0
     
    LVL 3

    Accepted Solution

    by:
    Also for creating a skin u need not have a picturebox in place at all.. just set the picture property of the form to whatever image u need on the back ground. then create a window region to mask off all other parts than the ones u need of the image.

    and that is the best way to do it
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
    As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    884 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now