Lorenz Cuno Klopfenstein

Posts tagged "Win32"

While working on OnTopReplica I needed a way to constrain the aspect ratio of the "cloned" window. Since the live thumbnails created using the DWM API cannot be manipulated and always maintain the aspect of the original window, it makes sense to limit the user's choices in resizing the window, in order to fit the window to the cloned thumbnail automatically.

Much like in the case of media players, where video files have a certain aspect ratio (let's ignore that this ratio can usually be changed by the user). If the video doesn't fit inside the player window, black bars are added on top and bottom or on the sides. Limiting the user's resizing options in this case actually improves the interface experience because a tedious task is handled directly (like searching the right size of the window to reduce the black bars).

In Windows Forms you have two options to react to resize events of the window: the OnResize event and the couple OnResizeBegin and OnResizeEnd. The problem of those two methods is that they both run after the window has been resized. That is, after the window received the WM_SIZE message (in Win32 terms). You can force the window to adopt a correct size after receiving one of those events.

This would work, if it weren't for the option "Show window contents while resizing" (added a long way back in Windows 98, more or less). That option (which is usually on by default) causes the window to generate a lot of WM_SIZE messages while it is being resized. If you react by changing the size on each event, the result is an extremely jerky window that jumps back and forth while the users tries to resize it. And the contents of the window flicker awfully as a result.

More...

Posted on Sunday, November 08, 2009
Tagged as
195 Views
2 comments posted

I recently got an e-mail from an OnTopReplica user (they exist!  :S) asking for a new feature that allows clicking on the window's thumbnail in order to generate corresponding clicks on the window that is being cloned. It's a feature I would find quite useful myself, therefore I'm currently wasting lots of time I should be using to prepare my exams to work on the next version of OnTopReplica: 2.5.

Somehow, it's strange that a seemingly "interesting" things like the generation of fake clicks on an arbitrary window (using the Win32 APIs) appearently isn't talked about at all on the internet. So, instead of blatantly stealing some code from someone else, I had to find the way to do what I wanted by digging around in the Win32 documentation. I'm not completely sure the following code is correct, but it works (mostly).

More...

Posted on Thursday, January 22, 2009
1071 Views
1 comments posted
Back to Klopfenstein.net
Clemens Klopfenstein Serena Kiefer Lukas Tiberio Klopfenstein Lorenz Cuno Klopfenstein
English German