FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Commdlg.d

 
Post new topic   Reply to topic     Forum Index -> Core32
View previous topic :: View next topic  
Author Message
jcesar



Joined: 26 Apr 2004
Posts: 5

PostPosted: Thu May 13, 2004 10:29 am    Post subject: Commdlg.d Reply with quote

I send you this file last thuesday by email. Probably you missed it so I'm reposting it here.

The attached file is the COMMDLG.H translated to D. I managed to compile it with -version=STANDALONE after modifying other files in the package (including some definitions that were commented like TEXTMETRICA).

I've converted the macros to D functions so they can be used just as documented by Microsoft. Declarations are in the same order as in the header except for the UNICODE/ANSI aliases which I collected at the bottom of the file.

Also didn't find any symbol colliding with std.c.windows.windows so I removed all the STANDALONE blocks.

Please review the file and tell me what do you think.

Thanks.

Code:

module win32.commdlg;

import win32.windef;
import win32.winuser;

//
// Ported to D from below file by Mike Wynn <mike.wynn@l8night.co.uk>
// and Julio César Carrascal Urquijo <jcarrascal@artelogico.com>
//

/************************************************************************
*                                                                       *
*   commdlg.h -- This module defines the 32-Bit Common Dialog APIs      *
*                                                                       *
*   Copyright (c) 1992-1996, Microsoft Corp. All rights reserved.       *
*                                                                       *
************************************************************************/

//#include <pshpack1.h>         /* Assume byte packing throughout */

