Page 1 of 1
How can I call external 2 DLL files in my prog?*Successful*
Posted: Tue Nov 29, 2005 6:51 am
by dutch
Dear All,
I've used our 2 DLL files. How can I register or load in program and switch to use Dialog in 2nd Resource file (DLL)? I've used in FW16bits but I don't know how to use with xHB/FWH 2.5.
Thanks in advance,
Dutch
Posted: Tue Nov 29, 2005 6:39 pm
by Antonio Linares
Dutch,
You may select one of the DLLs doing a:
SET RESOURCES TO "name_dll"
before using resources from it.
It doesn't work with the same code FW and FWH
Posted: Tue Nov 29, 2005 7:05 pm
by dutch
Dear Antonio,
This is my code is following and it've shown below message on EntryScr procedure.
** Fivewin Error/3 Cannot Create Dialog **
//---------------//
Function Main
Public hResc
hResc := LoadLibrary( "BWCC32.dll" ) // new fwh
SET RESOURCES TO "EZ4SCR.DLL" // new fwh
SET RESOURCES TO "EZ4.DLL" // new fwh
BWCCRegister( GetResources() ) // new fwh
...
...
return
//----------------//
Function EntryScr
SET RESOURCES TO "EZ4SCR.DLL"
DEFINE DIALOG oDlg RESOURCE 'RSFIELDS' TITLE 'In House List'
..
..
ACTIVATE DIALOG oDlg ON PAINT (SetResources( MEMVAR->hResc ))
return
Regards,
Dutch
Posted: Tue Nov 29, 2005 9:55 pm
by Antonio Linares
Dutch,
Try this:
Function EntryScr
SET RESOURCES TO "EZ4SCR.DLL"
BWCCRegister( GetResources() ) // again
Posted: Wed Nov 30, 2005 12:28 am
by Rick Lipkin
Dutch
Just curious why you have two .dll's ... If you are creating your .dll's from .rc you can combine all your .rc's into one single .rc and then import them into a single .dll
I have modified rc2dll32.bat file as follows:
rem RC file to 32 bits resources DLL
rem syntax: rc2dll32.bat Your_rc_file !!! without the .RC extension
DEL VEH32.DLL
DEL VEH32.RC
: combine all .rc into a single .rc
COPY *.RC VEH32.RC
bcc32 -c c:\fwh26\dll\screen32.c
brc32 -r %1.rc
ilink32 /Tpd c:\borland\lib\c0d32.obj screen32.obj, %1.dll,,c:\borland\lib\cw32.lib c:\borland\lib\import32.lib,, %1.res
echo done!
Rick Lipkin
SC Dept of Health, USA
Thanks
Posted: Wed Nov 30, 2005 3:31 am
by dutch
Dear Rick,
The 1st DLL (Convert to RC) file is our fixed entry screen (unmodification for user) and 2nd DLL is user modification entry screen (Booking screen) for each customer site. I compile my first DLL (RC) file to EXE file and 2nd will be able to modify (custom screen without changing source code) for customer need. Why has it 2 DLL files.
****************
Dear Antonio,
It has another problem is the program does not focus to the main resource (1st RC file) when exit from 2nd DLL. I try to do exit EZ4SCR.DLL and focus to EZ4.RC as following but it didn't work.
//--------------------//
Function EntryScr
local hDLL := SETRESOURCES("EZ4SCR.DLL")
BWCCRegister( GetResources() )
DEFINE DIALOG oDlg RESOURCE "RSFIELDS"
ACTIVATE DIALOG oDlg ON PAINT (FreeLibrary( hDLL), SetResource( MEMVAR->hResc ))
return
How can I tell the program to focus at 1 RC file?
Thanks&Regards,
Dutch
Posted: Wed Nov 30, 2005 9:10 am
by Antonio Linares
Dutch,
Are you using Borland controls in both DLLs ?
Was it working on 16 bits ?
It works on FW16bits
Posted: Wed Nov 30, 2005 11:57 am
by dutch
Dear Antonio,
Yes, I've used Borland Control and it works in FW16bit. The 1st RC file is the same name of EXE file and the 2nd DLL is custom entry screen. This is my FW16 bits code
Example
=======
Static hResc
****************
Function main()
hResc := GetResources()
SET RESOURCES TO ("SECOND.DLL")
SET RESOURCES TO ("BWCC.DLL")
SetResource( hResc )
..
*************
Function Scr
Set Resource To "SECOND.DLL"
DEFINE DIALOG ...
ACTIVATE DIALOG ... ON PAINT SetResources( hResc )
return
Regards,
Dutch
Posted: Wed Nov 30, 2005 6:27 pm
by Antonio Linares
Dutch,
Maybe un 32 bits you have to FreeLibrary() the BWCC32.dll before registering it again. Please try it, thanks.
2 DLL files load is working
Posted: Wed Nov 30, 2005 7:04 pm
by dutch
Dear Antonio,
It works if I use all in DLL files as below. But it didn't work if I use main resource as RC file. How can I load default (main) RC file as this cause.
ACTIVATE DIALOG oDlg ;
ON PAINT (SetResources("EZ4.DLL"), BWCCRegister( GetResources() ))
This code is working but can I do my case?
//---------------//
Function Main
Public hResc
hResc := LoadLibrary( "BWCC32.dll" ) // new fwh
SET RESOURCES TO "EZ4SCR.DLL" // new fwh
SET RESOURCES TO "EZ4.DLL" // new fwh
BWCCRegister( GetResources() ) // new fwh
...
...
return
//----------------//
Function EntryScr
SET RESOURCES TO "EZ4SCR.DLL"
DEFINE DIALOG oDlg RESOURCE 'RSFIELDS' TITLE 'In House List'
..
..
ACTIVATE DIALOG oDlg ;
ON PAINT (SetResources("EZ4.DLL"), BWCCRegister( GetResources() ))
return
Best regards,
Dutch
Posted: Wed Nov 30, 2005 7:19 pm
by Antonio Linares
Dutch,
This code is dangerous:
ON PAINT (SetResources("EZ4.DLL"), BWCCRegister( GetResources() ))
as ON PAINT gets called many times. You should better do it from the ON INIT clause or use the <oDlg>:bStart codeblock, that it is evaluated just once.
Can I use EZ4.RC file instead of EZ4.DLL?
Posted: Thu Dec 01, 2005 3:25 am
by dutch
Dear Antonio,
Can I load from default RC (same name with EXE file) instead of DLL? Because I want to include RC in EXE and distribute one DLL only but I don't know how to recall default RC file.
Best regards,
Dutch
Posted: Thu Dec 01, 2005 9:21 am
by Antonio Linares
Dutch,
Yes. FWH will look in the EXE by default. In order to use a DLL you do a SET RESOURCES TO "name.dll" and when you are ready with it, then you do SET RESOURCES TO, so FWH will search again in the EXE.
Please try it this way.
Thanks a lot
Posted: Thu Dec 01, 2005 9:52 am
by dutch
Dear Antonio,
It works now.
Thanks for big help,
Dutch