Results 1 to 20 of 20

Thread: Very interesting code: Aero in Microsoft Visual Basic

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Sep 2012
    Posts
    2,083

    Very interesting code: Aero in Microsoft Visual Basic

    I found a very interesting code on PsCode
    http://www.planet-source-code.com/vb...xtCodeId=75090

    Original Author(Md Ashraful Islam): 
    When Windows Vista and 7 started their journey there was a new aero features. But it was a secret of Microsoft. It is revealed now and the code shows how to use aero and extending it DWM Api. I just translated it from C++.

    Code:
    Private Declare Function DwmExtendFrameIntoClientArea Lib "dwmapi.dll" (ByVal hwnd As Long, pMarinset As MARGINS) As Long
    
    Private Type MARGINS
         Lf As Long
         Rt As Long
         T As Long
         B As Long
    End Type
    
    
    Private Sub Form_Load()
        Dim bounds As MARGINS
        Dim ahwnd As Long
        ahwnd = Me.hwnd
        With bounds
            .Lf = 0
            .T = 1000 / Screen.TwipsPerPixelY
            .Rt = 0
            .B = 0
        End With
        
        Dim result As Long
        result = DwmExtendFrameIntoClientArea(ahwnd, bounds)
        Me.BackColor = vbBlack
    End Sub
    Note:
    After being compiled into an EXE, it will have an aero (or win8 or win10) effect.
    Attached Images Attached Images  
    Attached Files Attached Files
    Last edited by dreammanor; Jan 20th, 2018 at 09:54 PM.

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Very interesting code: Aero in Microsoft Visual Basic

    I'm not sure this was ever "secret" since the calls are documented and the topic was even discussed in blogs by different groups from Microsoft. It was also covered in videos and PowerPoint presentations posted to the old DevReadiness web site (now long gone).


    But since Aero is gone now, how does it matter? Vista is a dead OS now, and Windows 7 is dying (still in Extended Support but Microsoft says it cannot be patched to make it safe to be connected to the Internet). Windows 7 has other issues when SP1 came out that makes it an unsafe platform to develop on. The fixes are in Win8 and later but will never be back-ported to the dying Win7.

    Windows 8 was replaced by Windows 8.1 and then 8.1 Update but nobody should be using it either.


    Windows 10 has had several major updates equivalent to Service Packs or even new releases. It is a moving target. Get on the train, it has left the station but if you run fast enough you might still get aboard. Resistance is futile, the battle has long been over and lost. Welcome to 2018.

  3. #3
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,375

    Re: Very interesting code: Aero in Microsoft Visual Basic

    Quote Originally Posted by dilettante View Post
    Windows 7 has other issues when SP1 came out that makes it an unsafe platform to develop on. The fixes are in Win8 and later but will never be back-ported to the dying Win7.
    There were a few compatibility breaks yes, but they all got fixed. IMO. Which breaks remain exactly unresolved?

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Sep 2012
    Posts
    2,083

    Re: Very interesting code: Aero in Microsoft Visual Basic

    Quote Originally Posted by dilettante View Post
    I'm not sure this was ever "secret" since the calls are documented and the topic was even discussed in blogs by different groups from Microsoft. It was also covered in videos and PowerPoint presentations posted to the old DevReadiness web site (now long gone).


    But since Aero is gone now, how does it matter? Vista is a dead OS now, and Windows 7 is dying (still in Extended Support but Microsoft says it cannot be patched to make it safe to be connected to the Internet). Windows 7 has other issues when SP1 came out that makes it an unsafe platform to develop on. The fixes are in Win8 and later but will never be back-ported to the dying Win7.

    Windows 8 was replaced by Windows 8.1 and then 8.1 Update but nobody should be using it either.


    Windows 10 has had several major updates equivalent to Service Packs or even new releases. It is a moving target. Get on the train, it has left the station but if you run fast enough you might still get aboard. Resistance is futile, the battle has long been over and lost. Welcome to 2018.
    Hi dilettante, don't you find that it (the posted source code) replaces manifests and initcommoncontrols in a very simple and intuitive way?
    Last edited by dreammanor; Jan 20th, 2018 at 09:47 AM.

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Very interesting code: Aero in Microsoft Visual Basic

    Dream, manifests contain so much more than theme requests. In any case, wouldn't this be a curiosity just for O/S using Aero? I didn't try your code on Win10 to see the effect, but if it's anything like your screenshot, don't think we want our apps looking older than the current O/S. Just my opinion.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Sep 2012
    Posts
    2,083

    Re: Very interesting code: Aero in Microsoft Visual Basic

    Hi LaVolpe, when the program is run on Win10, the form renders as an effect of the win10 window.

  7. #7
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Very interesting code: Aero in Microsoft Visual Basic

    Quote Originally Posted by Krool View Post
    There were a few compatibility breaks yes, but they all got fixed. IMO. Which breaks remain exactly unresolved?
    As far as I can recall there was that problem when ADO 6.1 broke binary compatibility. The fix for this was never put into Windows 7 because it was already on Extended Support. People have a number of workarounds to try to get by, but then their programs can fall apart when run on other OSs.

    The fix fixed things so that programs developed on Windows 8 or later run everywhere. Not so if you develop on Win7 SP1.

  8. #8
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,375

    Re: Very interesting code: Aero in Microsoft Visual Basic

    Quote Originally Posted by dilettante View Post
    As far as I can recall there was that problem when ADO 6.1 broke binary compatibility. The fix for this was never put into Windows 7 because it was already on Extended Support. People have a number of workarounds to try to get by, but then their programs can fall apart when run on other OSs.

    The fix fixed things so that programs developed on Windows 8 or later run everywhere. Not so if you develop on Win7 SP1.
    Your wrong.
    Fixed by KB 2517589

    https://support.microsoft.com/de-de/...p1-or-in-windo

  9. #9
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Very interesting code: Aero in Microsoft Visual Basic

    I'm not convinced that "fix" fixes things correctly. It looks like one of the attempts to pave over the problem that ended up causing more trouble. Just let Win7 die.

  10. #10
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: Very interesting code: Aero in Microsoft Visual Basic

    dilettante can you please stop with this anti-7. if you don't like it, fine, but stop with this spam.
    we will not change because "U" keep trashing it.

    no, this info is new to me, it is compatible with 7,8,10 so whats the harm? if its works great. if not, it is still a new API we can play with.
    thx dreammanor for sharing this, and do not let bullies tell you differently. i will definitely try it out!

  11. #11
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,375

    Re: Very interesting code: Aero in Microsoft Visual Basic

    For me Win 7 works out so no need to change. "Never change a running system"
    If in 2 years it's not running for whatever reason then I might change the OS.

    DwmExtendFrameIntoClientArea is not specifically about Aero. It's just a generic function to fake draw the nonclient area over the client area. So it's no surprise that on Win10 it looks like Win10 and on Win7 like Aero - or Win7 so said.

  12. #12
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Very interesting code: Aero in Microsoft Visual Basic

    Out of curiosity. Anyone try this compiled, without a manifest -- no workie, at least on Win10, not even close. I'll let you guys/gals experiment to see the for yourself. For the test, I used the sample project in post #1 and simply compiled it without any modifications.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

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

    Re: Very interesting code: Aero in Microsoft Visual Basic

    Quote Originally Posted by LaVolpe View Post
    Out of curiosity. Anyone try this compiled, without a manifest -- no workie, at least on Win10...
    Not sure whether this counts as "no workie" (due to the messed up Font-Rendering in the two Controls),
    but here is the output on my Win 8.1 machine (also no manifest, straight compiled):



    Olaf

  14. #14

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

    Re: Very interesting code: Aero in Microsoft Visual Basic

    Quote Originally Posted by The trick View Post
    You can put 32bpp picture to image control to semi-transparent effect
    Please show Text-RenderOutput (in the ForeColor you defined on the Control in question,
    especially try Label-Controls with BackStyle transparent)...

    Olaf

  16. #16
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Very interesting code: Aero in Microsoft Visual Basic

    Quote Originally Posted by Schmidt View Post
    Not sure whether this counts as "no workie" (due to the messed up Font-Rendering in the two Controls),
    but here is the output on my Win 8.1 machine (also no manifest, straight compiled):

    Olaf
    Well, I did mention I was using Win10. Here's that screenshot

    Name:  Untitled.png