version (Windows)
{
    alias UINT function (HWND, UINT, WPARAM, LPARAM) LPOFNHOOKPROC;

    struct OPENFILENAMEA
    {
       DWORD            lStructSize;
       HWND             hwndOwner;
       HINSTANCE        hInstance;
       LPCSTR           lpstrFilter;
       LPSTR            lpstrCustomFilter;
       DWORD            nMaxCustFilter;
       DWORD            nFilterIndex;
       LPSTR            lpstrFile;
       DWORD            nMaxFile;
       LPSTR            lpstrFileTitle;
       DWORD            nMaxFileTitle;
       LPCSTR           lpstrInitialDir;
       LPCSTR           lpstrTitle;
       DWORD            Flags;
       WORD             nFileOffset;
       WORD             nFileExtension;
       LPCSTR           lpstrDefExt;
       LPARAM           lCustData;
       LPOFNHOOKPROC    lpfnHook;
       LPCSTR           lpTemplateName;
    }


    alias OPENFILENAMEA* LPOPENFILENAMEA;

    struct OPENFILENAMEW
    {
       DWORD            lStructSize;
       HWND             hwndOwner;
       HINSTANCE        hInstance;
       LPCWSTR          lpstrFilter;
       LPWSTR           lpstrCustomFilter;
       DWORD            nMaxCustFilter;
       DWORD            nFilterIndex;
       LPWSTR           lpstrFile;
       DWORD            nMaxFile;
       LPWSTR           lpstrFileTitle;
       DWORD            nMaxFileTitle;
       LPCWSTR          lpstrInitialDir;
       LPCWSTR          lpstrTitle;
       DWORD            Flags;
       WORD             nFileOffset;
       WORD             nFileExtension;
       LPCWSTR          lpstrDefExt;
       LPARAM           lCustData;
       LPOFNHOOKPROC    lpfnHook;
       LPCWSTR          lpTemplateName;
    }

    alias OPENFILENAMEW* LPOPENFILENAMEW;

    BOOL  GetOpenFileNameA(LPOPENFILENAMEA);
    BOOL  GetOpenFileNameW(LPOPENFILENAMEW);
    BOOL  GetSaveFileNameA(LPOPENFILENAMEA);
    BOOL  GetSaveFileNameW(LPOPENFILENAMEW);
    short GetFileTitleA(LPCSTR, LPSTR, WORD);
    short GetFileTitleW(LPCWSTR, LPWSTR, WORD);

    enum OpenFileNameFlags : UINT
    {
        OFN_READONLY                = 0x00000001,
        OFN_OVERWRITEPROMPT         = 0x00000002,
        OFN_HIDEREADONLY            = 0x00000004,
        OFN_NOCHANGEDIR             = 0x00000008,
        OFN_SHOWHELP                = 0x00000010,
        OFN_ENABLEHOOK              = 0x00000020,
        OFN_ENABLETEMPLATE          = 0x00000040,
        OFN_ENABLETEMPLATEHANDLE    = 0x00000080,
        OFN_NOVALIDATE              = 0x00000100,
        OFN_ALLOWMULTISELECT        = 0x00000200,
        OFN_EXTENSIONDIFFERENT      = 0x00000400,
        OFN_PATHMUSTEXIST           = 0x00000800,
        OFN_FILEMUSTEXIST           = 0x00001000,
        OFN_CREATEPROMPT            = 0x00002000,
        OFN_SHAREAWARE              = 0x00004000,
        OFN_NOREADONLYRETURN        = 0x00008000,
        OFN_NOTESTFILECREATE        = 0x00010000,
        OFN_NONETWORKBUTTON         = 0x00020000,
        OFN_NOLONGNAMES             = 0x00040000,   // force no long names for 4.x modules
        OFN_EXPLORER                = 0x00080000,   // new look commdlg
        OFN_NODEREFERENCELINKS      = 0x00100000,
        OFN_LONGNAMES               = 0x00200000,   // force long names for 3.x modules
        OFN_ENABLEINCLUDENOTIFY     = 0x00400000,   // send include message to callback
        OFN_ENABLESIZING            = 0x00800000,

        // Return values for the registered message sent to the hook function
        // when a sharing violation occurs.  OFN_SHAREFALLTHROUGH allows the
        // filename to be accepted, OFN_SHARENOWARN rejects the name but puts
        // up no warning (returned when the app has already put up a warning
        // message), and OFN_SHAREWARN puts up the default warning message
        // for sharing violations.
        //
        // Note:  Undefined return values map to OFN_SHAREWARN, but are
        //        reserved for future use.

        OFN_SHAREFALLTHROUGH     = 2,
        OFN_SHARENOWARN          = 1,
        OFN_SHAREWARN            = 0
    }

    alias UINT function (HWND, UINT, WPARAM, LPARAM) LPCCHOOKPROC;

    // Structure used for all file based OpenFileName notifications
    struct OFNOTIFYA
    {
        NMHDR           hdr;
        LPOPENFILENAMEA lpOFN;
        LPSTR           pszFile;        // May be NULL
    }

    alias OFNOTIFYA* LPOFNOTIFYA;

    // Structure used for all file based OpenFileName notifications
    struct OFNOTIFYW
    {
        NMHDR           hdr;
        LPOPENFILENAMEW lpOFN;
        LPWSTR          pszFile;        // May be NULL
    }
    alias OFNOTIFYW* LPOFNOTIFYW;


    // Structure used for all object based OpenFileName notifications
    struct OFNOTIFYEXA
    {
        NMHDR           hdr;
        LPOPENFILENAMEA lpOFN;
        LPVOID          psf;
        LPVOID          pidl;          // May be NULL
    }
    alias OFNOTIFYEXA* LPOFNOTIFYEXA;

    // Structure used for all object based OpenFileName notifications
    struct OFNOTIFYEXW
    {
        NMHDR           hdr;
        LPOPENFILENAMEW lpOFN;
        LPVOID          psf;
        LPVOID          pidl;          // May be NULL
    }

    alias OFNOTIFYEXW* LPOFNOTIFYEXW;

    enum CommonDialogNotification : UINT
    {
        CDN_FIRST   = (0U-601U),
        CDN_LAST    = (0U-699U),

        // Notifications when Open or Save dialog status changes
        CDN_INITDONE        = (CDN_FIRST - 0x0000),
        CDN_SELCHANGE       = (CDN_FIRST - 0x0001),
        CDN_FOLDERCHANGE    = (CDN_FIRST - 0x0002),
        CDN_SHAREVIOLATION  = (CDN_FIRST - 0x0003),
        CDN_HELP            = (CDN_FIRST - 0x0004),
        CDN_FILEOK          = (CDN_FIRST - 0x0005),
        CDN_TYPECHANGE      = (CDN_FIRST - 0x0006),
        CDN_INCLUDEITEM     = (CDN_FIRST - 0x0007),

        CDM_FIRST   = (WM_USER + 100),
        CDM_LAST    = (WM_USER + 200),

        // Messages to query information from the Open or Save dialogs

        // lParam = pointer to text buffer that gets filled in
        // wParam = max number of characters of the text buffer (including NULL)
        // return = < 0 if error; number of characters needed (including NULL)
        CDM_GETSPEC = (CDM_FIRST + 0x0000),

        // lParam = pointer to text buffer that gets filled in
        // wParam = max number of characters of the text buffer (including NULL)
        // return = < 0 if error; number of characters needed (including NULL)
        CDM_GETFILEPATH = (CDM_FIRST + 0x0001),

        // lParam = pointer to text buffer that gets filled in
        // wParam = max number of characters of the text buffer (including NULL)
        // return = < 0 if error; number of characters needed (including NULL)
        CDM_GETFOLDERPATH   = (CDM_FIRST + 0x0002),

        // lParam = pointer to ITEMIDLIST buffer that gets filled in
        // wParam = size of the ITEMIDLIST buffer
        // return = < 0 if error; length of buffer needed
        CDM_GETFOLDERIDLIST = (CDM_FIRST + 0x0003),

        // lParam = pointer to a string
        // wParam = ID of control to change
        // return = not used
        CDM_SETCONTROLTEXT  = (CDM_FIRST + 0x0004),

        // lParam = not used
        // wParam = ID of control to change
        // return = not used
        CDM_HIDECONTROL = (CDM_FIRST + 0x0005),

        // lParam = pointer to default extension (no dot)
        // wParam = not used
        // return = not used
        CDM_SETDEFEXT   = (CDM_FIRST + 0x0006),
    }

    LRESULT CommDlg_OpenSave_GetSpecA(HWND _hdlg, LPSTR _psz, UINT _cbmax)
    {
        return SendMessageA(_hdlg, CommonDialogNotification.CDM_GETSPEC,
            cast (WPARAM)_cbmax, cast (LPARAM)_psz);
    }
    LRESULT CommDlg_OpenSave_GetSpecW(HWND _hdlg, LPWSTR _psz, UINT _cbmax)
    {
        return SendMessageW(_hdlg, CommonDialogNotification.CDM_GETSPEC,
            cast (WPARAM)_cbmax, cast (LPARAM)_psz);
    }

    LRESULT CommDlg_OpenSave_GetFilePathA(HWND _hdlg, LPSTR _psz, UINT _cbmax)
    {
        return SendMessageA(_hdlg, CommonDialogNotification.CDM_GETFILEPATH,
            cast (WPARAM)_cbmax, cast (LPARAM)_psz);
    }

    LRESULT CommDlg_OpenSave_GetFilePathW(HWND _hdlg, LPWSTR _psz, UINT _cbmax)
    {
        return SendMessageW(_hdlg, CommonDialogNotification.CDM_GETFILEPATH,
            cast (WPARAM)_cbmax, cast (LPARAM)_psz);
    }

    LRESULT CommDlg_OpenSave_GetFolderPathA(HWND _hdlg, LPSTR _psz, UINT _cbmax)
    {
        return SendMessageA(_hdlg, CommonDialogNotification.CDM_GETFOLDERPATH,
            cast (WPARAM)_cbmax, cast (LPARAM)_psz);
    }

    LRESULT CommDlg_OpenSave_GetFolderPathW(HWND _hdlg, LPWSTR _psz, UINT _cbmax)
    {
        return SendMessageW(_hdlg, CommonDialogNotification.CDM_GETFOLDERPATH,
            cast (WPARAM)_cbmax, cast (LPARAM)_psz);
    }


    LRESULT CommDlg_OpenSave_GetFolderIDList(HWND _hdlg, LPVOID _pidl, UINT _cbmax)
    {
        return SendMessage(_hdlg, CommonDialogNotification.CDM_GETFOLDERIDLIST,
            cast (WPARAM)_cbmax, cast (LPARAM)_pidl);
    }

    LRESULT CommDlg_OpenSave_SetControlText(HWND _hdlg, LPVOID _id, UINT _text)
    {
        return SendMessage(_hdlg, CommonDialogNotification.CDM_SETCONTROLTEXT,
            cast (WPARAM)_id, cast (LPARAM)_text);
    }

    void CommDlg_OpenSave_HideControl(HWND _hdlg, UINT _id)
    {
        SendMessage(_hdlg, CommonDialogNotification.CDM_HIDECONTROL,
            cast (WPARAM)_id, 0);
    }

    void CommDlg_OpenSave_SetDefExt(HWND _hdlg, LPSTR _pszext)
    {
        SendMessage(_hdlg, CommonDialogNotification.CDM_SETDEFEXT, 0,
            cast (LPARAM)_pszext);
    }


    struct CHOOSECOLORA
    {
       DWORD        lStructSize;
       HWND         hwndOwner;
       HWND         hInstance;
       COLORREF     rgbResult;
       COLORREF*    lpCustColors;
       DWORD        Flags;
       LPARAM       lCustData;
       LPCCHOOKPROC lpfnHook;
       LPCSTR       lpTemplateName;
    }
    alias CHOOSECOLORA* LPCHOOSECOLORA;

    struct CHOOSECOLORW
    {
       DWORD        lStructSize;
       HWND         hwndOwner;
       HWND         hInstance;
       COLORREF     rgbResult;
       COLORREF*    lpCustColors;
       DWORD        Flags;
       LPARAM       lCustData;
       LPCCHOOKPROC lpfnHook;
       LPCWSTR      lpTemplateName;
    }
    alias CHOOSECOLORW* LPCHOOSECOLORW;

    BOOL ChooseColorA(LPCHOOSECOLORA);
    BOOL ChooseColorW(LPCHOOSECOLORW);

    enum ChooseColorFlags : UINT
    {
        CC_RGBINIT              = 0x00000001,
        CC_FULLOPEN             = 0x00000002,
        CC_PREVENTFULLOPEN      = 0x00000004,
        CC_SHOWHELP             = 0x00000008,
        CC_ENABLEHOOK           = 0x00000010,
        CC_ENABLETEMPLATE       = 0x00000020,
        CC_ENABLETEMPLATEHANDLE = 0x00000040,
        CC_SOLIDCOLOR           = 0x00000080,
        CC_ANYCOLOR             = 0x00000100
    }

    alias UINT function (HWND, UINT, WPARAM, LPARAM) LPFRHOOKPROC;

    struct FINDREPLACEA
    {
       DWORD        lStructSize;        // size of this struct 0x20
       HWND         hwndOwner;          // handle to owner's window
       HINSTANCE    hInstance;          // instance handle of.EXE that
                                        //   contains cust. dlg. template
       DWORD        Flags;              // one or more of the FR_??
       LPSTR        lpstrFindWhat;      // ptr. to search string
       LPSTR        lpstrReplaceWith;   // ptr. to replace string
       WORD         wFindWhatLen;       // size of find buffer
       WORD         wReplaceWithLen;    // size of replace buffer
       LPARAM       lCustData;          // data passed to hook fn.
       LPFRHOOKPROC lpfnHook;           // ptr. to hook fn. or NULL
       LPCSTR       lpTemplateName;     // custom template name
    }
    alias FINDREPLACEA* LPFINDREPLACEA;

    struct FINDREPLACEW
    {
       DWORD        lStructSize;        // size of this struct 0x20
       HWND         hwndOwner;          // handle to owner's window
       HINSTANCE    hInstance;          // instance handle of.EXE that
                                        //   contains cust. dlg. template
       DWORD        Flags;              // one or more of the FR_??
       LPWSTR       lpstrFindWhat;      // ptr. to search string
       LPWSTR       lpstrReplaceWith;   // ptr. to replace string
       WORD         wFindWhatLen;       // size of find buffer
       WORD         wReplaceWithLen;    // size of replace buffer
       LPARAM       lCustData;          // data passed to hook fn.
       LPFRHOOKPROC lpfnHook;           // ptr. to hook fn. or NULL
       LPCWSTR      lpTemplateName;     // custom template name
    }
    alias FINDREPLACEW* LPFINDREPLACEW;

    enum FindReplaceFlags : UINT
    {
        FR_DOWN                 = 0x00000001,
        FR_WHOLEWORD            = 0x00000002,
        FR_MATCHCASE            = 0x00000004,
        FR_FINDNEXT             = 0x00000008,
        FR_REPLACE              = 0x00000010,
        FR_REPLACEALL           = 0x00000020,
        FR_DIALOGTERM           = 0x00000040,
        FR_SHOWHELP             = 0x00000080,
        FR_ENABLEHOOK           = 0x00000100,
        FR_ENABLETEMPLATE       = 0x00000200,
        FR_NOUPDOWN             = 0x00000400,
        FR_NOMATCHCASE          = 0x00000800,
        FR_NOWHOLEWORD          = 0x00001000,
        FR_ENABLETEMPLATEHANDLE = 0x00002000,
        FR_HIDEUPDOWN           = 0x00004000,
        FR_HIDEMATCHCASE        = 0x00008000,
        FR_HIDEWHOLEWORD        = 0x00010000
    }

    HWND FindTextA(LPFINDREPLACEA);
    HWND FindTextW(LPFINDREPLACEW);
    HWND ReplaceTextA(LPFINDREPLACEA);
    HWND ReplaceTextW(LPFINDREPLACEW);
    HWND AfxReplaceTextA(LPFINDREPLACEA);
    HWND AfxReplaceTextW(LPFINDREPLACEW);

    alias UINT function (HWND, UINT, WPARAM, LPARAM) LPCFHOOKPROC;

    struct CHOOSEFONTA
    {
       DWORD           lStructSize;
       HWND            hwndOwner;          // caller's window handle
       HDC             hDC;                // printer DC/IC or NULL
       LPLOGFONTA      lpLogFont;          // ptr. to a LOGFONT struct
       INT             iPointSize;         // 10 * size in points of selected font
       DWORD           Flags;              // enum. type flags
       COLORREF        rgbColors;          // returned text color
       LPARAM          lCustData;          // data passed to hook fn.
       LPCFHOOKPROC    lpfnHook;           // ptr. to hook function
       LPCSTR          lpTemplateName;     // custom template name
       HINSTANCE       hInstance;          // instance handle of.EXE that
                                           //   contains cust. dlg. template
       LPSTR           lpszStyle;          // return the style field here
                                           // must be LF_FACESIZE or bigger
       WORD            nFontType;          // same value reported to the EnumFonts
                                           //   call back with the extra FONTTYPE_
                                           //   bits added
       WORD            ___MISSING_ALIGNMENT__;
       INT             nSizeMin;           // minimum pt size allowed &
       INT             nSizeMax;           // max pt size allowed if
                                           //   CF_LIMITSIZE is used
    }
    alias CHOOSEFONTA* LPCHOOSEFONTA;

    struct CHOOSEFONTW
    {
       DWORD           lStructSize;
       HWND            hwndOwner;          // caller's window handle
       HDC             hDC;                // printer DC/IC or NULL
       LPLOGFONTW      lpLogFont;          // ptr. to a LOGFONT struct
       INT             iPointSize;         // 10 * size in points of selected font
       DWORD           Flags;              // enum. type flags
       COLORREF        rgbColors;          // returned text color
       LPARAM          lCustData;          // data passed to hook fn.
       LPCFHOOKPROC    lpfnHook;           // ptr. to hook function
       LPCWSTR         lpTemplateName;     // custom template name
       HINSTANCE       hInstance;          // instance handle of.EXE that
                                           //   contains cust. dlg. template
       LPWSTR          lpszStyle;          // return the style field here
                                           // must be LF_FACESIZE or bigger
       WORD            nFontType;          // same value reported to the EnumFonts
                                           //   call back with the extra FONTTYPE_
                                           //   bits added
       WORD            ___MISSING_ALIGNMENT__;
       INT             nSizeMin;           // minimum pt size allowed &
       INT             nSizeMax;           // max pt size allowed if
                                           //   CF_LIMITSIZE is used
    }
    alias CHOOSEFONTW* LPCHOOSEFONTW;

    BOOL ChooseFontA(LPCHOOSEFONTA);
    BOOL ChooseFontW(LPCHOOSEFONTW);

    enum ChooseFontFlags : UINT
    {
        CF_SCREENFONTS          = 0x00000001,
        CF_PRINTERFONTS         = 0x00000002,
        CF_BOTH                 = (CF_SCREENFONTS | CF_PRINTERFONTS),
        CF_SHOWHELP             = 0x00000004L,
        CF_ENABLEHOOK           = 0x00000008L,
        CF_ENABLETEMPLATE       = 0x00000010L,
        CF_ENABLETEMPLATEHANDLE = 0x00000020L,
        CF_INITTOLOGFONTSTRUCT  = 0x00000040L,
        CF_USESTYLE             = 0x00000080L,
        CF_EFFECTS              = 0x00000100L,
        CF_APPLY                = 0x00000200L,
        CF_ANSIONLY             = 0x00000400L,
        CF_SCRIPTSONLY          = CF_ANSIONLY,
        CF_NOVECTORFONTS        = 0x00000800L,
        CF_NOOEMFONTS           = CF_NOVECTORFONTS,
        CF_NOSIMULATIONS        = 0x00001000L,
        CF_LIMITSIZE            = 0x00002000L,
        CF_FIXEDPITCHONLY       = 0x00004000L,
        CF_WYSIWYG              = 0x00008000L, // must also have CF_SCREENFONTS & CF_PRINTERFONTS
        CF_FORCEFONTEXIST       = 0x00010000L,
        CF_SCALABLEONLY         = 0x00020000L,
        CF_TTONLY               = 0x00040000L,
        CF_NOFACESEL            = 0x00080000L,
        CF_NOSTYLESEL           = 0x00100000L,
        CF_NOSIZESEL            = 0x00200000L,
        CF_SELECTSCRIPT         = 0x00400000L,
        CF_NOSCRIPTSEL          = 0x00800000L,
        CF_NOVERTFONTS          = 0x01000000L,
    }

    // these are extra nFontType bits that are added to what is returned to the
    // EnumFonts callback routine

    enum FontType
    {
        SIMULATED_FONTTYPE  = 0x8000,
        PRINTER_FONTTYPE    = 0x4000,
        SCREEN_FONTTYPE     = 0x2000,
        BOLD_FONTTYPE       = 0x0100,
        ITALIC_FONTTYPE     = 0x0200,
        REGULAR_FONTTYPE    = 0x0400,

        // EnumFonts callback routine only uses these bits, so we can use the rest

        // #define RASTER_FONTTYPE     0x001
        // #define DEVICE_FONTTYPE     0x002
        // #define TRUETYPE_FONTTYPE   0x004

        OPENTYPE_FONTTYPE   = 0x10000,
        TYPE1_FONTTYPE      = 0x20000,
        DSIG_FONTTYPE       = 0x40000,
    }

    enum ChooseFontMessage : UINT
    {
        WM_CHOOSEFONT_GETLOGFONT    = (WM_USER + 1),
        WM_CHOOSEFONT_SETLOGFONT    = (WM_USER + 101),
        WM_CHOOSEFONT_SETFLAGS      = (WM_USER + 102)
    }

    // strings used to obtain unique window message for communication
    // between dialog and caller

    const LPSTR LBSELCHSTRINGA  = "commdlg_LBSelChangedNotify";
    const LPSTR SHAREVISTRINGA  = "commdlg_ShareViolation";
    const LPSTR FILEOKSTRINGA   = "commdlg_FileNameOK";
    const LPSTR COLOROKSTRINGA  = "commdlg_ColorOK";
    const LPSTR SETRGBSTRINGA   = "commdlg_SetRGBColor";
    const LPSTR HELPMSGSTRINGA  = "commdlg_help";
    const LPSTR FINDMSGSTRINGA  = "commdlg_FindReplace";

    const LPWSTR LBSELCHSTRINGW = "commdlg_LBSelChangedNotify";
    const LPWSTR SHAREVISTRINGW = "commdlg_ShareViolation";
    const LPWSTR FILEOKSTRINGW  = "commdlg_FileNameOK";
    const LPWSTR COLOROKSTRINGW = "commdlg_ColorOK";
    const LPWSTR SETRGBSTRINGW  = "commdlg_SetRGBColor";
    const LPWSTR HELPMSGSTRINGW = "commdlg_help";
    const LPWSTR FINDMSGSTRINGW = "commdlg_FindReplace";

    // HIWORD values for lParam of commdlg_LBSelChangeNotify message
    enum ListBoxSelectionChange
    {
        CD_LBSELNOITEMS = -1,
        CD_LBSELCHANGE  =  0,
        CD_LBSELSUB     =  1,
        CD_LBSELADD     =  2
    }

    alias UINT function (HWND, UINT, WPARAM, LPARAM) LPPRINTHOOKPROC;
    alias UINT function (HWND, UINT, WPARAM, LPARAM) LPSETUPHOOKPROC;

    struct PRINTDLGA
    {
       DWORD            lStructSize;
       HWND             hwndOwner;
       HGLOBAL          hDevMode;
       HGLOBAL          hDevNames;
       HDC              hDC;
       DWORD            Flags;
       WORD             nFromPage;
       WORD             nToPage;
       WORD             nMinPage;
       WORD             nMaxPage;
       WORD             nCopies;
       HINSTANCE        hInstance;
       LPARAM           lCustData;
       LPPRINTHOOKPROC  lpfnPrintHook;
       LPSETUPHOOKPROC  lpfnSetupHook;
       LPCSTR           lpPrintTemplateName;
       LPCSTR           lpSetupTemplateName;
       HGLOBAL          hPrintTemplate;
       HGLOBAL          hSetupTemplate;
    }
    alias PRINTDLGA* LPPRINTDLGA;

    struct PRINTDLGW
    {
       DWORD            lStructSize;
       HWND             hwndOwner;
       HGLOBAL          hDevMode;
       HGLOBAL          hDevNames;
       HDC              hDC;
       DWORD            Flags;
       WORD             nFromPage;
       WORD             nToPage;
       WORD             nMinPage;
       WORD             nMaxPage;
       WORD             nCopies;
       HINSTANCE        hInstance;
       LPARAM           lCustData;
       LPPRINTHOOKPROC  lpfnPrintHook;
       LPSETUPHOOKPROC  lpfnSetupHook;
       LPCWSTR          lpPrintTemplateName;
       LPCWSTR          lpSetupTemplateName;
       HGLOBAL          hPrintTemplate;
       HGLOBAL          hSetupTemplate;
    }
    alias PRINTDLGW* LPPRINTDLGW;

    BOOL PrintDlgA(LPPRINTDLGA);
    BOOL PrintDlgW(LPPRINTDLGW);

    enum PrintDialogFlags : UINT
    {
        PD_ALLPAGES                    = 0x00000000,
        PD_SELECTION                   = 0x00000001,
        PD_PAGENUMS                    = 0x00000002,
        PD_NOSELECTION                 = 0x00000004,
        PD_NOPAGENUMS                  = 0x00000008,
        PD_COLLATE                     = 0x00000010,
        PD_PRINTTOFILE                 = 0x00000020,
        PD_PRINTSETUP                  = 0x00000040,
        PD_NOWARNING                   = 0x00000080,
        PD_RETURNDC                    = 0x00000100,
        PD_RETURNIC                    = 0x00000200,
        PD_RETURNDEFAULT               = 0x00000400,
        PD_SHOWHELP                    = 0x00000800,
        PD_ENABLEPRINTHOOK             = 0x00001000,
        PD_ENABLESETUPHOOK             = 0x00002000,
        PD_ENABLEPRINTTEMPLATE         = 0x00004000,
        PD_ENABLESETUPTEMPLATE         = 0x00008000,
        PD_ENABLEPRINTTEMPLATEHANDLE   = 0x00010000,
        PD_ENABLESETUPTEMPLATEHANDLE   = 0x00020000,
        PD_USEDEVMODECOPIES            = 0x00040000,
        PD_USEDEVMODECOPIESANDCOLLATE  = 0x00040000,
        PD_DISABLEPRINTTOFILE          = 0x00080000,
        PD_HIDEPRINTTOFILE             = 0x00100000,
        PD_NONETWORKBUTTON             = 0x00200000
    }

    struct DEVNAMES
    {
       WORD wDriverOffset;
       WORD wDeviceOffset;
       WORD wOutputOffset;
       WORD wDefault;
    }
    alias DEVNAMES* LPDEVNAMES;

    const uint DN_DEFAULTPRN    = 0x0001;

    DWORD CommDlgExtendedError();

    enum PageSetupDialogMessage
    {
        WM_PSD_PAGESETUPDLG     = (WM_USER  ),
        WM_PSD_FULLPAGERECT     = (WM_USER+1),
        WM_PSD_MINMARGINRECT    = (WM_USER+2),
        WM_PSD_MARGINRECT       = (WM_USER+3),
        WM_PSD_GREEKTEXTRECT    = (WM_USER+4),
        WM_PSD_ENVSTAMPRECT     = (WM_USER+5),
        WM_PSD_YAFULLPAGERECT   = (WM_USER+6)
    }

    alias UINT function (HWND, UINT, WPARAM, LPARAM) LPPAGEPAINTHOOK;
    alias UINT function (HWND, UINT, WPARAM, LPARAM) LPPAGESETUPHOOK;

    struct PAGESETUPDLGA
    {
        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;
    }

    alias PAGESETUPDLGA* LPPAGESETUPDLGA;

    struct PAGESETUPDLGW
    {
        DWORD           lStructSize;
        HWND            hwndOwner;
        HGLOBAL         hDevMode;
        HGLOBAL         hDevNames;
        DWORD           Flags;
        POINT           ptPaperSize;
        RECT            rtMinMargin;
        RECT            rtMargin;
        HINSTANCE       hInstance;
        LPARAM          lCustData;
        LPPAGESETUPHOOK lpfnPageSetupHook;
        LPPAGEPAINTHOOK lpfnPagePaintHook;
        LPCWSTR         lpPageSetupTemplateName;
        HGLOBAL         hPageSetupTemplate;
    }
    alias PAGESETUPDLGW* LPPAGESETUPDLGW;

    BOOL PageSetupDlgA(LPPAGESETUPDLGA);
    BOOL PageSetupDlgW(LPPAGESETUPDLGW);

    enum PageSetupDialogFlags : UINT
    {
        PSD_DEFAULTMINMARGINS               = 0x00000000, // default (printer's)
        PSD_INWININIINTLMEASURE             = 0x00000000, // 1st of 4 possible

        PSD_MINMARGINS                      = 0x00000001, // use caller's
        PSD_MARGINS                         = 0x00000002, // use caller's
        PSD_INTHOUSANDTHSOFINCHES           = 0x00000004, // 2nd of 4 possible
        PSD_INHUNDREDTHSOFMILLIMETERS       = 0x00000008, // 3rd of 4 possible
        PSD_DISABLEMARGINS                  = 0x00000010,
        PSD_DISABLEPRINTER                  = 0x00000020,
        PSD_NOWARNING                       = 0x00000080, // must be same as PD_*
        PSD_DISABLEORIENTATION              = 0x00000100,
        PSD_RETURNDEFAULT                   = 0x00000400, // must be same as PD_*
        PSD_DISABLEPAPER                    = 0x00000200,
        PSD_SHOWHELP                        = 0x00000800, // must be same as PD_*
        PSD_ENABLEPAGESETUPHOOK             = 0x00002000, // must be same as PD_*
        PSD_ENABLEPAGESETUPTEMPLATE         = 0x00008000, // must be same as PD_*
        PSD_ENABLEPAGESETUPTEMPLATEHANDLE   = 0x00020000, // must be same as PD_*
        PSD_ENABLEPAGEPAINTHOOK             = 0x00040000,
        PSD_DISABLEPAGEPAINTING             = 0x00080000,
        PSD_NONETWORKBUTTON                 = 0x00200000 // must be same as PD_*
    }


    version (UNICODE)
    {
        alias OPENFILENAMEW OPENFILENAME;
        alias LPOPENFILENAMEW LPOPENFILENAME;
        alias GetOpenFileNameW GetOpenFileName;
        alias GetSaveFileNameW GetSaveFileName;
        alias GetFileTitleW GetFileTitle;

        alias OFNOTIFYW OFNOTIFY;
        alias LPOFNOTIFYW LPOFNOTIFY;
        alias OFNOTIFYEXW OFNOTIFYEX;
        alias LPOFNOTIFYEXW LPOFNOTIFYEX;
        alias CommDlg_OpenSave_GetSpecW CommDlg_OpenSave_GetSpec;
        alias CommDlg_OpenSave_GetFilePathW CommDlg_OpenSave_GetFilePath;
        alias CommDlg_OpenSave_GetFolderPathW CommDlg_OpenSave_GetFolderPath;
        alias CHOOSECOLORW CHOOSECOLOR;
        alias LPCHOOSECOLORW LPCHOOSECOLOR;
        alias ChooseColorW ChooseColor;
        alias FINDREPLACEW FINDREPLACE;
        alias LPFINDREPLACEW LPFINDREPLACE;
        alias FindTextW FindText;
        alias ReplaceTextW ReplaceText;
        alias AfxReplaceTextW AfxReplaceText;
        alias CHOOSEFONTW CHOOSEFONT;
        alias LPCHOOSEFONTW LPCHOOSEFONT;
        alias ChooseFontW ChooseFont;
        alias LBSELCHSTRINGW LBSELCHSTRING;
        alias SHAREVISTRINGW SHAREVISTRING;
        alias FILEOKSTRINGW FILEOKSTRING;
        alias COLOROKSTRINGW COLOROKSTRING;
        alias SETRGBSTRINGW SETRGBSTRING;
        alias HELPMSGSTRINGW HELPMSGSTRING;
        alias FINDMSGSTRINGW FINDMSGSTRING;
        alias PRINTDLGW PRINTDLG;
        alias LPPRINTDLGW LPPRINTDLG;
        alias PrintDlgW PrintDlg;
        alias PAGESETUPDLGW PAGESETUPDLG;
        alias LPPAGESETUPDLGW LPPAGESETUPDLG;
        alias PageSetupDlgW PageSetupDlg;
    }
    else
    {
        alias OPENFILENAMEA OPENFILENAME;
        alias LPOPENFILENAMEA LPOPENFILENAME;
        alias GetOpenFileNameA GetOpenFileName;
        alias GetSaveFileNameA GetSaveFileName;
        alias GetFileTitleA GetFileTitle;
        alias OFNOTIFYA OFNOTIFY;
        alias LPOFNOTIFYA LPOFNOTIFY;
        alias OFNOTIFYEXA OFNOTIFYEX;
        alias LPOFNOTIFYEXA LPOFNOTIFYEX;
        alias CommDlg_OpenSave_GetSpecA CommDlg_OpenSave_GetSpec;
        alias CommDlg_OpenSave_GetFilePathA CommDlg_OpenSave_GetFilePath;
        alias CommDlg_OpenSave_GetFolderPathA CommDlg_OpenSave_GetFolderPath;
        alias CHOOSECOLORA CHOOSECOLOR;
        alias LPCHOOSECOLORA LPCHOOSECOLOR;
        alias ChooseColorA ChooseColor;
        alias FINDREPLACEA FINDREPLACE;
        alias LPFINDREPLACEA LPFINDREPLACE;
        alias FindTextA FindText;
        alias ReplaceTextA ReplaceText;
        alias AfxReplaceTextA AfxReplaceText;
        alias CHOOSEFONTA CHOOSEFONT;
        alias LPCHOOSEFONTA LPCHOOSEFONT;
        alias ChooseFontA ChooseFont;
        alias LBSELCHSTRINGA LBSELCHSTRING;
        alias SHAREVISTRINGA SHAREVISTRING;
        alias FILEOKSTRINGA FILEOKSTRING;
        alias COLOROKSTRINGA COLOROKSTRING;
        alias SETRGBSTRINGA SETRGBSTRING;
        alias HELPMSGSTRINGA HELPMSGSTRING;
        alias FINDMSGSTRINGA FINDMSGSTRING;
        alias PRINTDLGA PRINTDLG;
        alias LPPRINTDLGA LPPRINTDLG;
        alias PrintDlgA PrintDlg;
        alias PAGESETUPDLGA PAGESETUPDLG;
        alias LPPAGESETUPDLGA LPPAGESETUPDLG;
        alias PageSetupDlgA PageSetupDlg;
    }
}

_________________
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS$ d- s+:+ a-- C++> ULS++ P++ L+> !E W+++ N+ o? K? w++>
O---@ M V? PS+ PE Y+ PGP t+ 5- X+++@ R- tv+(++) b++> DI!
D++> G e+> h-- r- y+
------END GEEK CODE BLOCK------
Back to top
View user's profile Send private message
jcc7



Joined: 22 Feb 2004
Posts: 657
Location: Muskogee, OK, USA

PostPosted: Thu May 13, 2004 11:59 am    Post subject: Re: Commdlg.d Reply with quote

jcesar wrote:
Also didn't find any symbol colliding with std.c.windows.windows so I removed all the STANDALONE blocks.

The STANDALONE versions are there for a reason. The conflicts don't appear until you try to use them in a program with Core32 and std.c.windows.windows both compiled in. Look at std.c.windows.windows, line 2165 (latest version of DMD): "struct OPENFILENAMEA {". That will conflict will your version of commdlg.d. There's no easy way to track down which portion will conflict, so the best policy to assume the STANDALONE should be there.

Here's an example that makes my point:
Code:
import win32.commdlg;
import std.c.windows.windows;

void main()
{
    OPENFILENAMEA a;
}


This is my error message that I got from using your version of commdlg.d (it compiles fine using Mike's version with the STANDALONE's):
win32\commdlg.d(26): struct OPENFILENAMEA conflicts with windows.OPENFILENAMEA at c:\dmd\bin\..\src\phobos\std\c\windows\windows.d(2165)
Back to top
View user's profile Send private message AIM Address
l8night



