cards(32).dll with Borland C++ Builder

hi guys, 200 points on offer, with a guaranteed A grade, but only for an exact answer - near misses don't even get a cigar.

I want to use cards.dll or cards32.dll in Borland C++ Builder. I found a bunch of stuff for Visual Basic but, while it gives me an idea, its not what I want.

I think that I will need to use cards32.dll, unless anyone knows better.

To get the points, I will accept your existing code, but would prefer a brand new project, since its less for me to weed through. This new project ought to initialise all necessary libraries, etc and display 3 cards - any 2 aces and the back of a card. I can figure out the rest from there; I'm just having problems initializing things.

Th.. Th.. Th.. That's all folks.  I would puzzle it through myself, but I'm short of time & loaded with points.

And, please don't forget, Borland C++ Builder.
LVL 6
graham_kAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

graham_kAuthor Commented:
Edited text of question.
0
AlexVirochovskyCommented:
1. You can't use cards.dll, becouse
it is 16b DLL.
2. For using cards32.dll
Francesco D'Inzeo prepose next:
You open in BC++ 5.02 the file "cards32.dll"
You will find tha it is a resource dll so you can save it within BC++ 5.02
as "cards.res",
reopen always with BC++ 5.02 the file "cards.res", remove the
Versioninfo
resource
and save it.
Then open your BCB project and add "cards.res" to it.
Now You don't have to deal anymore with "cards.dll" because the bitmap
are linked in Your executable.

I can't test it(i haven't cards32.dll),
but you can make it!
Alex
0
AlexVirochovskyCommented:
O, i have an idea(but a bit boring):
With help of BC5/workshop you
can extract all bitmaps(~ 78) from
cards.dll/cards32.dll. Every extruction ~ 1.5 min. If you really
want it , you can make it in 2 hours!
0
Introduction to Web Design

Develop a strong foundation and understanding of web design by learning HTML, CSS, and additional tools to help you develop your own website.

graham_kAuthor Commented:
hi Alex,

o.k, I can see how to extract the bitmaps (don't see the version info, but don't think that I want it). I can add the cards32.res to my BCB project, but how dow I then display the bitmaps?

Sorry if I sound stupid, but I didn't do any of this before. Most of my progs don't have a gui & those that do use standard BCB components.
0
AlexVirochovskyCommented:
For display bitmap from resource
file you can use(for example for
TImage):
 Image1->Picture->Bitmap->
LoadFromResourceId(0, IdBitmap);
IdBitmap = 1,2,...52 for cards and
53,..68 for back side.
Alex
0
luisrCommented:
I would try to reimplement it instead of using cards32.dll because it is not redistributable and some computers may not have it. As someone said before, extract the bitmaps, add them to your project and just draw them. I once disassembled the 16-bit cards.dll and if I can remember well, it only contained 5 functions:

cdtInit - initialize the library, and get card size
cdtDraw - draw a card on a device context
cdtDrawExt - draw a card on a device context, stretching it
cdtTerm - deinitialize the library
cdtAnimate - animates some card backs (for example the controls in the robot)

It is not so hard to develop a clone for it, and if you can, I'd highly recommend you do it.
0
chensuCommented:
Deal Me In (Visual Basic Information)
http://msdn.microsoft.com/isapi/msdnlib.idc?theURL=/library/books/hcvb/dealmein.htm

You probably have been there.

If you are not going to use cards32.dll, you might want to take a look at the following sample, from which you can extract what you need.

Card: Windowless ActiveX Control
http://msdn.microsoft.com/library/devprods/vs6/visualc/vcsample/vcsmpcardwindowlessactivexcontrol.htm
0
graham_kAuthor Commented:
hi Alex,

  your suggestion sounds best so far, but it still crashes.  Like I said at the start, I'll give the points at grade A to anyone who posts a mickey mouse program to display 2 or 3 cards.
0
AlexVirochovskyCommented:
grapham_k, i can extract BMP
from cards.dll , write .res file and write/test full code
of using it, but it demands from me 2
hours hard job(after my main job)!
I can make it, but how many PTS you can give for that?
0
chensuCommented:
Why don't you use the readymade class that comes with the sample "Card: Windowless ActiveX Control"?
0
chensuCommented:
And I did write a simple class to do it three years ago.

class CCards
{
    public:
        enum suit { club, diamond, heart, spade };
        enum card { ace = 1, two, three, four, five, six, seven, eight,
                    nine, ten, jack, queen, king };
       
        enum { BMP_WIDTH = 71, BMP_HEIGHT = 96 };
       
       
        CCards();
        ~CCards();
       
        BOOL Put(CDC *pdc, int nx, int ny, suit eSuit, card eCard);
   
    private:
        enum { MAXCARDNUM = king - ace + 1 };
        enum { IDB_MASK = 100 };
       
       
        HINSTANCE m_hDLLInst;
        HBITMAP m_hBmpMask;
};

Actually, it is very easy. The put function just displays the card bitmap transparently using a monochrome mask.
0
graham_kAuthor Commented:
Alex,

  I have already extracted the bitmaps & created a .RES file (5 minutes, tops). I believe that you have already given me 70% of the  solution, with LoadFromResourceID(), but now you are just becoming greedy. If 200 points at grade A aren't enough, just forget it. I will play about with it myself, after I finish my job; I'll just rearrange some priorities & code that instead of something else.

Chensu - yours sounds good & I will give it a try when I get hoem tonight. How do I position the cards ?
0
graham_kAuthor Commented:
Alex,

  I have already extracted the bitmaps & created a .RES file (5 minutes, tops). I believe that you have already given me 70% of the  solution, with LoadFromResourceID(), but now you are just becoming greedy. If 200 points at grade A aren't enough, just forget it. I will play about with it myself, after I finish my job; I'll just rearrange some priorities & code that instead of something else.

Chensu - yours sounds good & I will give it a try when I get home tonight. How do I position the cards ?
0
AlexVirochovskyCommented:
graham, it is very interresting,how
you extract 78 Bitmaps in 5 min?
You use some tool or you hands work faster that mine?
0
chensuCommented:
I can post my MFC code here. Or I can adapt it to non-MFC if you are going to accept my answer. But why don't you download the sample I mentioned? It is non-MFC. It implements the following class.

//=--------------------------------------------------------------------------=
// CardDraw.Cpp
//=--------------------------------------------------------------------------=
// Copyright 1996 - 1997 Microsoft Corporation.  All Rights Reserved.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//=--------------------------------------------------------------------------=
//
//

class CCardDraw {
      public:
            CCardDraw( int number );
            ~CCardDraw();
            BOOL DrawCard( HDC hdcMem, int suite, int number );
            BOOL DrawCardBack( HDC hdcMem, int backnum );
            HBITMAP CreateDIBCard( HDC drawDc );

            // size of the card
            enum { CardSizeX = 71, CardSizeY = 96 };

            // constants to use in constructor
            enum { DrawBack = -1, DrawAll = 15 };

            // rect for filling in the card blank,
            // POINT array for drawing the border with PolyLine()
            static const POINT CardBorder[9];
            static const RECT CardRect;

      private:
            // DC's for drawing, Mem's hold old DC bitmap contents
            HDC symsDc, symsiDc;
            HBITMAP symsMem, symsiMem;
            HDC centerDc;
            HBITMAP centerMem;
            HDC jokerDc;
            HBITMAP jokerMem;

            // constants for locations of card elements
            enum { SymsSizeX = 73, SymsSizeY = 51 };

            enum { JokerCornerSizeY = 49, JokerCornerSizeX = 38 };
            enum { JokerCornerSrcX = 0, JokerCornerSrcY = 0 };
            enum { JokerCornerY = 5, JokerCornerX = 4 };
            enum { JokerCornerRectSX = 13, JokerCornerRectSY = 15 };
            enum { JokerCornerRectEX = 13, JokerCornerRectEY = 15 };

            enum { LargeSymSrcX = 9, LargeSymSrcY = 36 };
            enum { LargeSymSizeX = 15, LargeSymSizeY = 15 };

            enum { SmallSymSizeX = 9, SmallSymSizeY = 10 };
            enum { SmallSymSrcX = 38, SmallSymSrcY = 0 };
            enum { SmallSymY = 19 };

            enum { NumberSrcX = 12, NumberSrcY = 10 };
            enum { NumberSizeX = 9, NumberSizeY = 12 };
            enum { NumberY = 5 };

            enum { JokerSizeY = 63, JokerSizeX = 45 };
            enum { JokerY = 17, JokerX = 13 };

            enum { PictSizeY = 72, PictSizeX = 45 };
             enum { PictY = 11, PictX = 12 };

};

Download it and use the carddraw.h and carddraw.cpp. Take a look at the Res directory, and you will find your DLL will be much smaller.
0
graham_kAuthor Commented:
well, Alex, I finally got something running. Maybe not exactly what I want, but I can figure it out from there.

Since you didn't give me exactly what I asked for, you can have either 100 points at grade A or 200 at grade C. Post an answer, saying which you prefer.

Chensu, since you did so much work, I'll give you 25 points at grade A. In fact, I didn't use any of  your stuff, but I realise that you put in a fair bit of effort & think that you deserve some reward.

Thanks again both of you.
0
AlexVirochovskyCommented:
graham,i think more fast , if i submit this Q, than wait an other.
Thanks, abd i am very glad, that if not to 100%,but to 70% i have helped you.
Alex
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
graham_kAuthor Commented:
thanks again for your help, Alex.

Oh, what the hell, it doesn't cost me more to give you A than C. So, I will give you A anyway (but I don't like it when people ask for more points).
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.