Initial implementation of OleUIInsertObject.

This commit is contained in:
Ulrich Czekalla 2003-11-05 01:34:38 +00:00 committed by Alexandre Julliard
parent 063cff8686
commit af0d2afe20
8 changed files with 804 additions and 12 deletions

View File

@ -2,3 +2,4 @@ Makefile
oledlg.dll.dbg.c
oledlg.spec.c
oledlg.spec.def
rsrc.res

View File

@ -3,12 +3,14 @@ TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = oledlg.dll
IMPORTS = kernel32
IMPORTS = ole32 comdlg32 user32 advapi32 kernel32 ntdll
C_SRCS = \
insobjdlg.c \
oledlg_main.c
RC_SRCS = rsrc.rc
@MAKE_DLL_RULES@
### Dependencies:

628
dlls/oledlg/insobjdlg.c Normal file
View File

@ -0,0 +1,628 @@
/*
* OLEDLG library
*
* Copyright 2003 Ulrich Czekalla for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
#include <stdio.h>
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
#include "winternl.h"
#include "winnls.h"
#include "winerror.h"
#include "wingdi.h"
#include "winuser.h"
#include "wine/debug.h"
#include "wine/unicode.h"
#include "oledlg.h"
#include "resource.h"
WINE_DEFAULT_DEBUG_CHANNEL(oledlg);
typedef struct
{
HWND hwndSelf;
BOOL bObjListInit; /* Object list has been initialized */
LPOLEUIINSERTOBJECTA lpOleUIInsertObject;
HWND hwndObjTypeLBL;
HWND hwndObjTypeLB;
HWND hwndFileLBL;
HWND hwndFileTB;
HWND hwndCreateCtrlCB;
HWND hwndCreateNewCB;
HWND hwndCreateFromFileCB;
HWND hwndDisplayIconCB;
HWND hwndAddCtrlBTN;
HWND hwndBrowseBTN;
HWND hwndResultDesc;
} InsertObjectDlgInfo;
INT_PTR CALLBACK UIInsertObjectDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
static LRESULT UIINSOBJDLG_OnWMCommand(HWND hwnd, WPARAM wParam, LPARAM lParam);
static void UIINSERTOBJECTDLG_InitDialog(InsertObjectDlgInfo* pdlgInfo);
static void UIINSERTOBJECTDLG_SelectCreateCtrl(InsertObjectDlgInfo* pdlgInfo);
static void UIINSERTOBJECTDLG_SelectCreateFromFile(InsertObjectDlgInfo* pdlgInfo);
static void UIINSERTOBJECTDLG_SelectCreateNew(InsertObjectDlgInfo* pdlgInfo);
static BOOL UIINSERTOBJECTDLG_PopulateObjectTypes(InsertObjectDlgInfo* pdlgInfo);
static void UIINSERTOBJECTDLG_FreeObjectTypes(InsertObjectDlgInfo* pdlgInfo);
static void UIINSERTOBJECTDLG_SelChange(InsertObjectDlgInfo* pdlgInfo);
static BOOL UIINSERTOBJECTDLG_OnOpen(InsertObjectDlgInfo* pdlgInfo);
static void UIINSERTOBJECTDLG_BrowseFile(InsertObjectDlgInfo* pdlgInfo);
static void UIINSERTOBJECTDLG_AddControl(InsertObjectDlgInfo* pdlgInfo);
typedef HRESULT (*DLLREGISTER) (void);
extern HINSTANCE OLEDLG_hInstance;
const char *OleUIInsertObjectInfoStr = "OleUIInsertObjectInfoStr";
/***********************************************************************
* OleUIInsertObjectA (OLEDLG.3)
*/
UINT WINAPI OleUIInsertObjectA(LPOLEUIINSERTOBJECTA lpOleUIInsertObject)
{
LRESULT lRes;
LPCVOID template;
HRSRC hRes;
InsertObjectDlgInfo dlgInfo;
HANDLE hDlgTmpl = 0;
if (lpOleUIInsertObject->lpszTemplate || lpOleUIInsertObject->hResource)
FIXME("Customized template not supported\n");
/* Create the dialog from a template */
if(!(hRes = FindResourceA(OLEDLG_hInstance,MAKEINTRESOURCEA(UIINSERTOBJECT),
(LPSTR)RT_DIALOG)))
{
return OLEUI_ERR_FINDTEMPLATEFAILURE;
}
if (!(hDlgTmpl = LoadResource(OLEDLG_hInstance, hRes )) ||
!(template = LockResource( hDlgTmpl )))
{
return OLEUI_ERR_LOADTEMPLATEFAILURE;
}
/* Initialize InsertObjectDlgInfo structure */
dlgInfo.lpOleUIInsertObject = lpOleUIInsertObject;
dlgInfo.bObjListInit = FALSE;
lRes = DialogBoxIndirectParamA(OLEDLG_hInstance, (LPDLGTEMPLATEA) template,
lpOleUIInsertObject->hWndOwner, UIInsertObjectDlgProc,
(LPARAM) &dlgInfo);
/* Unable to create the dialog */
if( lRes == -1)
return OLEUI_ERR_DIALOGFAILURE;
return lRes;
}
/***********************************************************************
* UIInsertObjectDlgProc
*
* OLE UI Insert Object dialog procedure
*/
INT_PTR CALLBACK UIInsertObjectDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
InsertObjectDlgInfo* pdlgInfo = (InsertObjectDlgInfo*) GetPropA(hwnd,OleUIInsertObjectInfoStr);
switch(uMsg)
{
case WM_INITDIALOG:
{
InsertObjectDlgInfo* pdlgInfo = (InsertObjectDlgInfo*)lParam;
pdlgInfo->hwndSelf = hwnd;
SetPropA(hwnd, OleUIInsertObjectInfoStr, (HANDLE) pdlgInfo);
UIINSERTOBJECTDLG_InitDialog(pdlgInfo);
return 0;
}
case WM_COMMAND:
return UIINSOBJDLG_OnWMCommand(hwnd, wParam, lParam);
case WM_DESTROY:
if (pdlgInfo)
UIINSERTOBJECTDLG_FreeObjectTypes(pdlgInfo);
RemovePropA(hwnd, OleUIInsertObjectInfoStr);
return FALSE;
default :
return FALSE;
}
}
/***********************************************************************
* UIINSOBJDLG_OnWMCommand
*
* WM_COMMAND message handler
*/
static LRESULT UIINSOBJDLG_OnWMCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
{
WORD wNotifyCode = HIWORD(wParam);
WORD wID = LOWORD(wParam);
InsertObjectDlgInfo* pdlgInfo = (InsertObjectDlgInfo*) GetPropA(hwnd,OleUIInsertObjectInfoStr);
switch(wID)
{
case IDOK:
EndDialog(hwnd, UIINSERTOBJECTDLG_OnOpen(pdlgInfo));
break;
case IDCANCEL:
EndDialog(hwnd, FALSE);
break;
case IDC_CREATECONTROL:
UIINSERTOBJECTDLG_SelectCreateCtrl(pdlgInfo);
break;
case IDC_CREATENEW:
UIINSERTOBJECTDLG_SelectCreateNew(pdlgInfo);
break;
case IDC_CREATEFROMFILE:
UIINSERTOBJECTDLG_SelectCreateFromFile(pdlgInfo);
break;
case IDC_BROWSE:
UIINSERTOBJECTDLG_BrowseFile(pdlgInfo);
break;
case IDC_ADDCONTROL:
UIINSERTOBJECTDLG_AddControl(pdlgInfo);
case IDC_OBJTYPELIST:
{
if (wNotifyCode == LBN_SELCHANGE)
UIINSERTOBJECTDLG_SelChange(pdlgInfo);
break;
}
}
return 0;
}
/***********************************************************************
* UIINSERTOBJECTDLG_InitDialog
*
* Initialize dialog display
*/
static void UIINSERTOBJECTDLG_InitDialog(InsertObjectDlgInfo* pdlgInfo)
{
/* Initialize InsertObjectDlgInfo data structure */
pdlgInfo->hwndObjTypeLB = GetDlgItem(pdlgInfo->hwndSelf, IDC_OBJTYPELIST);
pdlgInfo->hwndObjTypeLBL = GetDlgItem(pdlgInfo->hwndSelf, IDC_OBJTYPELBL);
pdlgInfo->hwndFileLBL = GetDlgItem(pdlgInfo->hwndSelf, IDC_FILELBL);
pdlgInfo->hwndFileTB = GetDlgItem(pdlgInfo->hwndSelf, IDC_FILE);
pdlgInfo->hwndCreateCtrlCB = GetDlgItem(pdlgInfo->hwndSelf, IDC_CREATECONTROL);
pdlgInfo->hwndCreateNewCB = GetDlgItem(pdlgInfo->hwndSelf, IDC_CREATENEW);
pdlgInfo->hwndCreateFromFileCB = GetDlgItem(pdlgInfo->hwndSelf, IDC_CREATEFROMFILE);
pdlgInfo->hwndDisplayIconCB = GetDlgItem(pdlgInfo->hwndSelf, IDC_ASICON);
pdlgInfo->hwndAddCtrlBTN = GetDlgItem(pdlgInfo->hwndSelf, IDC_ADDCONTROL);
pdlgInfo->hwndBrowseBTN = GetDlgItem(pdlgInfo->hwndSelf, IDC_BROWSE);
pdlgInfo->hwndResultDesc = GetDlgItem(pdlgInfo->hwndSelf, IDC_RESULTDESC);
/* Setup dialog controls based on flags */
if (pdlgInfo->lpOleUIInsertObject->lpszCaption)
SetWindowTextA(pdlgInfo->hwndSelf, pdlgInfo->lpOleUIInsertObject->lpszCaption);
ShowWindow(pdlgInfo->hwndCreateCtrlCB, (pdlgInfo->lpOleUIInsertObject->dwFlags &
IOF_SHOWINSERTCONTROL) ? SW_SHOW : SW_HIDE);
ShowWindow(pdlgInfo->hwndDisplayIconCB, (pdlgInfo->lpOleUIInsertObject->dwFlags &
IOF_CHECKDISPLAYASICON) ? SW_SHOW : SW_HIDE);
EnableWindow(pdlgInfo->hwndDisplayIconCB, (pdlgInfo->lpOleUIInsertObject->dwFlags &
IOF_DISABLEDISPLAYASICON) ? FALSE : TRUE);
if (pdlgInfo->lpOleUIInsertObject->dwFlags & IOF_SELECTCREATECONTROL)
UIINSERTOBJECTDLG_SelectCreateCtrl(pdlgInfo);
else if (pdlgInfo->lpOleUIInsertObject->dwFlags & IOF_SELECTCREATEFROMFILE)
UIINSERTOBJECTDLG_SelectCreateFromFile(pdlgInfo);
else /* (pdlgInfo->lpOleUIInsertObject->dwFlags & IOF_SELECTCREATENEW) */
UIINSERTOBJECTDLG_SelectCreateNew(pdlgInfo);
}
/***********************************************************************
* UIINSERTOBJECTDLG_SelectCreateCtrl
*
* Select Create Control Radio Button
*/
static void UIINSERTOBJECTDLG_SelectCreateCtrl(InsertObjectDlgInfo* pdlgInfo)
{
ShowWindow(pdlgInfo->hwndDisplayIconCB, SW_HIDE);
ShowWindow(pdlgInfo->hwndFileLBL, SW_HIDE);
ShowWindow(pdlgInfo->hwndFileTB, SW_HIDE);
ShowWindow(pdlgInfo->hwndBrowseBTN, SW_HIDE);
ShowWindow(pdlgInfo->hwndObjTypeLBL, SW_SHOW);
ShowWindow(pdlgInfo->hwndObjTypeLB, SW_SHOW);
ShowWindow(pdlgInfo->hwndAddCtrlBTN, SW_SHOW);
SendMessageA(pdlgInfo->hwndCreateCtrlCB, BM_SETCHECK, BST_CHECKED, 0);
/* Populate object type listbox */
if (!pdlgInfo->bObjListInit)
UIINSERTOBJECTDLG_PopulateObjectTypes(pdlgInfo);
}
/***********************************************************************
* UIINSERTOBJECTDLG_SelectCreateNew
*
* Select Create New Radio Button
*/
static void UIINSERTOBJECTDLG_SelectCreateNew(InsertObjectDlgInfo* pdlgInfo)
{
ShowWindow(pdlgInfo->hwndFileLBL, SW_HIDE);
ShowWindow(pdlgInfo->hwndFileTB, SW_HIDE);
ShowWindow(pdlgInfo->hwndAddCtrlBTN, SW_HIDE);
ShowWindow(pdlgInfo->hwndBrowseBTN, SW_HIDE);
if (pdlgInfo->lpOleUIInsertObject->dwFlags & IOF_CHECKDISPLAYASICON)
ShowWindow(pdlgInfo->hwndDisplayIconCB, SW_SHOW);
ShowWindow(pdlgInfo->hwndObjTypeLBL, SW_SHOW);
ShowWindow(pdlgInfo->hwndObjTypeLB, SW_SHOW);
SendMessageA(pdlgInfo->hwndCreateNewCB, BM_SETCHECK, BST_CHECKED, 0);
if (!pdlgInfo->bObjListInit)
UIINSERTOBJECTDLG_PopulateObjectTypes(pdlgInfo);
UIINSERTOBJECTDLG_SelChange(pdlgInfo);
}
/***********************************************************************
* UIINSERTOBJECTDLG_SelectCreateFromFile
*
* Select Create From File Radio Button
*/
static void UIINSERTOBJECTDLG_SelectCreateFromFile(InsertObjectDlgInfo* pdlgInfo)
{
char resstr[MAX_PATH];
ShowWindow(pdlgInfo->hwndAddCtrlBTN, SW_HIDE);
ShowWindow(pdlgInfo->hwndObjTypeLBL, SW_HIDE);
ShowWindow(pdlgInfo->hwndObjTypeLB, SW_HIDE);
if (pdlgInfo->lpOleUIInsertObject->dwFlags & IOF_CHECKDISPLAYASICON)
ShowWindow(pdlgInfo->hwndDisplayIconCB, SW_SHOW);
ShowWindow(pdlgInfo->hwndFileLBL, SW_SHOW);
ShowWindow(pdlgInfo->hwndFileTB, SW_SHOW);
ShowWindow(pdlgInfo->hwndBrowseBTN, SW_SHOW);
SendMessageA(pdlgInfo->hwndCreateFromFileCB, BM_SETCHECK, BST_CHECKED, 0);
if (LoadStringA(OLEDLG_hInstance, IDS_RESULTFILEOBJDESC, resstr, MAX_PATH))
SendMessageA(pdlgInfo->hwndResultDesc, WM_SETTEXT, 0, (LPARAM)resstr);
}
/***********************************************************************
* UIINSERTOBJECTDLG_PopulateObjectTypes
*
* Populate Object Type listbox
*/
static BOOL UIINSERTOBJECTDLG_PopulateObjectTypes(InsertObjectDlgInfo* pdlgInfo)
{
DWORD i, len;
HKEY hkclsids;
HKEY hkey;
CLSID clsid;
HRESULT ret;
CHAR szclsid[128];
CHAR keydesc[MAX_PATH];
CHAR keyname[MAX_PATH];
WCHAR wszclsid[128];
DWORD index = 0;
UIINSERTOBJECTDLG_FreeObjectTypes(pdlgInfo);
RegOpenKeyExA(HKEY_CLASSES_ROOT, "CLSID", 0, KEY_READ, &hkclsids);
while (ERROR_SUCCESS == (ret = RegEnumKeyA(hkclsids, index, szclsid, MAX_PATH)))
{
index++;
RegOpenKeyExA(hkclsids, szclsid, 0, KEY_READ, &hkey);
len = MAX_PATH;
if (ERROR_SUCCESS != RegQueryValueA(hkey, "Insertable", keyname, &len))
continue;
len = MAX_PATH;
if (ERROR_SUCCESS == RegQueryValueA(hkey, "NotInsertable", keyname, &len))
continue;
RtlMultiByteToUnicodeN(wszclsid, MAX_PATH, NULL, szclsid, MAX_PATH);
CLSIDFromString(wszclsid, &clsid);
for (i = 0; i < pdlgInfo->lpOleUIInsertObject->cClsidExclude; i++)
if (IsEqualGUID(&pdlgInfo->lpOleUIInsertObject->lpClsidExclude[i], &clsid))
break;
if (i < pdlgInfo->lpOleUIInsertObject->cClsidExclude)
continue;
len = MAX_PATH;
if (ERROR_SUCCESS == RegQueryValueA(hkey, NULL, keydesc, &len))
{
CLSID* lpclsid = (CLSID*) HeapAlloc(GetProcessHeap(), 0, sizeof(CLSID));
memcpy(lpclsid, &clsid, sizeof(CLSID));
len = SendMessageA(pdlgInfo->hwndObjTypeLB, LB_ADDSTRING, 0, (LPARAM)keydesc);
SendMessageA(pdlgInfo->hwndObjTypeLB, LB_SETITEMDATA, (WPARAM)len, (LPARAM)lpclsid);
}
}
pdlgInfo->bObjListInit = (ret == ERROR_NO_MORE_ITEMS);
return pdlgInfo->bObjListInit;
}
/***********************************************************************
* UIINSERTOBJECTDLG_FreeObjectTypes
*
* Free Object Types listbox
*/
static void UIINSERTOBJECTDLG_FreeObjectTypes(InsertObjectDlgInfo* pdlgInfo)
{
UINT i, count;
count = SendMessageA(pdlgInfo->hwndObjTypeLB, LB_GETCOUNT, (WPARAM)0, (LPARAM)0);
for (i = 0; i < count; i++)
{
CLSID* lpclsid = (CLSID*) SendMessageA(pdlgInfo->hwndObjTypeLB,
LB_GETITEMDATA, (WPARAM)i, (LPARAM)0);
HeapFree(GetProcessHeap(), 0, lpclsid);
}
}
/***********************************************************************
* UIINSERTOBJECTDLG_SelChange
*
* Handle object type selection change
*/
static void UIINSERTOBJECTDLG_SelChange(InsertObjectDlgInfo* pdlgInfo)
{
INT index;
CHAR objname[MAX_PATH];
CHAR objdesc[MAX_PATH];
CHAR resstr[MAX_PATH];
TRACE("\n");
if (LoadStringA(OLEDLG_hInstance, IDS_RESULTOBJDESC, resstr, MAX_PATH) &&
((index = SendMessageA(pdlgInfo->hwndObjTypeLB, LB_GETCURSEL, 0, 0)) >= 0) &&
SendMessageA(pdlgInfo->hwndObjTypeLB, LB_GETTEXT, (WPARAM)index, (LPARAM)objname))
sprintf(objdesc, resstr, objname);
else
objdesc[0] = 0;
SendMessageA(pdlgInfo->hwndResultDesc, WM_SETTEXT, 0, (LPARAM)objdesc);
}
/***********************************************************************
* UIINSERTOBJECTDLG_SelChange
*
* Handle OK Button
*/
static BOOL UIINSERTOBJECTDLG_OnOpen(InsertObjectDlgInfo* pdlgInfo)
{
BOOL bret = FALSE;
if (BST_CHECKED == SendMessageA(pdlgInfo->hwndCreateCtrlCB, BM_GETCHECK, 0, 0) ||
BST_CHECKED == SendMessageA(pdlgInfo->hwndCreateNewCB, BM_GETCHECK, 0, 0))
{
INT index = SendMessageA(pdlgInfo->hwndObjTypeLB, LB_GETCURSEL, 0, 0);
if (index >= 0)
{
CLSID* clsid = (CLSID*) SendMessageA(pdlgInfo->hwndObjTypeLB,
LB_GETITEMDATA, (WPARAM)index, 0);
memcpy(&pdlgInfo->lpOleUIInsertObject->clsid, clsid, sizeof(CLSID));
if (pdlgInfo->lpOleUIInsertObject->dwFlags & IOF_CREATENEWOBJECT)
{
pdlgInfo->lpOleUIInsertObject->sc= OleCreate(
&pdlgInfo->lpOleUIInsertObject->clsid,
&pdlgInfo->lpOleUIInsertObject->iid,
pdlgInfo->lpOleUIInsertObject->oleRender,
pdlgInfo->lpOleUIInsertObject->lpFormatEtc,
pdlgInfo->lpOleUIInsertObject->lpIOleClientSite,
pdlgInfo->lpOleUIInsertObject->lpIStorage,
pdlgInfo->lpOleUIInsertObject->ppvObj);
}
bret = TRUE;
}
}
else if (BST_CHECKED == SendMessageA(pdlgInfo->hwndCreateFromFileCB, BM_GETCHECK, 0, 0))
{
char fname[MAX_PATH];
if (pdlgInfo->lpOleUIInsertObject->lpszFile)
{
HRESULT hres;
WCHAR wcsFile[MAX_PATH];
SendMessageA(pdlgInfo->hwndFileTB, WM_GETTEXT, (WPARAM)MAX_PATH, (LPARAM)fname);
strncpy(pdlgInfo->lpOleUIInsertObject->lpszFile, fname, pdlgInfo->lpOleUIInsertObject->cchFile);
RtlMultiByteToUnicodeN(wcsFile, MAX_PATH, NULL, fname, MAX_PATH);
if (ERROR_SUCCESS == (hres = GetClassFile(wcsFile, &pdlgInfo->lpOleUIInsertObject->clsid)))
{
if (pdlgInfo->lpOleUIInsertObject->dwFlags & IOF_CREATEFILEOBJECT)
{
hres = OleCreateFromFile(
&pdlgInfo->lpOleUIInsertObject->clsid,
wcsFile,
&pdlgInfo->lpOleUIInsertObject->iid,
pdlgInfo->lpOleUIInsertObject->oleRender,
pdlgInfo->lpOleUIInsertObject->lpFormatEtc,
pdlgInfo->lpOleUIInsertObject->lpIOleClientSite,
pdlgInfo->lpOleUIInsertObject->lpIStorage,
pdlgInfo->lpOleUIInsertObject->ppvObj);
}
bret = TRUE;
}
pdlgInfo->lpOleUIInsertObject->sc = hres;
}
}
return bret;
}
/***********************************************************************
* UIINSERTOBJECTDLG_BrowseFile
*
* Browse for the file
*/
static void UIINSERTOBJECTDLG_BrowseFile(InsertObjectDlgInfo* pdlgInfo)
{
OPENFILENAMEA fn;
char fname[MAX_PATH];
char title[32];
fn.lStructSize = sizeof(OPENFILENAMEA);
fn.hwndOwner = pdlgInfo->hwndSelf;
fn.hInstance = 0;
fn.lpstrFilter = "All Files\0*.*\0\0";
fn.lpstrCustomFilter = NULL;
fn.nMaxCustFilter = 0;
fn.nFilterIndex = 0;
SendMessageA(pdlgInfo->hwndFileTB, WM_GETTEXT, (WPARAM)MAX_PATH, (LPARAM)fname);
fn.lpstrFile = fname;
fn.nMaxFile = MAX_PATH;
fn.lpstrFileTitle = NULL;
fn.nMaxFileTitle = 0;
fn.lpstrInitialDir = NULL;
LoadStringA(OLEDLG_hInstance, IDS_BROWSE, title, 32);
fn.lpstrTitle = title;
fn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST |
OFN_HIDEREADONLY | OFN_LONGNAMES;
fn.nFileOffset = 0;
fn.nFileExtension = 0;
fn.lpstrDefExt = NULL;
fn.lCustData = 0;
fn.lpfnHook = NULL;
fn.lpTemplateName = NULL;
if (GetOpenFileNameA(&fn))
SendMessageA(pdlgInfo->hwndFileTB, WM_SETTEXT, (WPARAM)0, (LPARAM)fn.lpstrFile);
}
/***********************************************************************
* UIINSERTOBJECTDLG_AddControl
*
* Add control to Object Type
*/
static void UIINSERTOBJECTDLG_AddControl(InsertObjectDlgInfo* pdlgInfo)
{
OPENFILENAMEA fn;
char fname[MAX_PATH];
char title[32];
fn.lStructSize = sizeof(OPENFILENAMEA);
fn.hwndOwner = pdlgInfo->hwndSelf;
fn.hInstance = 0;
fn.lpstrFilter = "OLE Controls\0*.ocx\0Libraries\0*.dll\0All Files\0*.*\0\0";
fn.lpstrCustomFilter = NULL;
fn.nMaxCustFilter = 0;
fn.nFilterIndex = 0;
fname[0] = 0;
fn.lpstrFile = fname;
fn.nMaxFile = MAX_PATH;
fn.lpstrFileTitle = NULL;
fn.nMaxFileTitle = 0;
fn.lpstrInitialDir = NULL;
LoadStringA(OLEDLG_hInstance, IDS_BROWSE, title, 32);
fn.lpstrTitle = title;
fn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST |
OFN_HIDEREADONLY | OFN_LONGNAMES;
fn.nFileOffset = 0;
fn.nFileExtension = 0;
fn.lpstrDefExt = NULL;
fn.lCustData = 0;
fn.lpfnHook = NULL;
fn.lpTemplateName = NULL;
if (GetOpenFileNameA(&fn))
{
HMODULE hMod;
BOOL bValid = FALSE;
hMod = LoadLibraryA(fn.lpstrFile);
if (hMod)
{
DLLREGISTER regproc;
regproc = (DLLREGISTER) GetProcAddress(hMod, "DllRegisterServer");
if (regproc)
{
if (S_OK == regproc())
{
UIINSERTOBJECTDLG_PopulateObjectTypes(pdlgInfo);
bValid = TRUE;
}
}
FreeLibrary(hMod);
}
if (!bValid)
{
char title[32];
char msg[256];
LoadStringA(OLEDLG_hInstance, IDS_NOTOLEMODCAPTION, title, 32);
LoadStringA(OLEDLG_hInstance, IDS_NOTOLEMOD, msg, 256);
MessageBoxA(pdlgInfo->hwndSelf, msg, title, MB_ICONEXCLAMATION);
}
}
}

