Channel 9 - Discussions by LeoDavidsonhttp://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.pngChannel 9 - Discussions by LeoDavidsonhttp://channel9.msdn.com/Niners/LeoDavidson/Discussions
Channel 9 keeps you up to date with the latest news and behind the scenes info from Microsoft that developers love to keep up with. From LINQ to SilverLight – Watch videos and hear about all the cool technologies coming and the people behind them.http://channel9.msdn.com/Niners/LeoDavidson/Discussions
enWed, 04 Mar 2015 00:37:16 GMTWed, 04 Mar 2015 00:37:16 GMTRev9000Tech Off - "Any CPU" - Is it evil?

Sven Groot said:

LeoDavidson said:

*snip*

You could also have a main 64 bit .Net process, and a 32 bit .Net process doing the interop, and then have the two communicate via .Net Remoting or WCF. It's pretty easy to set up.

.Net Remoting definitely makes more sense than COM for .Net projects. I forgot all about it, even though I've used it. It's great and, like you say, really easy to use.

What do you mean by "proxy"? If I have a seperate process load the 32 bit dll, do I not still have the same problem? How do I communicate with the 32 bit process from 64 bit process?

COM can make calls to objects hosted in other processes (i.e. out-of-process objects). When doing so it doesn't matter if either/both processes are 32/64 bit or not; COM handles the details for you.

You could also use other IPC mechanisms like pipes, shared memory, etc. but the beauty of the COM method is that you get all the marshalling code for free and if you're already using COM then you don't have to change much.

I would prefer to put all my legacy 32 bit code into a DLL however that quickly renders it useless as 64 bit clients appear to have no means of communicating with 32 bit code.

You can do it, you just need a 32-bit process to load the 32-bit DLLs on your behalf and then act as a proxy between your main 64-bit process and the DLLs.

Obviously, how well this works depends on what the DLLs do. If the DLLs require that lots of pointers and complex data structures be passed in and out of them then you have to write a lot of marshalling glue. If not, though, it's very easy.

In C++ code, I've used COM to get all the marshalling I need for free. COM knows how to call across the 32/64-bit boundary between processes, converting arguments appropriately. (You're already unable to share pointers across processes so the 32/64-bit issue
doesn't change things there.) I'm not sure what the best approach for .Net code is, though.

Custom hardware? What does that mean? Did you literally build the hardware? If that is correct then it is your duty to write proper drivers and make sure that the hardware works.

Or does "custom hardware" mean that you bought hardware and assembled the PC on your own? If that is correct and you get the described experience that might more likely mean that you bought some hardware that doesn't work well together. Or some of the parts
that you bought are faulty.

I bought a set of hardware components recently too. And assembled them as my living room PC. Everything is brand new. Installed Windows 7. Had it go to Windows Update and install all the drivers. Everything works great. Solid and fast performance.

To add to that, there have been problems with certain combinations of hardware/software/OS/drivers/whatever forever. People see one Vista (or whatever) machine with the problem and someone jump to the conclusion that it's the OS when the same sort of problem
could happen on any OS, including Winodws XP, Linux, OS X...

]]>http://channel9.msdn.com/Forums/Coffeehouse/442409-Windows-7-Epic-Failure/f9b7c32a90d64bdd822a9dea010bf6d7#f9b7c32a90d64bdd822a9dea010bf6d7
Sat, 24 Oct 2009 17:38:17 GMThttp://channel9.msdn.com/Forums/Coffeehouse/442409-Windows-7-Epic-Failure/f9b7c32a90d64bdd822a9dea010bf6d7#f9b7c32a90d64bdd822a9dea010bf6d7LeoDavidson106http://channel9.msdn.com/Niners/LeoDavidson/Discussions/RSSTech Off - Turning off FUS in Windows 7This guide for Vista looks like it should still work:

