Results 1 to 10 of 10

Thread: Transparent troubles... must but can't?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Posts
    21
    Can anyone tell me how to make a form a bit transparent (translucent) so i can just barely see the form behind it? if anyone can i will be forever grateful

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Technically, you can only do this in Win2000, but I think if you controlled the drawing of ALL your window (including the non-client areas), you'd be able to make them semitransparent by mixing them with the current screen image below.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Posts
    21

    Unhappy

    well i am running 2000... i just simply have no idea how to do what you said... thanks though

  4. #4
    Guest
    Make your form transparent:

    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

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Posts
    21
    do i put that first part in a module or the declarations?

  6. #6
    Guest
    Code:
    Module Declarations:
    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
    Code:
    Goes in form:
    Code:
    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

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Posts
    21
    thanks..

    do i need to change any settings on the form? when i try that my form remains but the title bar disappears

  8. #8
    Guest
    Don't have any objects on the form. And no, you shouldn't have to change any settings. Try that code in Form_Activate.

    Code:
    Private Sub Form_Activate()
    SetWindowLong Me.hwnd, GWL_EXSTYLE, _
    WS_EX_TRANSPARENT
    SetWindowPos Me.hwnd, HWND_NOTOPMOST, _
    0&, 0&, 0&, 0&, SWP_SHOWME
    End Sub

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Mar 2000
    Posts
    21
    thats almost it! io just need it to be translucent... not totally transparent.. arg!

  10. #10
    Guest
    Try:

    Code:
    Private Sub Form_Activate()
    SetWindowLong Me.hwnd, GWL_EXSTYLE, _
    WS_EX_TRANSPARENT
    SetWindowPos Me.hwnd, HWND_NOTOPMOST, _
    0&, 0&, 0&, 0&, SWP_SHOWME
    Me.Refresh
    End Sub
    That will allow you to move the title bar.

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