ReactOS 0.4.15-dev-7924-g5949c20
COpenWithDialog Class Reference
Collaboration diagram for COpenWithDialog:

Public Member Functions

 COpenWithDialog (const OPENASINFO *pInfo, COpenWithList *pAppList)
 
 ~COpenWithDialog ()
 
BOOL IsNoOpen (HWND hwnd)
 

Static Public Member Functions

static INT_PTR CALLBACK DialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Private Member Functions

VOID Init (HWND hwnd)
 
VOID AddApp (COpenWithList::SApp *pApp, BOOL bSelected)
 
VOID Browse ()
 
VOID Accept ()
 
COpenWithList::SAppGetCurrentApp ()
 

Static Private Member Functions

static INT_PTR CALLBACK NoOpenDlgProc (HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
 

Private Attributes

const OPENASINFOm_pInfo
 
COpenWithListm_pAppList
 
BOOL m_bListAllocated
 
HWND m_hDialog
 
HWND m_hTreeView
 
HTREEITEM m_hRecommend
 
HTREEITEM m_hOther
 
HIMAGELIST m_hImgList
 
BOOL m_bNoOpen
 

Detailed Description

Definition at line 788 of file COpenWithMenu.cpp.

Constructor & Destructor Documentation

◆ COpenWithDialog()

COpenWithDialog::COpenWithDialog ( const OPENASINFO pInfo,
COpenWithList pAppList = NULL 
)

Definition at line 814 of file COpenWithMenu.cpp.

814 :
815 m_pInfo(pInfo), m_pAppList(pAppList), m_hImgList(NULL), m_bNoOpen(FALSE)
816{
817 if (!m_pAppList)
818 {
821 }
822 else
824}
COpenWithList * m_pAppList
HIMAGELIST m_hImgList
const OPENASINFO * m_pInfo
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117

◆ ~COpenWithDialog()

COpenWithDialog::~COpenWithDialog ( )

Definition at line 826 of file COpenWithMenu.cpp.

827{
829 delete m_pAppList;
830 if (m_hImgList)
832}
BOOL WINAPI ImageList_Destroy(HIMAGELIST himl)
Definition: imagelist.c:928

Member Function Documentation

◆ Accept()

VOID COpenWithDialog::Accept ( )
private

Definition at line 1046 of file COpenWithMenu.cpp.

1047{
1049 if (pApp)
1050 {
1051 /* Set programm as default handler */
1054
1055 /* Execute program */
1058
1059 EndDialog(m_hDialog, 1);
1060 }
1061}
COpenWithList::SApp * GetCurrentApp()
static BOOL Execute(SApp *pApp, LPCWSTR pwszFilePath)
BOOL SetDefaultHandler(SApp *pApp, LPCWSTR pwszFilename)
@ OAIF_EXEC
Definition: shlobj.h:2667
LPCWSTR pcszFile
Definition: shlobj.h:2678
OPEN_AS_INFO_FLAGS oaifInFlags
Definition: shlobj.h:2680
#define SendDlgItemMessage
Definition: winuser.h:5842
#define BST_CHECKED
Definition: winuser.h:197
#define BM_GETCHECK
Definition: winuser.h:1918
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by DialogProc().

◆ AddApp()

VOID COpenWithDialog::AddApp ( COpenWithList::SApp pApp,
BOOL  bSelected 
)
private

Definition at line 881 of file COpenWithMenu.cpp.

882{
883 LPCWSTR pwszName = m_pAppList->GetName(pApp);
884 if (!pwszName) return;
885 HICON hIcon = m_pAppList->GetIcon(pApp);
886
887 TRACE("AddApp Cmd %ls Name %ls\n", pApp->wszCmd, pwszName);
888
889 /* Add item to the list */
890 TVINSERTSTRUCT tvins;
891
892 if (pApp->bRecommended)
893 tvins.hParent = tvins.hInsertAfter = m_hRecommend;
894 else
895 tvins.hParent = tvins.hInsertAfter = m_hOther;
896
897 tvins.item.mask = TVIF_TEXT|TVIF_PARAM;
898 tvins.item.pszText = const_cast<LPWSTR>(pwszName);
899 tvins.item.lParam = (LPARAM)pApp;
900
901 if (hIcon)
902 {
903 tvins.item.mask |= TVIF_IMAGE | TVIF_SELECTEDIMAGE;
904 tvins.item.iImage = tvins.item.iSelectedImage = ImageList_AddIcon(m_hImgList, hIcon);
905 }
906
908
909 if (bSelected)
911}
HTREEITEM m_hRecommend
static LPCWSTR GetName(SApp *pApp)
static HICON GetIcon(SApp *pApp)
static HICON
Definition: imagelist.c:84
HICON hIcon
Definition: msconfig.c:44
#define TVIF_TEXT
Definition: commctrl.h:3266
#define TreeView_SelectItem(hwnd, hitem)
Definition: commctrl.h:3481
#define TVINSERTSTRUCT
Definition: commctrl.h:3402
#define TVIF_IMAGE
Definition: commctrl.h:3267
#define ImageList_AddIcon(himl, hicon)
Definition: commctrl.h:415
#define TVIF_PARAM
Definition: commctrl.h:3268
#define TreeView_InsertItem(hwnd, lpis)
Definition: commctrl.h:3412
#define TVIF_SELECTEDIMAGE
Definition: commctrl.h:3271
#define TRACE(s)
Definition: solgame.cpp:4
WCHAR wszCmd[MAX_PATH]
LONG_PTR LPARAM
Definition: windef.h:208
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by Browse(), and Init().

◆ Browse()

VOID COpenWithDialog::Browse ( )
private

Definition at line 913 of file COpenWithMenu.cpp.

914{
915 WCHAR wszTitle[64];
916 WCHAR wszFilter[256];
917 WCHAR wszPath[MAX_PATH];
919
920 /* Initialize OPENFILENAMEW structure */
921 ZeroMemory(&ofn, sizeof(OPENFILENAMEW));
922 ofn.lStructSize = sizeof(OPENFILENAMEW);
926 ofn.nMaxFile = (sizeof(wszPath) / sizeof(WCHAR));
927 ofn.lpstrFile = wszPath;
928 ofn.lpstrInitialDir = L"%programfiles%";
929
930 /* Init title */
931 if (LoadStringW(shell32_hInstance, IDS_OPEN_WITH, wszTitle, sizeof(wszTitle) / sizeof(WCHAR)))
932 {
933 ofn.lpstrTitle = wszTitle;
934 ofn.nMaxFileTitle = wcslen(wszTitle);
935 }
936
937 /* Init the filter string */
940 ZeroMemory(wszPath, sizeof(wszPath));
941
942 /* Create OpenFile dialog */
943 if (!GetOpenFileNameW(&ofn))
944 return;
945
946 /* Setup context for insert proc */
947 COpenWithList::SApp *pApp = m_pAppList->Add(wszPath);
948 AddApp(pApp, TRUE);
949}
#define shell32_hInstance
static WCHAR wszFilter[MAX_STRING_LEN *4+6 *3+5]
Definition: wordpad.c:72
VOID AddApp(COpenWithList::SApp *pApp, BOOL bSelected)
SApp * Add(LPCWSTR pwszPath)
#define OFN_EXPLORER
Definition: commdlg.h:104
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
struct tagOFNW OPENFILENAMEW
BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
Definition: filedlg.c:4736
#define MAX_PATH
Definition: compat.h:34
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define L(x)
Definition: ntvdm.h:50
#define IDS_OPEN_WITH_FILTER
Definition: shresdef.h:148
#define IDS_OPEN_WITH
Definition: shresdef.h:136
OPENFILENAME ofn
Definition: sndrec32.cpp:56
HWND hwndOwner
Definition: commdlg.h:330
LPCSTR lpstrTitle
Definition: commdlg.h:341
HINSTANCE hInstance
Definition: commdlg.h:331
LPSTR lpstrFile
Definition: commdlg.h:336
DWORD nMaxFileTitle
Definition: commdlg.h:339
DWORD Flags
Definition: commdlg.h:342
LPCSTR lpstrInitialDir
Definition: commdlg.h:340
DWORD lStructSize
Definition: commdlg.h:329
LPCSTR lpstrFilter
Definition: commdlg.h:332
DWORD nMaxFile
Definition: commdlg.h:337
#define ZeroMemory
Definition: winbase.h:1712
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by DialogProc().

◆ DialogProc()

INT_PTR CALLBACK COpenWithDialog::DialogProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1063 of file COpenWithMenu.cpp.

1064{
1065 COpenWithDialog *pThis = reinterpret_cast<COpenWithDialog *>(GetWindowLongPtr(hwndDlg, DWLP_USER));
1066
1067 switch(uMsg)
1068 {
1069 case WM_INITDIALOG:
1070 {
1071 COpenWithDialog *pThis = reinterpret_cast<COpenWithDialog *>(lParam);
1072
1073 pThis->Init(hwndDlg);
1074 return TRUE;
1075 }
1076 case WM_COMMAND:
1077 switch(LOWORD(wParam))
1078 {
1079 case 14004: /* browse */
1080 {
1081 pThis->Browse();
1082 return TRUE;
1083 }
1084 case IDOK: /* ok */
1085 {
1086 pThis->Accept();
1087 return TRUE;
1088 }
1089 case IDCANCEL: /* cancel */
1090 EndDialog(hwndDlg, 0);
1091 return TRUE;
1092 default:
1093 break;
1094 }
1095 break;
1096 case WM_NOTIFY:
1097 switch (((LPNMHDR)lParam)->code)
1098 {
1099 case TVN_SELCHANGED:
1100 EnableWindow(GetDlgItem(hwndDlg, IDOK), pThis->GetCurrentApp() ? TRUE : FALSE);
1101 break;
1102 case NM_DBLCLK:
1103 case NM_RETURN:
1104 pThis->Accept();
1105 break;
1106 }
1107 break;
1108 case WM_CLOSE:
1109 EndDialog(hwndDlg, 0);
1110 return TRUE;
1111 default:
1112 break;
1113 }
1114 return FALSE;
1115}
VOID Init(HWND hwnd)
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define TVN_SELCHANGED
Definition: commctrl.h:3735
#define NM_DBLCLK
Definition: commctrl.h:131
#define NM_RETURN
Definition: commctrl.h:132
#define WM_NOTIFY
Definition: richedit.h:61
Definition: inflate.c:139
#define GetWindowLongPtr
Definition: treelist.c:73
#define WM_CLOSE
Definition: winuser.h:1621
#define DWLP_USER
Definition: winuser.h:872
#define IDCANCEL
Definition: winuser.h:831
#define WM_COMMAND
Definition: winuser.h:1740
#define WM_INITDIALOG
Definition: winuser.h:1739
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define IDOK
Definition: winuser.h:830
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)

