DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2005

    Making the form invisble

    I am working on a game where there is a game console inside the screen and the console is circle. I want to make the area arround the circle invisible. Is there a backstyle or a way to make the form invisible in vb 6?


  2. #2
    Join Date
    Feb 2004
    Colton, CA
    So you have a form infront of another form? If so, set the .visible property of the back form to false.

    Or - make the backcolor of the back form black/white.

  3. #3
    Join Date
    Nov 2003
    Portland, OR
    Phil Weber

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  4. #4
    Join Date
    Apr 2005
    i am sorry i did not clerify my self. In the picture that i have attached you can see the light green. the light green is what i want to get rid of.
    Attached Images Attached Images

  5. #5
    Join Date
    Nov 2003
    Alameda, CA
    Using the SetWindowRgn API.
    I got this from the internet on 9/10/2003, thus I do not remember where... propably from allapi. just paste it into a new exe project and modify as you wish

    Option Explicit
    Private Type POINTAPI
        X As Long
        Y As Long
    End Type
    Private Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
    End Type
    ' Region API functins
    Private Declare Function CreateEllipticRgn Lib "gdi32" (ByVal X1 As Long, _
        ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
    Private Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, _
        ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
    Private 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
    Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, _
        lpRect As RECT) As Long
    Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, _
        ByVal hRgn As Long, ByVal bRedraw As Long) As Long
    Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As _
    Private Declare Function CreatePolyPolygonRgn Lib "gdi32" (lpPoint As POINTAPI, lpPolyCounts As Long, ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
    ' modify the shape of a window
    ' This routine supports three values for SHAPE
    '    0 = circle/ellipse, 1=rounded rect, 2=rhomb
    ' NOTES: You get best effects using borderless forms
    '        Remember to provide alternative commands for
    '        closing and moving the form
    Sub SetWindowShape(ByVal hWnd As Long, ByVal Shape As Long)
        Dim lpRect As RECT
        Dim wi As Long, he As Long
        Dim hRgn As Long
        ' get the bounding rectangle's size
        GetWindowRect hWnd, lpRect
        wi = lpRect.Right - lpRect.Left
        he = lpRect.Bottom - lpRect.Top
        ' create a region
        Select Case Shape
            Case 0          ' circle/ellipse
                hRgn = CreateEllipticRgn(0, 0, wi, he)
            Case 1          ' rounded rectangle
                hRgn = CreateRoundRectRgn(0, 0, wi, he, 20, 20)
            Case 2          ' rhomb
                Dim lpPoints(3) As POINTAPI
                lpPoints(0).X = wi \ 2
                lpPoints(0).Y = 0
                lpPoints(1).X = 0
                lpPoints(1).Y = he \ 2
                lpPoints(2).X = wi \ 2
                lpPoints(2).Y = he
                lpPoints(3).X = wi
                lpPoints(3).Y = he \ 2
                hRgn = CreatePolygonRgn(lpPoints(0), 4, 1)
            Case 3
                Dim lp(5) As POINTAPI
                Dim lpc(1) As Long
                lpc(0) = 3
                lpc(1) = 3
                lp(0).X = 0: lp(0).Y = 0
                lp(1).X = wi / 2: lp(1).Y = he / 2
                lp(2).X = 0: lp(2).Y = he
                lp(3).X = wi: lp(3).Y = 0
                lp(4).X = wi / 2: lp(4).Y = he / 2
                lp(5).X = wi: lp(5).Y = he
                hRgn = CreatePolyPolygonRgn(lp(0), lpc(0), 2, 1)
        End Select
        ' trim the window to the region
        SetWindowRgn hWnd, hRgn, True
        DeleteObject hRgn
    End Sub
    Private Sub Form_Click()
        Unload Me
    End Sub
    Private Sub Form_Load()
        SetWindowShape Me.hWnd, 0
    End Sub
    "There are two ways to write error-free programs. Only the third one works."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center