From: Jim Mack on 3 Mar 2010 18:51 Bee wrote: > I do not want the calling form code to proceed until the user makes > a choice on frmX. > I do not want a modal form using vbModal because I cannot get past > other issues using a vbModal form. > > frmX.Show ' this opens the form > ' after the frmX _Load event execution continues here. > ' but I do not want it to be until the user makes a choice. > > So I put the loop in frmX to wait there until the choice is made. > > What way would you implement this? One problem with making the new form non-modal is that if you wait nicely in the original form, you allow UI actions there. So you may also need to disable that form, or some elements of it. You could wait in a 'loose' DoEvents loop, using Sleep or PeekMessage within it. Inside the loop, check the status of the form you opened, and exit when it's no longer active. A sneaky way to do that might be: Do Sleep 50 Loop While DoEvents > 1 But you'll probably need something less generic. -- Jim
From: Paul Clement on 3 Mar 2010 18:58 On Wed, 3 Mar 2010 13:59:02 -0800, Bee <Bee(a)discussions.microsoft.com> wrote: � I have seen this talked about but still not sure which is the correct way to � do this. � Either way below seems to work. � � A form is opened for the user to click on something. � The form is modless. It cannot be modal. � � I want other events in the app (timer driven) and outside the app to have � max process time while the user is thinking. � � so, do I use Sleep or a system timer or ...? � � Do � DoEvents � Sleep 200& � Loop While bLoop � � or � � Do � DoEvents � WaitMS 200& � Loop While bLoop � � The user clicking a button changes the state of bLoop to False. � � WaitMS is a � CreateWaitableTimer � subroutine � � Or if there is a better way, what is it? If I understand your question correctly, try using the SetWaitableTimer API function call. The problem with Sleep is that it suspends the application thread for the duration specified. That doesn't sound like what you want. http://support.microsoft.com/kb/231298 Paul ~~~~ Microsoft MVP (Visual Basic)
From: Henning on 3 Mar 2010 19:13 I have a similar situation, opening a setup form and waiting till it's done. In a .bas Module: Public Channel As Byte 'it is later reused therefor a Byte Public Const RS232 As Byte = 1 Public Const LAN As Byte = 2 In the main form: Channel = 0 frm_InitLAN.Show While Channel = 0 DoEvents Wend In frm_InitLAN: Channel = LAN Unload Me It has worked ok for years. /Henning "Bee" <Bee(a)discussions.microsoft.com> skrev i meddelandet news:3663D214-7D32-49D1-930D-1ACDC57511B3(a)microsoft.com... >I do not want the calling form code to proceed until the user makes a >choice > on frmX. > I do not want a modal form using vbModal because I cannot get past other > issues using a vbModal form. > > frmX.Show ' this opens the form > ' after the frmX _Load event execution continues here. > ' but I do not want it to be until the user makes a choice. > > So I put the loop in frmX to wait there until the choice is made. > > What way would you implement this? > > > > > "Karl E. Peterson" wrote: > >> Bee wrote: >> > I have seen this talked about but still not sure which is the correct >> > way to >> > do this. >> >> Do what, exactly? Won't the form just wait all by itself? >> >> -- >> ..NET: It's About Trust! >> http://vfred.mvps.org >> >> >> . >>
From: Helmut Meukel on 3 Mar 2010 19:46 "Bee" <Bee(a)discussions.microsoft.com> schrieb im Newsbeitrag news:3663D214-7D32-49D1-930D-1ACDC57511B3(a)microsoft.com... >I do not want the calling form code to proceed until the user makes a choice > on frmX. > I do not want a modal form using vbModal because I cannot get past other > issues using a vbModal form. > > frmX.Show ' this opens the form > ' after the frmX _Load event execution continues here. > ' but I do not want it to be until the user makes a choice. > > So I put the loop in frmX to wait there until the choice is made. > > What way would you implement this? > Break your code in two parts: 1) all code including the line frmX.Show ' this opens the form End Sub 2) the second part - processing the data from frmX put into a new Property Let routine of the calling form. Public Property Get X_Data(vData as Variant) ' here goes the code processing the Data from frmX End Property 3) in frmX: when the user has entered his data and clicks ok frmMain.X_Data = myNewData I used a Variant for this example, if there are more than one value use an array... Or instead of a Property use a Public Sub with all your values as parameters. With your idea of a loop you slow down the execution of the code in frmX. HTH, Helmut.
From: Bee on 3 Mar 2010 20:54 After I posted I tried doing just that in a .bas module to centralize the process since this routine gets called fro six different places and returns a parameter related to six different control properties. So ... Sleep is OK compared to CreateWaitableTimer? DoEvents has what negativness if not needed? I have nothing that needs real speed at this time in th eapp. Thanks "Karl E. Peterson" wrote: > Bee wrote: > > I do not want the calling form code to proceed until the user makes a choice > > on frmX. > > I do not want a modal form using vbModal because I cannot get past other > > issues using a vbModal form. > > Ahhhhh! I see. You want to "wait" the calling form. > > > frmX.Show ' this opens the form > > ' after the frmX _Load event execution continues here. > > ' but I do not want it to be until the user makes a choice. > > > > So I put the loop in frmX to wait there until the choice is made. > > > > What way would you implement this? > > I'd loop while the called form is visible, then query it's properties > (though which you'd return the result code[s]), and destroy it. > > Something like: > > frmX.Show > Do While frmX.Visible > DoEvents '<- only if needed, try without first > Sleep 20 > Loop > Result = frmX.CustomResultCode > Set frmX = Nothing > > Make sense? > > -- > ..NET: It's About Trust! > http://vfred.mvps.org > > > . >
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: Debugging Tricks : Going Blank Next: disable mdi form resize |