Web Development

General discussion


VB6 SetFocus From Module to Form Problem

By stevenicoloff ·
I have a problem with the SetFocus command in VB6 that I am hoping someone can help me with. From the main module I access a from call frmMain, that pops up a window. The user can click on Run, Cancel, Exit, etc. However, unless I exit the main program, no action is allowed, the computer just beeps if they click on Run. I am trying to come up with a way to set the focus to the form so user interaction is allowed. I dont want to exit Main in order to pass control to the form. Does anyone have any suggestions?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -


by onbliss In reply to VB6 SetFocus From Module ...

It has been many years that I have worked in VB6. So do take what I say with a load of salt.

Is'nt there a way to set the focus to the form? SetFocus() or Focus() method. So if your code does a form.show(), then follow it with a form.setfocus()

Note: please,check out the correct syntax.

Collapse -


by Bob G Beechey In reply to Activate...

I may be missing something, but if you are staying in Main(), I presume you are doing some work behind the scenes. This will block any standard Windows messages to any form you are showing. So after YourForm.Show amd YourForm.SetFocus you will need to do a periodioc DoEvents() so that your module will give up timeslices to your form or forms.

Collapse -

If you want frmmain to do something on a user

by Tony Hopkinson In reply to VB6 SetFocus From Module ...

interaction ir must have have control (focus), that's how windows works.
Turn fromMain into a dialogue and show it modally send back to main which action was selected and then run the appropriate code, will be the nearest you get to what you want.
Other optio is not to raise it modally and send a windows message back to main and then take the relevant action. You have to deal with synchronous options and contending selections then though.

Collapse -

Set Focus Problem

by renelabban In reply to VB6 SetFocus From Module ...

Based on How I understand your problem . I think you need to use MDI Forms and MDI Child. What this does is the main for has a property of MDI Parent and all other form has MDI Child so all form will open in the main . I did not use VB for some time now but I think if this does ot work do a lookup on MDi forms in Help and you will be able to understand it .
Let me know if you get through.

Collapse -

VB6 SetFocus From Module to Form Problem

by lambros.net In reply to VB6 SetFocus From Module ...

You should display the form modally.
< frmMain.show vbmodal or 1 >
The form will be displayed, after you
unload the form and return to main method.

Hope it helps

Related Discussions

Related Forums