Fabian R Silva, -
|
|
Group: StrataFrame Users
Posts: 153,
Visits: 1.2K
|
I like to display a InfoBox, but I want to keep the focus on the active control. How I can do that? I don't find a property on the infobox that says "getFocus" or something else, thanks
|
|
|
Peter Jones
|
|
Group: Forum Members
Posts: 386,
Visits: 2.1K
|
Hi, I think InfoBox.focus is what you want. Cheers, Peter
|
|
|
Fabian R Silva, -
|
|
Group: StrataFrame Users
Posts: 153,
Visits: 1.2K
|
Hello, thanks for reply, my english is bad and I not make good questions I try to avoid the infobox to give focus, I try to validate a textbox and show an infobox that say something, but while the infobox is displaying I like to mantain the focus on the textbox, it is posible? I try with mytextbox.focus before calling the infobox without sucess, but when I call the infobox, if I press faster click on the textbox, it get focus. I think that if I pause some millisecons and focus on textbox it can have focus but I think that's not a good idea :/ Thanks
|
|
|
Peter Jones
|
|
Group: Forum Members
Posts: 386,
Visits: 2.1K
|
Hi Fabian, Sorry for the misunderstanding. I've never used the InfoBox control so I'm not speaking from experience but, from the SF Help, I see that it has these propeties: .CanFocus - you could set this to false so it never receives focus. .GotFocus - you could trap the focus event and return focus to your text box. Cheers, Peter
|
|
|
Fabian R Silva, -
|
|
Group: StrataFrame Users
Posts: 153,
Visits: 1.2K
|
Peter Jones (11/02/2007)
Hi Fabian, Sorry for the misunderstanding. I've never used the InfoBox control so I'm not speaking from experience but, from the SF Help, I see that it has these propeties: .CanFocus - you could set this to false so it never receives focus. .GotFocus - you could trap the focus event and return focus to your text box. Cheers, Peter Thanks for reply .CanFocus is readonly and I try to trap gotfocus with an eventhandler, but the infobox is a static class and I guess that cannot trap it I not sure what more I can try :/ thanks
|
|
|
Trent Taylor
|
|
Group: StrataFrame Developers
Posts: 6.6K,
Visits: 6.9K
|
The problem you are running into is the basic window handle issue that comes up from time to time when using WinForms. The InfoBox is a window, which will take the focus away from the calling form. However, you CAN set the focus back to your main for that called the InfoBox. InfoxBox.NotifyBox(...) Me.Focus() If this doesn't work, then you can go a step further by using the WinAPI methods such as the SetActiveWindow: SetActiveWindow(Me.Handle) Ultimately you will just have to make a call to refocus your main window rather than the InfoBox. Finally, you may experience different behavior depending upon whether or not the InfoBox parent is the screen or the form. This is a parameter that can be provided when showing an InfoBox (it is the Parent parameter). If you set it to Nothing, then the InfoBox will show in the screen. Otherwise it will appear within the control or form that you specify. This may have an effect on getting the focus back as well, just FYI.
|
|
|
Fabian R Silva, -
|
|
Group: StrataFrame Users
Posts: 153,
Visits: 1.2K
|
Thanks for reply. Dim HWmdActiveWindow As Integer = GetActiveWindow()
MicroFour.StrataFrame.Messaging.InfoBox.NotifyBox("Notificación", "No se encontró el registro tipeado") ', Me.ParentForm
SetActiveWindow(HWmdActiveWindow)
I try from a usercontrol.textbox_keypress with me.parentform.Focus() and SetActiveWindow(me.parentform.handle) and no luck, the infoBox get the focus again I try to use system.threading.thread.sleep with some variants and nothing... to gain form focus I see that only works when I call the infobox and click on the form, It get focus and don't loose it again. Any idea? thanks!
|
|
|
StrataFrame Team
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
You might try this from within the form: InfoBox.NofityBox(...) Me.Activate() Me.textBox.Focus() You might even need to make a call to System.Windows.Forms.Application.DoEvents(). What it does is force all of the Windows messages that are caught up on the message pump to push through, so even if the UI thread is busy, it will pause there and process the activate and focus calls. It's worth a try. A word of warning, though... always be careful with the call to DoEvents(). It can get you into trouble more often than not. Just Google it and I'm sure you'll find some articles telling you how horrible it is.
|
|
|
Fabian R Silva, -
|
|
Group: StrataFrame Users
Posts: 153,
Visits: 1.2K
|
Thanks for the reply I try with you suggestions (Activate, SetActiveWindow, Focus, DoEvent) but I cannot make the form got focus while the infobox is showing (except with a mouse click on the form)... If I can't make it work, I will edit the infobox source to accept a parameter with the calling form to see if I can call form.activate() or form.focus() from there and see if it get the order Thanks for the support, I known I'm try to make the stuff from another way that the framework works and it give me troubles, but I have to make the try because my boss have his needs to adapt from his FoxPro DOS App. and I are the only programmer and I convinced him to use .NET & SF
|
|
|
StrataFrame Team
|
|
Group: StrataFrame Developers
Posts: 3K,
Visits: 2.5K
|
Well, I'm sorry, but I'm all out of ideas on trying to get the form to re-activate.
|
|
|