code_junkie

MDI Child .Show() Method Raises NullReferenceException in Framework

Nov 13th, 2011
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.16 KB | None | 0 0
  1. system.windows.forms.dll!System.Windows.Forms.NativeWindow::WindowClassCallback(__int32 hWnd = 461572, __int32 msg = 36, __int32 wparam = 0, __int32 lparam = 1239164) + 0x48 bytes
  2. system.windows.forms.dll!System.Windows.Forms.UnsafeNativeMethods::CreateWindowEx(__int32 dwExStyle = 327744, String* lpszClassName = "WindowsForms10.Window.8.app13", String* lpszWindowName = "Diary Entry: ROSIE MILES", __int32 style = 1204748288, __int32 x = -2147483648, __int32 y = -2147483648, __int32 width = 480, __int32 height = 380, __int32 hWndParent = 920114, __int32 hMenu = 0, __int32 hInst = 285212672, System.Object pvParam = null) + 0x3c bytes
  3. system.windows.forms.dll!System.Windows.Forms.NativeWindow::CreateHandle(System.Windows.Forms.CreateParams cp = {System.Windows.Forms.CreateParams}) + 0x1d6 bytes
  4. system.windows.forms.dll!System.Windows.Forms.Control::CreateHandle() + 0x19a bytes
  5. system.windows.forms.dll!System.Windows.Forms.Form::CreateHandle() + 0x12f bytes
  6. system.windows.forms.dll!System.Windows.Forms.Control::get_Handle() + 0x2f bytes
  7. system.windows.forms.dll!System.Windows.Forms.Form::SetVisibleCore(bool value = true) + 0x1e9 bytes
  8. system.windows.forms.dll!System.Windows.Forms.Control::set_Visible(bool value = true) + 0x1e bytes
  9. system.windows.forms.dll!System.Windows.Forms.Control::Show() + 0x14 bytes
  10. > SpecMed.exe!SpecMed.ScheduleForm.viewScheduleMenuItem_Click(Object sender = {System.Windows.Forms.MenuItem}, System.EventArgs e = {System.EventArgs}) Line 1508 + 0xb bytes Basic
  11. system.windows.forms.dll!System.Windows.Forms.MenuItem::OnClick(System.EventArgs e = {System.EventArgs}) + 0x8d bytes
  12. system.windows.forms.dll!MenuItemData::Execute() + 0x1e bytes
  13. system.windows.forms.dll!System.Windows.Forms.Command::Invoke() + 0x4c bytes
  14. system.windows.forms.dll!System.Windows.Forms.Command::DispatchID(__int32 id = 299) + 0x2c bytes
  15. system.windows.forms.dll!System.Windows.Forms.Control::WmCommand(System.Windows.Forms.Message m = {System.Windows.Forms.Message}) + 0x4a bytes
  16. system.windows.forms.dll!System.Windows.Forms.Control::WndProc(System.Windows.Forms.Message m = {System.Windows.Forms.Message}) + 0x1f3 bytes
  17. system.windows.forms.dll!ControlNativeWindow::OnMessage(System.Windows.Forms.Message m = {System.Windows.Forms.Message}) + 0x19 bytes
  18. system.windows.forms.dll!ControlNativeWindow::WndProc(System.Windows.Forms.Message m = {System.Windows.Forms.Message}) + 0xda bytes
  19. system.windows.forms.dll!System.Windows.Forms.NativeWindow::Callback(__int32 hWnd = 6621754, __int32 msg = 273, __int32 wparam = 299, __int32 lparam = 0) + 0x4a bytes
  20. system.windows.forms.dll!System.Windows.Forms.Application::ComponentManagerSystem.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(__int32 dwComponentID = 1, __int32 reason = -1, __int32 pvLoopData = 0) + 0x2c1 bytes
  21. system.windows.forms.dll!ThreadContext::RunMessageLoop(__int32 reason = -1, System.Windows.Forms.ApplicationContext context = {System.Windows.Forms.ApplicationContext}) + 0x1c5 bytes
  22. system.windows.forms.dll!System.Windows.Forms.Application::Run(System.Windows.Forms.Form mainForm = {SpecMed.MainForm}) + 0x34 bytes
  23. SpecMed.exe!SpecMed.Program.Main() Line 15 + 0x1d bytes Basic
  24.  
  25. public IntPtr Callback(IntPtr hWnd, int msg, IntPtr wparam, IntPtr lparam)
  26. {
  27. try
  28. {
  29. UnsafeNativeMethods.SetWindowLong(hWnd, -4, this.defWindowProc);
  30. this.targetWindow.AssignHandle(hWnd);
  31. return this.targetWindow.Callback(hWnd, msg, wparam, lparam);
  32. }
  33. catch (Exception)
  34. {
  35. }
  36. return IntPtr.Zero;
  37. }
  38.  
  39. '-- workaround to prevent UI problem with maximised child form calling another maxmised child form --'
  40. Dim isMaximised As Boolean = (WindowState = FormWindowState.Maximized)
  41.  
  42. '-- minimise the current form so the problem wont occur when we call the new child Form --'
  43. If isMaximised Then WindowState = FormWindowState.Minimized
  44.  
  45. Dim form As DiaryEntryForm = DiaryEntryForm.GetForm(scheduleId, Me)
  46. '-- if the calling child was originally maximised, then maximsed the called form to similute what should normally happen --'
  47. If isMaximised Then form.WindowState = FormWindowState.Maximized
  48. form.Show()
Add Comment
Please, Sign In to add comment