I get this error randomly that doesn't seem to cause anything to not work
correctly. The exception is caught, and seems to not affect the application
at all:

The code I used to make is so the form cannot be moved:
private const int WM_NCLBUTTONDOWN = 0XA1;

private const int WM_SYSCOMMAND = 0X112;

private const int HTCAPTION = 0X2;

private const int SC_MOVE = 0XF010;

protected override void WndProc(ref Message m)
{

if (m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_MOVE || m.Msg ==
WM_NCLBUTTONDOWN && m.WParam.ToInt32() == HTCAPTION)

return;

}

base.WndProc(ref m);

}

The exception:

General Information
*********************************************
Additional Info:
ExceptionManager.MachineName: XXXXXXXXXX
ExceptionManager.TimeStamp: 12/1/2004 1:26:24 PM
ExceptionManager.FullName: Microsoft.ApplicationBlocks.ExceptionManagement,
Version=1.0.1441.27626, Culture=neutral, PublicKeyToken=null
ExceptionManager.AppDomainName: AdltTestUILoader.exe
ExceptionManager.ThreadIdentity:
ExceptionManager.WindowsIdentity:XXXXXXXXXX\Administrator

1) Exception Information
*********************************************
Exception Type: System.NullReferenceException
Message: Object reference not set to an instance of an object.
TargetSite: Void Form_Activated(System.Object, System.EventArgs)
HelpLink: NULL
Source: Microsoft.ApplicationBlocks.UIProcess

StackTrace Information
*********************************************
at
Microsoft.ApplicationBlocks.UIProcess.WindowsFormViewManager.Form_Activated(
Object source, EventArgs e)
at System.Windows.Forms.Form.OnActivated(EventArgs e)
at System.Windows.Forms.Form.set_Active(Boolean value)
at System.Windows.Forms.Form.WmActivate(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at TxDpsAdlt.UI.BaseForm.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
IntPtr wparam, IntPtr lparam)


Is there anyway to figure out what is happening? Like I said, it happens
very irregularly, so I can't really debug it.

thanks a bunch!

RE: error caused possibly by overriding WndProc method of form while u by Serg

Serg
Thu Dec 02 21:25:04 CST 2004

below is the Forms's WndProc, see if anything in it pertains to moving your
window and maybe it will help you disable it.

[EditorBrowsable(EditorBrowsableState.Advanced),
SecurityPermission(SecurityAction.LinkDemand, UnmanagedCode=true)]
protected override void WndProc(ref Message m)
{
int num1 = m.Msg;
if (num1 <= 0xa1)
{
if (num1 <= 0x18)
{
if (num1 == 1)
{
this.WmCreate(ref m);
return;
}
switch (num1)
{
case 5:
{
this.WmSize(ref m);
return;
}
case 6:
{
this.WmActivate(ref m);
return;
}
case 0x10:
case 0x11:
case 0x16:
{
this.WmClose(ref m);
return;
}
case 0x12:
case 0x13:
case 0x15:
case 0x17:
{
goto Label_0209;
}
case 20:
{
this.WmEraseBkgnd(ref m);
return;
}
case 0x18:
{
this.WmShowWindow(ref m);
return;
}
}
goto Label_0209;
}
if (num1 <= 0x47)
{
if (num1 == 0x24)
{
this.WmGetMinMaxInfo(ref m);
return;
}
if (num1 == 0x47)
{
this.WmWindowPosChanged(ref m);
return;
}
goto Label_0209;
}
switch (num1)
{
case 130:
{
this.WmNCDestroy(ref m);
return;
}
case 0x83:
case 0x85:
{
goto Label_0209;
}
case 0x84:
{
this.WmNCHitTest(ref m);
return;
}
case 0x86:
{
if (this.IsRestrictedWindow)
{
base.BeginInvoke(new
MethodInvoker(this.RestrictedProcessNcActivate));
}
base.WndProc(ref m);
return;
}
case 0xa1:
{
goto Label_0163;
}
}
goto Label_0209;
}
if (num1 <= 0x112)
{
if (num1 <= 0xa7)
{
if ((num1 == 0xa4) || (num1 == 0xa7))
{
goto Label_0163;
}
goto Label_0209;
}
if (num1 == 0xab)
{
goto Label_0163;
}
if (num1 == 0x112)
{
this.WmSysCommand(ref m);
return;
}
goto Label_0209;
}
if (num1 <= 0x120)
{
if (num1 == 0x117)
{
this.WmInitMenuPopup(ref m);
return;
}
if (num1 == 0x120)
{
this.WmMenuChar(ref m);
return;
}
goto Label_0209;
}
switch (num1)
{
case 0x211:
{
this.WmEnterMenuLoop(ref m);
return;
}
case 530:
{
this.WmExitMenuLoop(ref m);
return;
}
case 0x213:
case 0x214:
{
goto Label_0209;
}
case 0x215:
{
base.WndProc(ref m);
if (base.Capture && (Control.MouseButtons ==
MouseButtons.None))
{
base.CaptureInternal = false;
}
return;
}
case 0x222:
{
this.WmMdiActivate(ref m);
return;
}
default:
{
goto Label_0209;
}
}
Label_0163:
this.WmNcButtonDown(ref m);
return;
Label_0209:
base.WndProc(ref m);
}