55
dlls/oledlg/oledlg_En.rc Normal file
View File

@ -0,0 +1,55 @@
/*
* Copyright 2003 Ulrich Czekalla for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
UIINSERTOBJECT DIALOG DISCARDABLE 0, 0, 294, 151
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Insert Object"
FONT 8, "MS Sans Serif"
BEGIN
LISTBOX IDC_OBJTYPELIST,82,19,131,66,LBS_SORT |
LBS_NOINTEGRALHEIGHT | WS_VISIBLE | WS_VSCROLL |
WS_TABSTOP
LTEXT "Object Type:",IDC_OBJTYPELBL,82,7,53,8,WS_VISIBLE
DEFPUSHBUTTON "OK",IDOK,221,7,66,14
PUSHBUTTON "Cancel",IDCANCEL,221,24,66,14
GROUPBOX "Result",IDC_RESULT,7,103,208,41
CONTROL "Create New",IDC_CREATENEW,"Button",BS_AUTORADIOBUTTON |
WS_GROUP,7,20,62,10
CONTROL "Create Control",IDC_CREATECONTROL,"Button",
BS_AUTORADIOBUTTON | NOT WS_VISIBLE,7,54,62,10
CONTROL "Create From File",IDC_CREATEFROMFILE,"Button",
BS_AUTORADIOBUTTON,7,37,67,10
LTEXT "",IDC_RESULTDESC,49,112,159,23
PUSHBUTTON "&Add Control...",IDC_ADDCONTROL,81,88,63,14,NOT WS_VISIBLE
CONTROL "Display As Icon",IDC_ASICON,"Button",BS_AUTOCHECKBOX |
WS_TABSTOP | NOT WS_VISIBLE,223,58,64,10
PUSHBUTTON "Browse...",IDC_BROWSE,83,53,50,14,NOT WS_VISIBLE
LTEXT "File:",IDC_FILELBL,83,27,20,8, NOT WS_VISIBLE
EDITTEXT IDC_FILE,83,37,132,13,ES_AUTOHSCROLL | NOT WS_VISIBLE
END
STRINGTABLE DISCARDABLE
{
IDS_RESULTOBJDESC "Insert a new %s object into your document"
IDS_RESULTFILEOBJDESC "Insert the contents of the file as an object into your document so that you may activate it using the program which created it."
IDS_BROWSE "Browse"
IDS_NOTOLEMOD "File does not appear to be a valid OLE module. Unable to register OLE control."
IDS_NOTOLEMODCAPTION "Add Control"
}

View File

@ -32,6 +32,29 @@
WINE_DEFAULT_DEBUG_CHANNEL(ole);
HINSTANCE OLEDLG_hInstance = 0;
/***********************************************************************
* DllMain
*/
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID fImpLoad)
{
TRACE("%p 0x%lx %p\n", hinstDLL, fdwReason, fImpLoad);
switch(fdwReason) {
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
OLEDLG_hInstance = hinstDLL;
break;
case DLL_PROCESS_DETACH:
OLEDLG_hInstance = 0;
break;
}
return TRUE;
}
/***********************************************************************
* OleUIAddVerbMenuA (OLEDLG.1)
*/
@ -79,16 +102,6 @@ BOOL WINAPI OleUICanConvertOrActivateAs(
return FALSE;
}
/***********************************************************************
* OleUIInsertObjectA (OLEDLG.3)
*/
UINT WINAPI OleUIInsertObjectA(LPOLEUIINSERTOBJECTA lpOleUIInsertObject)
{
FIXME("(%p): stub\n", lpOleUIInsertObject);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return OLEUI_FALSE;
}
/***********************************************************************
* OleUIInsertObjectW (OLEDLG.20)
*/

