Hi there.
Thank you for your help.
However, I tried changing the code a bit so it could see that Shift was
beeing pressed and, as such, close the tab instead but to no avail.
How can this be done?
The code I tried is below. The program just closes without any error message
or anything when opening the form that contains this control.
Thank you again for your patience!
Andre Nogueira
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
Dim OldTab, NewTab As Integer
Try
If Me.TabPages.Count > 0 Then OldTab = Me.SelectedIndex
If m.Msg = (WM_REFLECT + WM_NOTIFY) Then
'We've received a WM_NOTIFY message
'get the NMHDR struct
Dim hdr As NMHDR
hdr = System.Runtime.InteropServices.Marshal.PtrToStruct ure(m.LParam,
hdr.GetType())
If hdr.code = TCN_SELCHANGING Then
'the selection is changing.
'Raise the SelectedIndexChanging event and allow user to change
Dim e As New System.ComponentModel.CancelEventArgs
RaiseEvent SelectedIndexChanging(Me, e)
m.Result = IIf(e.Cancel, New IntPtr(1), m.Result)
End If
End If
Catch ex As Exception
'ignore errors
Finally
'if we haven't cancelled the closing, call the default window procedure
If Me.TabPages.Count > 0 Then NewTab = Me.SelectedIndex
If m.Result.ToInt32 <> 1 Then MyBase.WndProc(m)
Dim ShiftState As Integer
ShiftState = GetKeyState(Keys.ShiftKey)
If (ShiftState And &H8000) And Me.TabPages.Count > 1 Then
If NewTab > OldTab Then NewTab = NewTab - 1
Me.TabPages.RemoveAt(OldTab)
Me.SelectedIndex = NewTab
End If
End Try
End Sub
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:2i************@uni-berlin.de...
* "Andre Nogueira" <an**@netcabo.pt.NOSPAM> scripsit: I would like to know it is possible in VB.Net 2003 to see that a user
has clicked a tab page.
My goal is to close the tab page if the user clicks a tabpage
"separator" (not sure how to call it.. but it's that part that when you click on it
the whole tab page becomes visible) holding the Shift key it closes.
I can already see if the Shift key is being pressed using the Windows
API, but I don't have a clue about where should I place that code...
<URL:http://www.google.de/groups?selm=hxA...%40rwcrnsc52.o
ps.asp.att.net>
--
Herfried K. Wagner [MVP]
URL:http://dotnet.mvps.org/