Welcome to LEAD Support Forum Login | Register | Faq  

    LEAD Support Forum
  Resource to find answers and post technical questions about LEAD products.
Search    
   

Re: LDialogFile::DoModalSave - Can't seem to set file filters
Started by JezzerP at 12-11-2007 5:41. Topic has 9 replies.

Print Search « Previous Thread Next Thread »
  12-11-2007, 5:41
JezzerP is not online. Last active: 3/10/2010 4:09:59 PM JezzerP



Top 150 Posts
Joined on 05-22-2006
York, UK
Posts 22
LDialogFile::DoModalSave - Can't seem to set file filters
Reply Quote
Hi,

Using Raster Imaging Tools v15 C++ Class Libraries, and I'm having trouble setting the file filters for the LDialogFile::DoModalSave common dialog. The code I have at present just isn't doing what I think it should be doing, and I'm getting the complete list of possible save formats.

    try
    }
        LDialogFile dlg(pBitmap);
        dlg.Initialize(0);

        SAVEDLGPARAMS fsp;
        memset ( &fsp, 0, sizeof ( SAVEDLGPARAMS ) ) ;
        dlg.GetSaveParams(&fsp, sizeof(SAVEDLGPARAMS));
        fsp.nPageNumber = 1;
        fsp.uSaveMulti  = FALSE;

        // Keep file types to a bare minimum so user can understand!
        FILESAVEFORMAT fsf[5];
        fsf[0].nFormat = DLG_FF_SAVE_JPEG;
        fsf[1].nFormat = DLG_FF_SAVE_PNG;
        fsf[2].nFormat = DLG_FF_SAVE_TIFF;
        fsf[3].nFormat = DLG_FF_SAVE_BMP;
        fsf[4].nFormat = DLG_FF_SAVE_PCX;
   
        fsp.uFileFormatsCount = 5;
        fsp.pFileFormats = fsf;
        dlg.SetSaveParams(&fsp);

        .........
    }

Any help would be most welcome.

thanks

Jeremy

   Report 
  12-11-2007, 12:29
GregR is not online. Last active: 3/18/2010 11:41:49 AM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 2,252
Re: LDialogFile::DoModalSave - Can't seem to set file filters
Reply Quote
Try filling the uStructSize property.  It worked for me.


fsf[0].nFormat = DLG_FF_SAVE_JPEG;
fsf[0].uStructSize = sizeof(FILESAVEFORMAT);
fsf[1].nFormat = DLG_FF_SAVE_PNG;
fsf[1].uStructSize = sizeof(FILESAVEFORMAT);
fsf[2].nFormat = DLG_FF_SAVE_TIFF;
fsf[2].uStructSize = sizeof(FILESAVEFORMAT);
fsf[3].nFormat = DLG_FF_SAVE_BMP;
fsf[3].uStructSize = sizeof(FILESAVEFORMAT);
fsf[4].nFormat = DLG_FF_SAVE_PCX;
fsf[4].uStructSize = sizeof(FILESAVEFORMAT);


Greg Ross
LEADTOOLS Technical Support
   Report 
  12-12-2007, 4:13
JezzerP is not online. Last active: 3/10/2010 4:09:59 PM JezzerP



Top 150 Posts
Joined on 05-22-2006
York, UK
Posts 22
Re: LDialogFile::DoModalSave - Can't seem to set file filters
Reply Quote
Thanks for the response, but no, that's not solved it....still getting the full list of possible file save formats

Jeremy

   Report 
  12-12-2007, 8:34
GregR is not online. Last active: 3/18/2010 11:41:49 AM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 2,252
Re: LDialogFile::DoModalSave - Can't seem to set file filters
Reply Quote
Please send a small sample project (NOT your entire application) that isolates the problem so I can try to reproduce it here.

NOTE: If you are attaching a project or file to the forums...
1.) Zip the file(s) up.
2.) Make sure it is less than 5 MB.  If it is larger, please send an email to support@leadtools.com and we'll send you FTP instructions.
3.) Remove ANY AND ALL unlock codes and LEADTOOLS DLLs.
4.) Do not click the preview button, the attachment will not show up when you post it.
 
If you do not wish to post your file(s) on the forum since they are publically viewable, please send an email to support@leadtools.com and make sure that you include a link to this forum post.


Greg Ross
LEADTOOLS Technical Support
   Report 
  12-12-2007, 10:26
