🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
7 messages
7 total messages Started by ScOe Mon, 24 Mar 2003 19:19
Resource dll
#17427
Author: ScOe
Date: Mon, 24 Mar 2003 19:19
21 lines
1744 bytes
I have one dll that will contain resource images ...
now i dont know did i made it in right way and how do i use it.
I made dll with dll wizard and include .rc file which contain something like
...
BACKGROUND BITMAP BCK.BMP
SNAKE BITMAP SNAKE.BMP
...
I tried two way of using them but with no luck ...
first way is simple:
SnakeImage = new Graphics::TBitmap ();
SnakeImage->LoadFromResourceName((int)HInstance, "SNAKE");

other way is
(HBITMAP)LoadImage(GetModuleHandle(NULL), "SNAKE", IMAGE_BITMAP, 0, 0,
LR_CREATEDIBSECTION);

Second way would be better couse i need HBITMAP result

I'm working on game ... and i'm not sure what should i use as main game loop
... do i need to make my own message handling loop or can i use OnIdle
(which i saw in some tutorial), Timer is not very useful.
Re: Resource dll
#17430
Author: Remy Lebeau (TeamB)
Date: Mon, 24 Mar 2003 20:13
40 lines
2065 bytes
"ScOe" <sven.savic@zg.hinet.hr> wrote in message
news:3e7f5a3a@newsgroups.borland.com...

> BACKGROUND BITMAP BCK.BMP
> SNAKE BITMAP SNAKE.BMP

How exactly did you define BACKGROUND and SNAKE?  Are they integers or
strings?  Are you using a .rh header file as well?

> SnakeImage->LoadFromResourceName((int)HInstance, "SNAKE");

Assuming you're calling that from within the application itself, you need to
use the HINSTANCE for the DLL itself, not the application.  Look at
LoadLibrary() in the Win32 API.

> (HBITMAP)LoadImage(GetModuleHandle(NULL), "SNAKE", IMAGE_BITMAP, 0, 0,
> LR_CREATEDIBSECTION);

GetModuleHandle() will return the instance of the application that loaded
your DLL, not for the DLL itself.

> Second way would be better couse i need HBITMAP result

Using TBitmap as in your first sample, the Handle property will contain the
HBITMAP.

> I'm working on game ... and i'm not sure what should i use as
> main game loop ...

That depends, what exactly are you trying to accomplish?

> Timer is not very useful.

Why not?  You need to be more specific when you say something doesn't work
for you.



Gambit
Re: Resource dll
#17434
Author: ScOe
Date: Mon, 24 Mar 2003 21:14
28 lines
2048 bytes
>
> How exactly did you define BACKGROUND and SNAKE?  Are they integers or
> strings?  Are you using a .rh header file as well?
>
As String ... I'm not using .rh ...
I've edited .rc file which i've include in .dll and that is all ... did i
miss something ? I'm using same thing in application and i didnt have
any problems ...

> Assuming you're calling that from within the application itself, you need
to
> use the HINSTANCE for the DLL itself, not the application.  Look at
> LoadLibrary() in the Win32 API.
Dll is staticaly attached to application ... is there any diferences ?
>
> Why not?  You need to be more specific when you say something doesn't work
> for you.
It is too slow ... i need to achive smoother character move ... and with 10
milisec i cant do it ..
character is constantly moving in some direction. On key down direction is
changing.
On higher level moving need to be faster ... and it seems that i cant achive
that with timer ... so i will need to use some kind of
user defined message loops, or something like that ...
>
> Gambit
>
>
Re: Resource dll
#17437
Author: Remy Lebeau (TeamB)
Date: Mon, 24 Mar 2003 22:05
49 lines
3039 bytes
"ScOe" <sven.savic@zg.hinet.hr> wrote in message
news:3e7f7554@newsgroups.borland.com...

> As String ...

You didn't show that in your original sample.  Please provide more complete,
compilable, examples in the future.

> I'm not using .rh ...

Why not?

> I've edited .rc file which i've include in .dll and that is all ... did i
> miss something ? I'm using same thing in application and i didnt have
> any problems ...

How did you create the DLL to begin with?

> Dll is staticaly attached to application ... is there any diferences ?

Yes.  You don't have direct access to the DLL's HINSTANCE when statically
linking.  Unless you use GetModuleHandle(), but I haven't tried that with
static custom DLLs myself before.  Should work, though.

In any case, you're passing NULL to GetModuleHandle() when you should be
passing the DLL's actual filename instead.  As previously mentioned, when
passing NULL to GetModuleHandle(), the returned HINSTANCE will be for the
application itself, not the DLL.  But your resources reside in the DLL, so
you need the DLL's HINSTANCE instead.  Just because you statically link does
not negate the fact that the resources are still stored in an external file,
not the application.  You do not statically link to the DLL directly, but
instead only to its .lib file, which provides a means for the compiler to
resolve address references to the DLL's functions and such, nothing else.
The DLL itself is not put into the application directly.

> i need to achive smoother character move ... and with 10
> milisec i cant do it .. character is constantly moving in some
> direction. On key down direction is changing. On higher
> level moving need to be faster ... and it seems that i cant
> achive that with timer ... so i will need to use some kind
> of user defined message loops, or something like that ...

Sounds like you need to use a separate dedicated thread instead and don't
use messages at all, just track the keyboard directly for changes and update
your animation accordingly.


Gambit
Re: Resource dll
#17460
Author: ScOe
Date: Tue, 25 Mar 2003 06:24
26 lines
1760 bytes
"Remy Lebeau (TeamB)" <gambit47@yahoo.com> wrote in message
news:3e7f7ecb$1@newsgroups.borland.com...
>
> "ScOe" <sven.savic@zg.hinet.hr> wrote in message
> news:3e7f7554@newsgroups.borland.com...
>
>
> You didn't show that in your original sample.  Please provide more
complete,
> compilable, examples in the future.
>
in .rc file i put line like this
BACKGROUND BITMAP BACK.BMP
Now i refer to background image as bmp->LoadFromResourceName (HInstance,
"BACKGROUND");
I understand what was you talked about HInstance, i'll try with
GetModuleHandle ...
>
> How did you create the DLL to begin with?
I've created it with dll wizard ... and all i did is include .rc to dll an
compile it, nothing else.
>
> Gambit
>
>
Re: Resource dll
#17461
Author: Remy Lebeau (TeamB)
Date: Tue, 25 Mar 2003 07:06
17 lines
1508 bytes
"ScOe" <sven.savic@zg.hinet.hr> wrote in message
news:3e7ff621@newsgroups.borland.com...
> in .rc file i put line like this
> BACKGROUND BITMAP BACK.BMP

You need to surround the third column in quotes:

    BACKGROUND BITMAP "BACK.BMP"

> I've created it with dll wizard ...

But, which one?  There are two DLL wizards - one that is for code DLLs, and
one that is for resource DLLs.  Are you using the second one?


Gambit
Re: Resource dll
#17405
Author: ScOe
Date: Wed, 26 Mar 2003 18:08
25 lines
1770 bytes
"Remy Lebeau (TeamB)" <gambit47@yahoo.com> wrote in message
news:3e7ffdb8@newsgroups.borland.com...
>
> "ScOe" <sven.savic@zg.hinet.hr> wrote in message
> news:3e7ff621@newsgroups.borland.com...
> > in .rc file i put line like this
> > BACKGROUND BITMAP BACK.BMP
>
> You need to surround the third column in quotes:
>
>     BACKGROUND BITMAP "BACK.BMP"
>
> > I've created it with dll wizard ...
>
> But, which one?  There are two DLL wizards - one that is for code DLLs,
and
> one that is for resource DLLs.  Are you using the second one?
>
I didnt understand how to use second one ... i thought that it was only for
language resources ...
>
> Gambit
>
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads