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

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

Postby dutch » Tue Nov 29, 2005 6:51 am

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

Postby Antonio Linares » Tue Nov 29, 2005 6:39 pm

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

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

Postby dutch » Tue Nov 29, 2005 7:05 pm

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

Postby Antonio Linares » Tue Nov 29, 2005 9:55 pm

Dutch,

Try this:

Function EntryScr

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41439
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Rick Lipkin » Wed Nov 30, 2005 12:28 am

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
Rick Lipkin
 
Posts: 2638
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Thanks

Postby dutch » Wed Nov 30, 2005 3:31 am

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

Postby Antonio Linares » Wed Nov 30, 2005 9:10 am

Dutch,

Are you using Borland controls in both DLLs ?

Was it working on 16 bits ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41439
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

It works on FW16bits

Postby dutch » Wed Nov 30, 2005 11:57 am

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

Postby Antonio Linares » Wed Nov 30, 2005 6:27 pm

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

2 DLL files load is working

Postby dutch » Wed Nov 30, 2005 7:04 pm

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

Postby Antonio Linares » Wed Nov 30, 2005 7:19 pm

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

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

Postby dutch » Thu Dec 01, 2005 3:25 am

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

Postby Antonio Linares » Thu Dec 01, 2005 9:21 am

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

Thanks a lot

Postby dutch » Thu Dec 01, 2005 9:52 am

Dear Antonio,

It works now.

Thanks for big help,
Dutch
User avatar
dutch
 
Posts: 1535
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Otto and 41 guests