Announcement

Collapse
No announcement yet.

Missing Declaration in comdlg32.inc - PageSetupDlg

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

  • Missing Declaration in comdlg32.inc - PageSetupDlg

    There is a missing declaration in the comdlg32.inc file !

    It is the declaration for the Page Setup Dialog, which is the
    recommended Dialog to use instead of the old Setup Dialog. All API
    docs I have seen say the old Setup Dialog is obsolete and only kept for
    backward compatibility. All new Win32 apps should be using the
    Page Setup Dialog.

    Here is the necessary declarations needed for the Page Setup Dialog :

    Code:
    TYPE tagPSD
        lStructSize AS DWORD
        hwndOwner AS LONG
        hDevMode AS LONG
        hDevNames AS LONG
        Flags AS DWORD
        ptPaperSize AS POINTAPI
        rtMinMargin AS RECT
        rtMargin AS RECT
        hInstance AS LONG
        lCustData AS LONG
        lpfnPageSetupHook AS LONG
        lpfnPagePaintHook AS LONG
        lpPageSetupTemplateName AS LONG
        hPageSetupTemplate AS LONG
    END TYPE
    
    DECLARE FUNCTION PageSetupDlg LIB "COMDLG32.DLL" ALIAS "PageSetupDlgA" (PSD AS tagPSD) AS LONG
    Note to PB Tech Support:
    You may want to add this to the comdlg32.inc file !




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

  • #2
    Hmmmmmmmmmmm!!!!! Chris are you sure about the C to PB
    translation. From the commdlg.h file:

    Code:
    typedef UINT (APIENTRY* LPPAGEPAINTHOOK)( HWND, UINT, WPARAM, LPARAM );
    typedef UINT (APIENTRY* LPPAGESETUPHOOK)( HWND, UINT, WPARAM, LPARAM );
    
    typedef struct tagPSDA
    {
        DWORD           lStructSize;
        HWND            hwndOwner;
        HGLOBAL         hDevMode;
        HGLOBAL         hDevNames;
        DWORD           Flags;
        POINT           ptPaperSize;
        RECT            rtMinMargin;
        RECT            rtMargin;
        HINSTANCE       hInstance;
        LPARAM          lCustData;
        LPPAGESETUPHOOK lpfnPageSetupHook;
        LPPAGEPAINTHOOK lpfnPagePaintHook;
        LPCSTR          lpPageSetupTemplateName;
        HGLOBAL         hPageSetupTemplate;
    } PAGESETUPDLGA, * LPPAGESETUPDLGA;
    
    BOOL APIENTRY PageSetupDlgA( LPPAGESETUPDLGA );
    LPCSTR lpPageSetupTemplateName; would be translated to
    PB as lpPageSetupTemplateName as asciiz ptr. Initializing
    would be lpPageSetupTemplateName = varptr(whatever).

    Both the lpfn elements would be translated as:

    lpfnPageSetupHook as dword ptr
    lpfnPagePaintHook as dword ptr

    Initializing: lpfnPageSetupHook = codeptr(myhookfn), etc.
    Maybe Tom Hanlin needs to verify this??????????

    Cheers,
    Cecil

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

    Comment


    • #3
      Well guess what, the darn thing is in the win32api.inc file.
      Go figure!!!!!!! That is, the UDT def, no fn def.

      Cheers,
      Cecil

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


      [This message has been edited by Cecil Williams (edited February 15, 2001).]

      Comment


      • #4
        Cecil;

        You are right !

        It is in the win32api.inc file, but the Function Declaration is
        missing though !

        Yes, I should have made one of the members an Asciiz PTR instead
        of a long !

        The TYPE name is what made it hard to find. My Windows programming
        book refered to it as tagPSD and I noticed the code you posted used
        tagPSDA . The Win32 help file refers to the structure as tagPD .

        The win32api.inc file uses PAGESETUPDLGAPI !

        Code:
        TYPE PAGESETUPDLGAPI
          lStructSize AS LONG
          hwndOwner AS LONG
          hDevMode AS LONG
          hDevNames AS LONG
          flags AS LONG
          ptPaperSize AS POINTAPI
          rtMinMargin AS Rect
          rtMargin AS Rect
          hInstance AS LONG
          lCustData AS LONG
          lpfnPageSetupHook AS LONG
          lpfnPagePaintHook AS LONG
          lpPageSetupTemplateName AS ASCIIZ PTR
          hPageSetupTemplate AS LONG
        END TYPE
        I think the Type name should be changed to reflect what is in
        Windows programming books. I would never have found this one.


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

        Comment


        • #5
          Chris,

          There are two versions in my commdlg.h file, which is the
          "C" rendition. One is "A" and one is "W" and the corresponding
          functions are typed to match. One, ANSI, the other UNICODE.
          Obviously, PB uses the "A" version.

          PB always translates the LPSTR, LPTSTR and LPCSTR to ASCIIZ PTR.
          LPCSTR is equivalent to (const char *), just been typed to
          make the verbage simpler.

          Cheers,
          Cecil

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

          Comment


          • #6
            We'll make the appropriate updates. Thanks.

            ------------------
            Tom Hanlin
            PowerBASIC Staff

            Comment


            • #7
              The definition given by Chris is also correct.
              LPCSTR lpPageSetupTemplateName is the address of a string so a
              LONG will suffice.

              TYPE tagPSD
              ...
              lpPageSetupTemplateName AS LONG
              ...
              END TYPE

              tagPSD.lpPageSetupTemplateName = VARPTR(szTemplate)

              ------------------
              Dominic Mitchell
              Dominic Mitchell
              Phoenix Visual Designer
              http://www.phnxthunder.com

              Comment


              • #8
                Originally posted by Dominic Mitchell:
                The definition given by Chris is also correct.
                LPCSTR lpPageSetupTemplateName is the address of a string so a
                LONG will suffice.

                TYPE tagPSD
                ...
                lpPageSetupTemplateName AS LONG
                ...
                END TYPE

                tagPSD.lpPageSetupTemplateName = VARPTR(szTemplate)

                While it may suffice, there will come a day when that will bite
                you on the derrier. Pointers in "C" are just like PB, 32-bit
                DWORDS. A DWORD in C is typedefed as "unsigned long". The value
                on the plus side will get wrapped when casting a DWORD to a LONG
                using VARPTR, STRPTR, or CODEPTR functions.

                Cheers,
                Cecil



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

                Comment

                Working...
                X