Click here to Skip to main content
16,005,437 members
Home / Discussions / C#
   

C#

 
GeneralMaking a button in C#/.NET the Default for the form Pin
31-Jul-02 13:03
suss31-Jul-02 13:03 
GeneralRe: Making a button in C#/.NET the Default for the form Pin
rift31-Jul-02 14:03
rift31-Jul-02 14:03 
GeneralCreating a Microsoft Word plugin ! Pin
Maerlin31-Jul-02 4:36
Maerlin31-Jul-02 4:36 
QuestionWhat does the GCHandle object? Pin
Anonymous30-Jul-02 23:13
Anonymous30-Jul-02 23:13 
AnswerRe: What does the GCHandle object? Pin
Eric Gunnerson (msft)31-Jul-02 6:54
Eric Gunnerson (msft)31-Jul-02 6:54 
GeneralRe: What does the GCHandle object? Pin
Anonymous31-Jul-02 9:50
Anonymous31-Jul-02 9:50 
GeneralRe: What does the GCHandle object? Pin
Eric Gunnerson (msft)31-Jul-02 10:35
Eric Gunnerson (msft)31-Jul-02 10:35 
GeneralMessages not reaching WndProc Pin
Kastro30-Jul-02 19:11
Kastro30-Jul-02 19:11 
I am writing a class that overrides Control and utilizes the non-client area. I need to be able to have hotspots within the non-client area. However, because of what seems to me to be unusual behavior, I am not able to get it working.

I override WndProc to intercept WM_NCMOUSEMOVE and WM_NCPAINT (as well as WM_NCCALCSIZE, WM_NCHITTEST, and WM_LBUTTONDOWN/UP) as follows:

(Please don't flame me for posting VB.NET code. I use both interchangably as they are pretty much the same thing anyways. It just so happens that I wrote this in VB.NET. I posted here because I would guess that C# programmers know more about the Win32 API than VB.NET programmers, and my questions have nothing to do with VB.NET)

Protected Overrides Sub WndProc(ByRef msg As Message)
    Select Case msg.Msg
        Case 131 'WM_NCCALCSIZE
            ...
        Case 132 'WM_NCHITTEST
            ...
        Case 133 'WM_NCPAINT
            Dim dc As Integer
            dc = GetDCEx(msg.HWnd.ToInt32(), msg.WParam.ToInt32(), 65536 + 128 + 1)
            Dim hdc As IntPtr = New IntPtr(dc)
            Dim g As Graphics = Graphics.FromHdc(hdc)
            OnPaintNonClient(New PaintEventArgs(g, Rectangle.Round(g.ClipBounds)))
            ReleaseDC(msg.HWnd.ToInt32(), hdc.ToInt32())
        Case 160 'WM_NCMOUSEMOVE
            Dim pt As PointL
            pt.x = msg.LParam.ToInt32() Mod 65536
            pt.y = msg.LParam.ToInt32() / 65536
            Dim ppt As IntPtr = Marshal.AllocHGlobal(8)
            Marshal.StructureToPtr(pt, ppt, False)
            ScreenToClient(msg.HWnd.ToInt32(), ppt.ToInt32())
            pt = Marshal.PtrToStructure(ppt, GetType(PointL))
            Dim args As MouseEventArgs = New MouseEventArgs(MouseButtons.None, 0, pt.x, pt.y, 0)
            OnNonClientMouseMove(args)
            Marshal.FreeHGlobal(ppt)
        Case 161 'WM_NCLBUTTONDOWN
            ...
        Case 162 'WM_NCLBUTTONUP
            ...
        Case Else
            MyBase.WndProc(msg)
    End Select
End Sub

Protected Overridable Sub OnNonClientMouseMove(ByVal args As MouseEventArgs)
    If ... Then 'Test hotspots
        ...
        PostMessage(Me.Handle, 133, 0, 0) 'WM_NCPAINT
    End If
End Sub

Protected Overridable Sub OnPaintNonClient(ByVal args As PaintEventArgs)
    ...
End Sub


There are no problems painting the non-client area for resizes, max/min, etc. Intercepting WM_NCMOUSEMOVE and testing for mouse-overs on my hotspots works fine. However, the weird thing is that when my code does the PostMessage call, the WM_NCPAINT message never reaches WndProc.

Does anyone know what is going on?
Does Windows.Forms not send every message on to WndProc?
Do I have to do something with PreProcessMessage?

Can what I am trying to do actually be done in Windows.Forms?

Thanks.
GeneralRe: Messages not reaching WndProc Pin
Kastro30-Jul-02 19:51
Kastro30-Jul-02 19:51 
QuestionHow do I hide a property from the property window? Pin
Ray Cassick30-Jul-02 18:42
Ray Cassick30-Jul-02 18:42 
AnswerRe: How do I hide a property from the property window? Pin
Andy Smith30-Jul-02 19:42
Andy Smith30-Jul-02 19:42 
GeneralRe: How do I hide a property from the property window? Pin
Ray Cassick31-Jul-02 2:41
Ray Cassick31-Jul-02 2:41 
GeneralRe: How do I hide a property from the property window? Pin
Ray Cassick31-Jul-02 18:49
Ray Cassick31-Jul-02 18:49 
GeneralRe: How do I hide a property from the property window? Pin
Nathan Blomquist1-Aug-02 1:27
Nathan Blomquist1-Aug-02 1:27 
QuestionBug in VS.NET? Pin
Johnny Zee30-Jul-02 10:01
sussJohnny Zee30-Jul-02 10:01 
AnswerRe: Bug in VS.NET? Pin
Johnny Zee1-Aug-02 2:49
sussJohnny Zee1-Aug-02 2:49 
GeneralThe Web Service FREEZE the App Pin
laphijia30-Jul-02 9:05
laphijia30-Jul-02 9:05 
GeneralRe: The Web Service FREEZE the App Pin
James T. Johnson30-Jul-02 16:56
James T. Johnson30-Jul-02 16:56 
GeneralLate binding to objects... Pin
Ryan Cromwell30-Jul-02 7:47
Ryan Cromwell30-Jul-02 7:47 
GeneralRe: Late binding to objects... Pin
Andy Smith30-Jul-02 8:34
Andy Smith30-Jul-02 8:34 
GeneralRe: Late binding to objects... Pin
Ryan Cromwell30-Jul-02 8:44
Ryan Cromwell30-Jul-02 8:44 
GeneralRe: Late binding to objects... Pin
Eric Gunnerson (msft)30-Jul-02 8:54
Eric Gunnerson (msft)30-Jul-02 8:54 
GeneralRe: Late binding to objects... Pin
Ryan Cromwell30-Jul-02 9:04
Ryan Cromwell30-Jul-02 9:04 
GeneralRe: Late binding to objects... Pin
Ryan Cromwell30-Jul-02 9:33
Ryan Cromwell30-Jul-02 9:33 
GeneralRe: Late binding to objects... Pin
Eric Gunnerson (msft)30-Jul-02 9:49
Eric Gunnerson (msft)30-Jul-02 9:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.