Click to See Complete Forum and Search --> : VB MultiPage Focus problem


vbdude
01-26-2005, 02:07 PM
Hi

I have a MultiPage control on my form which has 4 pages (tabs).

Each page has controls on it like textboxes, comboxes etc.

When the current focus is inside a textbox/combobox on a tab, I have to click the another desired tab twice to select it.

e.g.

Current focus is in a textbox on tab 3. I want to select tab 4.
The first click on the tab 4 gets the focus on Multipage control only.
Now I have to click again on tab 4, to view its contents.

What is the solution, so that i can get this done in a singe click?.

vbdude

vbdude
01-31-2005, 01:17 PM
Hello

Can anyone provide help on this issue please?

I am stuck here. And the users are getting really annoyed by having to click twice to get into the tab.

Thanks.

brhsolutions
01-31-2005, 03:38 PM
OK, Let me make sure I'm understanding the issue. You have a tab control, and you are using the tab to show different forms. The controls you are attempting to see are not on the tab right.

If the above is true you need to control it via your code. I would bet your sub looks similar to this:

Private Sub SSTab1_DblClick()


Change it to this:

Private Sub SSTab1_Click(PreviousTab As Integer)


Tabs are strange you have to double click on them to get to code view from GUI veiw. Next time swap to code view then select your control and the event at the top. I hope this helps. If not you should clarify you issue a bit more.

vbdude
01-31-2005, 04:03 PM
Thanks for the reply brhsolutions.

Ok. Let me re-word my problem.

I have a MultiPage control on my form which has 3 pages
(This is different from the Tab control, but looks exactly similar)

Each "page" (tab) has a frame on it.

So page 1 has frame 1 on it,
page 2 has frame 2 on it
page 3 has frame 3 on it.

Frames are used to hold all the related controls (textboxes,label,combos etc) together.

A click on the pages (or tabs) on top of this Multipage control generates the following event:

Private Sub mPage_change()

If mPage.Value = 0 Then
Frame1.Visible = True
End if
If mPage.Value = 1 Then
Frame2.Visible = True
End if
If mPage.Value = 2 Then
Frame3.Visible = True
End if

End Sub


Now here is the problem:

If user selects page 1. The corresponding frame becomes visible and the user starts typing in a textbox on that frame.

The cursor/focus is in the textbox. Now the user decides to change the page (tab).

The first click by user just selects (gets focus on) the "MultiPage Control".

The user has to click once more to actually initiate the mPage_change() event.

The user gets annoyed when he clicks the tabs on the top for the first time and nothing happens.

Is there any way we can get the "focus" and "change" event both done in single user click?

Thanks.

brhsolutions
01-31-2005, 06:17 PM
This control also has a click event

Change the
Private Sub mPage_change()

to

Private Sub mPage_Click(Index As Long)

I built a small app to simulate the code you had below and it you use change you must double click if you use click it works for me with single.

vbdude
02-01-2005, 02:49 PM
Yes, I tried with
Private Sub mPage_Click(Index As Long)

But it still needs 2 clicks :confused:

I am on page 2.
Page 2 has a frame on it.
My focus is inside a textbox on that frame.

Now I click on the Page(tab) 4.
First click selects the mPage control only.
I checked this in debug mode. The first click does not generate any event.

The second click generates mPage_Click event.

Need Help.
Thanks

(note: The MultiPage control is on a form, and has 4 pages.)

vbdude
02-02-2005, 10:41 AM
Hello Everyone

Need help.

Am I not explaining the problem properly?

Need to fix this bug asap in my application, and release it to client.

Thanks

brhsolutions
02-02-2005, 11:47 AM
http://www.dicks-blog.com/archives/2004/07/20/bug-multipage-controls-on-2003/

I would try this but not sure.

vbdude
02-02-2005, 05:46 PM
I have attached the form here.

click inside textbox1 (on frame1) and type anything

Then click pag2 tab.......nothing happens.

Needs one more click to activate the change event on MultiPage

Please help. Thanks

NOTE: Add Components: Microsoft Forms 2.0 Object Library

mstraf
02-02-2005, 06:32 PM
The MultiPage control is a bad beast, and MS does not support it anymore. Basically the first click switch the focus to the page, and the second sends the Click event. Any reason why not to use the TabStrip control (there is a version of it in the Forms 2.0 library)
The index of the selected tab strip item is:
tabstrip.selecteditem.index
and it starts from 1 (if I remember correctly)