The options are still there in Windows 7. (I haven't actually tried them, and I'm not on a domain, but they are still in the same place except that Local Computer Policy has been renamed to Computer Configuration in the tree on the left of gpedit.msc.)

]]>http://channel9.msdn.com/Forums/TechOff/498754-Turning-off-FUS-in-Windows-7/2e3a2d57530e4e65bfbf9deb00097893#2e3a2d57530e4e65bfbf9deb00097893
Thu, 15 Oct 2009 14:34:21 GMThttp://channel9.msdn.com/Forums/TechOff/498754-Turning-off-FUS-in-Windows-7/2e3a2d57530e4e65bfbf9deb00097893#2e3a2d57530e4e65bfbf9deb00097893LeoDavidson7http://channel9.msdn.com/Niners/LeoDavidson/Discussions/RSSTech Off - Way to detect DWM open/close window animations?I gave up on the alternative method in the end. Ran into too many problems with controls drawing directly into the window, or directly manipulating the window (e.g. shifting parts of it around in when scrolling), over the top of what I was doing. That's
what makes the DWM thumbnail method so great: It takes the rendering output or the windows and does things to it without affecting it at all. (It also lets me easily create effects on areas of the top-level window which can cross over child windows.)

So I went back to plan A. Almost ditched the idea completely but it looked so nice (to me ) that I kept at it a bit more, and I think I now have it working really well, albeit with some kludges. Long term testing will determine whether the feature sticks
or is canned.

While playing with this stuff I discovered that Windows 7's DWM process will crash (and sometimes reset the desktop back to classic rendering) if the user invokes Aero Peek while a DWM thumbnail is being moved around in another window as Peek fades things
out to sheets of glass.

Workaround is to set the new DWM window flag on the window the thumbnail is rendered into, telling DWM to ignore that window for Aero Peek. (Drawback is that it then stays visible while the other windows are faded to glass, but in my case that's fine as
it's only visible for half a second anyway.)

I also noticed that my overlay window is considered part of the main window when minimising/restoring the window, and within Flip 3D. So it's only considered a separate window during the window-open animation, which seems weird. It's like the pop-up is only
"attached" to its parent after that window-open animation has completed. (I checked that I'm not opening my pop-up before the parent window has been made visible, and I'm not.)

As you say, it's a bit of a hack and you aren't really using DWM thumbnails in a way anyone ever intended them to work, which is probably why it doesn't. I suspect the best you'll get is to disable DWM animations for your window, although I have a suspicion
that something like Flip3D may make your UI break also.

Flip3D is fine, FWIW. You can opt windows out of it so the overlay window would be hidden whenever it's active (including when it's animating things into position).

Think I'll explore an alternative way to do the effect now. Have an idea that might give a good result but won't be hardware accelerated and will only work with windows that allow painting to a specific device-context. If that works well enough then it'll
save a lot of hassle.

Wait, what? I'm not sure I follow you here... are you using this window as an overlay to add visual effects to your application or are you using this window to draw a custom preview thumbnail?

At any rate, anything you do on this is a hack. You're only going to get so far before you need to move to a proper animation framework (through WPF, through the Windows 7-specific Animation Manager, or through a third-party framework). Might as well do
it right from the start than have to come back in a year and rewrite everything when you need to do something that's beyond what your hack-around can do.

It is a bit of a hack, but one which works well (so far, at least) apart from this one issue.

Spending the next few years re-writing the entire app to get a bit of eye candy isn't an option, as nice as that idea may sound in an ideal world with infinite time & resources and access to the source code of all OS and 3rd party components. (This effect
has to work, for example, on hosted ActiveX controls.) If re-writing the whole app is the only option then I'll simply do without the effect.

However, if there is some way to detect when DWM has finished animating my window then I believe I can make everything work perfectly.

You don't need to "make it act like a docking panel" (or provide any behavior at all, really), just setting the parent of your effects window to your main window should be sufficient to make it behave as though its part of the main window from the DWM's
perspective (along with the obvious change to use coordinates relative to the window).

Downside: if your child window has a title bar, it will most likely no longer be drawn by the DWM. Also, you can get some weirdness WRT keyboard focus when doing this; if your effects window is just a transient thing, this shouldn't be an issue (and it
won't be any more of an issue than when you were using a separate window).

The effects window can't be a proper child (WS_CHILD) of the main window since DWM thumbnails can only be drawn into top-level windows.

(Drawing the thumbnail directly into the main window won't work as the thumbnail is
of the main window and DWM checks for such loops.)

