Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.basic.visual.misc > #2144
| From | GS <gs@somewhere.net> |
|---|---|
| Newsgroups | comp.lang.basic.visual.misc, microsoft.public.vb.general.discussion |
| Subject | Re: Win8 & VB6 |
| Date | 2014-08-29 05:37 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <ltphka$n69$1@dont-email.me> (permalink) |
| References | <lto8fv$jna$1@dont-email.me> <20140829095319.000000c1@albasani.net> |
Cross-posted to 2 groups.
>>> On Thu, 28 Aug 2014 17:55:08 -0400 >>> (comp.lang.basic.visual.misc,microsoft.public.vb.general.discussion) >>> <lto8fv$jna$1@dont-email.me> >>> GS <gs@somewhere.net> wrote: > >> Does anyone have any idea why \win8 throws an error? > > when the load event fires, you aren't guaranteed that all the > controls on the form have already been drawn and in some cases the > setfocus throws an error so it's common practice moving the > "setfocus" into the "Activate" event; to avoid repeating the setfocus > over and over just add a static boolean variable and use it as a > semaphore; for example > > Sub Form_Activate() > Static bFirstTime As Boolean > > If Not bFirstTime Then > bFirstTime = True > txtLicenseKey.SetFocus > End If > End Sub Thank you.., that's a great idea! As it happens, the code is about 10 years old but the Form has been revised from a multi-use component to a dedicated one. That means my concern for repeating SetFocus in this case is now mute. When the Form was multi-use I was managing 'pages' using frame controls and a 'ShowPage' routine. Each 'page' was used in a specific 'AppMode' state which was checked each time the form was loaded. (No multi-instancing) I use the same code and form design in my VBA projects and so is why the OERN statement persisted. VBA uses an _Initialize event (instead of _Load) and so behaves differently in that SetFocus works without error. Now that I have recently made identical frm components for both VB6/VBA projects, I can update the component code specific to each. Both still use the same .bas component and so are named the same in either project environment. Initially, both VB6/VBA projects used the same component for app startup where my VBA projects use a VB6.exe 'frontloader' to load the VBA project into an automated instance of MSO Excel. In the VB6 apps the user could always enter a LicenseKey at runtime (when LicenseStatus = TrialVer) as well as during startup. The VBA apps (inconveniently) could only do this during startup (via the frontloader) until recently when I added a MSO Userform duplicate of the VB6 Form. Both use the presence of a value stored in the 'app.ini' file to determine license 'state'; a blank value sets LicenseStatus to 0 (TrialVer), and a non-blank value sets to 1 (Licensed). The ini file gets read at startup in InitGlobals(), and so this now happens twice with VBA projects. Both can reset this during runtime so next startup knows how to configure the workspace to hide the 'Register...' menuitem used to display the frm component. The VBA project does not check if it's licensed or not because the only way it runs is if its frontloader determines a valid LicenseStatus (ie: NOT 'Expired') -- Garry Free usenet access at http://www.eternal-september.org Classic VB Users Regroup! comp.lang.basic.visual.misc microsoft.public.vb.general.discussion
Back to comp.lang.basic.visual.misc | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Win8 & VB6 GS <gs@somewhere.net> - 2014-08-28 17:55 -0400
Re: Win8 & VB6 john@jeasonNoSpam.cix.co.uk (John K.Eason) - 2014-08-28 23:58 +0100
Re: Win8 & VB6 GS <gs@somewhere.net> - 2014-08-28 20:46 -0400
Re: Win8 & VB6 GS <gs@somewhere.net> - 2014-08-28 20:49 -0400
Re: Win8 & VB6 GS <gs@somewhere.net> - 2014-08-28 20:58 -0400
Re: Win8 & VB6 john@jeasonNoSpam.cix.co.uk (John K.Eason) - 2014-08-29 12:16 +0100
Re: Win8 & VB6 GS <gs@somewhere.net> - 2014-08-29 07:42 -0400
Re: Win8 & VB6 ObiWan <obiwan@mvps.org> - 2014-08-29 09:53 +0200
Re: Win8 & VB6 GS <gs@somewhere.net> - 2014-08-29 05:37 -0400
Re: Win8 & VB6 GS <gs@somewhere.net> - 2014-08-29 05:44 -0400
Re: Win8 & VB6 ObiWan <obiwan@mvps.org> - 2014-08-29 12:59 +0200
Re: Win8 & VB6 GS <gs@somewhere.net> - 2014-08-29 07:55 -0400
csiph-web