40
dlls/oledlg/resource.h Normal file
View File

@ -0,0 +1,40 @@
/*
* Definitions for OLE dialog resources
*
* Copyright 2003 Ulrich Czekalla for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define IDS_RESULTOBJDESC 101
#define IDS_RESULTFILEOBJDESC 102
#define IDS_BROWSE 103
#define IDS_NOTOLEMOD 104
#define IDS_NOTOLEMODCAPTION 105
#define UIINSERTOBJECT 129
#define IDC_OBJTYPELIST 1000
#define IDC_RESULT 1001
#define IDC_CREATENEW 1002
#define IDC_CREATECONTROL 1003
#define IDC_CREATEFROMFILE 1004
#define IDC_OBJTYPELBL 1005
#define IDC_RESULTDESC 1006
#define IDC_ADDCONTROL 1007
#define IDC_ASICON 1008
#define IDC_BROWSE 1009
#define IDC_FILELBL 1010
#define IDC_FILE 1011

34
dlls/oledlg/rsrc.rc Normal file
View File

@ -0,0 +1,34 @@
/*
* Top level resource file for OLE Dialogs
*
* Copyright 2003 Ulrich Czekalla for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winnls.h"
#include "resource.h"
/*
* Everything specific to any language goes
* in one of the specific files.
* Note that you can and may override resources
* which also have a neutral version. This is to
* get localized bitmaps for example.
*/
#include "oledlg_En.rc"