here is the solution though by Serg

Serg
Thu Dec 02 21:49:06 CST 2004

protected override void WndProc(ref Message m)
{
const int WM_NCHITTEST = 0x84;
base.WndProc(ref m);

if(m.Msg == WM_NCHITTEST && m.Result == (IntPtr)2)
{
m.Result = (IntPtr) 1;
}
}


Re: error caused possibly by overriding WndProc method of form while using UIP AB by Claes

Claes
Fri Dec 03 03:11:51 CST 2004

Are you sure the problem is in WndProc?
The stack trace seems to indicate something else

When you handle WM_SYSCOMMAND and
WM_NCLBUTTONDOWN you should return 0
(i.e. m.Result = IntPtr.Zero before return;)

/claes

"TS" <manofsteele@311.com> wrote in message
news:eU5ocnK2EHA.204@TK2MSFTNGP10.phx.gbl...
> I get this error randomly that doesn't seem to cause anything to not work
> correctly. The exception is caught, and seems to not affect the
application
> at all:
>
> The code I used to make is so the form cannot be moved:
> private const int WM_NCLBUTTONDOWN = 0XA1;
>
> private const int WM_SYSCOMMAND = 0X112;
>
> private const int HTCAPTION = 0X2;
>
> private const int SC_MOVE = 0XF010;
>
> protected override void WndProc(ref Message m)
> {
>
> if (m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_MOVE || m.Msg ==
> WM_NCLBUTTONDOWN && m.WParam.ToInt32() == HTCAPTION)
>
> return;
>
> }
>
> base.WndProc(ref m);
>
> }
>
> The exception:
>
> General Information
> *********************************************
> Additional Info:
> ExceptionManager.MachineName: XXXXXXXXXX
> ExceptionManager.TimeStamp: 12/1/2004 1:26:24 PM
> ExceptionManager.FullName:
Microsoft.ApplicationBlocks.ExceptionManagement,
> Version=1.0.1441.27626, Culture=neutral, PublicKeyToken=null
> ExceptionManager.AppDomainName: AdltTestUILoader.exe
> ExceptionManager.ThreadIdentity:
> ExceptionManager.WindowsIdentity:XXXXXXXXXX\Administrator
>
> 1) Exception Information
> *********************************************
> Exception Type: System.NullReferenceException
> Message: Object reference not set to an instance of an object.
> TargetSite: Void Form_Activated(System.Object, System.EventArgs)
> HelpLink: NULL
> Source: Microsoft.ApplicationBlocks.UIProcess
>
> StackTrace Information
> *********************************************
> at
>
Microsoft.ApplicationBlocks.UIProcess.WindowsFormViewManager.Form_Activated(
> Object source, EventArgs e)
> at System.Windows.Forms.Form.OnActivated(EventArgs e)
> at System.Windows.Forms.Form.set_Active(Boolean value)
> at System.Windows.Forms.Form.WmActivate(Message& m)
> at System.Windows.Forms.Form.WndProc(Message& m)
> at TxDpsAdlt.UI.BaseForm.WndProc(Message& m)
> at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
> at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
> at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
> IntPtr wparam, IntPtr lparam)
>
>
> Is there anyway to figure out what is happening? Like I said, it happens
> very irregularly, so I can't really debug it.
>
> thanks a bunch!
>
>



Re: error caused possibly by overriding WndProc method of form whi by Serg

Serg
Fri Dec 03 12:43:03 CST 2004

Claes you don't need any of that. Why WM_SYSCOMMAND? I posted the codes that
does exactly what he needed. Here it is again for you:

protected override void WndProc(ref Message m)
{
const int WM_NCHITTEST = 0x84;
base.WndProc(ref m);

if(m.Msg == WM_NCHITTEST && m.Result == (IntPtr)2)
{
m.Result = (IntPtr) 1;
}
}





"Claes Bergefall" wrote:

> Are you sure the problem is in WndProc?
> The stack trace seems to indicate something else
>
> When you handle WM_SYSCOMMAND and
> WM_NCLBUTTONDOWN you should return 0
> (i.e. m.Result = IntPtr.Zero before return;)
>
> /claes
>
> "TS" <manofsteele@311.com> wrote in message
> news:eU5ocnK2EHA.204@TK2MSFTNGP10.phx.gbl...
> > I get this error randomly that doesn't seem to cause anything to not work
> > correctly. The exception is caught, and seems to not affect the
> application
> > at all:
> >
> > The code I used to make is so the form cannot be moved:
> > private const int WM_NCLBUTTONDOWN = 0XA1;
> >
> > private const int WM_SYSCOMMAND = 0X112;
> >
> > private const int HTCAPTION = 0X2;
> >
> > private const int SC_MOVE = 0XF010;
> >
> > protected override void WndProc(ref Message m)
> > {
> >
> > if (m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_MOVE || m.Msg ==
> > WM_NCLBUTTONDOWN && m.WParam.ToInt32() == HTCAPTION)
> >
> > return;
> >
> > }
> >
> > base.WndProc(ref m);
> >
> > }
> >
> > The exception:
> >
> > General Information
> > *********************************************
> > Additional Info:
> > ExceptionManager.MachineName: XXXXXXXXXX
> > ExceptionManager.TimeStamp: 12/1/2004 1:26:24 PM
> > ExceptionManager.FullName:
> Microsoft.ApplicationBlocks.ExceptionManagement,
> > Version=1.0.1441.27626, Culture=neutral, PublicKeyToken=null
> > ExceptionManager.AppDomainName: AdltTestUILoader.exe
> > ExceptionManager.ThreadIdentity:
> > ExceptionManager.WindowsIdentity:XXXXXXXXXX\Administrator
> >
> > 1) Exception Information
> > *********************************************
> > Exception Type: System.NullReferenceException
> > Message: Object reference not set to an instance of an object.
> > TargetSite: Void Form_Activated(System.Object, System.EventArgs)
> > HelpLink: NULL
> > Source: Microsoft.ApplicationBlocks.UIProcess
> >
> > StackTrace Information
> > *********************************************
> > at
> >
> Microsoft.ApplicationBlocks.UIProcess.WindowsFormViewManager.Form_Activated(
> > Object source, EventArgs e)
> > at System.Windows.Forms.Form.OnActivated(EventArgs e)
> > at System.Windows.Forms.Form.set_Active(Boolean value)
> > at System.Windows.Forms.Form.WmActivate(Message& m)
> > at System.Windows.Forms.Form.WndProc(Message& m)
> > at TxDpsAdlt.UI.BaseForm.WndProc(Message& m)
> > at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
> > at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
> > at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg,
> > IntPtr wparam, IntPtr lparam)
> >
> >
> > Is there anyway to figure out what is happening? Like I said, it happens
> > very irregularly, so I can't really debug it.
> >
> > thanks a bunch!
> >
> >
>
>
>

Re: here is the solution though by TS

TS
Mon Dec 06 09:45:40 CST 2004

ok, so i just replace what i had with this?
I still need to call base.WndProc(), right?


"Serg" <Serg@discussions.microsoft.com> wrote in message
news:D6DC6976-D1D9-4F6B-AAF6-B15C46CF9E84@microsoft.com...
> protected override void WndProc(ref Message m)
> {
> const int WM_NCHITTEST = 0x84;
> base.WndProc(ref m);
>
> if(m.Msg == WM_NCHITTEST && m.Result == (IntPtr)2)
> {
> m.Result = (IntPtr) 1;
> }
> }
>



Re: here is the solution though by TS

TS
Mon Dec 06 09:54:51 CST 2004

The application is going to be run on a touch screen with the cursor set to
invisible. Does this have any implications?

"Serg" <Serg@discussions.microsoft.com> wrote in message
news:D6DC6976-D1D9-4F6B-AAF6-B15C46CF9E84@microsoft.com...
> protected override void WndProc(ref Message m)
> {
> const int WM_NCHITTEST = 0x84;
> base.WndProc(ref m);
>
> if(m.Msg == WM_NCHITTEST && m.Result == (IntPtr)2)
> {
> m.Result = (IntPtr) 1;
> }
> }
>



Re: here is the solution though by TS

TS
Mon Dec 06 12:17:08 CST 2004

the touch system calls mouse events, so its treated as a mouse

"TS" <manofsteele@311.com> wrote in message
news:ubDg9w62EHA.1152@TK2MSFTNGP14.phx.gbl...
> The application is going to be run on a touch screen with the cursor set
to
> invisible. Does this have any implications?
>
> "Serg" <Serg@discussions.microsoft.com> wrote in message
> news:D6DC6976-D1D9-4F6B-AAF6-B15C46CF9E84@microsoft.com...
> > protected override void WndProc(ref Message m)
> > {
> > const int WM_NCHITTEST = 0x84;
> > base.WndProc(ref m);
> >
> > if(m.Msg == WM_NCHITTEST && m.Result == (IntPtr)2)
> > {
> > m.Result = (IntPtr) 1;
> > }
> > }
> >
>
>