Announcement

Collapse
No announcement yet.

How to call an ActiveX dll (works with VB)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to call an ActiveX dll (works with VB)

    Not getting email about responses to this thread 6:31 AM Monday 8/17/09.

    Code:
    'How would this be used with early binding?
    'Late binding prints Action canceled.
    'Please go easy, this is my first attempt.
    'Also, nothing prints unless a MSGBOX is used at the end.
    'Get no errors.
    'Everything works using VB6.
    'Evaluation or DLL of ASP Printer can be downloaded at: http://www.vbgold.com/Downloads.shtml
     
    #DIM ALL
    #COMPILE EXE
    FUNCTION PBMAIN () AS LONG
     
      'Late binding prints Action canceled
      LOCAL suKey          AS STRING    'key must be unicode
      LOCAL sHTMLDocument AS STRING
      LOCAL obj AS IDISPATCH                                   'late binding
      LET obj = NEWCOM "ASPPrinterCOM.ASPPrinter"              'create object
      IF ISFALSE(ISOBJECT(obj)) THEN ? "object not created":EXIT FUNCTION
     
      suKey = UCODE$("ABC")                                     'not real key here
      OBJECT LET obj.key = suKey                               'key must be unicode
      IF OBJRESULT THEN ? "Error setting key " + OBJRESULT$:SET obj=NOTHING:EXIT FUNCTION
     
      REM sHTMLDocument = "c:\keep\test.html"
      sHTMLDocument = UCODE$("c:\keep\test.html")     'solution  8/17/09 11:11AM CST
      OBJECT CALL obj.PrintHTMLDocument(sHTMLDocument)
      IF OBJRESULT THEN ? "Error printing document" + OBJRESULT$
     
      ? "Why is this required for printer to allocate?"
      SET obj = NOTHING
    END FUNCTION
     
    ' Generated by: PowerBASIC COM Browser v.2.00.0071
    ' Date & Time : 8/16/2009 at 10:12 AM
    ' ------------------------------------------------
    ' Library Name: ASPPrinterCOM
    ' Library File: C:\aspprint\aspprint.dll
    ' Description : ASP Printer COM (VBGold Software)
    ' Help File : C:\aspprint\ASPPrinter.chm
    ' Help Context : 0
    ' GUID : {77050CAF-A874-4C12-9599-5004B5953CB7}
    ' LCID : 0
    ' Version : 7.0
    ' Version Dependent ProgID's
    $PROGID_ASPPrinterCOM_ASPPrinterASPPrinter = "ASPPrinterCOM.ASPPrinter"
    ' Class Indentifiers
    $CLSID_ASPPrinterCOM_ASPPrinter = GUID$("{48CB850F-41FF-4EE6-B87D-FB9EC26D193F}")
    $CLSID_ASPPrinterCOM_Event___ASPPrinter = GUID$("{3F26BC29-46B9-485C-BD01-E5E8A3F28BCF}")
    ' Interface Indentifiers
    $IID_ASPPrinterCOM_Int__ASPPrinter = GUID$("{5AE646E2-61A8-4EE8-A7A8-4156E2B803A1}")
    $IID_ASPPrinterCOM_Int___ASPPrinter = GUID$("{6DE00814-0515-4B89-96AE-FB24D4A2E2DF}")
    ' spOrientation enumeration
    %spOrientation_spOrientationPortrait = 1
    %spOrientation_spOrientationLandscape = 2
    ' spLineSpacing enumeration
    %spLineSpacing_spLineSpacingSingle = 1
    %spLineSpacing_spLineSpacingOneHalf = 2
    %spLineSpacing_spLineSpacingDouble = 3
    ' spPaperSize enumeration
    %spPaperSize_spPaperLetter = 1
    %spPaperSize_spPaperLetterSmall = 2
    %spPaperSize_spPaperTabloid = 3
    %spPaperSize_spPaperLedger = 4
    %spPaperSize_spPaperLegal = 5
    %spPaperSize_spPaperStatement = 6
    %spPaperSize_spPaperExecutive = 7
    %spPaperSize_spPaperA3 = 8
    %spPaperSize_spPaperA4 = 9
    %spPaperSize_spPaperA4Small = 10
    %spPaperSize_spPaperA5 = 11
    %spPaperSize_spPaperB4 = 12
    %spPaperSize_spPaperB5 = 13
    %spPaperSize_spPaperFolio = 14
    %spPaperSize_spPaperQuarto = 15
    %spPaperSize_spPaper10x14 = 16
    %spPaperSize_spPaper11x17 = 17
    %spPaperSize_spPaperNote = 18
    %spPaperSize_spPaperEnv9 = 19
    %spPaperSize_spPaperEnv10 = 20
    %spPaperSize_spPaperEnv11 = 21
    %spPaperSize_spPaperEnv12 = 22
    %spPaperSize_spPaperEnv14 = 23
    %spPaperSize_spPaperCSheet = 24
    %spPaperSize_spPaperDSheet = 25
    %spPaperSize_spPaperESheet = 26
    %spPaperSize_spPaperEnvDL = 27
    %spPaperSize_spPaperEnvC3 = 29
    %spPaperSize_spPaperEnvC4 = 30
    %spPaperSize_spPaperEnvC5 = 28
    %spPaperSize_spPaperEnvC6 = 31
    %spPaperSize_spPaperEnvC65 = 32
    %spPaperSize_spPaperEnvB4 = 33
    %spPaperSize_spPaperEnvB5 = 34
    %spPaperSize_spPaperEnvB6 = 35
    %spPaperSize_spPaperEnvItaly = 36
    %spPaperSize_spPaperEnvMonarch = 37
    %spPaperSize_spPaperEnvPersonal = 38
    %spPaperSize_spPaperFanfoldUS = 39
    %spPaperSize_spPaperFanfoldStdGerman = 40
    %spPaperSize_spPaperFanfoldLglGerman = 41
    ' spPrintQuality enumeration
    %spPrintQuality_spQualityDraft = 1
    %spPrintQuality_spQualityLow = 2
    %spPrintQuality_spQualityMedium = 3
    %spPrintQuality_spQualityHigh = 4
    ' spPaperBin enumeration
    %spPaperBin_spPaperBinUpper = 1
    %spPaperBin_spPaperBinLower = 2
    %spPaperBin_spPaperBinMiddle = 3
    %spPaperBin_spPaperBinManual = 4
    %spPaperBin_spPaperBinEnvelope = 5
    %spPaperBin_spPaperBinEnvManual = 6
    %spPaperBin_spPaperBinAuto = 7
    %spPaperBin_spPaperBinTractor = 8
    %spPaperBin_spPaperBinSmallFmt = 9
    %spPaperBin_spPaperBinLargeFmt = 10
    %spPaperBin_spPaperBinLargeCapacity = 11
    %spPaperBin_spPaperBinCassette = 14
     
    ' Interface Name  : Int__ASPPrinter
    ' Class Name      : ASPPrinter
    ' ClassID         : $CLSID_ASPPrinterCOM_ASPPrinter
    INTERFACE Int__ASPPrinter $IID_ASPPrinterCOM_Int__ASPPrinter
        INHERIT IDISPATCH
        METHOD PrintDoc <1610809374> (OPT BYVAL PrinterName AS STRING) AS VARIANT
        PROPERTY GET Key <1745027098> () AS STRING
        PROPERTY SET Key <1745027098> (BYVAL Rhs AS STRING)
        PROPERTY GET DocTitleFont <1745027097> () AS STRING
        PROPERTY SET DocTitleFont <1745027097> (BYVAL Rhs AS STRING)
        PROPERTY GET DocTextFont <1745027096> () AS STRING
        PROPERTY SET DocTextFont <1745027096> (BYVAL Rhs AS STRING)
        PROPERTY GET DocHeaderFont <1745027095> () AS STRING
        PROPERTY SET DocHeaderFont <1745027095> (BYVAL Rhs AS STRING)
        PROPERTY GET DocFooterFont <1745027094> () AS STRING
        PROPERTY SET DocFooterFont <1745027094> (BYVAL Rhs AS STRING)
        PROPERTY GET PrintBorder <1745027093> () AS INTEGER
        PROPERTY SET PrintBorder <1745027093> (BYVAL Rhs AS INTEGER)
        PROPERTY GET LineBelowHeader <1745027092> () AS INTEGER
        PROPERTY SET LineBelowHeader <1745027092> (BYVAL Rhs AS INTEGER)
        PROPERTY GET LineAboveFooter <1745027091> () AS INTEGER
        PROPERTY SET LineAboveFooter <1745027091> (BYVAL Rhs AS INTEGER)
        PROPERTY GET DocTitle <1745027090> () AS STRING
        PROPERTY SET DocTitle <1745027090> (BYVAL Rhs AS STRING)
        PROPERTY GET DocText <1745027089> () AS STRING
        PROPERTY SET DocText <1745027089> (BYVAL Rhs AS STRING)
        PROPERTY GET DocHeader <1745027088> () AS STRING
        PROPERTY SET DocHeader <1745027088> (BYVAL Rhs AS STRING)
        PROPERTY GET DocFooter <1745027087> () AS STRING
        PROPERTY SET DocFooter <1745027087> (BYVAL Rhs AS STRING)
        PROPERTY GET FileName <1745027086> () AS STRING
        PROPERTY SET FileName <1745027086> (BYVAL Rhs AS STRING)
        PROPERTY GET MarginLeft <1745027085> () AS INTEGER
        PROPERTY SET MarginLeft <1745027085> (BYVAL Rhs AS INTEGER)
        PROPERTY GET MarginRight <1745027084> () AS INTEGER
        PROPERTY SET MarginRight <1745027084> (BYVAL Rhs AS INTEGER)
        PROPERTY GET MarginTop <1745027083> () AS INTEGER
        PROPERTY SET MarginTop <1745027083> (BYVAL Rhs AS INTEGER)
        PROPERTY GET MarginBottom <1745027082> () AS INTEGER
        PROPERTY SET MarginBottom <1745027082> (BYVAL Rhs AS INTEGER)
        PROPERTY GET COPIES <1745027081> () AS INTEGER
        PROPERTY SET COPIES <1745027081> (BYVAL Rhs AS INTEGER)
        PROPERTY GET IncludeDateTime <1745027080> () AS INTEGER
        PROPERTY SET IncludeDateTime <1745027080> (BYVAL Rhs AS INTEGER)
        PROPERTY GET AllDataFromFile <1745027079> () AS INTEGER
        PROPERTY SET AllDataFromFile <1745027079> (BYVAL Rhs AS INTEGER)
        PROPERTY GET LineSpacing <1745027078> () AS LONG
        PROPERTY SET LineSpacing <1745027078> (BYVAL Rhs AS LONG)
        PROPERTY GET PaperOrientation <1745027077> () AS LONG
        PROPERTY SET PaperOrientation <1745027077> (BYVAL Rhs AS LONG)
        PROPERTY GET BorderLineWidth <1745027076> () AS INTEGER
        PROPERTY SET BorderLineWidth <1745027076> (BYVAL Rhs AS INTEGER)
        PROPERTY GET PaperSize <1745027075> () AS LONG
        PROPERTY SET PaperSize <1745027075> (BYVAL Rhs AS LONG)
        PROPERTY GET PrintQuality <1745027074> () AS LONG
        PROPERTY SET PrintQuality <1745027074> (BYVAL Rhs AS LONG)
        PROPERTY GET PaperBin <1745027073> () AS LONG
        PROPERTY SET PaperBin <1745027073> (BYVAL Rhs AS LONG)
        PROPERTY GET PrintPageNumber <1745027072> () AS INTEGER
        PROPERTY SET PrintPageNumber <1745027072> (BYVAL Rhs AS INTEGER)
        METHOD GetPrinters <1610809375> (OPT BYREF INOUT PRINTERCOUNT AS VARIANT) AS VARIANT
        METHOD SetPrinter <1610809376> (BYVAL PrinterName AS STRING) AS VARIANT
        METHOD PrintRTFData <1610809378> (BYVAL RTFData AS STRING, OPT BYVAL DocMarginLeft AS LONG, OPT BYVAL DocMarginTop AS _
            LONG, OPT BYVAL DocMarginRight AS LONG, OPT BYVAL DocMarginBottom AS LONG, OPT BYVAL PrnPaperOrientation AS LONG, _
            OPT BYVAL PrnPaperSize AS LONG, OPT BYVAL PrnPaperBin AS LONG, OPT BYVAL PrnPrintQuality AS LONG, OPT BYVAL _
            PrnCopies AS INTEGER) AS VARIANT
        METHOD PrintRTFFile <1610809379> (BYVAL RTFFileName AS STRING, OPT BYVAL DocMarginLeft AS LONG, OPT BYVAL DocMarginTop _
            AS LONG, OPT BYVAL DocMarginRight AS LONG, OPT BYVAL DocMarginBottom AS LONG, OPT BYVAL PrnPaperOrientation AS _
            LONG, OPT BYVAL PrnPaperSize AS LONG, OPT BYVAL PrnPaperBin AS LONG, OPT BYVAL PrnPrintQuality AS LONG, OPT _
            BYVAL PrnCopies AS INTEGER) AS VARIANT
        METHOD PrintTextFile <1610809380> (BYVAL TextFileName AS STRING, OPT BYVAL FontSettings AS STRING, OPT BYVAL _
            DocMarginLeft AS LONG, OPT BYVAL DocMarginTop AS LONG, OPT BYVAL DocMarginRight AS LONG, OPT BYVAL _
            DocMarginBottom AS LONG, OPT BYVAL PrnPaperOrientation AS LONG, OPT BYVAL PrnPaperSize AS LONG, OPT BYVAL _
            PrnPaperBin AS LONG, OPT BYVAL PrnPrintQuality AS LONG, OPT BYVAL PrnCopies AS INTEGER) AS VARIANT
        METHOD PrintText <1610809381> (BYVAL TextString AS STRING, OPT BYVAL FontSettings AS STRING, OPT BYVAL DocMarginLeft AS _
            LONG, OPT BYVAL DocMarginTop AS LONG, OPT BYVAL DocMarginRight AS LONG, OPT BYVAL DocMarginBottom AS LONG, OPT _
            BYVAL PrnPaperOrientation AS LONG, OPT BYVAL PrnPaperSize AS LONG, OPT BYVAL PrnPaperBin AS LONG, OPT BYVAL _
            PrnPrintQuality AS LONG, OPT BYVAL PrnCopies AS INTEGER) AS VARIANT
        METHOD PrintHTMLDocument <1610809382> (BYVAL HTMLDocument AS STRING) AS VARIANT
        METHOD PrintHTMLDocFromSource <1610809383> (BYVAL HTMLSource AS STRING) AS VARIANT
        METHOD PrintPDFFile <1610809384> (BYVAL PDFFileName AS STRING) AS VARIANT
        METHOD About <1610809386> ()
    END INTERFACE
    ' Interface Name  : Int___ASPPrinter
    ' ClassID         : $CLSID_ASPPrinterCOM_Event___ASPPrinter
    CLASS Class_Int___ASPPrinter $CLSID_ASPPrinterCOM_Event___ASPPrinter AS EVENT
        INTERFACE Int___ASPPrinter $IID_ASPPrinterCOM_Int___ASPPrinter
            INHERIT IDISPATCH
            METHOD PrintComplete <1> ()
                ' Insert your code here
            END METHOD
            METHOD PrintError <2> (BYREF INOUT ErrNumber AS VARIANT, BYREF INOUT ErrDescription AS VARIANT)
                ' Insert your code here
            END METHOD
            METHOD PrintProgress <3> (BYREF INOUT PageNumber AS VARIANT)
                ' Insert your code here
            END METHOD
        END INTERFACE
    END CLASS
    Last edited by Mike Doty; 17 Aug 2009, 12:11 PM.
    CMD shortcut to open any location:
    %windir%\system32\cmd.exe /k " cd\ & x: & cd x:\xxxx
    Change to run as administrator
    How long is an idea? Write it down.

  • #2
    Good question.
    I had a similar issue with a different interface.
    I suspect the com interface is doing things in a thread but the object is terminated on exit and therefore the thread me be as well.
    Isn't there a mechanism to wait until it's done?
    hellobasic

    Comment


    • #3
      Can't get printer to allocate using 3rd party COM

      Sorry, Edwin for being so late. Didn't see you responded earlier.

      Changed code to be called from PBForms using DDT so I would have a message loop and added the code below. It doesn't help.

      BEEP
      'Wait for printer to allocate
      LOCAL x AS LONG
      FOR x = 1 TO 100: DIALOG DOEVENTS:SLEEP 100:NEXT
      BEEP

      It appears email responses to postings are no longer being received.

      Not sure how to call these using last binding?
      Code:
      METHOD PrintComplete <1> ()
                  ' Insert your code here
                  ? "How is this called"
              END METHOD
              METHOD PrintError <2> (BYREF INOUT ErrNumber AS VARIANT, BYREF INOUT ErrDescription AS VARIANT)
                  ' Insert your code here
                  ? "How is this called"
              END METHOD
              METHOD PrintProgress <3> (BYREF INOUT PageNumber AS VARIANT)
                  ' Insert your code here
                  ? "How is this called"
      Even tried using a global object and SET g_obj = NOTHING when dialog ends.

      Have to move on since I spent a day trying to figure this out.
      Attached Files
      Last edited by Mike Doty; 17 Aug 2009, 08:00 AM.
      CMD shortcut to open any location:
      %windir%\system32\cmd.exe /k " cd\ & x: & cd x:\xxxx
      Change to run as administrator
      How long is an idea? Write it down.

      Comment


      • #4
        Not sure how to call these using last binding?
        You don't call them. Class_Int___ASPPrinter is an event class whose methods will be called by the ActiveX if you first connect them with it. See the EVENTS statement in the help file.
        Forum: http://www.jose.it-berater.org/smfforum/index.php

        Comment


        • #5
          Thanks,
          Gettting email notifications, again.
          Appears I need a callback to get them to work.
          CMD shortcut to open any location:
          %windir%\system32\cmd.exe /k " cd\ & x: & cd x:\xxxx
          Change to run as administrator
          How long is an idea? Write it down.

          Comment


          • #6
            Solution: UCODE$(sDocument$)
            VB6 no longer needed with this control that will print about any document with graphics over the net or locally!

            A good night sleep sure helps.
            Posted solution with original posting.
            CMD shortcut to open any location:
            %windir%\system32\cmd.exe /k " cd\ & x: & cd x:\xxxx
            Change to run as administrator
            How long is an idea? Write it down.

            Comment


            • #7
              After all this work, deleted MSVBVM60.DLL and it fails.
              Component missing error, bummer.
              Is there a way to see dependencies of activex.dll's? Dependency walker?
              Last edited by Mike Doty; 17 Aug 2009, 01:12 PM.
              CMD shortcut to open any location:
              %windir%\system32\cmd.exe /k " cd\ & x: & cd x:\xxxx
              Change to run as administrator
              How long is an idea? Write it down.

              Comment


              • #8
                Some ActiveX controls are Visual Basic controls and require the runtimes.

                You can use the Depends utility program that comes with the Windows SDK to see the dependencies.


                It appears though the SDK no longer comes with Dependency Walker and the MSDN web site points to this web site to downlaod it from:

                http://www.dependencywalker.com/
                Chris Boss
                Computer Workshop
                Developer of "EZGUI"
                http://cwsof.com
                http://twitter.com/EZGUIProGuy

                Comment

                Working...
                X