Results 1 to 19 of 19

Thread: Transparent Activex Control,WS_EX_LAYERED on child controls

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Transparent Activex Control,WS_EX_LAYERED on child controls

    Project 5:Transparent Png Control by vb6-VBForums
    https://www.vbforums.com/showthread....Control-by-vb6

    Project 1:
    VB6 Transparent Textbox By API(WM_CTLCOLOREDIT)-VBForums
    https://www.vbforums.com/showthread...._CTLCOLOREDIT)

    Project2:VB6 UserControl-Transparency Container-VBForums
    https://www.vbforums.com/showthread....ency-Container

    Project3: Transparent Control By Multiple transparent windows form-VBForums
    https://www.vbforums.com/showthread....t-windows-form

    Project 4:vb6 Transparent Control by BitBlt,Transparent Picturebox-VBForums
    https://www.vbforums.com/showthread....ent-Picturebox


    Starting from Window 8, WS_EX_LAYERED can be used for child controls.

    Method: A manifest file is required, and at least Window 8 compatibility is specified (sub-layering only supports starting from Window 8).

    For anyone who wants to use hierarchical child windows, the following content should be included as a manifest file.

    Windows-classic-samples/Samples/DirectCompositionLayeredChildWindow at master · microsoft/Windows-classic-samples · GitHub
    https://github.com/Microsoft/Windows...redChildWindow
    saveas :Project1.exe.manifest
    Code:
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
      <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> 
        <application>
          <!--The ID below indicates app support for Windows 8 -->
          <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
        </application>
      </compatibility>
      <dependency>
        <dependentAssembly>
            <assemblyIdentity
                type="win32"
                name="Microsoft.Windows.Common-Controls"
                version="6.0.0.0"
                processorArchitecture="*"
                publicKeyToken="6595b64144ccf1df"
                language="*"
            />
        </dependentAssembly>
      </dependency>
    </assembly>
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by xiaoyao; Mar 30th, 2021 at 08:25 AM.

  2. #2

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: WS_EX_LAYERED on child controls(Transparent Activex Control)

    where is Transparent text control (can put on commandbutton,change zorder). Is there a way to add another file box to the custom control and set the transparent color to white?

  3. #3
    Fanatic Member
    Join Date
    Aug 2016
    Posts
    673

    Re: WS_EX_LAYERED on child controls(Transparent Activex Control)

    Why do you copy the code from dilettante? The code you posted is meaningless

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: WS_EX_LAYERED on child controls(Transparent Activex Control)

    form(PngControl.frm):
    Code:
    PngOcx_Layer1.Do_LoadPng App.Path & "\02button.png"
    PngOcx_Layer2.Do_LoadPng App.Path & "\01Alpha_Png.png"

    add a UserControl :PngOcx_Layer.ctl,code here:

    Code:
    Public Event Click()
     Function Do_LoadPng(PngFile As String)
        LoadPng PngFile, UserControl.hwnd
     End Function
    
    Private Sub UserControl_Click()
        PngControl.Caption = "ocx-click " & Now
        RaiseEvent Click
    End Sub
    
    Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
    If Button = 1 Then
        Call ReleaseCapture
        SendMessage UserControl.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&
    End If
    End Sub
    Last edited by xiaoyao; Mar 28th, 2021 at 04:38 AM.

  5. #5
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: WS_EX_LAYERED on child controls(Transparent Activex Control)

    There is no PngOcx_Layer.ctl user-control in the sample project. This is faking it by re-parenting a transparent form to simulate the fake child "flower control".

    Since commit ea789f6 "Add transparency for containers lacking windowless controls support" of the poor man's AlphaBlendImage control you can add the single-file user control to a project and set Windowless = False from properties window for a true WS_EX_LAYERED transparency on a true VB6 user-control.

    This requires Win8+ to work and a proper manifest for the final executable (and VBIDE).

    cheers,
    </wqw>

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: WS_EX_LAYERED on child controls(Transparent Activex Control)

    Quote Originally Posted by wqweto View Post
    There is no PngOcx_Layer.ctl user-control in the sample project. This is faking it by re-parenting a transparent form to simulate the fake child "flower control".

    Since commit ea789f6 "Add transparency for containers lacking windowless controls support" of the poor man's AlphaBlendImage control you can add the single-file user control to a project and set Windowless = False from properties window for a true WS_EX_LAYERED transparency on a true VB6 user-control.

    This requires Win8+ to work and a proper manifest for the final executable (and VBIDE).

    cheers,
    </wqw>
    use AlphaBlendImage,when add a button can't show.

    My final thought: add multiple PNG images with transparent channels to the control or independent new form, support zorder sequence operation. You can control the relationship between the upper and lower layers, there used to be the simplest set image1.picture=**(from png ), this can only be in the same Z order as the label control, and cannot be overwritten to the button control or Picturebox and other controls

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: WS_EX_LAYERED on child controls(Transparent Activex Control)

    If you just want to make the picturebox transparent, you can try the simplest way: take out the client area coordinates of the picture box, and then hide the control.
    Take a screenshot from the screen or the form, set it as the back view of the picture box, and then display the control (move off the screen, or set the width and height to 0)
    It would be great if there were fewer lines of code.
    I saw a transparent Picturebox control before, and found that the picture displayed in high DPI was incomplete.
    There is another way, if there are 2 other controls on the Picturebox, you can hollow out the other vacant places (CreateRectRgn),
    This is truly transparent. If you move the Picturebox, you can see the real situation of other forms or controls below.

  8. #8
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,120

    Re: WS_EX_LAYERED on child controls(Transparent Activex Control)

    Quote Originally Posted by xiaoyao View Post
    use AlphaBlendImage,when add a button can't show.
    Yes, it can! This is possible since latest commit ea789f6 which implements WS_EX_LAYERED transparency on the user-control.

    You just have to double-click on AlphaBlendImage.ctl in sources treeview to open the control's designer and in Properties Window set Windowless = False so that the control is *not* windowless. Since latest commit when the control is marked windowed it automagically uses WS_EX_LAYERED transparency and can overlap buttons, listviews, labels and every other control on the form.

    cheers,
    </wqw>

  9. #9
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Transparent Activex Control,WS_EX_LAYERED on child controls

    Just for the record...

    For nested Alpha-layering to work properly (on each and every existing Form or Control),
    the underlying Form- and Widget-engine has to support it from the ground up.

    And by using the RC5/RC6 Form+Widget-engine, the VB6 community can do "proper nested alpha" for nearly a decade now -
    (without using any Win32-APIs, fully DPI-aware and down to Windows-XP and older systems).



    The above shot is a fully interactive demo - with working TextBox-controls in the little moveable "frosted window-widgets".
    Code for the above output was shown here:
    https://www.vbforums.com/showthread....=1#post5252719

    Olaf

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: Transparent Activex Control,WS_EX_LAYERED on child controls

    [vb6] Transparent PictureBox - Page 2-VBForums
    https://www.vbforums.com/showthread....ctureBox/page2

    can use usercontrol to replace Picture for "Transparent-PictureBox"

  11. #11

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: Transparent Activex Control,WS_EX_LAYERED on child controls

    Quote Originally Posted by Schmidt View Post
    Just for the record...

    For nested Alpha-layering to work properly (on each and every existing Form or Control),
    the underlying Form- and Widget-engine has to support it from the ground up.

    And by using the RC5/RC6 Form+Widget-engine, the VB6 community can do "proper nested alpha" for nearly a decade now -
    (without using any Win32-APIs, fully DPI-aware and down to Windows-XP and older systems).



    The above shot is a fully interactive demo - with working TextBox-controls in the little moveable "frosted window-If there is a visual form designer, it is too much, or directly convert the control form of VB6 into widgets code".
    Code for the above output was shown here:
    https://www.vbforums.com/showthread....=1#post5252719

    Olaf
    IF THE MAIN FORM,ALL CONTROLS ,ALL support alpha Transparent ,that's funny.
    by miniblink.dll
    all webpage in webkit,all is Transparent .
    like a Transparent clock on desktop ,screen,it's only by js,miniblink.dll

    IF WE CAN DESIGN WINDOW LIKE usercontrol,
    Last edited by xiaoyao; Mar 28th, 2021 at 07:51 AM.

  12. #12

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: Transparent Activex Control,WS_EX_LAYERED on child controls

    one dll for Beautiful and cool software interface, button elements, etc.
    Name:  0579 exui-1.png
