I implemented an old fashioned way of registering a window using 'RegisterClass' and 'CreateWindow' APIs. 'WindowProc' looks like this
protected virtual IntPtr InternalWindowProc( IntPtr hWnd, uint uintMsg, UIntPtr wParam, IntPtr lParam
IntPtr iptrReturn = IntPtr.Zero
switch( uintParam
case WM_LBUTTONUP
this.OnMouseButtonUp( )
break
//Other cases ..
default
//Debug.WriteLine( "Calling 'DefWindowProc'" ); //Uncomment this to prevent "System.NullReferenceException". (see Choice 2 below
iptrReturn = DefWindowProc( hWnd, uintMsg, wParam, lParam )
break
return iptrReturn
protected virtual void OnMouseButtonUp(
Debug.WriteLine( "OnMouseButtonUp" ); //Comment this out to prevent "System.NullReferenceException" (see Choice 1 below
I'm getting this exception upon exiting "InternalWindowProc"
An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dl
Additional information: Object reference not set to an instance of an object
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object
at System.Windows.Forms.UnsafeNativeMethods.PeekMessage(MSG& msg, HandleRef hwnd, Int32 msgMin, Int32 msgMax, Int32 remove
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(Form mainForm
at Startup.Main() in c:\my projects\start.cs:line 1
However, either one of the following two choices will stop "System.NullReferenceException"
Choice 1. Comment out "Debug.WriteLine( "OnMouseButtonUp" )"
O
Choice 2. Uncomment "Debug.WriteLine( "Calling 'DefWindowProc'" )"
I'm puzzled as to why this is happening
Please help me out who can explain this matter. Even little hint may be valuable to me
Thank you
Eugen
"Ying-Shen Yu[MSFT]" - 12 Apr 2004 04:17 GMT
Hi,
After reading your post, I think to assist you on this issue further, I
need do some debugging on this issue, could you send me a simple sample to
reproduce this problem?
By the way, why you need create a window complete on your own?
Thanks!
Best regards,
Ying-Shen Yu [MSFT]
Microsoft community Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
Eugene Lerner - 12 Apr 2004 14:21 GMT
Hi Ying-Shen
Thank you very much for your help
The code is rather long for this post - would you like me to e-mail it to you
To answer your question as to my needs I can tell you that my goal is to display an icon in the task bar with the ability to show balloon notifications. "System.Windows.Forms.NotifyIcon" class is really handy as far as task bar icon with a menu but it lacks balloon functionality. I found some samples from other people that suggested creating window manually. Since I’m formerly "C" programmer in Windows 3.1/95 environment the approach looked quite familiar to me. Unfortunately I ran into problem I described in my previous post. Future more, the whole application is a subject to random crashes, not only when "Debug.WriteLine" is called
I've already come to resolution by using "System.Windows.Forms.NativeWindow" class. The application is now stable and there is no emergency for me as of now. Still, I do appreciate your offer for help. If you still desire to have my code please let me know and I'll forward it to you
Thanks again
Eugen
"Ying-Shen Yu[MSFT]" - 13 Apr 2004 04:09 GMT
Hi Eugene,
The NativeWindow class is a good choice for making a balloon tip.
I was thinking to recommend it in my previous reply. However thinking you
need to register window class, which is not possible in NativeWindow, so
I'd like to know more information on this issue to confirm it fit your
needs.
Since you used a better way to implement the balloon window successfully, I
think needn't look into the original problem.
If you meet some problem next time, please feel free to post it in the
newsgroup to share it with the community!
Best regards,
Ying-Shen Yu [MSFT]
Microsoft Community Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.