Views: 1045
Size:  1.5 KB
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  17. #17
    PowerPoster
    Join Date
    Feb 2015
    Posts
    2,672

    Re: Very interesting code: Aero in Microsoft Visual Basic

    Quote Originally Posted by Schmidt View Post
    Please show Text-RenderOutput (in the ForeColor you defined on the Control in question,
    especially try Label-Controls with BackStyle transparent)...

    Olaf
    Can't, because GDI text drawing functions draw with zero alpha value. You can draw it to temporary bitmap and then move to form. Other GDI seems can (i didn't check) with ROPs which don't touch alpha channel. I made example with layered windows with drawing via standart Line method http://forum.sources.ru/index.php?sh...=392336&st=15#. If i'm not wrong the same rules for DWM.

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

    Re: Very interesting code: Aero in Microsoft Visual Basic

    Quote Originally Posted by The trick View Post
    Can't, because GDI text drawing functions draw with zero alpha value.
    Yep - that's why I was asking...

    The .NETers have the exact same problem, when they use their .NET-WinForms-Controls on top of such areas.

    And the fact that "absolutely nothing" is shown on LaVolpes Win10 (leaving out more than just the TextRenderings)
    is probably due to the same problem (just happening more "strictly").

    As soon as uxTheme-Dll takes over the rendering (in case an appropriate manifest was provided),
    then at least the CommonControls will start to show up again, but also in this case the TextOut is messed up...

    Well, the .NETers have WPF-Controls to switch to - and we have the RC5 Form- and Widget-engine:



    The above is rendering a TextBox, a CommandButton and an Alpha-supporting ImageWidget on the Form
    (see code below - please ensure references to vbRichClient5 and vbWidgets in your Project - and start from Sub Main):

    Code:
    Sub Main()
      Cairo.ImageList.AddIconFromResourceFile "ico", "shell32", 167, 48, 48
      
      Dim Form As cWidgetForm
      Set Form = Cairo.WidgetForms.Create(vbSizable, "RC5-DwmExtendFrame", , 300, 200)
          Form.IconImageKey = "ico"
          Form.WidgetRoot.BackColor = -1
          Form.Glassify 'this implements the DWMExtendFrame-call under the covers (Optional Params left out)
          
          With Form.Widgets.Add(New cwTextBox, "txt1", 10, 20, 150, 23)
            .Widget.Alpha = 0.9
            .Text = "Text1"
          End With
          With Form.Widgets.Add(New cwButton, "btn1", 170, 20, 100, 23)
            .Widget.Alpha = 0.9
            .Widget.ImageKey = "ico"
            .Caption = "Command1"
          End With
          Form.Widgets.Add(New cwImage, "img1", 10, 50, 48, 48).Widget.ImageKey = "ico"
      Form.Show
      
      Cairo.WidgetForms.EnterMessageLoop
    End Sub
    Olaf

  19. #19
    Hyperactive Member
    Join Date
    Aug 2017
    Posts
    380

    Re: Very interesting code: Aero in Microsoft Visual Basic

    Here's another Aero Glass demo that uses the poor man's method described in this article. Perhaps, it'll be good enough for some scenarios.




    Appears nice on some backgrounds



    Looks terrible on others


    BTW, there is a utility that brings Aero Glass to Windows 8 and above, so judicious use of Aero on those OSes probably isn't pointless after all.
    Attached Files Attached Files

  20. #20
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Very interesting code: Aero in Microsoft Visual Basic

    All this effort to make your programs look like a refugee from 2006? Weird.

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