Make a window "Click-through"

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Martijn Coppoolse

    Make a window "Click-through"

    Hello everyone,

    I've got two little apps which are able to create a window that displays
    something on the desktop, but are not clickable. Instead, when you
    click on the window, the item 'behind' or 'under' that window gets clicked.

    I'd like to know how to do this, using VB6, VB.Net, Windows Forms, or
    API functions.

    Any ideas?

    PS. The apps in question are (both freeware):
    Desktop Logo - http://mt.smolyan.info/desktoplogo.php
    ClocX - http://www.tenzor.cz/clocx/

    Thanks in advance,
    --
    Martijn <@> Coppoolse <.com>
  • DalePres

    #2
    Re: Make a window &quot;Click-through&quot;

    Another opportunity to advertise one of my favorite API functions:
    SendMessage. Use the SendMessage Win32 API method to send a WM_LBUTTONDOWN
    message, adding the appropriate parameters as described in
    http://www.mangovision.com/vbapi/ref...uttondown.html to pass the click
    location to the target application.

    There may be other ways, but based on my knowledge and experience, this is
    how I would begin to tackle the problem.

    Dale

    "Martijn Coppoolse" <msnewsgroups@m artijn.coppools e.com> wrote in message
    news:40A53F1B.8 030600@martijn. coppoolse.com.. .[color=blue]
    > Hello everyone,
    >
    > I've got two little apps which are able to create a window that displays
    > something on the desktop, but are not clickable. Instead, when you
    > click on the window, the item 'behind' or 'under' that window gets[/color]
    clicked.[color=blue]
    >
    > I'd like to know how to do this, using VB6, VB.Net, Windows Forms, or
    > API functions.
    >
    > Any ideas?
    >
    > PS. The apps in question are (both freeware):
    > Desktop Logo - http://mt.smolyan.info/desktoplogo.php
    > ClocX - http://www.tenzor.cz/clocx/
    >
    > Thanks in advance,
    > --
    > Martijn <@> Coppoolse <.com>[/color]


    Comment

    • Justin Rogers

      #3
      Re: Make a window &quot;Click-through&quot;

      The problem is a bit more complicated. It requires that you enumerate windows
      on the machine to find
      the window that is immediately below you. GetWindow and GetNextWindow are prime
      candidates.
      Another possibility is to create you window with WS_EX_NOACTIVE (or is it
      NO_ACTIVATE, can't
      remember), and then set it top-most. It'll be top visible, but it won't be the
      *foreground* window and so
      it won't receive the input. I haven't tried this later one, but I did some
      research yesterday after the original
      post to try and find a concrete answer.

      The biggest problem is that getting the window underneath you is not easy.
      Z-Ordering in windows is not
      easy to control or get information about. The closest I could come is that
      GetNextWindow might allow
      you to cycle windows in z-ordered order, so you could find the window at your
      point, that was immediately
      behind your window.


      --
      Justin Rogers
      DigiTec Web Consultants, LLC.
      Blog: http://weblogs.asp.net/justin_rogers

      "DalePres" <nospam@nomail. com> wrote in message
      news:udPz6IoOEH A.2336@TK2MSFTN GP09.phx.gbl...[color=blue]
      > Another opportunity to advertise one of my favorite API functions:
      > SendMessage. Use the SendMessage Win32 API method to send a WM_LBUTTONDOWN
      > message, adding the appropriate parameters as described in
      > http://www.mangovision.com/vbapi/ref...uttondown.html to pass the click
      > location to the target application.
      >
      > There may be other ways, but based on my knowledge and experience, this is
      > how I would begin to tackle the problem.
      >
      > Dale
      >
      > "Martijn Coppoolse" <msnewsgroups@m artijn.coppools e.com> wrote in message
      > news:40A53F1B.8 030600@martijn. coppoolse.com.. .[color=green]
      > > Hello everyone,
      > >
      > > I've got two little apps which are able to create a window that displays
      > > something on the desktop, but are not clickable. Instead, when you
      > > click on the window, the item 'behind' or 'under' that window gets[/color]
      > clicked.[color=green]
      > >
      > > I'd like to know how to do this, using VB6, VB.Net, Windows Forms, or
      > > API functions.
      > >
      > > Any ideas?
      > >
      > > PS. The apps in question are (both freeware):
      > > Desktop Logo - http://mt.smolyan.info/desktoplogo.php
      > > ClocX - http://www.tenzor.cz/clocx/
      > >
      > > Thanks in advance,
      > > --
      > > Martijn <@> Coppoolse <.com>[/color]
      >
      >[/color]


      Comment

      • Bob Powell [MVP]

        #4
        Re: Make a window &quot;Click-through&quot;

        I too went through some experimental code and created a form that handled
        the WM_NCHITTEST message. This works a treat for controls but not forms and
        top-level windows.

        I created a clock that showed up semi-transparent on the desktop but I
        couldn't click through it. I can set a transparency key and click through
        that but the numerals on the clock are never transparent to clicks.

        I'd post the code but it doesn't do what's needed so I won't bother. :-(

        --
        Bob Powell [MVP]
        Visual C#, System.Drawing

        Image transition effects, automatic persistent configuration and
        design time mouse operations all in April's issue of Well Formed


        Answer those GDI+ questions with the GDI+ FAQ


        The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
        Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
        Bob's Blog: http://royo.is-a-geek.com/siteFeeder...aspx?FeedId=41





        "Justin Rogers" <Justin@games4d otnet.com> wrote in message
        news:Ov8w8GrOEH A.3012@tk2msftn gp13.phx.gbl...[color=blue]
        > The problem is a bit more complicated. It requires that you enumerate[/color]
        windows[color=blue]
        > on the machine to find
        > the window that is immediately below you. GetWindow and GetNextWindow are[/color]
        prime[color=blue]
        > candidates.
        > Another possibility is to create you window with WS_EX_NOACTIVE (or is it
        > NO_ACTIVATE, can't
        > remember), and then set it top-most. It'll be top visible, but it won't[/color]
        be the[color=blue]
        > *foreground* window and so
        > it won't receive the input. I haven't tried this later one, but I did[/color]
        some[color=blue]
        > research yesterday after the original
        > post to try and find a concrete answer.
        >
        > The biggest problem is that getting the window underneath you is not easy.
        > Z-Ordering in windows is not
        > easy to control or get information about. The closest I could come is[/color]
        that[color=blue]
        > GetNextWindow might allow
        > you to cycle windows in z-ordered order, so you could find the window at[/color]
        your[color=blue]
        > point, that was immediately
        > behind your window.
        >
        >
        > --
        > Justin Rogers
        > DigiTec Web Consultants, LLC.
        > Blog: http://weblogs.asp.net/justin_rogers
        >
        > "DalePres" <nospam@nomail. com> wrote in message
        > news:udPz6IoOEH A.2336@TK2MSFTN GP09.phx.gbl...[color=green]
        > > Another opportunity to advertise one of my favorite API functions:
        > > SendMessage. Use the SendMessage Win32 API method to send a[/color][/color]
        WM_LBUTTONDOWN[color=blue][color=green]
        > > message, adding the appropriate parameters as described in
        > > http://www.mangovision.com/vbapi/ref...uttondown.html to pass the[/color][/color]
        click[color=blue][color=green]
        > > location to the target application.
        > >
        > > There may be other ways, but based on my knowledge and experience, this[/color][/color]
        is[color=blue][color=green]
        > > how I would begin to tackle the problem.
        > >
        > > Dale
        > >
        > > "Martijn Coppoolse" <msnewsgroups@m artijn.coppools e.com> wrote in[/color][/color]
        message[color=blue][color=green]
        > > news:40A53F1B.8 030600@martijn. coppoolse.com.. .[color=darkred]
        > > > Hello everyone,
        > > >
        > > > I've got two little apps which are able to create a window that[/color][/color][/color]
        displays[color=blue][color=green][color=darkred]
        > > > something on the desktop, but are not clickable. Instead, when you
        > > > click on the window, the item 'behind' or 'under' that window gets[/color]
        > > clicked.[color=darkred]
        > > >
        > > > I'd like to know how to do this, using VB6, VB.Net, Windows Forms, or
        > > > API functions.
        > > >
        > > > Any ideas?
        > > >
        > > > PS. The apps in question are (both freeware):
        > > > Desktop Logo - http://mt.smolyan.info/desktoplogo.php
        > > > ClocX - http://www.tenzor.cz/clocx/
        > > >
        > > > Thanks in advance,
        > > > --
        > > > Martijn <@> Coppoolse <.com>[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • yEaH rIgHt

          #5
          Re: Make a window &quot;Click-through&quot;

          The reason you can click through with ClocX is because it's drawn directly
          to the main screen (if you set it to click through). Otherwise, it sits on
          its own form and you can't click through. A simple trick.


          "Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message
          news:e$hDmvrOEH A.624@TK2MSFTNG P11.phx.gbl...[color=blue]
          > I too went through some experimental code and created a form that handled
          > the WM_NCHITTEST message. This works a treat for controls but not forms[/color]
          and[color=blue]
          > top-level windows.
          >
          > I created a clock that showed up semi-transparent on the desktop but I
          > couldn't click through it. I can set a transparency key and click through
          > that but the numerals on the clock are never transparent to clicks.
          >
          > I'd post the code but it doesn't do what's needed so I won't bother. :-(
          >
          > --
          > Bob Powell [MVP]
          > Visual C#, System.Drawing
          >
          > Image transition effects, automatic persistent configuration and
          > design time mouse operations all in April's issue of Well Formed
          > http://www.bobpowell.net/wellformed.htm
          >
          > Answer those GDI+ questions with the GDI+ FAQ
          > http://www.bobpowell.net/gdiplus_faq.htm
          >
          > The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
          > Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
          > Bob's Blog: http://royo.is-a-geek.com/siteFeeder...aspx?FeedId=41
          >
          >
          >
          >
          >
          > "Justin Rogers" <Justin@games4d otnet.com> wrote in message
          > news:Ov8w8GrOEH A.3012@tk2msftn gp13.phx.gbl...[color=green]
          > > The problem is a bit more complicated. It requires that you enumerate[/color]
          > windows[color=green]
          > > on the machine to find
          > > the window that is immediately below you. GetWindow and GetNextWindow[/color][/color]
          are[color=blue]
          > prime[color=green]
          > > candidates.
          > > Another possibility is to create you window with WS_EX_NOACTIVE (or is[/color][/color]
          it[color=blue][color=green]
          > > NO_ACTIVATE, can't
          > > remember), and then set it top-most. It'll be top visible, but it won't[/color]
          > be the[color=green]
          > > *foreground* window and so
          > > it won't receive the input. I haven't tried this later one, but I did[/color]
          > some[color=green]
          > > research yesterday after the original
          > > post to try and find a concrete answer.
          > >
          > > The biggest problem is that getting the window underneath you is not[/color][/color]
          easy.[color=blue][color=green]
          > > Z-Ordering in windows is not
          > > easy to control or get information about. The closest I could come is[/color]
          > that[color=green]
          > > GetNextWindow might allow
          > > you to cycle windows in z-ordered order, so you could find the window at[/color]
          > your[color=green]
          > > point, that was immediately
          > > behind your window.
          > >
          > >
          > > --
          > > Justin Rogers
          > > DigiTec Web Consultants, LLC.
          > > Blog: http://weblogs.asp.net/justin_rogers
          > >
          > > "DalePres" <nospam@nomail. com> wrote in message
          > > news:udPz6IoOEH A.2336@TK2MSFTN GP09.phx.gbl...[color=darkred]
          > > > Another opportunity to advertise one of my favorite API functions:
          > > > SendMessage. Use the SendMessage Win32 API method to send a[/color][/color]
          > WM_LBUTTONDOWN[color=green][color=darkred]
          > > > message, adding the appropriate parameters as described in
          > > > http://www.mangovision.com/vbapi/ref...uttondown.html to pass the[/color][/color]
          > click[color=green][color=darkred]
          > > > location to the target application.
          > > >
          > > > There may be other ways, but based on my knowledge and experience,[/color][/color][/color]
          this[color=blue]
          > is[color=green][color=darkred]
          > > > how I would begin to tackle the problem.
          > > >
          > > > Dale
          > > >
          > > > "Martijn Coppoolse" <msnewsgroups@m artijn.coppools e.com> wrote in[/color][/color]
          > message[color=green][color=darkred]
          > > > news:40A53F1B.8 030600@martijn. coppoolse.com.. .
          > > > > Hello everyone,
          > > > >
          > > > > I've got two little apps which are able to create a window that[/color][/color]
          > displays[color=green][color=darkred]
          > > > > something on the desktop, but are not clickable. Instead, when you
          > > > > click on the window, the item 'behind' or 'under' that window gets
          > > > clicked.
          > > > >
          > > > > I'd like to know how to do this, using VB6, VB.Net, Windows Forms,[/color][/color][/color]
          or[color=blue][color=green][color=darkred]
          > > > > API functions.
          > > > >
          > > > > Any ideas?
          > > > >
          > > > > PS. The apps in question are (both freeware):
          > > > > Desktop Logo - http://mt.smolyan.info/desktoplogo.php
          > > > > ClocX - http://www.tenzor.cz/clocx/
          > > > >
          > > > > Thanks in advance,
          > > > > --
          > > > > Martijn <@> Coppoolse <.com>
          > > >
          > > >[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • M?ht?n

            #6
            Re: Make a window &quot;Click-through&quot;

            "yEaH rIgHt" wrote:[color=blue]
            > The reason you can click through with ClocX is because it's drawn directly
            > to the main screen (if you set it to click through). Otherwise, it sits on
            > its own form and you can't click through. A simple trick.[/color]

            How could that be done, then?

            Drawing directly onto the desktop's hDC wouldn't show on screen, if
            there's a window on top of it, would it?

            In the meantime, I'll look into figuring out what other window's
            supposed to get the clicks. Thanks for the pointers!
            --
            Martijn <@> Coppoolse <.com>

            Comment

            • yEaH rIgHt

              #7
              Re: Make a window &quot;Click-through&quot;

              Try this out. This will get you started.

              Private Sub Timer1_Tick(ByV al sender As System.Object, ByVal e As System.EventArg s) Handles Timer1.Tic
              Dim dc As IntPtr = Me.GetDC(IntPtr .Zero
              Dim grfx As Graphics = Graphics.FromHd c(dc
              Dim ft As New Font(Me.Font.Na me, 25, GraphicsUnit.Po int
              grfx.DrawString ("Writing on the desktop! Isn't this cool?", ft, Brushes.Black,1 25, 150
              ft.Dispose(
              grfx.Dispose(
              End Su

              Comment

              Working...