Semi Transparent Form using VB6

后端 未结 2 2014
鱼传尺愫
鱼传尺愫 2020-12-19 22:47

Is it possible to create a form that is semi transparent, It should be visible over any open windows, not hidden behind ? Please guide!

2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-19 23:11

    Sure, see Karl Peterson's "Translucent" example: http://vb.mvps.org/samples/Translucent/

    To keep the form visible over other windows, you want to use the SetWindowPos API function.

    Private 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 Const HWND_TOPMOST = -1
    Private Const SWP_NOMOVE = &H2
    Private Const SWP_NOSIZE = &H1
    Private Const OnTopFlags = SWP_NOMOVE Or SWP_NOSIZE
    
    Public Sub FormOnTop(frm As Form)
        Call SetWindowPos(frm.hWnd, HWND_TOPMOST, 0&, 0&, 0&, 0&, OnTopFlags)
    End Sub
    

提交回复
热议问题