home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
mltwin.zip
/
READ.ME
< prev
next >
Wrap
Text File
|
1992-10-06
|
3KB
|
90 lines
SUMMARY. Gpf generated code normally creates 1 window instance
for 1 class. It allows access to every window through hwndXXXX
and hwndFrameXXXX static variables(XXXX is the window name).
When necessary, it is very simple to work with multiple
instances of a window class in Gpf generated code.
To create a new instance you must call the CreateXXXX Gpf
generated function from a user function. After this you must be
careful if you use the hwndXXXX and hwndFrameXXXX statics. They
are correct only for the most recently created window. These
statics are only valid during the, possibly short, time after a
window instance is created and before another window is created
or destroyed. To access these windows it is more correct to use
the GpfParms structure attached to the window. This structure
is created and updated by Gpf generated code for the current
window.
Not quite as straightforward is how to destroy the current
window within a Gpf generated application. In most cases you
wouldn't need to destroy any window. Normally modal windows are
created and destroyed as they are shown and dismissed
respectively and modeless windows, complete with all controls
and data, exist from when they are created until the program
ends. In the case of multiple instances of the same window, it
is more likely you would want to destroy an instance when its
work is done. The problem is that you can't call the
WinDestroyWindow API directly from user code attached to the
current window. This will cause a protection violation because
GpfParms contains a return field called mresult which is updated
by the current window procedure. Unfortunately, destroying
window will destroy the attached information (including
GpfParms). This is easily overcome as long as you are aware of
it. You simply call the WinDestroyWindow API from another
window; i.e. from a user function attached to another window.
The following example demonstrates one such solution:
EXAMPLE. This example demonstrates how to destroy windows with
WinDestroyWindow and how to make multiple windows.
Configuration:
MULTWIN.ORC:
window MainWindow with Button1 'Create next copy' window
MultWindow with Button2 'Destroy me'
UFMULTW.C
userFunction UFSelfDestruct - sends WM_USER_DESTROY message
to MainWindow
userFunction UFMultDestroy - received WM_USER_DESTROY message and
destroys window
userFunction UFCreateMultWindow - calls CreateMultWindow, generated
by Gpf.
UFMULTW.H
userFunction descriptions
ACTIONS: in window MainWindow:
on Click Button1
userFunction UFCreateMultWindow
Shell Position MultWindow
Show window MultWindow
on UserMessage
userFunction UFMultDestroy
in window MultWindow:
on Click Button2
userFunction UFSelfDestruct