Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Use Microsoft.Windows.Shell instead of hand-coded solution for WinForms interop #503

Closed
wants to merge 8 commits into from

Conversation

shiftkey
Copy link

@shiftkey shiftkey commented Jun 2, 2013

This is the work that @bitterskittles started which should resolve a number of issues spotted recently:

Other changes:

  • use NuGet package instead of binary (thanks @flagbug)
  • update nuspec - only reference Microsoft.Windows.Shell for net40
  • by default AllowTransparency = !EnableDWMDropShadow - the demo shows how you disable this but it seems like the this should be the default

TODO:

  • include a sample to ensure we can catch regressions
  • making AllowTransparency = true by default - this line
  • stop using EnableDWMDropShadow
  • feedback from others who aren't running Win8 that dropshadows are fine for the Panorama demo (I think they changed something DWM-related and the dropshadows are no longer used)
  • introduce AllowTransparency dependency property into BorderlessWindowBehaviour and replace the related EnableDWMDropShadow usages
  • update demo to use AllowTransparency instead

Thanks again to @bitterskittles for getting to the bottom of this.

@shiftkey
Copy link
Author

shiftkey commented Jun 5, 2013

Here's the demo:

image

@Amrykid @flagbug can you guys confirm I haven't impacted the Panorama demo behaviour?

@shiftkey shiftkey mentioned this pull request Jun 5, 2013
5 tasks
@punker76
Copy link
Member

punker76 commented Jun 5, 2013

@shiftkey interop demo works for me
2013-06-05_09h17_20

panorama demo has no drop shadow (is this correct?)
2013-06-05_09h18_03

this should fix the missing drop shadow

                case Constants.WM_NCPAINT:
                    {
                        if (ShouldHaveBorder())
                        {
                            this.AddBorder();
                        }
                        else if (EnableDWMDropShadow)
                        {
                            var metroWindow = AssociatedObject as MetroWindow;
                            if (!(metroWindow != null && metroWindow.GlowBrush != null))
                            {
                                var val = 2;
                                UnsafeNativeMethods.DwmSetWindowAttribute(_mHWND, 2, ref val, 4);
                                var m = new MARGINS { bottomHeight = 1, leftWidth = 1, rightWidth = 1, topHeight = 1 };
                                UnsafeNativeMethods.DwmExtendFrameIntoClientArea(_mHWND, ref m);
                            }
                        }

                        handled = true;
                    }
                    break;

my machine: win 7 64 bit net 4

@shiftkey
Copy link
Author

shiftkey commented Jun 5, 2013

@punker76 no, that sounds wrong. Damnit.

@bitterskittles
Copy link
Contributor

@shiftkey I think it is better to keep AllowsTransparency and EnableDWMDropShadow properties separate in case they both need to be set to false at the same time.

@spiritdead
Copy link
Contributor

well testing i see this
http://img856.imageshack.us/img856/5943/error8.jpg
when I open it, the animation of the windowformshost metrowindow position is erroneous
when resized, fits
http://img802.imageshack.us/img802/183/error9.jpg

:S i test the recent changes 06/06/2013 (this branch)

@spiritdead
Copy link
Contributor

well reading this PR i see this
when u change to false this vars in the file BorderlessWindowBehavior.cs
lane 87 AssociatedObject.AllowsTransparency = false;//!EnableDWMDropShadow;

and in the metrowindowDEMO i set the allowtransparency = false (xaml)

and i finally can add a picturebox in the demo

http://img855.imageshack.us/img855/3233/qywf.jpg

NOTE:

if you set in the xaml this
< i:Interaction.Behaviors>
< behaviours:BorderlessWindowBehavior ResizeWithGrip="True" EnableDWMDropShadow="True" />
< /i:Interaction.Behaviors>

is true you can see the windowsformhost BUT you cant see the glow in the borders

< Controls:MetroWindow.GlowBrush>
< SolidColorBrush Color="{DynamicResource AccentColor}" />
< /Controls:MetroWindow.GlowBrush>

exist the chance for add a new dependency property for the allow transparency ? and remove the lane
AssociatedObject.AllowsTransparency =!EnableDWMDropShadow;

?

@AzureKitsune
Copy link
Member

Another bug that may be related #571.

@spiritdead
Copy link
Contributor

i need this merge :(

@shiftkey
Copy link
Author

If someone can sanity check b8734dd for me (separating out AllowsTransparency and EnableDWMDropShadow into two properties) I'll then rebase this and merge it in asap.

@shiftkey
Copy link
Author

Another issue: #560

@spiritdead
Copy link
Contributor

:( you can merge more PRs ? :D

@shiftkey
Copy link
Author

@spiritdead I think I'll just push it up now and create a new package. If something comes up we should be able to turn it around quickly...

@spiritdead
Copy link
Contributor

ok @shiftkey if in the future you need rollback is better make a backup, and thx for merge i rly need this fix

@spiritdead
Copy link
Contributor

i have a dude or problem, during the animations move or flyout close/open the objects winforms not move correctly example this

http://img560.imageshack.us/img560/3607/ztyi.jpg

@shiftkey
Copy link
Author

Merged

@shiftkey shiftkey closed this Jul 12, 2013
@shiftkey
Copy link
Author

i have a dude or problem, during the animations move or flyout close/open the objects winforms not move correctly example this

I don't understand. Please open a different issue with details.

@shiftkey shiftkey deleted the make-windowchrome-not-suck branch July 12, 2013 03:53
@spiritdead
Copy link
Contributor

ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

6 participants