Views: 1016
Size:  24.6 KBName:  0578 exui-2.png
Views: 958
Size:  197.1 KBName:  EXUI_login.png
Views: 1013
Size:  44.2 KB
    http://iexui.com/exuiskin

    EXUI++
    http://iexui.com/

  13. #13

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: Transparent Activex Control,WS_EX_LAYERED on child controls

    Hierarchical window transparent method and several issues using this method, for the above questions, in order to improve or avoid the above method, I have been looking for methods that make the child's window transparent, can't use the hollow painted brush, which makes me Suddenly realize: hollow hollow_brush is equal to null_brush, the meaning is not to use the painting, that is, not to draw a brush, not filling is actually transparent,

    hook message
    Just intercept the ON_WM_CTLCOLOR message, then return to the empty painting brush in this processing function is Return (Hbrush) getStockObject (Hollow_brush); that, this window is transparent [this window is specified as a sub-window for other windows. After that, the sub-window is also transparent]

    transparent textbox by hook,subclasd
    https://blog.csdn.net/qq2399431200/a...tails/10991917
    Last edited by xiaoyao; Mar 28th, 2021 at 10:00 AM.

  14. #14

  15. #15

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: Transparent Activex Control,WS_EX_LAYERED on child controls

    Transparent textbox by WS_EX_LAYERED (should be included as a manifest file)

    Code:
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
    Private Const WS_EX_LAYERED = &H80000
    Private Const GWL_EXSTYLE = (-20)
    Private Const LWA_ALPHA = &H2
    Private Const LWA_COLORKEY = &H1
    Function SetAlphaColor(hwnd As Long, Optional AlphaColor As Long = vbBlue) As Long
        Dim rtn As Long
        rtn = GetWindowLong(hwnd, GWL_EXSTYLE)
        rtn = rtn Or WS_EX_LAYERED
        SetWindowLong hwnd, GWL_EXSTYLE, rtn
        SetLayeredWindowAttributes hwnd, AlphaColor, 0, LWA_COLORKEY
        SetAlphaColor = rtn
    End Function
    
    Private Sub Form_Load()
    
    Text1.ForeColor = vbYellow
    Text1.BackColor = vbBlue
    
    SetAlphaColor Text1.hwnd, vbBlue
    
    Me.Picture = LoadPicture("01.jpg")
    Timer1.Interval = 500
    Timer1.Enabled = True
    End Sub
    
    Private Sub Timer1_Timer()
        Text1.Left = Text1.Left + 50
    End Sub

  16. #16

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: Transparent Activex Control,WS_EX_LAYERED on child controls

    Programming Challenge:How to make Picturebox1 control truly transparent.Remove the background color, set the transparency of the PNG channel as a background image function.
    Code:
    SetWindowLong Picturebox1.hwnd, GWL_EXSTYLE, GetWindowLong(Picturebox1.hwnd, GWL_EXSTYLE) Or WS_EX_TRANSPARENT
        Set mSubclass = New clsTrickSubclass
        mSubclass.Hook Me.hwnd
    VB6 Transparent Textbox By API(WM_CTLCOLOREDIT)
    https://www.vbforums.com/showthread.php?891144-VB6-Transparent-Textbox-By-API(WM_CTLCOLOREDIT)

  17. #17

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: Transparent Activex Control,WS_EX_LAYERED on child controls

    Transparency effect function that took a day to study

    Code:
    TransparentWithHdc Picture1.hwnd,Picture1.Hdc
    Project 1:
    VB6 Transparent Textbox By API(WM_CTLCOLOREDIT)-VBForums
    https://www.vbforums.com/showthread...._CTLCOLOREDIT)

  18. #18
    New Member
    Join Date
    Mar 2024
    Posts
    1

    Re: Transparent Activex Control,WS_EX_LAYERED on child controls

    Quote Originally Posted by xiaoyao View Post
    one dll for Beautiful and cool software interface, button elements, etc.
    Name:  0579 exui-1.png
Views: 1016
Size:  24.6 KBName:  0578 exui-2.png
Views: 958
Size:  197.1 KBName:  EXUI_login.png
Views: 1013
Size:  44.2 KB
    http://iexui.com/exuiskin

    EXUI++
    http://iexui.com/

    Excuse me where is this Dll File
    xiaoyao

  19. #19

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    Re: Transparent Activex Control,WS_EX_LAYERED on child controls

    Can't I open the URL above? Download it from the official website.

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