JezzerP is not online. Last active: 3/10/2010 4:09:59 PM JezzerP



Top 150 Posts
Joined on 05-22-2006
York, UK
Posts 22
Re: LDialogFile::DoModalSave - Can't seem to set file filters
Reply Quote
Thanks Greg,

I'll see if I can find time to work-up a small project. However, it will probably work as required if I do that!!

Jeremy

   Report 
  12-12-2007, 10:48
GregR is not online. Last active: 3/18/2010 11:41:49 AM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 2,252
Re: LDialogFile::DoModalSave - Can't seem to set file filters
Reply Quote
Sometimes that happens, if it does, then you have a working example with which you can compare your main application's code and find the problem.

If you still have the problem in a small sample project, I'll gladly take a look at it.

Greg Ross
LEADTOOLS Technical Support
   Report 
  12-13-2007, 7:01
JezzerP is not online. Last active: 3/10/2010 4:09:59 PM JezzerP



Top 150 Posts
Joined on 05-22-2006
York, UK
Posts 22
Re: LDialogFile::DoModalSave - Can't seem to set file filters
Reply Quote
Thanks for prodding me in the right direction Greg. Got a small app working the way I wanted it to, and it turns out I wasn't setting the size of the SAVEDLGPARAMS structure before calling SetSaveParams(LPSAVEDLGPARAMS). Also, several of my calls into LeadTools methods that return error codes were not surrounded by a try-catch block so I was missing the errors!!

Jeremy

   Report 
  03-19-2009, 3:50
CTS_user is not online. Last active: 7/17/2009 4:20:32 PM CTS_user



Not Ranked
Joined on 03-17-2009
Posts 4
Re: LDialogFile::DoModalSave - Can't seem to set file filters
Reply Quote
i have the same problem :
FILESAVEFORMAT f[17];


memset ( &FSParm, 0, sizeof ( SAVEDLGPARAMS ) ) ;
memset ( &OpenFileName, 0, sizeof ( OPENFILENAMEW ) ) ;
memset (f , 0 , 17 );


//f[0].nFormat = F_JFIF8;
f[0].nBppCount = 8 ;
f[0].uStructSize = sizeof( FILESAVEFORMAT);
f[0].nFormat = DLG_FF_SAVE_SUB_JPEG8_YUV_400 |
DLG_FF_SAVE_SUB_JPEG8_PROG_400 |
DLG_FF_SAVE_SUB_JPEG8_LOSSLESS;

//f[1].nFormat = FS_JFIF12;
f[1].nBppCount = 12 ;
f[1].uStructSize = sizeof( FILESAVEFORMAT);
f[1].nFormat = DLG_FF_SAVE_SUB_JPEG12_YUV_400 |
DLG_FF_SAVE_SUB_JPEG12_LOSSLESS;


//f[2].nFormat = FS_JFIF24;
f[2].nBppCount = 24 ;
f[2].uStructSize = sizeof( FILESAVEFORMAT);
f[2].nFormat = DLG_FF_SAVE_SUB_JPEG24_YUV_444 |
DLG_FF_SAVE_SUB_JPEG24_YUV_422 |
DLG_FF_SAVE_SUB_JPEG24_YUV_411 |
DLG_FF_SAVE_SUB_JPEG24_PROG_444 |
DLG_FF_SAVE_SUB_JPEG24_PROG_422 |
DLG_FF_SAVE_SUB_JPEG24_PROG_411 |
DLG_FF_SAVE_SUB_JPEG24_LOSSLESS;


//f[3].nFormat = FS_BMP1;
f[3].nFormat = DLG_FF_SAVE_OS2BMP;
f[3].nBppCount = 1 ;
f[3].uStructSize = sizeof( FILESAVEFORMAT);

//f[4].nFormat = FS_BMP4;
f[4].nFormat = DLG_FF_SAVE_OS2BMP;
f[4].nBppCount = 4 ;
f[4].uStructSize = sizeof( FILESAVEFORMAT);
f[4].nFormat = DLG_FF_SAVE_SUB_BMP_UNCOMPRESSED |
DLG_FF_SAVE_SUB_BMP_RLECOMPRESSED;

//f[5].nFormat = FS_BMP8;
f[5].nFormat = DLG_FF_SAVE_OS2BMP;
f[5].nBppCount = 8 ;
f[5].uStructSize = sizeof( FILESAVEFORMAT);
f[5].nFormat = DLG_FF_SAVE_SUB_BMP_UNCOMPRESSED |
DLG_FF_SAVE_SUB_BMP_RLECOMPRESSED;

f[6].nFormat = DLG_FF_SAVE_OS2BMP;
f[6].nBppCount = 16 ;
f[6].uStructSize = sizeof( FILESAVEFORMAT);

//f[7].nFormat = FS_BMP24;
f[7].nFormat = DLG_FF_SAVE_OS2BMP;
f[7].nBppCount = 24 ;
f[7].uStructSize = sizeof( FILESAVEFORMAT);

f[8].nFormat = DLG_FF_SAVE_OS2BMP;
f[8].nBppCount = 32 ;
f[8].uStructSize = sizeof( FILESAVEFORMAT);


//f[9].nFormat = FS_TIFF1;
f[9].nBppCount = 1 ;
f[9].uStructSize = sizeof( FILESAVEFORMAT);
f[9].nFormat = DLG_FF_SAVE_SUB_TIFF1_CCITT |
DLG_FF_SAVE_SUB_TIFF1_CCITT_G3_1D |
DLG_FF_SAVE_SUB_TIFF1_CCITT_G3_2D |
DLG_FF_SAVE_SUB_TIFF1_CCITT_G4 |
DLG_FF_SAVE_SUB_TIFF1_UNCOMPRESSEDRGB;


//f[10].nFormat = FS_TIFF4;
f[10].nBppCount = 4 ;
f[10].uStructSize = sizeof( FILESAVEFORMAT);
f[10].nFormat = f[0].nFormat ;

//f[11].nFormat = FS_TIFF8;
f[11].nBppCount = 8 ;
f[11].uStructSize = sizeof( FILESAVEFORMAT);
f[11].nFormat = DLG_FF_SAVE_SUB_TIFF8_JPEG_GRAY_YCC |
DLG_FF_SAVE_SUB_TIFF8_LOSSLESSJPEG|
DLG_FF_SAVE_SUB_TIFF8_JBIG |
DLG_FF_SAVE_SUB_TIFF8_CMP |
DLG_FF_SAVE_SUB_TIFF8_J2K |
DLG_FF_SAVE_SUB_TIFF8_CMW;

//f[12].nFormat = FS_TIFF12;
f[12].nBppCount = 12 ;
f[12].uStructSize = sizeof( FILESAVEFORMAT);
f[12].nFormat = DLG_FF_SAVE_SUB_TIFF12_UNCOMPRESSED |
DLG_FF_SAVE_SUB_TIFF12_RLE |
DLG_FF_SAVE_SUB_TIFF12_LOSSLESSJPEG |
DLG_FF_SAVE_SUB_TIFF12_JPEG_GRAY_YCC |
DLG_FF_SAVE_SUB_TIFF12_LZW |
DLG_FF_SAVE_SUB_TIFF12_J2K |
DLG_FF_SAVE_SUB_TIFF12_CMW;


//f[13].nFormat = FS_TIFF16;
f[13].nBppCount = 16 ;
f[13].uStructSize = sizeof( FILESAVEFORMAT);
f[13].nFormat = DLG_FF_SAVE_SUB_TIFF16_UNCOMPRESSED |
DLG_FF_SAVE_SUB_TIFF16_RLE |
DLG_FF_SAVE_SUB_TIFF16_LOSSLESSJPEG |
DLG_FF_SAVE_SUB_TIFF16_LZW |
DLG_FF_SAVE_SUB_TIFF16_J2K |
DLG_FF_SAVE_SUB_TIFF16_CMW;


//f[14].nFormat = FS_TIFF24;
f[14].nBppCount = 24 ;
f[14].uStructSize = sizeof( FILESAVEFORMAT);
f[14].nFormat = DLG_FF_SAVE_SUB_TIFF24_UNCOMPRESSEDRGB |
DLG_FF_SAVE_SUB_TIFF24_UNCOMPRESSEDCMYK |
DLG_FF_SAVE_SUB_TIFF24_UNCOMPRESSEDYCC |
DLG_FF_SAVE_SUB_TIFF24_RLERGB |
DLG_FF_SAVE_SUB_TIFF24_RLECMYK |
DLG_FF_SAVE_SUB_TIFF24_RLEYCC |
DLG_FF_SAVE_SUB_TIFF24_JPEG_YCC_444 |
DLG_FF_SAVE_SUB_TIFF24_JPEG_YCC_422 |
DLG_FF_SAVE_SUB_TIFF24_JPEG_YCC_411 |
DLG_FF_SAVE_SUB_TIFF24_LOSSLESSJPEG |
DLG_FF_SAVE_SUB_TIFF24_LZWRGB |
DLG_FF_SAVE_SUB_TIFF24_LZWCMYK |
DLG_FF_SAVE_SUB_TIFF24_LZWYCC |
DLG_FF_SAVE_SUB_TIFF24_CMP_NONPROGRESSIVE |
DLG_FF_SAVE_SUB_TIFF24_CMP_PROGRESSIVE |
DLG_FF_SAVE_SUB_TIFF24_J2K |
DLG_FF_SAVE_SUB_TIFF24_CMW;


//f[15].nFormat = FS_TIFF32;
f[15].nBppCount = 32 ;
f[15].uStructSize = sizeof( FILESAVEFORMAT);
f[15].nFormat = DLG_FF_SAVE_SUB_TIFF32_UNCOMPRESSEDRGB |
DLG_FF_SAVE_SUB_TIFF32_UNCOMPRESSEDCMYK |
DLG_FF_SAVE_SUB_TIFF32_RLERGB |
DLG_FF_SAVE_SUB_TIFF32_RLECMYK |
DLG_FF_SAVE_SUB_TIFF32_LZWRGB |
DLG_FF_SAVE_SUB_TIFF32_LZWCMYK;


//f[16].nFormat = FS_TIFF64;
f[16].nBppCount = 64 ;
f[16].uStructSize = sizeof( FILESAVEFORMAT);
f[16].nFormat = DLG_FF_SAVE_SUB_TIFF64_UNCOMPRESSEDRGB |
DLG_FF_SAVE_SUB_TIFF64_LZWRGB;

FSParm.pFileFormats = f ;

FSParm.uFileFormatsCount = 17;

and the nRet = L_DlgSave ( hwnd, (struct tagOFNA *)&SaveFileName, &FSParm ); return -13

can yu help me ?
   Report 
  03-19-2009, 6:04
JezzerP is not online. Last active: 3/10/2010 4:09:59 PM JezzerP



Top 150 Posts
Joined on 05-22-2006
York, UK
Posts 22
Re: LDialogFile::DoModalSave - Can't seem to set file filters
Reply Quote
Here's what works for me. Obviously the CLeadToolsUtils::Try() function is one of our own, but you should get the gist of what I'm doing.

    try
    {
        LDialogFile DlgFile;
        DlgFile.SetBitmap (pBitmap);
        CLeadToolsUtils::Try(LDialogFile::Initialize(0));

        SAVEDLGPARAMS DlgParams ; 
        OPENFILENAMEW  OpenFileName ;
        memset ( &DlgParams, 0, sizeof ( SAVEDLGPARAMS ) ) ;
        OpenFileName.lStructSize     = sizeof ( OPENFILENAMEW ) ;
        OpenFileName.lpstrInitialDir = NULL;
        OpenFileName.nFilterIndex    = 0 ;

        // Set up the file format subformat arrays
        FILESAVEFORMATBPP jpgFSFBPP[1];
        jpgFSFBPP[0].uSubFormats = DLG_FF_SAVE_SUB_JPEG24_YUV_444;
        jpgFSFBPP[0].nFormatBpp = 24;
        jpgFSFBPP[0].uStructSize = sizeof(FILESAVEFORMATBPP);

        FILESAVEFORMATBPP pngFSFBPP[1];
        pngFSFBPP[0].uSubFormats = 0;
        pngFSFBPP[0].nFormatBpp = 24;
        pngFSFBPP[0].uStructSize = sizeof(FILESAVEFORMATBPP);

        FILESAVEFORMATBPP bmpFSFBPP[1];
        bmpFSFBPP[0].uSubFormats = 0;
        bmpFSFBPP[0].nFormatBpp = 24;
        bmpFSFBPP[0].uStructSize = sizeof(FILESAVEFORMATBPP);

        FILESAVEFORMATBPP pcxFSFBPP[1];
        pcxFSFBPP[0].uSubFormats = 0;
        pcxFSFBPP[0].nFormatBpp = 24;
        pcxFSFBPP[0].uStructSize = sizeof(FILESAVEFORMATBPP);

        FILESAVEFORMATBPP tiffFSFBPP[1];
        tiffFSFBPP[0].uSubFormats = DLG_FF_SAVE_SUB_TIFF24_UNCOMPRESSEDRGB;
        tiffFSFBPP[0].nFormatBpp = 24;
        tiffFSFBPP[0].uStructSize = sizeof(FILESAVEFORMATBPP);

        // Limit the filter to bitmap, gif, cmp and jpg
        FILESAVEFORMAT fsf[5];
       
        fsf[0].nFormat = DLG_FF_SAVE_JPEG;
        fsf[0].uStructSize = sizeof(FILESAVEFORMAT);
        fsf[0].nBppCount = 2;
        fsf[0].pFileSaveFormatBpp = jpgFSFBPP;
       
        fsf[1].nFormat = DLG_FF_SAVE_PNG;
        fsf[1].uStructSize = sizeof(FILESAVEFORMAT);
        fsf[1].nBppCount = 1;
        fsf[1].pFileSaveFormatBpp = pngFSFBPP;
       
        fsf[2].nFormat = DLG_FF_SAVE_TIFF;
        fsf[2].uStructSize = sizeof(FILESAVEFORMAT);
        fsf[2].nBppCount = 1;
        fsf[2].pFileSaveFormatBpp = tiffFSFBPP;
       
        fsf[3].nFormat = DLG_FF_SAVE_BMP;
        fsf[3].uStructSize = sizeof(FILESAVEFORMAT);
        fsf[3].nBppCount = 1;
        fsf[3].pFileSaveFormatBpp = bmpFSFBPP;
       
        fsf[4].nFormat = DLG_FF_SAVE_PCX;
        fsf[4].uStructSize = sizeof(FILESAVEFORMAT);
        fsf[4].nBppCount = 1;
        fsf[4].pFileSaveFormatBpp = pcxFSFBPP;

        DlgParams.uFileFormatsCount = 5;
        DlgParams.pFileFormats = fsf;
        DlgParams.uStructSize = sizeof (SAVEDLGPARAMS) ;
        DlgParams.nQFactor = 2 ;
        DlgParams.nPageNumber = 1 ;
        DlgParams.uSaveMulti = MULTIPAGE_OPERATION_REPLACE ;
        DlgParams.uDlgFlags = DLG_SAVE_SHOW_FILEOPTIONS_PROGRESSIVE     |
            DLG_SAVE_SHOW_FILEOPTIONS_MULTIPAGE       |
            DLG_SAVE_SHOW_FILEOPTIONS_STAMP           |
            DLG_SAVE_SHOW_FILEOPTIONS_QFACTOR         |
            DLG_SAVE_SHOW_FILEOPTIONS_J2KOPTIONS      |
            DLG_SAVE_SHOW_FILEOPTIONS_BASICJ2KOPTIONS ;
        DlgFile.EnableCallBack (FALSE);
        DlgFile.EnableAutoProcess(TRUE);
        CLeadToolsUtils::Try(DlgFile.SetSaveParams (&DlgParams));

        // Set the initial folder
        CFolderManager fmWell(pszWellNameOrId);
        CWFilename sfDefault = fmWell.GetWellImagesFolder();

        sfDefault.SetElements(sfChartName, WFName);
        sfDefault.SetElements(_T("*.jpg"), WFExt);
        sfDefault.MakeNextAvailable();

        CLeadToolsUtils::Try(DlgFile.SetFileName(sfDefault.GetBuffer(_MAX_PATH)));

        sfDefault.ReleaseBuffer();

        CLeadToolsUtils::Try(DlgFile.DoModalSave(pParent->GetSafeHwnd()));

        // Gets the updated values for the structure
        CLeadToolsUtils::Try(DlgFile.GetSaveParams(&DlgParams, sizeof(DlgParams)));

        DlgFile.GetFileName(sfImageNameGiven.GetBuffer(_MAX_PATH), _MAX_PATH);
        sfImageNameGiven.ReleaseBuffer();

        CLeadToolsUtils::Try(LDialogFile::Free());

[:)]

   Report 
  03-20-2009, 6:41
CTS_user is not online. Last active: 7/17/2009 4:20:32 PM CTS_user



Not Ranked
Joined on 03-17-2009
Posts 4
Re: LDialogFile::DoModalSave - Can't seem to set file filters
Reply Quote
thanks!it's ok! :)
   Report 
Post
LEAD Support Fo... » Developer » Common Dialogs » Re: LDialogFile::DoModalSave - Can't seem to set file filters

Powered by Community Server, by Telligent Systems