Normally you would leave the settings for those at default so they take on what ever theme the user has selected. On my system they are both the same on all the programs I have created.
I notice you have blue buttons on the child and grey on the midi and one of the blue buttons is a different shade from the others so it looks like you are overriding the theme somewhere.
I notice you have blue buttons on the child and grey on the midi and one of the blue buttons is a different shade from the others so it looks like you are overriding the theme somewhere.
Actually the buttons and other controls are my ocx controls ...
I think the question is why is the MDI child form's non-client area (titlebar, borders, etc) drawn different than a normal form? Visual appearance isn't the only thing that is different. For example, what happens when your right click on the child title bar? And now when you right click on the MDI titlebar or any non-child form's titlebar?
Unless someone already tested this by creating dynamic API MDI child forms, it simply looks like VB custom draws the non-client area. If that rendering is how API MDI children look also-- then wow, what a visual goof-up by Microsoft, in my opinion.
Insomnia is just a byproduct of, "It can't be done"
I assume the image is under Windows 10 given the flat appearance.
I tested mine on this machine which is windows 7 running classic theme and both the parent and child title bars are the same gradient blue. no difference between the two.
I just tried the same program on my Windows 10 machine and see the different colors on the title bars. Looks a lot better in Windows 7.
I don't know what is behind, but it seems that Windows (at least Windows 10) has two ways for painting the non client area.
Try this code:
Code:
Private Declare Function PrintWindow Lib "user32" (ByVal hWnd As Long, ByVal hdcBlt As Long, ByVal nFlags As Long) As Long
Private Sub Command1_Click()
AutoRedraw = True
PrintWindow hWnd, hDC, 0
Refresh
End Sub
Last edited by Eduardo-; Aug 4th, 2020 at 10:43 AM.
hello it is not possible to apply the style to the child windows, the only solution and not the most beautiful is to eliminate the style in the parent window
Code:
Option Explicit
Private Declare Function DwmSetWindowAttribute Lib "dwmapi.dll" (ByVal hWnd As Long, ByVal dwAttribute As Long, ByRef pvAttribute As Long, ByVal cbAttribute As Long) As Long
Private Const DWMNCRP_DISABLED = 1
Private Const DWMNCRP_ENABLED = 2
Private Const DWMWA_NCRENDERING_POLICY = 2
Private Sub MDIForm_Load()
Call DwmSetWindowAttribute(hWnd, DWMWA_NCRENDERING_POLICY, DWMNCRP_DISABLED, 4)
End Sub
hello it is not possible to apply the style to the child windows, the only solution and not the most beautiful is to eliminate the style in the parent window
Definitely an option for MDI applications. That at least makes the child & parent have the same non-client look. Unfortunately, but now neither are themed. It's a shame we can't apply some API to the child window to make it themed. It is probably the WS_CHILD or WS_EX_MDICHILD style bit that is the reason?
Insomnia is just a byproduct of, "It can't be done"
Definitely an option for MDI applications. That at least makes the child & parent have the same non-client look. Unfortunately, but now neither are themed. It's a shame we can't apply some API to the child window to make it themed. It is probably the WS_CHILD or WS_EX_MDICHILD style bit that is the reason?
Just a question of curiosity. Not sure why it's important that the titlebars are the same gradient/color when other things like the min/max/restore buttons are completely different, as are the borders?
Insomnia is just a byproduct of, "It can't be done"
Just a question of curiosity. Not sure why it's important that the titlebars are the same gradient/color when other things like the min/max/restore buttons are completely different, as are the borders?
I don't know if I understood correctly, but is it to discern each other?
Definitely an option for MDI applications. That at least makes the child & parent have the same non-client look. Unfortunately, but now neither are themed. It's a shame we can't apply some API to the child window to make it themed. It is probably the WS_CHILD or WS_EX_MDICHILD style bit that is the reason?
Different theme of titlebar seems to identify whether it is normal window or Child window on win10. On Win7, turn off theme, they are the same.
Just a question of curiosity. Not sure why it's important that the titlebars are the same gradient/color when other things like the min/max/restore buttons are completely different, as are the borders?
The article is suggesting trapping WM_NCPAINT and filling the title bar with a solid color. Find VB examples that subclass WM_NCPAINT. I would think simply searching for WM_NCPAINT as a key word should get you started.
Subclassing to change the non-client (NC in the WM_NCPAINT) is not a trivial exercise with VB.
Insomnia is just a byproduct of, "It can't be done"
The article is suggesting trapping WM_NCPAINT and filling the title bar with a solid color. Find VB examples that subclass WM_NCPAINT. I would think simply searching for WM_NCPAINT as a key word should get you started.
Subclassing to change the non-client (NC in the WM_NCPAINT) is not a trivial exercise with VB.
LaVolpe, I just grabbed your post to quote. However, I've been thinking this every time I look at this thread.
Episcopal, why don't you just create a borderless MDI child and build your own form to look and behave exactly how you want. It would take a bit of work, but at least it'd be clear what you need to do:
Dig out the Windows titlebar color and use it for your custom titlebar.
Build little Min, Max, Close buttons that behaved the way you wanted (I'd probably use labels).
Build custom side bars for resizing, if you wanted this.
Build a "move" ability for your custom titlebar.
When you got it all done, you could throw it into a class, and then attach the class to your form, using a little "WithEvents" magic to make it all general purpose.
Heck, such an endeavor would be CodeBank worthy.
Take Care,
Elroy
EDIT1: Just thinking through how I'd do it, I'd make sure to "attach the class" (i.e., instantiate it) in the Form_Initialize event, and not the Form_Load event. If you had the class reference in the form's module level code, that way it'd have the correct lifetime, and you wouldn't need to worry about uninstantiating the class.
EDIT2: Or even better (than the above), just use the "New" keyword when declaring the class at the form's module level. Ackk, you've still got to somehow tell the class which form it's working with. Form_Initialize, call some method in the class and tell it.
EDIT3: Just in case you decide to go this route, there are some interesting pages to assist with fetching these colors, such as here or here ... or this is also a helpful page.
Last edited by Elroy; Aug 9th, 2020 at 03:20 PM.
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
Instead of getting hung up on gingerbread, make sure your program has enough useful functionality to outweigh silly skinning.
You can try to build a Buck Roger's Rocket Ship look and never get off the ground. Or put the engineering into practical needs instead of looks and get to the Moon.
VB6 is all about getting things done. If you really must be competitive on looks you may as well write it all in C++ from dirt.
Declare Function SetSysColors Lib "user32" _
(ByVal nChanges As Long, lpSysColor As _
Long, lpColorValues As Long) As Long
Public Const COLOR_CAPTIONTEXT = 9
And in your form add this:
Code:
Private Sub Form_Load()
'You can change the title bar text color to
'anytihng you want by changing the "VbBlack to Whatever you want"
s = SetSysColors(1, COLOR_CAPTIONTEXT, vbBlack)
End Sub
Private Sub Form_Unload(Cancel As Integer)
'To set default colors...... (Don't Change or remove this)
s = SetSysColors(1, COLOR_CAPTIONTEXT, vbWhite)
'Removing this will make all app's Titlebar text to be that color!!
End Sub
Declare Function SetSysColors Lib "user32" _
(ByVal nChanges As Long, lpSysColor As _
Long, lpColorValues As Long) As Long
Public Const COLOR_CAPTIONTEXT = 9
And in your form add this:
Code:
Private Sub Form_Load()
'You can change the title bar text color to
'anytihng you want by changing the "VbBlack to Whatever you want"
s = SetSysColors(1, COLOR_CAPTIONTEXT, vbBlack)
End Sub
Private Sub Form_Unload(Cancel As Integer)
'To set default colors...... (Don't Change or remove this)
s = SetSysColors(1, COLOR_CAPTIONTEXT, vbWhite)
'Removing this will make all app's Titlebar text to be that color!!
End Sub
As attached, the Titlebar of MDIForm and MDIChild are different. How do you standardize?
normally,windows (xp to 11) cant appl DWM.exe to childs because those windowses are in other type (in execute not in vb)
we cant see this on xp because non dwm and dwm is same themed but in vista(i hate it) to 11,they re not same
Windows changed the code for display of title-bars and the OCX no longer works correctly. Microsoft stated, in various posts, that they have no intention of "updating that OCX". It will no longer work as desired, even with API.
Solution: Make your own title-bar and the problem is solved. Make it an OCX, if desired, so you can just replace it in any form. However, it will now be within the "client area", but API can trick that, if needed.
You can hijack the settings for the actual title-bar, and adopt them into the one you make.
Windows created the "title-bar", which is actually the real "form", which has a "sub-form", within it, which we are tricked into knowing as the "client area form". That primary container, which is the shell of a program/form, is never truly "gone", when it is hidden. It is always there and just reduced to match the frame of the "client area", unless you select borderless form also. So every aspect of the title-bar should always be available, at all times, even when unseen. Like "form1.caption", the buttons for minimize, maximize and close, etc..
There is a similar issue with the "file menu", where it will no longer change colors, correctly. Again, that can be hidden too, and still be used for input, if you make your own custom "file menu". The "file menu" is also a sub-form, which pushes the client-area down lower too.
Last edited by ISAWHIM; Mar 2nd, 2024 at 09:00 AM.
Windows changed the code for display of title-bars and the OCX no longer works correctly. Microsoft stated, in various posts, that they have no intention of "updating that OCX". It will no longer work as desired, even with API.
Yaaaa, you are right. Since I'm walking around to find many information about this issue. I may confused that this is the original post that I found the link here. Thank you for updating me.
Anyway, I still looking for the VB.Net for this issue. I just want to change the MDI Child form border color. No need for any skin. Even, now I'm working with non-border forms already. Better if I know how to change its color by the sizeable window style.
Yaaaa, you are right. Since I'm walking around to find many information about this issue. I may confused that this is the original post that I found the link here. Thank you for updating me.
Anyway, I still looking for the VB.Net for this issue. I just want to change the MDI Child form border color. No need for any skin. Even, now I'm working with non-border forms already. Better if I know how to change its color by the sizeable window style.
yes friend... in post 9 and 15, we talked about alternatives, explore them for VB.Net as you said