ファイルを開くダイアログにコントロールを追加する

#define CLSID_FileOpenDialog "{DC1C5A9C-E88A-4dde- […]

#define CLSID_FileOpenDialog "{DC1C5A9C-E88A-4dde- […]

#define CLSID_FileOpenDialog "{DC1C5A9C-E88A-4dde-A5A1-60F82A20AEF7}"
#define IID_IFileOpenDialog "{d57c7288-d4ad-4768-be02-9d969532d960}"
#usecom IFileOpenDialog IID_IFileOpenDialog CLSID_FileOpenDialog
#comfunc IFileOpenDialog_QueryInterface 0 int, int
#comfunc IFileOpenDialog_Show 3 int
#comfunc IFileOpenDialog_SetFileTypes 4 int, var
#comfunc IFileOpenDialog_SetFileTypeIndex 5 int
#comfunc IFileOpenDialog_GetFileTypeIndex 6 int
#comfunc IFileOpenDialog_Advise 7 int, int
#comfunc IFileOpenDialog_Unadvise 8 int, int
#comfunc IFileOpenDialog_SetOptions 9 int
#comfunc IFileOpenDialog_GetOptions 10 var
#comfunc IFileOpenDialog_SetDefaultFolder 11 int
#comfunc IFileOpenDialog_SetFolder 12 int
#comfunc IFileOpenDialog_GetFolder 13 int
#comfunc IFileOpenDialog_GetCurrentSelection 14 int
#comfunc IFileOpenDialog_SetFileName 15 int
#comfunc IFileOpenDialog_GetFileName 16 int
#comfunc IFileOpenDialog_SetTitle 17 wstr
#comfunc IFileOpenDialog_SetOkButtonLabel 18 wstr
#comfunc IFileOpenDialog_SetFileNameLabel 19 wstr
#comfunc IFileOpenDialog_GetResult 20 var
#comfunc IFileOpenDialog_AddPlace 21 var, int
#comfunc IFileOpenDialog_SetDefaultExtension 22 wstr
#comfunc IFileOpenDialog_Close 23 var
#comfunc IFileOpenDialog_ClearClientData 24
#comfunc IFileOpenDialog_SetFilter 25 var
#comfunc IFileOpenDialog_GetResults 26 var
#comfunc IFileOpenDialog_GetSelectedItems 27 var

#define IID_IUnknown "{00000000-0000-0000-C000-000000000046}"
#define IID_IFileDialogCustomize "{e6fdd21a-163f-4975-9c8c-a69f1ba37034}"
#usecom IFileDialogCustomize IID_IFileDialogCustomize CLSID_FileOpenDialog
#comfunc IFileDialogCustomize_EnableOpenDropDown 3 int
#comfunc IFileDialogCustomize_AddMenu 4 int, wstr
#comfunc IFileDialogCustomize_AddPushButton 5 int, wstr
#comfunc IFileDialogCustomize_AddComboBox 6 int
#comfunc IFileDialogCustomize_AddRadioButtonList 7 int
#comfunc IFileDialogCustomize_AddCheckButton 8 int, wstr, int
#comfunc IFileDialogCustomize_AddEditBox 9 int, wstr
#comfunc IFileDialogCustomize_AddSeparator 10 int
#comfunc IFileDialogCustomize_AddText 11 int, wstr
#comfunc IFileDialogCustomize_SetControlLabel 12 int, wstr
#comfunc IFileDialogCustomize_GetControlState 13 int, var
#comfunc IFileDialogCustomize_SetControlState 14 int, int
#comfunc IFileDialogCustomize_GetEditBoxText 15 int, var
#comfunc IFileDialogCustomize_SetEditBoxText 16 int, wstr
#comfunc IFileDialogCustomize_GetCheckButtonState 17 int, var
#comfunc IFileDialogCustomize_SetCheckButtonState 18 int, int
#comfunc IFileDialogCustomize_AddControlItem 19 int, int, wstr
#comfunc IFileDialogCustomize_RemoveControlItem 20 int, int
#comfunc IFileDialogCustomize_RemoveAllControlItems 21 int
#comfunc IFileDialogCustomize_GetControlItemState 22 int, int, var
#comfunc IFileDialogCustomize_SetControlItemState 23 int, int, int
#comfunc IFileDialogCustomize_GetSelectedControlItem 24 int, var
#comfunc IFileDialogCustomize_SetSelectedControlItem 25 int, int
#comfunc IFileDialogCustomize_StartVisualGroup 26 int, wstr
#comfunc IFileDialogCustomize_EndVisualGroup 27
#comfunc IFileDialogCustomize_MakeProminent 28 int
#comfunc IFileDialogCustomize_SetControlItemText 29 int, int, wstr

#uselib "rpcrt4"
#func UuidFromStringA "UuidFromStringA" str, int

//typedef enum CDCONTROLSTATE { 
#enum CDCS_INACTIVE        = 0x00000000
#enum CDCS_ENABLED         = 0x00000001
#enum CDCS_VISIBLE         = 0x00000002
#enum CDCS_ENABLEDVISIBLE  = 0x00000003
//} CDCONTROLSTATE;

screen 0
title "HSPでコモンダイアログをカスタマイズ"
button gosub "表示", *ShowDialog
stop
*ShowDialog
	newcom pFod, IFileOpenDialog
	//IFileOpenDialog の IFileDialogCustomizeを使えるようにする
	string=IID_IFileDialogCustomize: string=strmid(string, 1, strlen(IID_IFileDialogCustomize)-2)
	dim iid, 4: UuidFromStringA string, varptr(iid)
	IFileOpenDialog_QueryInterface pFod, varptr(iid), varptr(_pFdc)
	newcom pFdc, IFileDialogCustomize, -1, _pFdc
	
	IFileOpenDialog_SetTitle pFod, "HSPでコモンダイアログをカスタマイズ"
	IFileOpenDialog_SetOkButtonLabel pFod, "おーけー"
	IFileOpenDialog_SetFileNameLabel pFod, "あいうえお:"

	//コントロール追加
	#define IDC_LABEL1		1000
	#define IDC_LABEL2		1001
	#define IDC_BUTTON1		1100
	#define IDC_EDIT1		1200
	#define IDC_CHECK1		1300
	#define IDC_CHECK2		1301
	#define IDC_RADIO1		1400
	#define IDC_COMBO1		1500
	#define IDC_MENU1		1600
	#define IDC_SEP1		1700
	#define IDC_SEP2		1701
	#define IDC_GROUP1		1800
	#define IDC_GROUP2		1801

	#define IDM_ITEM1		2000
	#define IDM_ITEM2		2001
	#define IDM_ITEM3		2002
	#define IDM_ITEM4		2003
	#define IDM_ITEM5		2004
	#define IDM_ITEM6		2005
	
	IFileDialogCustomize_AddText pFdc, IDC_LABEL1, "ラベル。"
	IFileDialogCustomize_AddText pFdc, IDC_LABEL2, "(´・ω・`)"
	IFileDialogCustomize_AddPushButton pFdc, IDC_BUTTON1, "プッシュボタン"
	IFileDialogCustomize_StartVisualGroup pFdc, IDC_GROUP1, "グループ:"
	IFileDialogCustomize_AddPushButton pFdc, IDC_BUTTON2, "押せない"
	IFileDialogCustomize_SetControlState pFdc, IDC_BUTTON2, CDCS_VISIBLE
	IFileDialogCustomize_AddEditBox pFdc, IDC_EDIT1, "入力ボックス"
	IFileDialogCustomize_AddSeparator pFdc, IDC_SEP1
	IFileDialogCustomize_AddCheckButton pFdc, IDC_CHECK1, "チェック1", 0
	IFileDialogCustomize_AddCheckButton pFdc, IDC_CHECK2, "チェック2", 1
	IFileDialogCustomize_AddSeparator pFdc, IDC_SEP2
	IFileDialogCustomize_AddRadioButtonList pFdc, IDC_RADIO1
	IFileDialogCustomize_AddControlItem pFdc, IDC_RADIO1, IDM_ITEM1, "ラジオボタン項目1"
	IFileDialogCustomize_AddControlItem pFdc, IDC_RADIO1, IDM_ITEM2, "ラジオボタン項目2"
	IFileDialogCustomize_EndVisualGroup pFdc
	IFileDialogCustomize_StartVisualGroup pFdc, IDC_GROUP2, "グループ2:"
	IFileDialogCustomize_AddComboBox pFdc, IDC_COMBO1
	IFileDialogCustomize_AddControlItem pFdc, IDC_COMBO1, IDM_ITEM3, "項目1"
	IFileDialogCustomize_AddControlItem pFdc, IDC_COMBO1, IDM_ITEM4, "項目2"
	IFileDialogCustomize_AddMenu pFdc, IDC_MENU1, "メニュー"
	IFileDialogCustomize_AddControlItem pFdc, IDC_MENU1, IDM_ITEM5, "メニュー項目1"
	IFileDialogCustomize_AddControlItem pFdc, IDC_MENU1, IDM_ITEM6, "メニュー項目2"
	IFileDialogCustomize_EndVisualGroup pFdc
	IFileOpenDialog_Show pFod, hwnd
	
	delcom pFdc
	delcom pFod
return