Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Message Handler in VB.NET

Message Handler in VB.NET

Scheduled Pinned Locked Moved Visual Basic
csharpc++
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JGraves
    wrote on last edited by
    #1

    Hi, I'm trying to add a GUI effect for a form in VB.NET that will cause the window to fade to 50% transparency when the title bar is clicked on. It's easy to get the form to fade, but I'm having trouble finding a way to capture the event of clicking on the title bar. Since this is a nonclient area of the window, VB does not raise one of the built-in events for forms. If anyone knows a way for me to capture the messages for when the title bar is clicked, I would be most happy... the only way i think i can do this is by writing a control in C++ that will capture the window messages and let VB know when the title bar has been clicked... thanks in advance.. Jon

    Richard DeemingR 1 Reply Last reply
    0
    • J JGraves

      Hi, I'm trying to add a GUI effect for a form in VB.NET that will cause the window to fade to 50% transparency when the title bar is clicked on. It's easy to get the form to fade, but I'm having trouble finding a way to capture the event of clicking on the title bar. Since this is a nonclient area of the window, VB does not raise one of the built-in events for forms. If anyone knows a way for me to capture the messages for when the title bar is clicked, I would be most happy... the only way i think i can do this is by writing a control in C++ that will capture the window messages and let VB know when the title bar has been clicked... thanks in advance.. Jon

      Richard DeemingR Online
      Richard DeemingR Online
      Richard Deeming
      wrote on last edited by
      #2

      Try this in the form code:

      Private Const WM_NCLBUTTONDOWN As Integer = &HA1
      Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
      If m.Msg = WM_NCLBUTTONDOWN Then
      Me.Opacity = 0.5
      End If
      MyBase.WndProc(m)
      End Sub

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      J 1 Reply Last reply
      0
      • Richard DeemingR Richard Deeming

        Try this in the form code:

        Private Const WM_NCLBUTTONDOWN As Integer = &HA1
        Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        If m.Msg = WM_NCLBUTTONDOWN Then
        Me.Opacity = 0.5
        End If
        MyBase.WndProc(m)
        End Sub

        J Offline
        J Offline
        JGraves
        wrote on last edited by
        #3

        Thanks a bunch, that worked just great.. one more question, is there a way to capture the left mouse button being released? I tried &HA2 as a code, but that is a double click (i think). Even Spy++ doesn't capture WM_NCLBUTTONUP. Thanks for the help!

        Richard DeemingR 1 Reply Last reply
        0
        • J JGraves

          Thanks a bunch, that worked just great.. one more question, is there a way to capture the left mouse button being released? I tried &HA2 as a code, but that is a double click (i think). Even Spy++ doesn't capture WM_NCLBUTTONUP. Thanks for the help!

          Richard DeemingR Online
          Richard DeemingR Online
          Richard Deeming
          wrote on last edited by
          #4

          &HA2 is the correct code, but the window never seems to get it! Spy++ seems to see it as a WM_LBUTTONUP with a negative y value, but that message never gets to the WndProc on the form. :confused:

          "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

          J 1 Reply Last reply
          0
          • Richard DeemingR Richard Deeming

            &HA2 is the correct code, but the window never seems to get it! Spy++ seems to see it as a WM_LBUTTONUP with a negative y value, but that message never gets to the WndProc on the form. :confused:

            J Offline
            J Offline
            JGraves
            wrote on last edited by
            #5

            Unfortunately, that's correct. I did some investigation this weekend and discovered that same problem. I think the only way to do this is to write a mouse hook to intercept the messages before Windows sends them to the form. I have a project that somebody did like this in C++ and i'm trying now to convert it to a DLL to use in my VB project.. i can post it here if I am successful, if you like. Jon

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups