LDialogFile::DoModalFilesAssociation

#include "ltwrappr.h"

virtual L_INT LDialogFile::DoModalFilesAssociation (hWndOwner)

HWND hWndOwner;

/* handle of the window which owns the dialog */

Displays the File Association dialog, in order to change file association options.

Parameter

Description

hWndOwner

Handle of the window which owns the dialog.

Returns

SUCCESS_DLG_OK

The "OK" button was pressed, and the dialog exited successfully.

SUCCESS_DLG_CANCEL

The "Cancel" button was pressed, and the dialog exited successfully.

< 1

An error occurred. Refer to Return Codes.

Comments

LDialogFile::SetFilesAssociationParams must be called before using this function to set the initial values for the dialog. You can get the updated FILESASSOCIATIONDLGPARAMS with the values entered by the user through the dialog by using LDialogFile::GetFilesAssociationParams.

The File Association dialog is shown in the following figure:

image\FileAssociation.gif

Use this dialog to control how the shell treats certain types of files. This lets you link your application to a certain file type, which causes the application to take ownership of that file type.

The parameters are used as input only and will not be updated by the dialog.

If the function was successful, then file formats will be associated or de-associated accordingly.

The same filter group string can be passed for both LDialogFile::DoModalOpen and LDialogFile::DoModalFilesAssociation because they have the same format.

Required DLLs and Libraries

LTDLGFILE
LTDLGKRN
LTDLGUTL
LTDLGCTRL
LTDLGCOM
LTFIL
LTDIS
LTIMG

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

See Also

Functions:

Class Members, LDialogFile::GetFilesAssociationParams, LDialogFile::SetFilesAssociationParams, LBase::EnableCallBack, LDialogBase::EnablePreview, LDialogBase::EnableAutoProcess, LDialogBase::EnableToolbar, LDialogBase::Free, LDialogBase::Initialize, LBitmapBase::Load

Topics:

Using Imaging Common Dialog

Example 1:

void TestFunction(LBitmap * pBitmap, HWND hWnd, L_TCHAR* pszServerAppName ) 
{
   L_INT nRet = 0; 
   LDialogFile DlgFile; 
   
   DlgFile.SetBitmap (pBitmap); 
   LDialogFile::Initialize (0); 

   FILESASSOCIATIONDLGPARAMS DLGPARAMSFileAssociation ; 
   
   memset ( &DLGPARAMSFileAssociation, 0, sizeof ( FILESASSOCIATIONDLGPARAMS ) ) ; 
   
   DLGPARAMSFileAssociation.uStructSize           = sizeof ( FILESASSOCIATIONDLGPARAMS ) ; 
   DLGPARAMSFileAssociation.pszFormats             = NULL ; 
   DLGPARAMSFileAssociation.pszServerAppName      = pszServerAppName; 
   DLGPARAMSFileAssociation.pszSelectedExt         = NULL ; 
   DLGPARAMSFileAssociation.pHelpCallBackUserData = NULL ; 
   DLGPARAMSFileAssociation.pfnHelpCallback       = NULL ; 
 

   DlgFile.EnableCallBack(FALSE); 
   DlgFile.SetFilesAssociationParams (&DLGPARAMSFileAssociation) ; 
   nRet = DlgFile.DoModalFilesAssociation(hWnd); 
   // Gets the updated values for the structure
   DlgFile.GetFilesAssociationParams(&DLGPARAMSFileAssociation, sizeof(DLGPARAMSFileAssociation)) ; 
   
   LDialogFile::Free ();

}

Example 2:

void TestFunction(LBitmap * pBitmap, HWND hWnd, L_TCHAR* pszServerAppName ) 
{
   L_INT nRet = 0; 
   LDialogFile DlgFile; 
   
   DlgFile.SetBitmap (pBitmap); 
   LDialogFile::Initialize (0); 

   FILESASSOCIATIONDLGPARAMS DLGPARAMSFileAssociation ; 
   
   L_TCHAR* pszFormats = 
   {
      TEXT("LEAD (*.cmp)\0")           TEXT("*.cmp\0")
      TEXT("DICOM (*.dic)\0")          TEXT("*.dic\0")
      TEXT("Windows Bitmap (*.bmp)\0") TEXT("*.bmp\0")
      TEXT("\0")
   } ; 

   L_TCHAR* pszSelectedFormats = 
   { 
      TEXT(".cmp\0")
      TEXT(".dic\0")
      TEXT("\0")
   } ; 
   
   memset ( &DLGPARAMSFileAssociation, 0, sizeof ( FILESASSOCIATIONDLGPARAMS ) ) ; 
   
   DLGPARAMSFileAssociation.uStructSize           = sizeof ( FILESASSOCIATIONDLGPARAMS ) ; 
   DLGPARAMSFileAssociation.pszFormats             = pszFormats ; 
   DLGPARAMSFileAssociation.pszServerAppName      = pszServerAppName ; 
   DLGPARAMSFileAssociation.pszSelectedExt         = pszSelectedFormats ; 
   DLGPARAMSFileAssociation.pHelpCallBackUserData = NULL ; 
   DLGPARAMSFileAssociation.pfnHelpCallback       = NULL ; 
   

   DlgFile.EnableCallBack(FALSE); 
   DlgFile.SetFilesAssociationParams (&DLGPARAMSFileAssociation) ; 
   nRet = DlgFile.DoModalFilesAssociation(hWnd); 
   // Gets the updated values for the structure
   DlgFile.GetFilesAssociationParams(&DLGPARAMSFileAssociation, sizeof(DLGPARAMSFileAssociation)) ; 
   
   LDialogFile::Free ();

}