View File

@ -104,6 +104,25 @@ typedef struct IOleUIObjInfoW IOleUIObjInfoW, *POLEUIOBJINFOW, *LPOLEUIOBJINFOW;
#define OLEUI_OK 1 /* OK button pressed */
#define OLEUI_CANCEL 2 /* Cancel button pressed */
#define OLEUI_ERR_STANDARDMIN 100
#define OLEUI_ERR_OLEMEMALLOC 100
#define OLEUI_ERR_STRUCTURENULL 101
#define OLEUI_ERR_STRUCTUREINVALID 102
#define OLEUI_ERR_CBSTRUCTINCORRECT 103
#define OLEUI_ERR_HWNDOWNERINVALID 104
#define OLEUI_ERR_LPSZCAPTIONINVALID 105
#define OLEUI_ERR_LPFNHOOKINVALID 106
#define OLEUI_ERR_HINSTANCEINVALID 107
#define OLEUI_ERR_LPSZTEMPLATEINVALID 108
#define OLEUI_ERR_HRESOURCEINVALID 109
#define OLEUI_ERR_FINDTEMPLATEFAILURE 110
#define OLEUI_ERR_LOADTEMPLATEFAILURE 111
#define OLEUI_ERR_DIALOGFAILURE 112
#define OLEUI_ERR_LOCALMEMALLOC 113
#define OLEUI_ERR_GLOBALMEMALLOC 114
#define OLEUI_ERR_LOADSTRING 115
#define OLEUI_ERR_STANDARDMAX 116
#define OPF_OBJECTISLINK 0x00000001L
#define OPF_NOFILLDEFAULT 0x00000002L
#define OPF_SHOWHELP 0x00000004L