Marco

brhsolutions
02-02-2005, 06:39 PM
I tested and it works the way you said.

This is a a bandaid but what you could do is set a varible say test1 to 1 if text box one is changed then to 2 if text 2 is changed. then instead of monitoring the value of the multipage monitor the value of this varible. I did not test very much but this looks as if it works. You would have to besure the on form load was set right and that if no data was changed it shows the right data. Hope this helps. it is a bit hooky but it is the only way I could get it to work right.

Private Sub MultiPage1_Change()
If test1 = 1 Then
Frame2.Visible = True
Frame1.Visible = False
MultiPage1.Value = 1
test2 = 0
test1 = 0

ElseIf test1 = 2 Then
Frame1.Visible = True
Frame2.Visible = False
MultiPage1.Value = 0
test2 = 0
test1 = 0
Else
If MultiPage1.Value = 1 Then
Frame1.Visible = True
Frame2.Visible = False

End If

If MultiPage1.Value = 0 Then
Frame2.Visible = True
Frame1.Visible = False

End If

End If
End Sub


Private Sub Text1_Change()
test1 = 1
End Sub
Private Sub Text2_Change()
test1 = 2
End Sub

svasile
02-03-2005, 10:22 AM
Use the GotFocus event instead of the Click.

vbdude
02-04-2005, 10:23 AM
Thanks for the replay everyone.

Mr. Marco
Unfortunately it will be difficult to change MultiPage to Tabstrip, since the application is already being used now.
I wish I would have known this in the beginning. But appreciate your help.


brhsolutions
The MultiPage1_Change() event itself needs 2 clicks to get fired.


svasile
Yes, I tried using the Gotfocus event. But surprisingly, the event is Not fired with the "first click" when the MultiPage controls gets into focus.
Also, even if that worked, how can i catch the index of tab that was clicked?

Thank You.

Anklebuster
02-04-2005, 11:56 AM
Eureka!

vbDude, if you can place the multipage and each of the frames inside of another frame - which I'll call wrapper -, all you'll need is a single line of code !


Private Sub fraWrapper_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
MultiPage1.SetFocus
End Sub



edit... You don't even need a frame! put the MultiPage1.SetFocus in your form's MosueMove event. I like the frame because you can move everything around at once.

I downloaded your project example and added the wrapper. The trick is to have space between the tab and the frames.

Important notes: the multi-page was not present or would not load from the zip, so i just dropped another one on the form, so I have no idea if this solution can be tailored to your application. I just know it works. In addition, while testing, I wanted to see if the textbox was a specific issue, so I added a non-functioning command button to each frame. As you know, as long as no other control has the focus, multipage works as you want it to.

Anklebuster

mstraf
02-04-2005, 03:03 PM
Originally posted by Anklebuster
put the MultiPage1.SetFocus in your form's MosueMove event.

Although this method works, it has a big problem. I click the text box to start edit then I move the mouse away: say hello to editing, the focus is lost. And more. Let's say I am editing a text box (or anything else in the form) and I move the mouse: bingo, the mutlipage gets the focus and I cannot edit anymore. Also I cannot select the all text by dragging the mouse unless I keep the mouse within the box: as soon as the mouse is outside the box, the multipage again get the focus.

Nice idea though. Maybe with some more twicking. But in my experience and IMHO, messing with the focus causes always trouble...

Marco

