Results 1 to 6 of 6

Thread: variables parameters and API oh my!

  1. #1

    Thread Starter
    Hyperactive Member scuzymoto's Avatar
    Join Date
    Aug 1999
    Location
    Washington State
    Posts
    316
    I am attempting to use the cards.dll (as in solitare). I have it working just fine except this one small exception... When I attempt to use the declared API function cdtDraw it will only work if I pass it literal values... For Example

    This works great

    call cdtDraw(form1.hdc,1,1,1,1,1)

    However this next example raises an illegal operation error. It won't even jump to my error handler. Just kills the app and pops the application error window.

    dim nVariable As Integer
    nVariable = 1
    call cdtDraw(form1.hdc,1,1,nVariable,1,1)

    Im new to API, is there some kind of notation that I need to pass with the variable to get it not choke? The other wierd thing is that it works fine in debug mode. Its when I run the compiled exe that it wont accept anything but a literal value.

    [Edited by scuzymoto on 05-18-2000 at 02:17 PM]
    SCUZ

  2. #2
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    Can I see the Declaration of your function.

  3. #3

    Thread Starter
    Hyperactive Member scuzymoto's Avatar
    Join Date
    Aug 1999
    Location
    Washington State
    Posts
    316
    Here ya go... Thanks for your help.

    Code:
    Public Declare Function cdtInit Lib "cards.DLL" _     
        (ByRef nWidth As Integer, ByRef nHeight As Integer) As Integer
    Public Declare Function cdtDraw Lib "cards.DLL" _
        (ByVal hDC As Long, ByVal xOrg As Integer, _
         ByVal yOrg As Integer, ByVal nCard As Byte, _
         ByVal nDraw As Byte, ByVal nColor As Integer) As Integer
    Public Declare Function cdtTerm Lib "cards.DLL" () As Integer
    I also tried it with integers instead of bytes on the cdtDraw Function...

    [Edited by scuzymoto on 05-18-2000 at 02:16 PM]
    SCUZ

  4. #4
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    Squeek, I can't see anything wrong trhere, try declaring nVariable as a byte, otherwise I can't think of anything. Where did you find out about using the DLLs?

  5. #5

    Thread Starter
    Hyperactive Member scuzymoto's Avatar
    Join Date
    Aug 1999
    Location
    Washington State
    Posts
    316
    Unfortunately I tried all kinds of mixtures of data types and it all boils down to the API won't accept anything but a literal (when compiled that is, it works like a dream in debug mode).

    However not to be conquered I spent an hour or so making an if elseif statement as long as your arm last night to get around it so that I wouldn't have to use variables. Sloppy programming and all that but it works. 52 lines of if then statments for every card. If ya can't beat 'em join 'em right.

    In answer to your other question. I learned about the exportable functions of the cards.dll (has to be the 32 bit version by the way... the one that ships with 95 won't work with VB) on the microsoft website. Ill include the link. It was designed for C++ but I figured it should be able to port over to VB. And it did.... kinda. Anyway thanks for your help.

    http://www.microsoft.com/devonly/MAG...0396/games.htm
    SCUZ

  6. #6
    Lively Member
    Join Date
    Apr 2000
    Location
    Hell
    Posts
    89
    Rule #1 for y'all: Win32 API functions all have Long parameters, and return Long values. If anybody here remembers doing API in VB 3.0, they know that the 16-bit SendMessage() function had an Integer value for the wParam parameter (the W is for Word, an unsigned integer). However, the 32-bit SendMessage() function has a Long value for the wParam parameter. This is because 32-bit functions all have 32-bit parameters. You can usually get away with using integers and bytes, because VB will convert for you, but it's not a good idea.

    Secondly...are you running NT?
    - Steve

    Real programmers use COPY CON PROGRAM.EXE

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width