When I create the effects window as a popup (WS_POPUP) I am specifying the main window as the parent in the CreateWindowEx call, but that doesn't seem to help. It opens in-place instantly instead of being animated like the main window is.

If I call SetParent on the effects window right after creating it, specifying the main window as its parent, then that breaks the DWM thumbnail.

it would seem like you could create a window that is a child of the "main" window and make it act like a docking panel

that might do it for you?

just don't try this with anti-matter BOOM!

They're all HWNDs but that doesn't mean WPF can draw a window that displays a modified copy of my native windows on top of those windows (which is what I'm doing at the moment), due to the "airspace restrictions".

As far as I can tell, mixing WPF and native controls just means they can sit next to each other in the same window. I don't think they can visually interact/overlap.

well one thing i was thinking of was to make a dll that was C++/CLI with just the UI bits only.

so 90% of the app logic would stay in raw C++ and would just have calls to an interface / with the impliemtation in C++/CLI

minimal impack to the perf of the app and to the non-ui code.

honestly there comes a point when IMHO it becomes time to embrace a chnage, WPF was made for making better visuals that in apps and to be able to do things that were difficult or impossible with GDI and WInforms.

sounds like you are getting into that area or right on the edge of it.

just as a bit of input - Over the last few months I have been getting more into SIlverlight as our clients use a lot of web stuff and they have been asking for more complex things that really needed silverlight or flash to do them.

so with silverlight what i have found is that on the code side i can't really see any huge change from winforms to xaml in event handlers and other mundane coding.

yes xaml is very different from the classic forms code but even then most of the code that interacts with the markup is not that far different.

now things like building a dependancy property - a bit funky but not hard to follow.

just so you know that it's some work but not all that hard if you take a bit of time and study some examples.

There's too much existing UI code in the project to make porting to WPF a realistic option. It also hosts several native 3rd party UI components that don't have WPF equivalents. An all-WPF UI would definitely make this kind of thing easier if it was a new
or small project but it'd take man-years to change the existing project.

Using WPF for individual controls in the UI would be fine, but I want something which can apply effects on top of existing controls/window regions.

Hmm, I wonder if there's a way to make DWM treat two top-level windows as part of the same thing, applying the same animations & transforms to both at once? That would solve things as well.

I think that's using C++/CLI so it'd turn my app into a managed one which I want to avoid. (On the grounds of avoiding complexity, if nothing else.)

Not sure WPF would solve the problem anyway, unless the whole UI was re-written as WPF? When WPF and Win32 are used in the same window they have to be segregated (no overlapping controls/regions). They can share a window but they can't interact, at least
as I understand it.

My aim is to make something that can be slotted into existing code without much plumbing and without having to change the way existing controls paint themselves or the way they are hosted in the window.

DWM's live-thumbnail API is perfect for that as it lets me render a live copy of the window, faded/enlarged/reduced. From just messing around with it for a day I've got something that's almost perfect, except when DWM is messing with my window's shape in
a way I don't know how to detect.

(Hope that makes sense. Probably not explaining myself very well at 4am. )

Plain GDI. GDI+ is an option but I don't think it would help here. I can't use WPF as it's a C++ app.

The effects window I'm overlaying has a static copy of what the main window used to look like. On to that I'm using DWM to render a live copy of the main window. The live copy scrolls/fades/zooms to give a smooth transition from the old UI state to the new
one.

Doing it this way means the existing UI elements don't need to be modified for the effect to work; they just paint themselves as normal. During the transition the UI remains "live", painting updates and responding to the mouse and keyboard (since the effects
window is "click-through"). With just two lines of code I can add a transition effect to almost any UI change.

It all seems to work great, except if the effect is triggered while DWM is applying its own transition animations to the window. So if I could just detect when/whether those are happening I could disable my effect.

(Obviously I also have to worry about the main window being moved or resized while the effects window is over the top of it. That is easy enough. The problem with the DWM animations is that they visually move the window and yet it doesn't move as far as
things like GetWindowRect or WM_SIZE are concerned.)

Maybe a picture shows it better. Say notepad is opening:

(It's actually a screenshot of notepad closing, as that was easier to capture, but just pretend it's opening instead. )

