Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / December 2005

Tip: Looking for answers? Try searching our database.

Prevent tab page from changing

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kosjanne@hotmail.com - 30 Dec 2005 13:34 GMT
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.
Mick Doherty - 30 Dec 2005 19:54 GMT
Yes, it's in the wrong place. It should be in the WndProc of an Inherited
TabControl.

Note that this will only prevent selection via mouse though. A user can
still change selection by using the Arrow keys as well as Ctrl+Tab and
Ctrl+Shift+Tab key combinations.

See the example on my site for a complete solution:
http://www.dotnetrix.co.uk/tabcontrols.html --> Add SelectedIndexChanging
Event.

Signature

Mick Doherty
http://dotnetrix.co.uk/nothing.html

>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
[quoted text clipped - 28 lines]
>
> Thank you.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.