Results 1 to 8 of 8

Thread: Under Application

  1. #1

    Thread Starter
    Fanatic Member Nove's Avatar
    Join Date
    Jul 2004
    Posts
    736

    Under Application

    Sorry, I know this sounds pretty impossible, but is there a way I could check to see what windows would be displaying under my application were it not there? Thanks.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Under Application

    Yes, but it may take a good amount of code using APIs. You would enumerate
    the windows checking the z order position and window areas that would
    overlap your apps form. Sounds like a real pain to code.

    Why do you want to get what is behind your form? Maybe there is a better solution.
    Are you trying to get the desktop display behind your form for some kind of
    transparency?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Under Application

    ZOrder may change at any given moment: user may activate or deactivate any window when they want regardless so handle that your app stored a few seconds ago might not be valid any longer.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Under Application

    Yes, thats a good point . I kind of think that the poster wants to do something like a transparency thing.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    Fanatic Member Nove's Avatar
    Join Date
    Jul 2004
    Posts
    736

    Re: Under Application

    I suppose it would be transparent, is that easier? I don't want the whole form to be transparent though, just the body of the form. So i'd want to keep the title bar and the small bit around the edges that gives it a 3d effect.

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Under Application

    Here is an example of alpha blending (transparency) for Windows 2000+
    VB Code:
    1. Option Explicit
    2. 'Add a slider control to your form.
    3. Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" _
    4. (ByVal lpLibFileName As String) As Long
    5.  
    6. Private Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As Long, _
    7. ByVal lpProcName As String) As Long
    8.  
    9. Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
    10.  
    11. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
    12. (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    13.  
    14. Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, _
    15. ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
    16.  
    17. Private Const GWL_EXSTYLE = (-20)
    18. Private Const WS_EX_LAYERED = &H80000
    19. Private Const LWA_ALPHA = &H2
    20.  
    21. Public Sub AlphaBlendForm(ByVal lHwnd As Long, ByVal intTranslucenceLevel As Integer)
    22.     If APIExists("SetLayeredWindowAttributes", "User32") Then
    23.         SetWindowLong lHwnd, GWL_EXSTYLE, WS_EX_LAYERED
    24.         SetLayeredWindowAttributes lHwnd, 0, intTranslucenceLevel, LWA_ALPHA
    25.     Else
    26.         MsgBox "Your OS does not support Alpha Blending.", vbExclamation, "Alpha Blend"
    27.     End If
    28. End Sub
    29.  
    30. Public Function APIExists(ByVal pstrFunctionName As String, ByVal pstrDllName As String) As Boolean
    31.     Dim lngHandle   As Long
    32.     Dim lngAddr     As Long
    33.     lngHandle = LoadLibrary(pstrDllName)
    34.     If Not (lngHandle = 0) Then
    35.         lngAddr = GetProcAddress(lngHandle, pstrFunctionName)
    36.         FreeLibrary lngHandle
    37.     End If
    38.     APIExists = Not (lngAddr = 0)
    39. End Function
    40.  
    41. Private Sub Form_Load()
    42.     Slider1.Max = 255
    43.     Slider1.Min = 10
    44.     Slider1.LargeChange = 5
    45.     AlphaBlendForm Me.Hwnd, 255 'MAX VALUE = OPAIC/ MIN VALUE = 0 CAN'T SEE
    46.     Slider1.Value = 255
    47. End Sub
    48.  
    49. Private Sub Slider1_Scroll()
    50.     AlphaBlendForm Me.Hwnd, Slider1.Value
    51. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Fanatic Member Nove's Avatar
    Join Date
    Jul 2004
    Posts
    736

    Re: Under Application

    I'm on windows 98

  8. #8
    Hyperactive Member Dmitri K's Avatar
    Join Date
    Sep 2002
    Location
    West Palm Beach, FL
    Posts
    444

    Re: Under Application

    yeah on Win 2k and XP it's easy using layers but on win98 there are two ways that I know of. I placed both ways into one function for your choice.

    VB Code:
    1. Option Explicit
    2.  
    3. Public Enum iMode
    4.   AlphaBlendingDLL = 1
    5.   msimg32DLL = 2
    6. End Enum
    7.  
    8. Public Type BLENDFUNCTION
    9.     BlendOp As Byte
    10.     BlendFlags As Byte
    11.     SourceConstantAlpha As Byte
    12.     AlphaFormat As Byte
    13. End Type
    14.  
    15. Public Declare Function AlphaBlending Lib "Alphablending.dll" _
    16.               (ByVal destHDC As Long, ByVal XDest As Long, ByVal YDest As Long, _
    17.               ByVal destWidth As Long, ByVal destHeight As Long, ByVal srcHDC As Long, _
    18.               ByVal xSrc As Long, ByVal ySrc As Long, ByVal srcWidth As Long, ByVal srcHeight As Long, ByVal AlphaSource As Long) As Long
    19.  
    20. Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
    21. Public Declare Function AlphaBlend Lib "msimg32" (ByVal hDestDC 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 WidthSrc As Long, ByVal HeightSrc As Long, ByVal blendFunct As Long) As Boolean
    22.  
    23. Public Sub Blend(Destination As Object, Source As Object, Amount As Integer, in_iMode As iMode)
    24.  
    25.   Dim bl As BLENDFUNCTION
    26.   Dim bl_lng As Long
    27.  
    28.     If in_iMode = AlphaBlendingDLL Then
    29.       AlphaBlending Destination.hDC, -Destination.Left - 1, -Destination.Top - 1, Source.ScaleWidth, Source.ScaleHeight, Source.hDC, 0, 0, Source.ScaleWidth, Source.ScaleHeight, Amount
    30.     ElseIf in_iMode = msimg32DLL Then
    31.       bl.SourceConstantAlpha = Amount
    32.  
    33.       CopyMemory bl_lng, bl, 4
    34.    
    35.       Destination.Cls
    36.       AlphaBlend Destination.hDC, -Destination.Left - 1, -Destination.Top - 1, Source.ScaleWidth, Source.ScaleHeight, _
    37.                  Source.hDC, 0, 0, Source.ScaleWidth, Source.ScaleHeight, bl_lng
    38.     End If
    39.    
    40.     Destination.Refresh
    41.  
    42. End Sub

    Use Blend PictureDestination, PictureSource, 120, AlphaBlendingDLL for the 1st method
    Use Blend PictureDestination, PictureSource, 120, msimg32DLL for the 2nd method

    Make sure all pictureboxes are set to autoredraw and are scaled in pixels. Also you SHOULD have msimg32.dll on your pc, but you might not have Alphablending.dll, so i'll attach it. Put the Alphablending.dll into your system folder. Also source and destination could be a form, not a picturebox but make sure autoredraw is on and form is scaled to pixels.
    Attached Files Attached Files
    Last edited by Dmitri K; Jan 3rd, 2005 at 08:31 PM.

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