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.
Last edited by dreammanor; Jan 20th, 2018 at 09:54 PM.
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.
Re: Very interesting code: Aero in Microsoft Visual Basic
Originally Posted by dilettante
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?
Re: Very interesting code: Aero in Microsoft Visual Basic
Originally Posted by dilettante
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.
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"
Re: Very interesting code: Aero in Microsoft Visual Basic
Originally Posted by Krool
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.
Re: Very interesting code: Aero in Microsoft Visual Basic
Originally Posted by dilettante
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.
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.
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!
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.
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"
Re: Very interesting code: Aero in Microsoft Visual Basic
Originally Posted by LaVolpe
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):
Re: Very interesting code: Aero in Microsoft Visual Basic
Originally Posted by Schmidt
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
Insomnia is just a byproduct of, "It can't be done"
Re: Very interesting code: Aero in Microsoft Visual Basic
Originally Posted by Schmidt
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.
Re: Very interesting code: Aero in Microsoft Visual Basic
Originally Posted by The trick
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