Results 1 to 5 of 5

Thread: transparent form

  1. #1

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Is there a way to make the background of a form transparent, while still being able to see, say a command button on the form??

  2. #2
    Guest
    This will make a form transparent making you able to only see the Command button.

    Code:
    Public Const GWL_EXSTYLE = (-20)
    Public Const WS_EX_TRANSPARENT = &H20&
    Public Const SWP_FRAMECHANGED = &H20
    Public Const SWP_NOMOVE = &H2
    Public Const SWP_NOSIZE = &H1
    Public Const SWP_SHOWME = SWP_FRAMECHANGED Or _
    SWP_NOMOVE Or SWP_NOSIZE
    Public Const HWND_NOTOPMOST = -2  
     Declare Function SetWindowLong Lib "user32" _
    Alias "SetWindowLongA" _
    (ByVal hwnd As Long, ByVal nIndex As Long, _
    ByVal dwNewLong As Long) As Long
    Declare Function SetWindowPos Lib "user32" _
    (ByVal hwnd As Long, ByVal hWndInsertAfter _
    As Long, ByVal x As Long, ByVal y As Long, _
    ByVal cx As Long, ByVal cy As Long, _
    ByVal wFlags As Long) As Long  
    
    Private Sub Command1_Click()
    SetWindowLong Me.hwnd, GWL_EXSTYLE, _
    WS_EX_TRANSPARENT
    SetWindowPos Me.hwnd, HWND_NOTOPMOST, _
    0&, 0&, 0&, 0&, SWP_SHOWME
    End Sub

  3. #3

    Thread Starter
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091

    What the!?

    It didn't seem to work, any other ideas?

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Code:
    'make a form transparent
    'put this code in a bas module
    
    Option Explicit
    
    Public Const GWL_EXSTYLE = (-20)
    Public Const WS_EX_TRANSPARENT = &H20&
    Public Const SWP_FRAMECHANGED = &H20
    Public Const SWP_NOMOVE = &H2
    Public Const SWP_NOSIZE = &H1
    Public Const SWP_SHOWME = SWP_FRAMECHANGED Or _
    SWP_NOMOVE Or SWP_NOSIZE
    Public Const HWND_NOTOPMOST = -2
    
    Declare Function SetWindowLong Lib "user32" _
    Alias "SetWindowLongA" _
    (ByVal hwnd As Long, ByVal nIndex As Long, _
    ByVal dwNewLong As Long) As Long
    
    Declare Function SetWindowPos Lib "user32" _
    (ByVal hwnd As Long, ByVal hWndInsertAfter _
    As Long, ByVal x As Long, ByVal y As Long, _
    ByVal cx As Long, ByVal cy As Long, _
    ByVal wFlags As Long) As Long
    
    '    <<<<    Form Code    >>>>
    
    Option Explicit
    
    'you must set the Form's  [ShowInTaskbar to false]
    'you must set the Form's  [BorderStyle to none]
    '
    '
    Private Sub Command1_Click()
       SetWindowLong Me.hwnd, GWL_EXSTYLE, _
       WS_EX_TRANSPARENT
       SetWindowPos Me.hwnd, HWND_NOTOPMOST, _
       0&, 0&, 0&, 0&, SWP_SHOWME
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  5. #5
    Addicted Member
    Join Date
    Jan 2000
    Location
    Sydney, Australia
    Posts
    196

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