Previous Thread
Next Thread
Print Thread
Rate Thread
Urgent! Any expert, please help - reference to other form! #17515
12/23/03 02:25 AM
12/23/03 02:25 AM
Joined: Dec 2003
Posts: 2
A
AskProf Offline OP
Junior Member
AskProf  Offline OP
Junior Member
A

Joined: Dec 2003
Posts: 2
Hello, All:

Recently I have been annoyed by the following question very much. It will be highly appreciated if anyone could help me!

I want to refer to some properties or controls in another form while I don't want to declare too much public variables.

For example, in module1, I want to get hwnd of frmMain:

hwnd = frmMain.hwnd

Here is my question:

When call the properties or control outside a form through the form name,

1. the event Form_Load (or Form_Initialize) will also be triggered in some projects;
2. while in some other projects, Form_Load (or Form_Initialize) will not be triggered and I can call it just as a variable.

In which cases Form_Load will be triggered and in which not?

Please help me!!! Thank you very much!

Re: Urgent! Any expert, please help - reference to other form! #17516
12/23/03 05:42 AM
12/23/03 05:42 AM
Joined: Mar 2002
Posts: 1,273
OH, USA
SilentRage Offline
DollarDNS Owner
SilentRage  Offline
DollarDNS Owner

Joined: Mar 2002
Posts: 1,273
OH, USA
When calling a public variable or property of a unloaded form:

1) That form's Form_Load event is called
2) The public variable or property is accessed

In that order. This always happens - and the form is not displayed. It won't be displayed until you call the form's show event or set the visible property to true. It is impossible to call those members of the form without first loading it.

Modules are the preferred choice. Modules are loaded when they are accessed and they stay loaded for the rest of that program's execution.


Domain Registration, Hosting, Management
http://www.dollardns.net
Re: Urgent! Any expert, please help - reference to other form! #17517
12/23/03 06:54 AM
12/23/03 06:54 AM
Joined: Dec 2003
Posts: 2
A
AskProf Offline OP
Junior Member
AskProf  Offline OP
Junior Member
A

Joined: Dec 2003
Posts: 2
Hello, SilentRage:

Thank you very much!

But the case I encountered is that:

'frmMain' has finished loading. In the course of running, I need to call another procedure and in this procedure I will access some properties of frmMain. 'frmMain' remains displayed and loaded. Anyway the Form_Load in frmMain is triggered again (but in some other similar projects will not).

Re: Urgent! Any expert, please help - reference to other form! #17518
12/28/03 02:09 AM
12/28/03 02:09 AM
Joined: Mar 2002
Posts: 1,273
OH, USA
SilentRage Offline
DollarDNS Owner
SilentRage  Offline
DollarDNS Owner

Joined: Mar 2002
Posts: 1,273
OH, USA
Form_Load will only be triggered multiple times if they are explicitly called in the code, or if you are loading duplicate forms like if you declare a variable as that form and play with it, or if the form is unloaded at any point (user presses the 'X' or the Unload method is called on it).


Domain Registration, Hosting, Management
http://www.dollardns.net

Member Spotlight
None yet
Show All Member Profiles 
Forum Statistics
Forums41
Topics33,680
Posts68,696
Average Daily Posts0
Members2,171
Most Online2,867
Nov 14th, 2019
Latest Postings
Animation,
by JohanKaariainen. 08/15/19 12:18 AM
Top Posters(All Time)
UGN Security 41,392
Gremelin 7,203
§intå× 3,255
SilentRage 1,273
Ice 1,146
pergesu 1,136
Infinite 1,041
jonconley 955
Girlie 908
unreal 860
Top Liked Users (All Time)
§intå× Likes: 3
Black Beard Likes: 1
Cold Sunn Likes: 1
Crime Likes: 1
Cyrez Likes: 1
Dartur Likes: 1
fleshwound Likes: 1
Ghost Likes: 2
Girlie Likes: 1
Gremelin Likes: 14
Powered by UBB.threads™ PHP Forum Software 7.7.0