If you were to overlay a copy of its client area on top of where the OS reports it to be, you'd end up with this:

]]>http://channel9.msdn.com/Forums/TechOff/497415-Way-to-detect-DWM-openclose-window-animations/46accea7d57f41b48fd89deb00096434#46accea7d57f41b48fd89deb00096434
Sat, 10 Oct 2009 01:41:55 GMThttp://channel9.msdn.com/Forums/TechOff/497415-Way-to-detect-DWM-openclose-window-animations/46accea7d57f41b48fd89deb00096434#46accea7d57f41b48fd89deb00096434LeoDavidson18http://channel9.msdn.com/Niners/LeoDavidson/Discussions/RSSTech Off - Way to detect DWM open/close window animations?On Windows 7, I'm trying to write something which overlays a top-level layered window above my app's main window to create some visual effects. The intention is to make it look like everything is part of the main window even though there's really another
window above it rendering some of the effects.

It goes wrong if the main window is opening / closing / minimizing / etc. because of the DWM's animations. The top-level effects window is positioned so that it's on top of where GetWindowRect reports the main window to be, but the on-screen representation
of the main window isn't really there. The main window is being transformed & animated in 3D space away from or towards the reported window location. So my top-level effects window is sitting in space looking really weird and drawing its effects over other
windows.

I'd be happy to simply disable my effect while the DWM animations are playing. Problem is I can't see a way to detect them. I'd like to do it properly in case future OS versions make the animations longer or shorter. i.e. I'd prefer not to use a kludge that
says "don't apply my effects if the window was only opened/restored/maximized 1 second ago."

(I don't want to turn off the DWM animations for the main window.)

There are a
bunch of stats returned by
DwmGetCompositionTimingInfo but I'm not sure if any of them are useful for detecting the animations. It's not very clear to me what the stats are for but I'm guessing it's to do with syncing multimedia or measuring performance rather than seeing what's
going on with a particular window.

It's worse because the cursor bug really exists while the chkdsk thing was part misunderstanding and part 3rd party chipset driver bug.

i.e. The chkdsk thing is 0 bad and the cursor thing is 0.00000001 bad.

Nobody is (seriously) calling it a showstopper, of course. Just a small cosmetic glitch that will drive some people with OCD crazy. (I can see it really easily but, thankfully, it doesn't bother me. It does have me curious about what the cause is, though,
as the .ani cursor file plays fine in other things.)

Edit:

I solved the mystery. The Win7 busy-cursor files have two sizes embedded (48x48 and 32x32). The larger size is fine and are what you'll see if you open the file in most editors. Not sure if any ani-cursor tools understand the dual-size files so I used a
hex editor to extract the individual 32x32 frames. Those are the ones Windows actually uses (at default DPI anyway). It's then
easy to see that frame 6 is an exact copy of frame 7, and what should be frame 6 is missing, causing the glitch. (You can also see that the 48x48 versions are fine.)

Very simple explanation in the end. It only seemed confusing because the tools we were using to look at the file hid the fact it had two sizes of images inside of it.

So far, I'm pleased and impressed with this version over Vista. Vista set the bar sort of low so to reach beyond that probably wasn't to much to ask.

I have win7 on my acer netbook for 3 days now. So far so good. I think my use of the OS features though is a lot less than some of the descriptions I see here.

Compared to XP though? time will tell. My netbook had XP Home on it from the factory and so far Win7 seems a little slower, which I expected, but it's not enough to for me to be too vociferous yet. The 60 second lag someone mentioned previously is about
the biggest complaint I have so far.

Once i get it on my dual monitor desktop, I may have more to say...

I just noticed a cool improvement in Win7's remote desktop for multi-monitors (unless I imagined it happening):

When you RDP from a single-monitor PC it moves all the windows to the one screen (Vista stopped doing that and it was a mixed blessing), but when you go back to using the machine locally it moves the windows back to the monitors they were on (fantastic!).

On the flipside, I don't really like how when I RDP into my desktop the desktop's monitors come out of powersaving just to show the screen lock (logon desktop). I guess I can give the logon desktop the Blank screensaver with a short timeout to stop the monitors
lighting up the room for long, though. (Assuming you still can. There's no longer any screensaver on the logon desktop, by default, which seems odd.)

]]>http://channel9.msdn.com/Forums/Coffeehouse/468733-What-dont-you-like-about-Windows-7/d17d10db23ea4f71a8509deb00dcb4e1#d17d10db23ea4f71a8509deb00dcb4e1
Thu, 13 Aug 2009 22:10:18 GMThttp://channel9.msdn.com/Forums/Coffeehouse/468733-What-dont-you-like-about-Windows-7/d17d10db23ea4f71a8509deb00dcb4e1#d17d10db23ea4f71a8509deb00dcb4e1LeoDavidson59http://channel9.msdn.com/Niners/LeoDavidson/Discussions/RSSCoffeehouse - Small server speed test... if you don't pay for bandwidth and have a few moments

