TreeView Send Message Error
-
Ok,I have a generic Treeview component that I have inherited and it has the following error. When I try to click on the X on the control bar I get the following error: External component has thrown an exception. Here is the stack trace.. at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(ApplicationContext context).... I have traced this error to the SendMessage fuction i.e the following line [DllImport("user32.dll")] private static extern int SendMessage (IntPtr hWnd, int wMsg, IntPtr wParam,int lParam); If I comment this out in the code and all calls to this function it works fine. Any ideas on the correct fix for this. As always all help is appreciated. Sameer:^)
-
Ok,I have a generic Treeview component that I have inherited and it has the following error. When I try to click on the X on the control bar I get the following error: External component has thrown an exception. Here is the stack trace.. at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(ApplicationContext context).... I have traced this error to the SendMessage fuction i.e the following line [DllImport("user32.dll")] private static extern int SendMessage (IntPtr hWnd, int wMsg, IntPtr wParam,int lParam); If I comment this out in the code and all calls to this function it works fine. Any ideas on the correct fix for this. As always all help is appreciated. Sameer:^)
Try using this version of the function:
[DllImport("user32.dll")] static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);