K
kosjanne
I need to prevent user from changing a tab page, if the current tab
page has incorrect data. I've been searching these forums for a
solution and have found a suggestion that goes something like this:
[StructLayout(LayoutKind.Sequential)]
public struct NMHDR
{
public int hwndFrom;
public int idFrom;
public int code;
}
protected override void WndProc( ref Message m)
{
if ( m.Msg == 0x4e ) //WM_NOTIFY
{
NMHDR hdr = (NMHDR)Marshal.PtrToStructure(m.LParam, typeof(NMHDR));
if (hdr.code == -552)
{
...
m.Result = new IntPtr(1);
}
}
base.WndProc(ref m);
}
However, this doesn't work for me. The tab page is still changed even
though the m.Result is 1. Any ideas how to get this working? Is my
WndProc in correct place, when it is in the MainForm (which owns the
tab control)? Should it be somewhere else?
Thank you.
page has incorrect data. I've been searching these forums for a
solution and have found a suggestion that goes something like this:
[StructLayout(LayoutKind.Sequential)]
public struct NMHDR
{
public int hwndFrom;
public int idFrom;
public int code;
}
protected override void WndProc( ref Message m)
{
if ( m.Msg == 0x4e ) //WM_NOTIFY
{
NMHDR hdr = (NMHDR)Marshal.PtrToStructure(m.LParam, typeof(NMHDR));
if (hdr.code == -552)
{
...
m.Result = new IntPtr(1);
}
}
base.WndProc(ref m);
}
However, this doesn't work for me. The tab page is still changed even
though the m.Result is 1. Any ideas how to get this working? Is my
WndProc in correct place, when it is in the MainForm (which owns the
tab control)? Should it be somewhere else?
Thank you.