WM_NOTIFY Reports incorrect values
-
Im new to vb.net and Im trying to move mi apliccations to the new language...and i have the following problem. Im trying to intercept the ListView messages because i want a LV footer to autoresize when a column resize. I create a Class inherit a LV and override the WndProc sub. But when i try to intercept the WM_NOTIFY message, the asociated code seems incorrect. Here is my code (the class): ----------------------------------------------------------------------------- Public Class MyListView Inherits System.Windows.Forms.ListView Structure NMHDR Dim hwndFrom As Long ' Window handle of control sending message Dim idFrom As Long ' Identifier of control sending message Dim code As Long ' Specifies the notification code End Structure Structure NMHEADER Dim hdr As NMHDR Dim iItem As Long Dim iButton As Long Dim lPtrHDItem As Long ' HDITEM FAR* pItem End Structure Public Const WM_NOTIFY = &H4E Public Const WM_PAINT = &HF Public Const WM_USER = &H400 Public Const WM_REFLECT = WM_USER + &H1C00 Const HDN_FIRST As Long = -300& Const HDN_LAST As Long = -399& Const HDN_GETDISPINFO As Long = (HDN_FIRST - 9) Const HDN_BEGINDRAG As Long = (HDN_FIRST - 10) Const HDN_ENDDRAG As Long = (HDN_FIRST - 11) Const HDN_ITEMCLICK As Long = (HDN_FIRST - 2) Const HDN_ITEMDBLCLICK As Long = (HDN_FIRST - 3) Const HDN_DIVIDERDBLCLICK As Long = (HDN_FIRST - 5) Const HDN_ITEMCHANGING As Long = (HDN_FIRST - 0) Const HDN_ITEMCHANGED As Long = (HDN_FIRST - 1) Const HDN_BEGINTRACK As Long = (HDN_FIRST - 6) Const HDN_ENDTRACK As Long = (HDN_FIRST - 7) Const HDN_TRACK As Long = (HDN_FIRST - 8) Const NM_FIRST As Long = -0& ' (0U- 0U) Const NM_CUSTOMDRAW As Long = (NM_FIRST - 12) Const NM_RCLICK As Long = (NM_FIRST - 5) Const NM_RELEASEDCAPTURE As Long = (NM_FIRST - 16) Const NM_CLICK As Long = NM_FIRST - 2 Const LVN_FIRST As Long = 100 Const LVN_COLUMNCLICK As Long = LVN_FIRST - 8 Protected Overrides Sub WndProc(ByRef m As Message) Dim nmh As NMHDR Select Case m.Msg Case WM_NOTIFY nmh = CType(m.GetLParam(nmh.GetType), NMHDR) If nmh.code = HDN_BEGINTRACK Then MsgBox("track") End If End Select MyBase.WndProc(m) End Sub End Class '
-
Im new to vb.net and Im trying to move mi apliccations to the new language...and i have the following problem. Im trying to intercept the ListView messages because i want a LV footer to autoresize when a column resize. I create a Class inherit a LV and override the WndProc sub. But when i try to intercept the WM_NOTIFY message, the asociated code seems incorrect. Here is my code (the class): ----------------------------------------------------------------------------- Public Class MyListView Inherits System.Windows.Forms.ListView Structure NMHDR Dim hwndFrom As Long ' Window handle of control sending message Dim idFrom As Long ' Identifier of control sending message Dim code As Long ' Specifies the notification code End Structure Structure NMHEADER Dim hdr As NMHDR Dim iItem As Long Dim iButton As Long Dim lPtrHDItem As Long ' HDITEM FAR* pItem End Structure Public Const WM_NOTIFY = &H4E Public Const WM_PAINT = &HF Public Const WM_USER = &H400 Public Const WM_REFLECT = WM_USER + &H1C00 Const HDN_FIRST As Long = -300& Const HDN_LAST As Long = -399& Const HDN_GETDISPINFO As Long = (HDN_FIRST - 9) Const HDN_BEGINDRAG As Long = (HDN_FIRST - 10) Const HDN_ENDDRAG As Long = (HDN_FIRST - 11) Const HDN_ITEMCLICK As Long = (HDN_FIRST - 2) Const HDN_ITEMDBLCLICK As Long = (HDN_FIRST - 3) Const HDN_DIVIDERDBLCLICK As Long = (HDN_FIRST - 5) Const HDN_ITEMCHANGING As Long = (HDN_FIRST - 0) Const HDN_ITEMCHANGED As Long = (HDN_FIRST - 1) Const HDN_BEGINTRACK As Long = (HDN_FIRST - 6) Const HDN_ENDTRACK As Long = (HDN_FIRST - 7) Const HDN_TRACK As Long = (HDN_FIRST - 8) Const NM_FIRST As Long = -0& ' (0U- 0U) Const NM_CUSTOMDRAW As Long = (NM_FIRST - 12) Const NM_RCLICK As Long = (NM_FIRST - 5) Const NM_RELEASEDCAPTURE As Long = (NM_FIRST - 16) Const NM_CLICK As Long = NM_FIRST - 2 Const LVN_FIRST As Long = 100 Const LVN_COLUMNCLICK As Long = LVN_FIRST - 8 Protected Overrides Sub WndProc(ByRef m As Message) Dim nmh As NMHDR Select Case m.Msg Case WM_NOTIFY nmh = CType(m.GetLParam(nmh.GetType), NMHDR) If nmh.code = HDN_BEGINTRACK Then MsgBox("track") End If End Select MyBase.WndProc(m) End Sub End Class '
First of all, in VB.NET long becomes integer, integer becomes short, ... This may not solve your problem, but will help you with this and future translations :-) I suggest you read the translation guidelines @ MSDN greetz ;-) *Niels Penneman*
Software/Dev Site
Personal Site
-
First of all, in VB.NET long becomes integer, integer becomes short, ... This may not solve your problem, but will help you with this and future translations :-) I suggest you read the translation guidelines @ MSDN greetz ;-) *Niels Penneman*
Software/Dev Site
Personal Site
Thanks a lot Niels!! Your sugestion was good, it help me a bit... Now the values looks more "real"....but aparently appears increased in 20 (i.e.: -326 instead -306) But now I'm closer to the solution! Any idea why this happenns?
-
Thanks a lot Niels!! Your sugestion was good, it help me a bit... Now the values looks more "real"....but aparently appears increased in 20 (i.e.: -326 instead -306) But now I'm closer to the solution! Any idea why this happenns?
Values are NOT incorrect... look what I found :-)
Hdn_begintrackw: INTEGER is -326
-- Notifies a header control's parent window that the user has
-- begun dragging a divider in the control (that is, the user
-- has pressed the left mouse button while the mouse cursor is
-- on a divider in the header control). This notification
-- message is sent in the form of a WM_NOTIFY message.
--
-- Declared in Windows as HDN_BEGINTRACKI found it here ;-) greetz ;-) *Niels Penneman*
Software/Dev Site
Personal Site
-
Thanks a lot Niels!! Your sugestion was good, it help me a bit... Now the values looks more "real"....but aparently appears increased in 20 (i.e.: -326 instead -306) But now I'm closer to the solution! Any idea why this happenns?
Correct translation to VB.NET is here:
Structure NMHDR Dim hwndFrom As IntPtr ' Window handle of control sending message Dim idFrom As Integer ' Identifier of control sending message Dim code As Integer ' Specifies the notification code End Structure Structure NMHEADER Dim hdr As NMHDR Dim iItem As Integer Dim iButton As Integer Dim lPtrHDItem As IntPtr ' HDITEM FAR\* pItem End Structure
greetz ;-) *Niels Penneman*
Software/Dev Site
Personal Site