How can I call external 2 DLL files in my prog?*Successful*

Post Reply
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

How can I call external 2 DLL files in my prog?*Successful*

Post 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
Last edited by dutch on Thu Dec 01, 2005 9:53 am, edited 2 times in total.
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Dutch,

You may select one of the DLLs doing a:

SET RESOURCES TO "name_dll"

before using resources from it.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

It doesn't work with the same code FW and FWH

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Dutch,

Try this:

Function EntryScr

SET RESOURCES TO "EZ4SCR.DLL"
BWCCRegister( GetResources() ) // again
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Post 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
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Thanks

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Dutch,

Are you using Borland controls in both DLLs ?

Was it working on 16 bits ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

It works on FW16bits

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Dutch,

Maybe un 32 bits you have to FreeLibrary() the BWCC32.dll before registering it again. Please try it, thanks.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

2 DLL files load is working

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Can I use EZ4.RC file instead of EZ4.DLL?

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
dutch
Posts: 1395
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Thanks a lot

Post by dutch »

Dear Antonio,

It works now.

Thanks for big help,
Dutch
Post Reply