Referenced by SHOpenWithDialog().

◆ GetCurrentApp()

COpenWithList::SApp * COpenWithDialog::GetCurrentApp ( )
private

Definition at line 951 of file COpenWithMenu.cpp.

952{
953 TVITEM tvi;
955 if (!tvi.hItem)
956 return NULL;
957
958 tvi.mask = TVIF_PARAM;
959 if (!TreeView_GetItem(m_hTreeView, &tvi))
960 return NULL;
961
962 return (COpenWithList::SApp*)tvi.lParam;
963}
#define TVITEM
Definition: commctrl.h:3365
#define TreeView_GetSelection(hwnd)
Definition: commctrl.h:3473
#define TreeView_GetItem(hwnd, pitem)
Definition: commctrl.h:3490

Referenced by Accept(), and DialogProc().

◆ Init()

VOID COpenWithDialog::Init ( HWND  hwnd)
private

Definition at line 965 of file COpenWithMenu.cpp.

966{
967 TRACE("COpenWithDialog::Init hwnd %p\n", hwnd);
968
969 m_hDialog = hwnd;
971
972 /* Handle register checkbox */
973 HWND hRegisterCheckbox = GetDlgItem(hwnd, 14003);
975 EnableWindow(hRegisterCheckbox, FALSE);
977 SendMessage(hRegisterCheckbox, BM_SETCHECK, BST_CHECKED, 0);
979 ShowWindow(hRegisterCheckbox, SW_HIDE);
980
981 if (m_pInfo->pcszFile)
982 {
983 WCHAR wszBuf[MAX_PATH];
984 UINT cchBuf;
985
986 /* Add filename to label */
987 cchBuf = GetDlgItemTextW(hwnd, 14001, wszBuf, _countof(wszBuf));
988 StringCchCopyW(wszBuf + cchBuf, _countof(wszBuf) - cchBuf, PathFindFileNameW(m_pInfo->pcszFile));
989 SetDlgItemTextW(hwnd, 14001, wszBuf);
990
991 /* Load applications from registry */
992 m_pAppList->Load();
994
995 /* Determine if the type of file can be opened directly from the shell */
996 if (m_pAppList->IsNoOpen() != FALSE)
997 m_bNoOpen = TRUE;
998
999 /* Init treeview */
1000 m_hTreeView = GetDlgItem(hwnd, 14002);
1003
1004 /* If there are some recommendations add parent nodes: Recommended and Others */
1005 UINT cRecommended = m_pAppList->GetRecommendedCount();
1006 if (cRecommended > 0)
1007 {
1008 TVINSERTSTRUCT tvins;
1009 HICON hFolderIcon;
1010
1011 tvins.hParent = tvins.hInsertAfter = TVI_ROOT;
1013 tvins.item.pszText = (LPWSTR)wszBuf;
1014 tvins.item.state = tvins.item.stateMask = TVIS_EXPANDED;
1016 tvins.item.iImage = tvins.item.iSelectedImage = ImageList_AddIcon(m_hImgList, hFolderIcon);
1017
1020
1023 }
1024 else
1026
1027 /* Add all applications */
1028 BOOL bNoAppSelected = TRUE;
1029 COpenWithList::SApp *pAppList = m_pAppList->GetList();
1030 for (UINT i = 0; i < m_pAppList->GetCount(); ++i)
1031 {
1032 if (!COpenWithList::IsHidden(&pAppList[i]))
1033 {
1034 if (bNoAppSelected && (pAppList[i].bRecommended || !cRecommended))
1035 {
1036 AddApp(&pAppList[i], TRUE);
1037 bNoAppSelected = FALSE;
1038 }
1039 else
1040 AddApp(&pAppList[i], FALSE);
1041 }
1042 }
1043 }
1044}
BOOL LoadRecommended(LPCWSTR pwszFilePath)
BOOL IsNoOpen(VOID)
UINT GetRecommendedCount()
SApp * GetList()
static BOOL IsHidden(SApp *pApp)
HIMAGELIST WINAPI ImageList_Create(INT cx, INT cy, UINT flags, INT cInitial, INT cGrow)
Definition: imagelist.c:804
LPWSTR WINAPI PathFindFileNameW(LPCWSTR lpszPath)
Definition: path.c:394
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define TVSIL_NORMAL
Definition: commctrl.h:3443
#define ILC_COLOR32
Definition: commctrl.h:358
#define TVI_ROOT
Definition: commctrl.h:3368
#define TVIS_EXPANDED
Definition: commctrl.h:3284
#define ILC_MASK
Definition: commctrl.h:351
#define TreeView_SetImageList(hwnd, himl, iImage)
Definition: commctrl.h:3447
#define TVIF_STATE
Definition: commctrl.h:3269
@ OAIF_ALLOW_REGISTRATION
Definition: shlobj.h:2665
@ OAIF_HIDE_REGISTRATION
Definition: shlobj.h:2670
@ OAIF_FORCE_REGISTRATION
Definition: shlobj.h:2668
#define IDS_OPEN_WITH_RECOMMENDED
Definition: shresdef.h:192
#define IDI_SHELL_PROGRAMS_FOLDER
Definition: shresdef.h:570
#define IDS_OPEN_WITH_OTHER
Definition: shresdef.h:193
#define _countof(array)
Definition: sndvol32.h:68
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
#define SetWindowLongPtr
Definition: treelist.c:70
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2263
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
#define SW_HIDE
Definition: winuser.h:768
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define IMAGE_ICON
Definition: winuser.h:212
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
#define BM_SETCHECK
Definition: winuser.h:1921
#define SendMessage
Definition: winuser.h:5843
#define LoadImage
Definition: winuser.h:5815
#define MAKEINTRESOURCE
Definition: winuser.h:591

