Results 1 to 5 of 5

Thread: vb6 bad dll calling convention 49

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2017

    vb6 bad dll calling convention 49

    Good Morning,
    I need help with the error: "vb6 bad dll calling convention 49", I have tried anyway but the error persists.
    The statement with error is this:
    Private Declare Function litePDF_AddPage Lib "litePDF.dll" (ByVal pctx As Long, ByVal width_u As Long, ByVal height_u As Long, ByVal width_px As Long, ByVal height_px As Long, ByVal drawFlags As Long) As Long

    HDC __stdcall LITEPDF_PUBLIC litePDF_AddPage(void *pctx, unsigned int width_u, unsigned int height_u, unsigned int width_px, unsigned int height_px, unsigned int drawFlags);


  2. #2
    Frenzied Member gibra's Avatar
    Join Date
    Oct 2009

    Re: vb6 bad dll calling convention 49

    Your VBP project refer to a OCX (AXC-2054.ocx).

    However, what'is the goal of this project/dll ?

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2017

    Re: vb6 bad dll calling convention 49

    I need to generate a PDF from GDI commands.
    Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
    Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As Long) As Long
    Private Declare Function DrawTextEx Lib "user32" Alias "DrawTextExA" (ByVal hDC As Long, ByVal lpsz As String, ByVal n As Long, lpRect As RECT, ByVal As As Long, lpDrawTextParams As DRAWTEXTPARAMS) As Long
    Private Declare Function Ellipse Lib "gdi32" Alias "Ellipse" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long

    Attached project without the ocx.


  4. #4
    Join Date
    Jun 2013

    Re: vb6 bad dll calling convention 49

    Could you show VB6-code, how you currently generate your "printed Pages" (whilst using the above GDI-APIs)?

    Just a short to midsized example for a "typical page" you print would be enough
    (if possible in a fully working Demo-Project, which you upload into the Forum)?

    Last edited by Schmidt; Jan 12th, 2018 at 09:00 PM.

  5. #5
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Beside Waldo

    Re: vb6 bad dll calling convention 49

    Got some of your DLL working. Here is what I've changed and you might want to replicate this and test it further....

    In your bas module, replace teste() with this
    Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal length As Long)
    Private Declare Function lstrlen Lib "kernel32.dll" (ByVal lpString As Long) As Long
    Public Sub teste(ByVal Code As Long, ByVal Msg As Long, ByVal UserData As Long)
        Dim lSize As Long, bData() As Byte
        lSize = lstrlen(Msg)
        ReDim bData(0 To lSize - 1)
        CopyMemory bData(0), ByVal Msg, lSize
        Debug.Print "error "; Code; Msg, UserData
        Debug.Print vbTab; StrConv(bData(), vbUnicode)
    End Sub
    At least your error goes away and the errors returned in that callback subroutine helps identify why specific DLL calls are failing.

    Edited. Here is some sample code I used to create a simple test pdf. Note. You'll need to finish creating your API declarations for the DLL functions. In the code below, for the test, I whipped up: litePDF_CreateMemDocument & litePDF_SaveToFile. Also included these common APIs for the test: SendMessage & SelectObject
    Private Sub Command1_Click()
    Dim pctx As Long
    Dim m_hdc As Long
    Dim hFont As Long
        pctx = litePDF_CreateContext(AddressOf teste, 1962&)
        litePDF_CreateMemDocument pctx
        m_hdc = litePDF_AddPage(pctx, ScaleX(800, vbPixels, vbMillimeters), ScaleX(800, vbPixels, vbMillimeters), 800, 800, 0)
        'hdc function
        hFont = SelectObject(m_hdc, SendMessage(Me.hwnd, WM_GETFONT, 0, ByVal 0&))
        TextOut m_hdc, 50, 50, "Now is the time for all good men to come the aid of their country.", 66
        SelectObject m_hdc, hFont
        litePDF_FinishPage pctx, m_hdc
        litePDF_SaveToFile pctx, App.Path & "\teste_lv.pdf"
        litePDF_Close pctx
        litePDF_FreeContext pctx
    End Sub
    Also note that litePDF_AddPage expects measurements in the the context's units. Per your .h file, the default is millimeters; hence the ScaleX() calls in the code above.
    Last edited by LaVolpe; Jan 12th, 2018 at 08:08 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online

    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

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