OVERVIEW
This libary is meant to be a way for code compiled into a DLL to use the instance of Win32Lib included in a main application. It was developed using Win32Lib v0.59.1. Other versions might work, but using a different version of Win32Lib is done at your own risk.
LICENSE AND DISCLAIMER
This software is freeware, but you must give me credit for any applications developed with WinDLL. You can modify any of the code, so long as you do not take credit for any of the original source, and any modifications must be marked as such.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFIT; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Topic | Description |
Index | Alphabetical list of all items. |
Demo | A simple example |
DLL | How to write the DLL |
Main Program | How to use this from your application |
The included demo is a very simple example of how to use this library. The main program, mainapp.exw, opens a window and connects to the DLL, testdll.dll. The DLL was built using the unregistered version of the Euphoria to C translator, so you'll have to wait for the built-in delay to go away before the DLL actually does anything.
Once the delay is gone, the DLL will create a button in the window, and will pop up a message box when the button is clicked. You will notice in testdll.ew (the source for the DLL) that the creation is actually done within a procedure that is called by mainapp.exw in its main window's w32Activate event. It is important to not have any Win32Lib calls at the top level of your DLL code, because this will be executed when open_dll() is called, before it has become aware of Win32Lib.
The code for the DLL is very simple. There are only two include files, windll_c.ew and msgbox.e. windll_c.ew is the interface between your DLL and the instance of Win32Lib contained within your main program. You can call and use all of the global routines contained within Win32Lib v0.59.1 as you would if you had included Win32Lib.ew, instead of windll_c.ew.
You will be able to write the code for the DLL almost as though Win32Lib were included in the project. There are some important things to remember. First, you'll need to use the retrieve() function in order to get any control ids from your main program. You'll need to move all Win32Lib calls into functions or procedures. Top level statements are executed when your main program calls open_dll(), which is before the call to register_dll(). You'll probably want to have some sort of an initializing routine that your main program can call. At current, the only constants defined for you are the control names (Window, PushButton, etc.) and the events (w32HEvent, w32HClick, etc.).
In order to allow a DLL to access your application's instance of Win32Lib, there are two things you need to do. First is to call open_dll() to open the DLL, and pass the handle to register_dll(). Then you can publish() data, such as the id's of key controls and windows so that the DLL can operate as though it were included in your main program.
This is how you communicate information to all DLL's that are registered. It is an easy way to pass the control id's contained within your program.
ex: -- Main program main = create( Window, "The Main Window", 0, 100, 100, 500, 300, 0 ) publish( "main", main )-- From the DLL... main = retrieve( "main" )
See Also: register_dll
This function sets up communication between your main application and the DLL. handle is the value returned by open_dll(). register_dll() returns 1 if successful, and 0 if unsuccessful.
See Also: publish
This function is meant to be an easy way to pass data from your main application to the DLL. From within the DLL, you can get any data that the main program has publish()'ed by passing the same key that the main program used.
] proc
] Communicates between your program and your DLLfunc
] Initializes the connection between your program and your DLLfunc
] Get data from the main program for use in the DLL