473,385 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

See that user selected a new Tabpage.. how?

Hi there.
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...
Any help would be greatly appreciated.
Thank you!

André Nogueira
Nov 20 '05 #1
8 2294
* "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=hxAg9.261485%24kp.887854%40rwcrnsc52.o ps.asp.att.net>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2
Hi,

This sample receives the TCN_SELCHANGING message. It allows you to
cancel the tabpage change.
http://www.onteorasoftware.com/downl...tabcontrol.zip
Ken
-------------------

"Andre Nogueira" <an**@netcabo.pt.NOSPAM> wrote in message
news:ON**************@TK2MSFTNGP10.phx.gbl:
Hi there.
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...
Any help would be greatly appreciated.
Thank you!

Andri Nogueira


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.0.0 - Release Date: 6/2/2004
Nov 20 '05 #3
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/

Nov 20 '05 #4
Do you need to cancel the tab page change before it occurs?
Or do you just want to revert back once it has occured and some condition is
met?

Richard
Nov 20 '05 #5
I just want to close the tab if the user clicks on it while holding shift.

André Nogueira

"spamfurnace" <bi*******@tastycheeks.com> wrote in message
news:#Y**************@TK2MSFTNGP11.phx.gbl...
Do you need to cancel the tab page change before it occurs?
Or do you just want to revert back once it has occured and some condition is met?

Richard

Nov 20 '05 #6
OK, this seems to be getting unnecessarily complicated. Although I do like
the method shown, it is not the answer.

You can get the state of the Shift key without interop.
\\\
Me.ModifierKeys = Keys.Shift
///

You can use the OnselectedIndexChanged event to determine when a tabpage is
selected.

However, You cannot use this event to remove the tabpage with your desired
method. As soon as the tabpage is removed another is selected and, since I
assume you cannot release the shift key faster than your app can remove a
tabpage, that tabpage is removed. This carries on until there are no more
tabpages.

The good news is that you can use the Tabcontrols MouseUp Method, and in
fact this is the only choice since you may shift-click on the currently
selectedtab.
\\\
Private Sub TabControl1_MouseUp(...)...
If e.Button = MouseButtons.Left Then
If Me.ModifierKeys = Keys.Shift Then
TabControl1.TabPages.Remove(TabControl1.SelectedTa b)
End If
End If
End Sub
///

--
Mick Doherty
http://homepage.ntlworld.com/mdaudi100/index.html
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.693 / Virus Database: 454 - Release Date: 31/05/2004
Nov 20 '05 #7
Hi there.
Thank you for your reply!
I soon found out that you can't release the Shiftkey quickly enough... So I
explored a bit and ended up trying the Mousedown event of the tab control.
Now I feel really dumb for not thinking about it before... :S
Thank you for your reply! It is indeed the best way to do it... Even better
than the Mousedown event (as I currently have to check the mouse position to
see what tab is underneath it)

André Nogueira

"Mick Doherty"
<EX***********@AND.REMOVE.SQUAREBRACKETS.[mdaudi100#ntlworld.com]> wrote in
message news:e1*************@tk2msftngp13.phx.gbl...
OK, this seems to be getting unnecessarily complicated. Although I do like
the method shown, it is not the answer.

You can get the state of the Shift key without interop.
\\\
Me.ModifierKeys = Keys.Shift
///

You can use the OnselectedIndexChanged event to determine when a tabpage is selected.

However, You cannot use this event to remove the tabpage with your desired
method. As soon as the tabpage is removed another is selected and, since I
assume you cannot release the shift key faster than your app can remove a
tabpage, that tabpage is removed. This carries on until there are no more
tabpages.

The good news is that you can use the Tabcontrols MouseUp Method, and in
fact this is the only choice since you may shift-click on the currently
selectedtab.
\\\
Private Sub TabControl1_MouseUp(...)...
If e.Button = MouseButtons.Left Then
If Me.ModifierKeys = Keys.Shift Then
TabControl1.TabPages.Remove(TabControl1.SelectedTa b)
End If
End If
End Sub
///

--
Mick Doherty
http://homepage.ntlworld.com/mdaudi100/index.html
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.693 / Virus Database: 454 - Release Date: 31/05/2004

Nov 20 '05 #8
You're welcome.
I've been playing around with the tabcontrol forever and I didn't
immediately jump to the MouseUp event.

--
Mick Doherty
http://homepage.ntlworld.com/mdaudi100/index.html
"Andre Nogueira" <an**@netcabo.pt.NOSPAM> wrote in message
news:Ok*************@TK2MSFTNGP10.phx.gbl...
Hi there.
Thank you for your reply!
I soon found out that you can't release the Shiftkey quickly enough... So I explored a bit and ended up trying the Mousedown event of the tab control.
Now I feel really dumb for not thinking about it before... :S
Thank you for your reply! It is indeed the best way to do it... Even better than the Mousedown event (as I currently have to check the mouse position to see what tab is underneath it)

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.693 / Virus Database: 454 - Release Date: 31/05/2004
Nov 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: JG | last post by:
Hi, I have a windows form with a TabControl on it. It has 3 tabpages on it. I have also coded a button that is supposed to 'add' a new tabpage. The code in that clicked event looks like this:...
1
by: RA | last post by:
Hi 1) I want to create a TabPage class in design mode - how do I do it? What type of project should I use? Is it going to be a custom control? 2) I have a TabControl that I would like to add to...
1
by: Sumit | last post by:
Hi all, I have a windows form in which i have a tabcontrol having 4 tabs. I have made 4 user controls for each of the tabpage. I add the user controls on the tabpage programatically. Now in...
8
by: touf | last post by:
Hi, I've a tabcontrol that contains many similar tabpages (exactly the same structure with different information), the tabpages number isn't known in the design time it depends of the data. Is...
5
by: Doug Handler | last post by:
Hi, I have a form (Form1) that contains a tab control which one tab has a customer user control (UserControl1). When the user double-clicks on the grid hosted there a new user control is...
5
by: svein.erik.storkas | last post by:
I'm creating an application where the user first selects a number from a combobox. Based on his choice of number, ComboBoxes and buttons are to be created (at runtime of course). Let's say that...
6
by: =?Utf-8?B?U2hhcm9u?= | last post by:
Hello gurus, I want to have a Form with a TabControl, this TabControl will contain TabPage that has controls in it, this TabPage is prepared at design time. I want in runtime to duplicate the...
3
by: Dave Kelly | last post by:
c#, .Net 2.0, VS2008 I have a user control, and wish to embed other custom/user controls within this control. I am getting problems in compilation though, that the type or namespace cannot be...
1
by: RobcPettit | last post by:
Hi, this sounds like a daft question but, if Im adding several tabds, and I want to have the same layout in each tab, eg textbox-treeview- labels, which is the the best way to do it. Would I be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.