W3bbo said:

LeoDavidson said:

*snip*

Leo, you should know better than thread necromancy

Oh, oops.

I thought it said Aug(ust) rather than Apr(il) and am suitably out of touch with reality to not realise that 17th August is in the future. lol

"My bad!"

Old posts should change colour or something so they're easier to spot.

But if I remember right, another example of a problem with iTunes, is that iTunes doesn't put your track ratings back into the mp3 files, it just keeps them in the library. Really rendering the rating system useless and proving that Apple just likes sitting
in it's own sandbox and won't let any kids come in and play with it, nor do they want to leave the sandbox and play with others. It's a crappy analogy but I think it gets the point across

There's a good argument for not putting track ratings into the music files: They're subjective, not objective data.

i.e. If the music file is shared by multiple people, they will not all agree on how much they like it. They'll all agree on things like the artist name, track name and publishing date though. (Well, within reason. Sometimes people disagree on what to
put in those fields as well.)

(People may also want to rate files on read-only network drives or optical media, I suppose.)

As usual, I'd say the ideal would be an option about where to store the rating data.

(Personally, "nowhere" is a good answer as I've never seen the point of rating files. If something is garbage, delete it, and everything else is so dependent on mood that the rating doesn't mean much to me. Could be because I'm an "album guy" rather than
a "shuffle play guy", though.)

Indeed. Every large company I've worked for has had dog slow networks (at least for the IT staff/buildings), limited desktop HDD space (sometimes painful with big C++ builds) and severely limited network storage (a constant annoyance). Logging in to a machine
that hadn't been used before was always slow, even without gratuitous data put into the roaming profile.

Despite being companies that made billions a year they were all very tight when it came to storage. Online web mail gives people more storage than any company I've worked at gave their employees... If you were lucky you'd be able to store a few hundred meg.
A few gigabytes would be out of the question. We used to joke about buying a HDD ourselves and installing it into the servers if the company couldn't afford it.

Some thing storing 270MB of data in the roaming profile would cause so many unneccssary problems.

(Not that I'd ever install iTunes on a work machine, but it's still something Apple should've fixed a long time ago. They've been putting stuff there for ages.)

]]>http://channel9.msdn.com/Forums/Coffeehouse/477407-Bravo-Apple/6baf109d85374c9daf279deb00e604b9#6baf109d85374c9daf279deb00e604b9
Wed, 08 Jul 2009 14:53:46 GMThttp://channel9.msdn.com/Forums/Coffeehouse/477407-Bravo-Apple/6baf109d85374c9daf279deb00e604b9#6baf109d85374c9daf279deb00e604b9LeoDavidson18http://channel9.msdn.com/Niners/LeoDavidson/Discussions/RSSCoffeehouse - Google (Chrome) OSSo Google are making an OS with the fewest features to couple with the web browser with the fewest features? Great, I'll rush to drink that Kool-Aid.

So many of their plus points seem to be "we avoid the speed/complexity/security issues of XYZ" when it's because they aren't allowing the user to do XYZ at all. Hardly seems like a win, at least in the cases where people were never forced to do that thing
by default.

I hope this isn't the future of computing as I hate the idea of web-based apps. They're good for some things (and I'm arguably typing into one right now to post this) but not for everything. Not while so many people still have slow and/or fragile net access,
and the technologies involved are still so klunky.

That isn't to say that the way traditional desktop apps/OS work is perfect, of course.

I'm sick of hearing "the open source community" as if it's a single group of people, too.