Joined: 03 May 2004
Posts: 32
Location: UK

PostPosted: Fri May 14, 2004 11:38 am    Post subject: Reply with quote

There are two issues with this:
ONE (as pointed out above), which is an unfortunate side effect of the module nature of D, symbol names only clash when used undecorated (i.e)
file a/boo.d symbol has FOO => a.boo.FOO;
file mine/other.d has symbol FOO => mine.other.FOO;
if both files are imported, then they only clash if a file used 'FOO' (as opposed to 'a.boo.FOO')
it is important that you try to compile a project that uses the symbols you think are no longer within phobos (unlikely to happen for a while)

TWO: this is rather important .....
there is a very good reason why the file was wrapped with extern(Windows) { ... } and NOT version(Windows) { ... }

version( xxx ) { ... } means compile if version xxx is to be compiled
extern( xxx ) { ... } means compile with Windows calling conventions
without this all external functions will be called with D conventions and not stdcall (Windows) and thus the call may cause stack corruption and other hard to track errors.

If you are going to change something check properly that it can be changed, unfortunatly just because it compiles does not mean its right!
Back to top
View user's profile Send private message
jcesar



Joined: 26 Apr 2004
Posts: 5

PostPosted: Thu May 27, 2004 2:19 pm    Post subject: Reply with quote

I've updated the source code taking care of your comments. The file should be on your inbox by now.
_________________
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS$ d- s+:+ a-- C++> ULS++ P++ L+> !E W+++ N+ o? K? w++>
O---@ M V? PS+ PE Y+ PGP t+ 5- X+++@ R- tv+(++) b++> DI!
D++> G e+> h-- r- y+
------END GEEK CODE BLOCK------
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Core32 All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group