Referenced by DialogProc().

◆ IsNoOpen()

BOOL COpenWithDialog::IsNoOpen ( HWND  hwnd)

Definition at line 862 of file COpenWithMenu.cpp.

863{
864 /* Only do the actual check if the file type has the 'NoOpen' flag. */
865 if (m_bNoOpen)
866 {
868
869 if (dReturnValue == IDNO)
870 return TRUE;
871 else if (dReturnValue == -1)
872 {
873 ERR("IsNoOpen failed to load dialog box\n");
874 return TRUE;
875 }
876 }
877
878 return FALSE;
879}
#define ERR(fmt,...)
Definition: debug.h:110
static INT_PTR CALLBACK NoOpenDlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
#define IDD_NOOPEN
Definition: shresdef.h:519
#define IDNO
Definition: winuser.h:836
#define DialogBox
Definition: winuser.h:5761

Referenced by SHOpenWithDialog().

◆ NoOpenDlgProc()

INT_PTR CALLBACK COpenWithDialog::NoOpenDlgProc ( HWND  hwnd,
UINT  Message,
WPARAM  wParam,
LPARAM  lParam 
)
staticprivate

Definition at line 834 of file COpenWithMenu.cpp.

835{
836 switch(Message)
837 {
838 case WM_INITDIALOG:
839 {
840 return TRUE;
841 }
842 case WM_CLOSE:
844 break;
845 case WM_COMMAND:
846 switch(LOWORD(wParam))
847 {
848 case IDYES:
850 break;
851 case IDNO:
853 break;
854 }
855 break;
856 default:
857 return FALSE;
858 }
859 return TRUE;
860}
static const WCHAR Message[]
Definition: register.c:74
#define IDYES
Definition: winuser.h:835

Referenced by IsNoOpen().

Member Data Documentation

◆ m_bListAllocated

BOOL COpenWithDialog::m_bListAllocated
private

Definition at line 806 of file COpenWithMenu.cpp.

Referenced by COpenWithDialog(), and ~COpenWithDialog().

◆ m_bNoOpen

BOOL COpenWithDialog::m_bNoOpen
private

Definition at line 811 of file COpenWithMenu.cpp.

Referenced by Init(), and IsNoOpen().

◆ m_hDialog

HWND COpenWithDialog::m_hDialog
private

Definition at line 807 of file COpenWithMenu.cpp.

Referenced by Accept(), Browse(), and Init().

◆ m_hImgList

HIMAGELIST COpenWithDialog::m_hImgList
private

Definition at line 810 of file COpenWithMenu.cpp.

Referenced by AddApp(), Init(), and ~COpenWithDialog().

◆ m_hOther

HTREEITEM COpenWithDialog::m_hOther
private

Definition at line 809 of file COpenWithMenu.cpp.

Referenced by AddApp(), and Init().

◆ m_hRecommend

HTREEITEM COpenWithDialog::m_hRecommend
private

Definition at line 808 of file COpenWithMenu.cpp.

Referenced by AddApp(), and Init().

◆ m_hTreeView

HWND COpenWithDialog::m_hTreeView
private

Definition at line 807 of file COpenWithMenu.cpp.

Referenced by AddApp(), GetCurrentApp(), and Init().

◆ m_pAppList

COpenWithList* COpenWithDialog::m_pAppList
private

Definition at line 805 of file COpenWithMenu.cpp.

Referenced by Accept(), AddApp(), Browse(), COpenWithDialog(), Init(), and ~COpenWithDialog().

◆ m_pInfo

const OPENASINFO* COpenWithDialog::m_pInfo
private

Definition at line 804 of file COpenWithMenu.cpp.

Referenced by Accept(), and Init().


The documentation for this class was generated from the following file: