Forwarding Windows Messages

  • Thread starter Thread starter Chris Dunaway
  • Start date Start date
C

Chris Dunaway

I have a form in which I have set the border style to None so that there is
no caption, no close box, etc.

I use this code to be able to click the form and move in the absense of the
caption:

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Const WmNcHitTest As Integer = &H84
Const HtCaption As Integer = 2

If m.Msg = WmNcHitTest Then
m.Result = New IntPtr(HtCaption)
Else
MyBase.WndProc(m) 'THIS IS IMPORTANT!
End If
End Sub


And this works well. My problem comes when I placed a panel on the form
and set it's Dock property to Fill. Now when I click on the form, I am
actually clicking on the panel and so the NCHitTest message is not getting
sent to the form. In fact, I am using a custom panel inherited from the
regular panel in which I am doing all the painting. If override the
WndProc method of the panel, then clicking on the panel MOVES THE PANEL
around the form but does not move the form.

I need to somehow have the form interrupt the message first and process it
if it is an NCHitTest message.

Can anyone provide me with any guidance?

Thanks,

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
 
Can't you fire an event from the panel up to the form and handle it there?
 
Can't you fire an event from the panel up to the form and handle it there?

What event would I fire? This is a Windows Message that occurs when the
mouse is clicked on the non client area. It then "tricks" Windows into
thinking you clicked on the caption.
--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top