0

I'm creating WPF application which has grip region and semi-transparent mouse pass-through region like below.

+----+---------------------------+
|Grip|                           |
+----+                           |
|  Semi-transparent region with  |
|      mouse pass-through        |
+--------------------------------+

XAML:

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525"
        WindowStyle="None" Background="Transparent" AllowsTransparency="True" Topmost="True" >
    <Grid>
        <!-- I want to make this contents pass-through -->
        <Rectangle>
            <Rectangle.Fill>
                <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
                    <GradientStop Color="#7F000000" Offset="0"/>
                    <GradientStop Color="#00000000" Offset="1"/>
                </LinearGradientBrush>
            </Rectangle.Fill>
        </Rectangle>
        <Label Content="Semi-transparency mouse pass-through region" 
               HorizontalAlignment="Center" 
               VerticalAlignment="Center"/>

        <!-- except this -->
        <Rectangle Name="grip"
                   Width="50" Height="50"
                   Fill="#7F000000"
                   VerticalAlignment="Top" 
                   HorizontalAlignment="Left" />
    </Grid>
</Window>

According to this question, I tried setting the WS_EX_TRANSPARENT for my window, but this method unable me to handle window messages to move or resize the window.

So, my question is, is there any way to make the window described above using WPF?

Edit: I want to make my window like this except grip.

Community
  • 1
  • 1
  • 1
    What is a semi-transparent mouse pass-through region? – clcto Nov 15 '13 at 23:37
  • 1
    Why do you need to use API's for transparency - WPF can make the entire form semi-transparent/transparent if needed. I don't think we understand exactly what your up to though. – OneFineDay Nov 15 '13 at 23:42
  • @clcto "Semi-transparent" means not completely transparent (Alpha > 0), and "mouse pass-through" means all of mouse events are passing through my window and the events goes to bottom windows. – user1968102 Nov 15 '13 at 23:47
  • @DonA: API's for mouse events pass-through, not transparency. Pass-through can achieve with `WS_EX_TRANSPARENT` extended window style, but this can't handle mouse event for grip. – user1968102 Nov 16 '13 at 00:08
  • Why are you not trying to set IsHitTestVisible=false on your 'passthrough' controls? –  Nov 16 '13 at 00:36
  • @elgonzo: I tried setting IsHitTestVisible property of Window, Grid, Rectangle and Label to false but not works. – user1968102 Nov 16 '13 at 00:58
  • I dont know for sure, but if you expose wndproc events you should be able to do it that way. Thats how I'd do it in winforms. – caesay Nov 16 '13 at 01:02
  • @user1968102, just to understand your scenario: How do you decide where to place the semi-transparent window on the desktop? If mouse events should fall through, you would not be able to move or resize this semi-transparent window (at least not directly). –  Nov 16 '13 at 01:27
  • Just an idea: Make the Grip a window, the semi-transparent rectangular area another, second window. Let that semi-transparent window follow the position of your grip window, if required. –  Nov 16 '13 at 01:34
  • @elgonzo: Nice and simple idea! I'd like to try it later. Thank you for your suggestions. – user1968102 Nov 16 '13 at 01:45

0 Answers0