vbdude
02-04-2005, 03:30 PM
Yes, that was the first thing i tried.
(putting Multipage1.setfocus in the form's MosueMove event. )

But as discussed by Marco(mstraf), it screws up.

I also tried this:

Private Sub MultiPage1_Click()
Multipage1.setfocus
End Sub

Private Sub MultiPage1_Change()
If mPage.Value = 0 Then
Frame1.Visible = True
End if
If mPage.Value = 1 Then
Frame2.Visible = True
End if
End Sub


But even the click event needs 2 clicks.

I am close to reach the conclusion that MultiPage control is all screwed up.

mstraf
02-04-2005, 03:45 PM
Dear vbdude,

the multiPage control was not designed for your application. The control has a collection of Pages, and in each page controls can be added using the controls.add method of that page. I guess (never tried...) playing by the rules the multipage (that AFAIK was designed for web applications) should work ok. Each Page is basically a form, can have scrollbars etc. In theory very powerful.

I still think that swithing to a tabStrip is the best solution. Even if the application is already in use, the controls look the same and the user will never see the difference (been there, done it, even though with different controls)

Marco

vbdude
02-04-2005, 03:58 PM
Mr.Marco

Thanks for the help. Yes, I have decided to switch to Tabstrip control. (means one more weekend spent at work!!)

thanks all for your poosts :WAVE:

Anklebuster
02-04-2005, 04:32 PM
Originally posted by mstraf
Although this method works, it has a big problem. I click the text box to start edit then I move the mouse away: say hello to editing, the focus is lost. And more. Let's say I am editing a text box (or anything else in the form) and I move the mouse: bingo, the mutlipage gets the focus and I cannot edit anymore. Also I cannot select the all text by dragging the mouse unless I keep the mouse within the box: as soon as the mouse is outside the box, the multipage again get the focus.

Marco

Marco,
I played with vbdude's example form. The issues you mention can't happen if the mouse is inside the frame holding the textbox. The textbox is not directly on the form. You would have to move the cursor far (or the container frame would have to have very little "white space" around the controls) for there to be any problems.
That's why I told vbdude that it depends on how his frames are laid out on the form.

Anklebuster

vbdude
02-07-2005, 04:32 PM
Hi Anklebuster

Here is how my form looks.

I agree that, the following code will decrease chance of user needing to double click the tabs.

Private Sub mPage_MouseMove()
mPage.SetFocus
End Sub

But if the user is inside a textbox on frame 1, he may not move a mouse on the form, but slide the mouse rom textbox to the tabs on the top and click them.

Hence, the MouseMove event of the form is not fired, if mouse was never outside the Multipage control.

Any ideas?

Thanks

Anklebuster
02-07-2005, 04:42 PM
vbdude,

*** After posting a response, I went back and REALLY read your last post.

The biggest problem was the fact that i never saw the way your form was laid out. when i had to plop my own MultiPage control onto your example, I assumed that you did not resize it vertically!
It never occurred to me that your multipage control sits "behind" the frames!
To fix it, just make your MultiPage tall enough to display the tabs and leave a gap (as described below.)

************

I just downloaded and viewed your package. I get an error regarding the multipage control. Last time, I just drew a new one onto the form. Can you upload a screenshot, so I can see exactly how the multipage control appears.

Even though your post implies that you are testing mousemove from within the Multipage control, the form you uploaded has what i think is the correct code. Therefore, the only issue seems to be whether you have a gap between the Multipage and the frames. (the size of the form suggests that you don't.) I understand that no space will create the visual impression of tabbed pages, however, even a pixel's width separation is enough for the form's mousemove event to fire. (If you can see the form between the controls. it will work.)


Anklebuster

vbdude
02-08-2005, 12:46 PM
Hi Anklebuster

Thanks for reply.

I understand what happened. SInce you had to add the Multipage control everytime you opened my vb project, ou did not know exact position of my frames wrt the Multipage.


Well, My main form has the Multipage control and some buttons.
All the frames, (each associated with one tab) , are inside/on the multipage.

Your solution works fine if frames are outside Multipage. (with multipage, buttons, and the frames all on the form)

It kind of looks ugly, since it looses the "nice looking tabs on the top left of each frame" look, but works fine.

Thanks.

Anklebuster
02-08-2005, 01:15 PM
Originally posted by vbdude

It kind of looks ugly, since it looses the "nice looking tabs on the top left of each frame" look, but works fine.

Thanks.

You can combat the ugly appearance with a slight change in tactics: create a locked textbox with the same color as the multipage control (I assume it is the System Button Face color). Stretch the textbox so that it is as wide as the multipage. Make it as short as you can.
Position it between the tabs and the frames. Place the setfocus code within this textbox's MouseMove event.

Here is a copy of the relevant textbox properties:

Appearance = 0 'Flat
BackColor = &H8000000F&
BorderStyle = 0 'None
Height = 195
Locked = -1 'True
Width = 6735 (you set this)

By the way, neither image nor label controls seem to be capable of "sitting on top" of the multipage control.

Anklebuster

vbdude
02-08-2005, 03:21 PM
Yes this what I did.

But thanks Anklebuster, you have been solving the problem.

Note:
You can not put labels etc on a Multipage. Best thing to do if you want to add controls on multipage is to put a frame on it associated with each tab, and add controls to the frame.

Thanks.:WAVE: