Announcement

Collapse
No announcement yet.

PB/DLL 2.0 -- 16 Bit Common Dialog

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

  • PB/DLL 2.0 -- 16 Bit Common Dialog

    I am converting some of my VB 3.0 application to DLL. I would
    like to remove cmdialog.vbx from my application an make calls
    directly to windows for common dialog routines, specifically
    File Open, File Save As. I have searched the PB forums but cannot
    find any examples to work with. Any suggestions or examples will
    help.

    Thanks...
    Spencer

  • #2
    I now have the File Open Dialog working in my application. I
    found the cmdlg.bas file in the samp16 directory. I am calling
    File Open routine with the following call:

    cmuFileOpen (Me.hWnd)

    Now what I would like to do is to pass into the PB/DLL dll that I
    have created a user defined type. I am unsure how to do this
    if it is possible.

    Thanks for any help.
    Spencer


    ------------------

    Comment


    • #3
      Yes, you can use a VB UDT with PB - just pass the UDT by reference (BYREF) to the DLL.

      However, you may have to take in account the alignment issues that 16-bit VB uses. There is a FAQ (on 32-bit VB and UDT alignment) in the FAQ forum on this BBS but I'm not sure how much of it (if any) applies to VB3. You may want to search your 16-bit VB documentation for more information.

      In general, if you make all your UDT members 4 bytes long (or a multiple of 4 bytes), then your problems will be minimized.

      JFYI: PB/DLL does not support dynamic (variable length) strings in UDT's - use ASCIIZ or fixed-length strings instead.


      ------------------
      Lance
      PowerBASIC Support
      mailto:[email protected][email protected]</A>
      Lance
      mailto:[email protected]

      Comment


      • #4
        Spencer
        As Lance mentioned it must be passed by reference. Simply create identical UDTs at both ends and pass them back and forth.

        Lance
        So far I haven't found any alignment issues in VB 4.0 (16 bit) either.


        This is a sample of passing a two diminsional array of UDT from VB to PBDLL
        PB CODE
        Code:
        $COMPILE DLL
        $DIM ALL
        
        TYPE Mytst
           FTxt AS STRING * 65
           FInt AS INTEGER
           FDbl AS DOUBLE
        END TYPE
        
        '====================== TWO DIM ARRAY OF TYPE FROM VB
        ' UDT1 is a 3X3 Array of Mytst(3, 3)
        ' VB 4.0 (16 Bit) passes this to a PBDLL 2.0
        
        FUNCTION TEST_2DIM_UDT   (BYVAL UDT1    AS DWORD, _
                                  BYVAL nSize   AS INTEGER, _
                                  BYVAL szScnd  AS INTEGER _
                                 ) EXPORT AS INTEGER
          
          DIM MYPTR AS Mytst PTR
          DIM A AS INTEGER, B AS INTEGER
        
          MYPTR = UDT1
           
          FOR A = 1 TO szScnd
              FOR B = 1 TO nSize
                 @MYPTR[B of nSize, A of szScnd].FInt = B * A * 1000
                 @MYPTR[B of nSize, A of szScnd].FDbl = B  / (A * B * 1000)
                 @MYPTR[B of nSize, A of szScnd].FTxt = " Test String" + " B=" + STR$(B) + " and A=" + STR$(A)
              NEXT B
           NEXT A
           
           FUNCTION = -1
        END FUNCTION
        And VB CODE

        Code:
        Type UDTTst
          FTxt As String * 65
          FInt As Integer
          FDbl As Double
        End Type
        
        Public MyArr() As UDTTst
        
        Declare Function TEST_2DIM_UDT Lib "1UDT.DLL" (MyArr As UDTTst, ByVal nSize%, ByVal szScnd%) As Integer
        Sub Main()
         ChDir "C:\PBDLL20"
         ReDim Preserve MyArr(3, 3)
           
        
         XX = TEST_2DIM_UDT(MyArr(0, 0), 3, 3)
         Stop
           For A = 1 To 3
              For B = 1 To 3
                Debug.Print MyArr(B, A).FInt;
                Debug.Print MyArr(B, A).FDbl;
                Debug.Print MyArr(B, A).FTxt
              Next B
           Next A
           
           For A = 1 To 3
              For B = 1 To 3
                Debug.Print MyArr(B, A).FInt & MyArr(B, A).FDbl & MyArr(B, A).FTxt
              Next B
           Next A
         Stop
         'Check it out
        End Sub
        Hope this helps
        Scott

        ------------------
        The most exasperating part of the "rat race" is how often the rats are in the lead!

        Comment


        • #5
          I've confirmed that 16-bit VB uses byte-alignment so there are no likely alignment issues here.

          It is only 32-bit VB that deviates from this by implementing "natural alignment" techiques.

          ------------------
          Lance
          PowerBASIC Support
          mailto:[email protected][email protected]</A>
          Lance
          mailto:[email protected]

          Comment

          Working...
          X