cmd: DIR command outputs free space for the path.
[wine.git] / dlls / oledlg / insobjdlg.c
blob18919b2b50055981c662e42e60b08ec5c2322afa
1 /*
2 * OLEDLG library
4 * Copyright 2003 Ulrich Czekalla for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <stdarg.h>
22 #include <stdio.h>
24 #include "windef.h"
25 #include "winbase.h"
26 #include "winreg.h"
27 #include "winternl.h"
28 #include "winerror.h"
29 #include "wingdi.h"
30 #include "winuser.h"
31 #include "wine/debug.h"
33 #include "oledlg.h"
34 #include "resource.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(oledlg);
38 typedef struct
40 HWND hwndSelf;
41 BOOL bObjListInit; /* Object list has been initialized */
42 LPOLEUIINSERTOBJECTA lpOleUIInsertObject;
44 HWND hwndObjTypeLBL;
45 HWND hwndObjTypeLB;
46 HWND hwndFileLBL;
47 HWND hwndFileTB;
48 HWND hwndCreateCtrlCB;
49 HWND hwndCreateNewCB;
50 HWND hwndCreateFromFileCB;
51 HWND hwndDisplayIconCB;
52 HWND hwndAddCtrlBTN;
53 HWND hwndBrowseBTN;
54 HWND hwndResultDesc;
56 } InsertObjectDlgInfo;
58 static INT_PTR CALLBACK UIInsertObjectDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
59 static LRESULT UIINSOBJDLG_OnWMCommand(HWND hwnd, WPARAM wParam, LPARAM lParam);
60 static void UIINSERTOBJECTDLG_InitDialog(InsertObjectDlgInfo* pdlgInfo);
61 static void UIINSERTOBJECTDLG_SelectCreateCtrl(InsertObjectDlgInfo* pdlgInfo);
62 static void UIINSERTOBJECTDLG_SelectCreateFromFile(InsertObjectDlgInfo* pdlgInfo);
63 static void UIINSERTOBJECTDLG_SelectCreateNew(InsertObjectDlgInfo* pdlgInfo);
64 static BOOL UIINSERTOBJECTDLG_PopulateObjectTypes(InsertObjectDlgInfo* pdlgInfo);
65 static void UIINSERTOBJECTDLG_FreeObjectTypes(InsertObjectDlgInfo* pdlgInfo);
66 static void UIINSERTOBJECTDLG_SelChange(InsertObjectDlgInfo* pdlgInfo);
67 static BOOL UIINSERTOBJECTDLG_OnOpen(InsertObjectDlgInfo* pdlgInfo);
68 static void UIINSERTOBJECTDLG_BrowseFile(InsertObjectDlgInfo* pdlgInfo);
69 static void UIINSERTOBJECTDLG_AddControl(InsertObjectDlgInfo* pdlgInfo);
71 typedef HRESULT (*DLLREGISTER) (void);
73 extern HINSTANCE OLEDLG_hInstance;
74 static const WCHAR OleUIInsertObjectInfoStr[] = {'O','l','e','U','I','I','n','s','e','r','t','O','b','j','e','c','t',
75 'I','n','f','o','S','t','r',0};
77 /***********************************************************************
78 * OleUIInsertObjectA (OLEDLG.3)
80 UINT WINAPI OleUIInsertObjectA(LPOLEUIINSERTOBJECTA lpOleUIInsertObject)
82 LRESULT lRes;
83 LPCVOID template;
84 HRSRC hRes;
85 InsertObjectDlgInfo dlgInfo;
86 HANDLE hDlgTmpl = 0;
88 if (lpOleUIInsertObject->lpszTemplate || lpOleUIInsertObject->hResource)
89 FIXME("Customized template not supported\n");
91 /* Create the dialog from a template */
92 if(!(hRes = FindResourceA(OLEDLG_hInstance,MAKEINTRESOURCEA(UIINSERTOBJECT),
93 (LPSTR)RT_DIALOG)))
95 return OLEUI_ERR_FINDTEMPLATEFAILURE;
98 if (!(hDlgTmpl = LoadResource(OLEDLG_hInstance, hRes )) ||
99 !(template = LockResource( hDlgTmpl )))
101 return OLEUI_ERR_LOADTEMPLATEFAILURE;
104 /* Initialize InsertObjectDlgInfo structure */
105 dlgInfo.lpOleUIInsertObject = lpOleUIInsertObject;
106 dlgInfo.bObjListInit = FALSE;
108 lRes = DialogBoxIndirectParamA(OLEDLG_hInstance, (const DLGTEMPLATE*) template,
109 lpOleUIInsertObject->hWndOwner, UIInsertObjectDlgProc,
110 (LPARAM) &dlgInfo);
112 /* Unable to create the dialog */
113 if( lRes == -1)
114 return OLEUI_ERR_DIALOGFAILURE;
116 return lRes;
120 /***********************************************************************
121 * UIInsertObjectDlgProc
123 * OLE UI Insert Object dialog procedure
125 INT_PTR CALLBACK UIInsertObjectDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
127 InsertObjectDlgInfo* pdlgInfo = GetPropW(hwnd, OleUIInsertObjectInfoStr);
129 switch(uMsg)
131 case WM_INITDIALOG:
133 InsertObjectDlgInfo* pdlgInfo = (InsertObjectDlgInfo*)lParam;
135 pdlgInfo->hwndSelf = hwnd;
137 SetPropW(hwnd, OleUIInsertObjectInfoStr, pdlgInfo);
139 UIINSERTOBJECTDLG_InitDialog(pdlgInfo);
141 return 0;
144 case WM_COMMAND:
145 return UIINSOBJDLG_OnWMCommand(hwnd, wParam, lParam);
147 case WM_DESTROY:
148 if (pdlgInfo)
149 UIINSERTOBJECTDLG_FreeObjectTypes(pdlgInfo);
150 RemovePropW(hwnd, OleUIInsertObjectInfoStr);
151 return FALSE;
153 default :
154 return FALSE;
159 /***********************************************************************
160 * UIINSOBJDLG_OnWMCommand
162 * WM_COMMAND message handler
164 static LRESULT UIINSOBJDLG_OnWMCommand(HWND hwnd, WPARAM wParam, LPARAM lParam)
166 InsertObjectDlgInfo* pdlgInfo = GetPropW(hwnd, OleUIInsertObjectInfoStr);
167 WORD wNotifyCode = HIWORD(wParam);
168 WORD wID = LOWORD(wParam);
170 switch(wID)
172 case IDOK:
173 EndDialog(hwnd, UIINSERTOBJECTDLG_OnOpen(pdlgInfo));
174 break;
176 case IDCANCEL:
177 EndDialog(hwnd, FALSE);
178 break;
180 case IDC_CREATECONTROL:
181 UIINSERTOBJECTDLG_SelectCreateCtrl(pdlgInfo);
182 break;
184 case IDC_CREATENEW:
185 UIINSERTOBJECTDLG_SelectCreateNew(pdlgInfo);
186 break;
188 case IDC_CREATEFROMFILE:
189 UIINSERTOBJECTDLG_SelectCreateFromFile(pdlgInfo);
190 break;
192 case IDC_BROWSE:
193 UIINSERTOBJECTDLG_BrowseFile(pdlgInfo);
194 break;
196 case IDC_ADDCONTROL:
197 UIINSERTOBJECTDLG_AddControl(pdlgInfo);
198 break;
200 case IDC_OBJTYPELIST:
201 if (wNotifyCode == LBN_SELCHANGE)
202 UIINSERTOBJECTDLG_SelChange(pdlgInfo);
203 break;
205 return 0;
209 /***********************************************************************
210 * UIINSERTOBJECTDLG_InitDialog
212 * Initialize dialog display
214 static void UIINSERTOBJECTDLG_InitDialog(InsertObjectDlgInfo* pdlgInfo)
216 /* Initialize InsertObjectDlgInfo data structure */
217 pdlgInfo->hwndObjTypeLB = GetDlgItem(pdlgInfo->hwndSelf, IDC_OBJTYPELIST);
218 pdlgInfo->hwndObjTypeLBL = GetDlgItem(pdlgInfo->hwndSelf, IDC_OBJTYPELBL);
219 pdlgInfo->hwndFileLBL = GetDlgItem(pdlgInfo->hwndSelf, IDC_FILELBL);
220 pdlgInfo->hwndFileTB = GetDlgItem(pdlgInfo->hwndSelf, IDC_FILE);
221 pdlgInfo->hwndCreateCtrlCB = GetDlgItem(pdlgInfo->hwndSelf, IDC_CREATECONTROL);
222 pdlgInfo->hwndCreateNewCB = GetDlgItem(pdlgInfo->hwndSelf, IDC_CREATENEW);
223 pdlgInfo->hwndCreateFromFileCB = GetDlgItem(pdlgInfo->hwndSelf, IDC_CREATEFROMFILE);
224 pdlgInfo->hwndDisplayIconCB = GetDlgItem(pdlgInfo->hwndSelf, IDC_ASICON);
225 pdlgInfo->hwndAddCtrlBTN = GetDlgItem(pdlgInfo->hwndSelf, IDC_ADDCONTROL);
226 pdlgInfo->hwndBrowseBTN = GetDlgItem(pdlgInfo->hwndSelf, IDC_BROWSE);
227 pdlgInfo->hwndResultDesc = GetDlgItem(pdlgInfo->hwndSelf, IDC_RESULTDESC);
229 /* Setup dialog controls based on flags */
230 if (pdlgInfo->lpOleUIInsertObject->lpszCaption)
231 SetWindowTextA(pdlgInfo->hwndSelf, pdlgInfo->lpOleUIInsertObject->lpszCaption);
233 ShowWindow(pdlgInfo->hwndCreateCtrlCB, (pdlgInfo->lpOleUIInsertObject->dwFlags &
234 IOF_SHOWINSERTCONTROL) ? SW_SHOW : SW_HIDE);
235 ShowWindow(pdlgInfo->hwndDisplayIconCB, (pdlgInfo->lpOleUIInsertObject->dwFlags &
236 IOF_CHECKDISPLAYASICON) ? SW_SHOW : SW_HIDE);
237 EnableWindow(pdlgInfo->hwndDisplayIconCB, !(pdlgInfo->lpOleUIInsertObject->dwFlags &
238 IOF_DISABLEDISPLAYASICON));
240 if (pdlgInfo->lpOleUIInsertObject->dwFlags & IOF_SELECTCREATECONTROL)
241 UIINSERTOBJECTDLG_SelectCreateCtrl(pdlgInfo);
242 else if (pdlgInfo->lpOleUIInsertObject->dwFlags & IOF_SELECTCREATEFROMFILE)
243 UIINSERTOBJECTDLG_SelectCreateFromFile(pdlgInfo);
244 else /* (pdlgInfo->lpOleUIInsertObject->dwFlags & IOF_SELECTCREATENEW) */
245 UIINSERTOBJECTDLG_SelectCreateNew(pdlgInfo);
249 /***********************************************************************
250 * UIINSERTOBJECTDLG_SelectCreateCtrl
252 * Select Create Control Radio Button
254 static void UIINSERTOBJECTDLG_SelectCreateCtrl(InsertObjectDlgInfo* pdlgInfo)
256 ShowWindow(pdlgInfo->hwndDisplayIconCB, SW_HIDE);
257 ShowWindow(pdlgInfo->hwndFileLBL, SW_HIDE);
258 ShowWindow(pdlgInfo->hwndFileTB, SW_HIDE);
259 ShowWindow(pdlgInfo->hwndBrowseBTN, SW_HIDE);
261 ShowWindow(pdlgInfo->hwndObjTypeLBL, SW_SHOW);
262 ShowWindow(pdlgInfo->hwndObjTypeLB, SW_SHOW);
263 ShowWindow(pdlgInfo->hwndAddCtrlBTN, SW_SHOW);
265 SendMessageA(pdlgInfo->hwndCreateCtrlCB, BM_SETCHECK, BST_CHECKED, 0);
267 /* Populate object type listbox */
268 if (!pdlgInfo->bObjListInit)
269 UIINSERTOBJECTDLG_PopulateObjectTypes(pdlgInfo);
273 /***********************************************************************
274 * UIINSERTOBJECTDLG_SelectCreateNew
276 * Select Create New Radio Button
278 static void UIINSERTOBJECTDLG_SelectCreateNew(InsertObjectDlgInfo* pdlgInfo)
280 ShowWindow(pdlgInfo->hwndFileLBL, SW_HIDE);
281 ShowWindow(pdlgInfo->hwndFileTB, SW_HIDE);
282 ShowWindow(pdlgInfo->hwndAddCtrlBTN, SW_HIDE);
283 ShowWindow(pdlgInfo->hwndBrowseBTN, SW_HIDE);
285 if (pdlgInfo->lpOleUIInsertObject->dwFlags & IOF_CHECKDISPLAYASICON)
286 ShowWindow(pdlgInfo->hwndDisplayIconCB, SW_SHOW);
288 ShowWindow(pdlgInfo->hwndObjTypeLBL, SW_SHOW);
289 ShowWindow(pdlgInfo->hwndObjTypeLB, SW_SHOW);
291 SendMessageA(pdlgInfo->hwndCreateNewCB, BM_SETCHECK, BST_CHECKED, 0);
293 if (!pdlgInfo->bObjListInit)
294 UIINSERTOBJECTDLG_PopulateObjectTypes(pdlgInfo);
296 UIINSERTOBJECTDLG_SelChange(pdlgInfo);
300 /***********************************************************************
301 * UIINSERTOBJECTDLG_SelectCreateFromFile
303 * Select Create From File Radio Button
305 static void UIINSERTOBJECTDLG_SelectCreateFromFile(InsertObjectDlgInfo* pdlgInfo)
307 WCHAR resstr[MAX_PATH];
309 ShowWindow(pdlgInfo->hwndAddCtrlBTN, SW_HIDE);
310 ShowWindow(pdlgInfo->hwndObjTypeLBL, SW_HIDE);
311 ShowWindow(pdlgInfo->hwndObjTypeLB, SW_HIDE);
313 if (pdlgInfo->lpOleUIInsertObject->dwFlags & IOF_CHECKDISPLAYASICON)
314 ShowWindow(pdlgInfo->hwndDisplayIconCB, SW_SHOW);
316 ShowWindow(pdlgInfo->hwndFileLBL, SW_SHOW);
317 ShowWindow(pdlgInfo->hwndFileTB, SW_SHOW);
318 ShowWindow(pdlgInfo->hwndBrowseBTN, SW_SHOW);
320 SendMessageW(pdlgInfo->hwndCreateFromFileCB, BM_SETCHECK, BST_CHECKED, 0);
322 if (LoadStringW(OLEDLG_hInstance, IDS_RESULTFILEOBJDESC, resstr, MAX_PATH))
323 SendMessageW(pdlgInfo->hwndResultDesc, WM_SETTEXT, 0, (LPARAM)resstr);
327 /***********************************************************************
328 * UIINSERTOBJECTDLG_PopulateObjectTypes
330 * Populate Object Type listbox
332 static BOOL UIINSERTOBJECTDLG_PopulateObjectTypes(InsertObjectDlgInfo* pdlgInfo)
334 static const WCHAR szClsid[] = {'C','L','S','I','D',0};
335 static const WCHAR szInsertable[] = {'I','n','s','e','r','t','a','b','l','e',0};
336 static const WCHAR szNotInsertable[] = {'N','o','t','I','n','s','e','r','t','a','b','l','e',0};
337 DWORD i;
338 LONG len;
339 HKEY hkclsids;
340 HKEY hkey;
341 CLSID clsid;
342 LSTATUS ret;
343 WCHAR keydesc[MAX_PATH];
344 WCHAR keyname[MAX_PATH];
345 WCHAR szclsid[128];
346 DWORD index = 0;
348 UIINSERTOBJECTDLG_FreeObjectTypes(pdlgInfo);
350 RegOpenKeyExW(HKEY_CLASSES_ROOT, szClsid, 0, KEY_READ, &hkclsids);
352 while (ERROR_SUCCESS == (ret = RegEnumKeyW(hkclsids, index, szclsid, ARRAY_SIZE(szclsid))))
354 index++;
356 RegOpenKeyExW(hkclsids, szclsid, 0, KEY_READ, &hkey);
358 len = sizeof(keyname);
359 if (ERROR_SUCCESS != RegQueryValueW(hkey, szInsertable, keyname, &len))
360 continue;
362 len = sizeof(keyname);
363 if (ERROR_SUCCESS == RegQueryValueW(hkey, szNotInsertable, keyname, &len))
364 continue;
366 CLSIDFromString(szclsid, &clsid);
368 for (i = 0; i < pdlgInfo->lpOleUIInsertObject->cClsidExclude; i++)
369 if (IsEqualGUID(&pdlgInfo->lpOleUIInsertObject->lpClsidExclude[i], &clsid))
370 break;
372 if (i < pdlgInfo->lpOleUIInsertObject->cClsidExclude)
373 continue;
375 len = sizeof(keydesc);
376 if (ERROR_SUCCESS == RegQueryValueW(hkey, NULL, keydesc, &len))
378 CLSID* lpclsid = HeapAlloc(GetProcessHeap(), 0, sizeof(CLSID));
379 *lpclsid = clsid;
381 len = SendMessageW(pdlgInfo->hwndObjTypeLB, LB_ADDSTRING, 0, (LPARAM)keydesc);
382 SendMessageW(pdlgInfo->hwndObjTypeLB, LB_SETITEMDATA, len, (LPARAM)lpclsid);
386 pdlgInfo->bObjListInit = (ret == ERROR_NO_MORE_ITEMS);
388 return pdlgInfo->bObjListInit;
392 /***********************************************************************
393 * UIINSERTOBJECTDLG_FreeObjectTypes
395 * Free Object Types listbox
397 static void UIINSERTOBJECTDLG_FreeObjectTypes(InsertObjectDlgInfo* pdlgInfo)
399 UINT i, count;
401 count = SendMessageA(pdlgInfo->hwndObjTypeLB, LB_GETCOUNT, 0, 0);
403 for (i = 0; i < count; i++)
405 CLSID* lpclsid = (CLSID*) SendMessageA(pdlgInfo->hwndObjTypeLB,
406 LB_GETITEMDATA, i, 0);
407 HeapFree(GetProcessHeap(), 0, lpclsid);
412 /***********************************************************************
413 * UIINSERTOBJECTDLG_SelChange
415 * Handle object type selection change
417 static void UIINSERTOBJECTDLG_SelChange(InsertObjectDlgInfo* pdlgInfo)
419 INT index;
420 WCHAR objname[MAX_PATH];
421 WCHAR objdesc[MAX_PATH];
422 WCHAR resstr[MAX_PATH];
424 TRACE("\n");
426 if (LoadStringW(OLEDLG_hInstance, IDS_RESULTOBJDESC, resstr, MAX_PATH) &&
427 ((index = SendMessageW(pdlgInfo->hwndObjTypeLB, LB_GETCURSEL, 0, 0)) >= 0) &&
428 SendMessageW(pdlgInfo->hwndObjTypeLB, LB_GETTEXT, index, (LPARAM)objname))
429 wsprintfW(objdesc, resstr, objname);
430 else
431 objdesc[0] = 0;
433 SendMessageW(pdlgInfo->hwndResultDesc, WM_SETTEXT, 0, (LPARAM)objdesc);
437 /***********************************************************************
438 * UIINSERTOBJECTDLG_SelChange
440 * Handle OK Button
442 static BOOL UIINSERTOBJECTDLG_OnOpen(InsertObjectDlgInfo* pdlgInfo)
444 BOOL bret = FALSE;
446 if (BST_CHECKED == SendMessageA(pdlgInfo->hwndCreateCtrlCB, BM_GETCHECK, 0, 0) ||
447 BST_CHECKED == SendMessageA(pdlgInfo->hwndCreateNewCB, BM_GETCHECK, 0, 0))
449 INT index = SendMessageA(pdlgInfo->hwndObjTypeLB, LB_GETCURSEL, 0, 0);
451 if (index >= 0)
453 CLSID* clsid = (CLSID*) SendMessageA(pdlgInfo->hwndObjTypeLB,
454 LB_GETITEMDATA, index, 0);
455 pdlgInfo->lpOleUIInsertObject->clsid = *clsid;
457 if (pdlgInfo->lpOleUIInsertObject->dwFlags & IOF_CREATENEWOBJECT)
459 pdlgInfo->lpOleUIInsertObject->sc= OleCreate(
460 &pdlgInfo->lpOleUIInsertObject->clsid,
461 &pdlgInfo->lpOleUIInsertObject->iid,
462 pdlgInfo->lpOleUIInsertObject->oleRender,
463 pdlgInfo->lpOleUIInsertObject->lpFormatEtc,
464 pdlgInfo->lpOleUIInsertObject->lpIOleClientSite,
465 pdlgInfo->lpOleUIInsertObject->lpIStorage,
466 pdlgInfo->lpOleUIInsertObject->ppvObj);
469 bret = TRUE;
472 else if (BST_CHECKED == SendMessageA(pdlgInfo->hwndCreateFromFileCB, BM_GETCHECK, 0, 0))
474 if (pdlgInfo->lpOleUIInsertObject->lpszFile)
476 HRESULT hres;
477 WCHAR wcsFile[MAX_PATH];
479 if (SendMessageW(pdlgInfo->hwndFileTB, WM_GETTEXT, MAX_PATH, (LPARAM)wcsFile))
480 WideCharToMultiByte(CP_ACP, 0, wcsFile, -1,
481 pdlgInfo->lpOleUIInsertObject->lpszFile, pdlgInfo->lpOleUIInsertObject->cchFile, NULL, NULL);
483 if (SUCCEEDED(hres = GetClassFile(wcsFile, &pdlgInfo->lpOleUIInsertObject->clsid)))
485 if (pdlgInfo->lpOleUIInsertObject->dwFlags & IOF_CREATEFILEOBJECT)
487 hres = OleCreateFromFile(
488 &pdlgInfo->lpOleUIInsertObject->clsid,
489 wcsFile,
490 &pdlgInfo->lpOleUIInsertObject->iid,
491 pdlgInfo->lpOleUIInsertObject->oleRender,
492 pdlgInfo->lpOleUIInsertObject->lpFormatEtc,
493 pdlgInfo->lpOleUIInsertObject->lpIOleClientSite,
494 pdlgInfo->lpOleUIInsertObject->lpIStorage,
495 pdlgInfo->lpOleUIInsertObject->ppvObj);
498 bret = TRUE;
500 pdlgInfo->lpOleUIInsertObject->sc = hres;
504 return bret;
508 /***********************************************************************
509 * UIINSERTOBJECTDLG_BrowseFile
511 * Browse for the file
513 static void UIINSERTOBJECTDLG_BrowseFile(InsertObjectDlgInfo* pdlgInfo)
515 OPENFILENAMEA fn;
516 char fname[MAX_PATH];
517 char title[32];
519 fn.lStructSize = sizeof(OPENFILENAMEA);
520 fn.hwndOwner = pdlgInfo->hwndSelf;
521 fn.hInstance = 0;
522 fn.lpstrFilter = "All Files\0*.*\0\0";
523 fn.lpstrCustomFilter = NULL;
524 fn.nMaxCustFilter = 0;
525 fn.nFilterIndex = 0;
527 SendMessageA(pdlgInfo->hwndFileTB, WM_GETTEXT, MAX_PATH, (LPARAM)fname);
528 fn.lpstrFile = fname;
529 fn.nMaxFile = MAX_PATH;
531 fn.lpstrFileTitle = NULL;
532 fn.nMaxFileTitle = 0;
533 fn.lpstrInitialDir = NULL;
535 LoadStringA(OLEDLG_hInstance, IDS_BROWSE, title, 32);
536 fn.lpstrTitle = title;
538 fn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST |
539 OFN_HIDEREADONLY | OFN_LONGNAMES;
540 fn.nFileOffset = 0;
541 fn.nFileExtension = 0;
542 fn.lpstrDefExt = NULL;
543 fn.lCustData = 0;
544 fn.lpfnHook = NULL;
545 fn.lpTemplateName = NULL;
547 if (GetOpenFileNameA(&fn))
548 SendMessageA(pdlgInfo->hwndFileTB, WM_SETTEXT, 0, (LPARAM)fn.lpstrFile);
552 /***********************************************************************
553 * UIINSERTOBJECTDLG_AddControl
555 * Add control to Object Type
557 static void UIINSERTOBJECTDLG_AddControl(InsertObjectDlgInfo* pdlgInfo)
559 OPENFILENAMEA fn;
560 char fname[MAX_PATH];
561 char title[32];
563 fn.lStructSize = sizeof(OPENFILENAMEA);
564 fn.hwndOwner = pdlgInfo->hwndSelf;
565 fn.hInstance = 0;
566 fn.lpstrFilter = "OLE Controls\0*.ocx\0Libraries\0*.dll\0All Files\0*.*\0\0";
567 fn.lpstrCustomFilter = NULL;
568 fn.nMaxCustFilter = 0;
569 fn.nFilterIndex = 0;
571 fname[0] = 0;
572 fn.lpstrFile = fname;
573 fn.nMaxFile = MAX_PATH;
575 fn.lpstrFileTitle = NULL;
576 fn.nMaxFileTitle = 0;
577 fn.lpstrInitialDir = NULL;
579 LoadStringA(OLEDLG_hInstance, IDS_BROWSE, title, 32);
580 fn.lpstrTitle = title;
582 fn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST |
583 OFN_HIDEREADONLY | OFN_LONGNAMES;
584 fn.nFileOffset = 0;
585 fn.nFileExtension = 0;
586 fn.lpstrDefExt = NULL;
587 fn.lCustData = 0;
588 fn.lpfnHook = NULL;
589 fn.lpTemplateName = NULL;
591 if (GetOpenFileNameA(&fn))
593 HMODULE hMod;
594 BOOL bValid = FALSE;
596 hMod = LoadLibraryA(fn.lpstrFile);
598 if (hMod)
600 DLLREGISTER regproc;
602 regproc = (DLLREGISTER) GetProcAddress(hMod, "DllRegisterServer");
603 if (regproc)
605 if (S_OK == regproc())
607 UIINSERTOBJECTDLG_PopulateObjectTypes(pdlgInfo);
608 bValid = TRUE;
612 FreeLibrary(hMod);
615 if (!bValid)
617 WCHAR title[32];
618 WCHAR msg[256];
620 LoadStringW(OLEDLG_hInstance, IDS_NOTOLEMODCAPTION, title, 32);
621 LoadStringW(OLEDLG_hInstance, IDS_NOTOLEMOD, msg, 256);
623 MessageBoxW(pdlgInfo->hwndSelf, msg, title, MB_ICONEXCLAMATION);