winefile: Use SendMessageW instead of SNDMSG.
[wine.git] / dlls / oledlg / insobjdlg.c
blob8ddf22756f89b623a9158f34f6e8cc6a092ec5ee
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"
32 #include "wine/unicode.h"
34 #include "oledlg.h"
35 #include "resource.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(oledlg);
39 typedef struct
41 HWND hwndSelf;
42 BOOL bObjListInit; /* Object list has been initialized */
43 LPOLEUIINSERTOBJECTA lpOleUIInsertObject;
45 HWND hwndObjTypeLBL;
46 HWND hwndObjTypeLB;
47 HWND hwndFileLBL;
48 HWND hwndFileTB;
49 HWND hwndCreateCtrlCB;
50 HWND hwndCreateNewCB;
51 HWND hwndCreateFromFileCB;
52 HWND hwndDisplayIconCB;
53 HWND hwndAddCtrlBTN;
54 HWND hwndBrowseBTN;
55 HWND hwndResultDesc;
57 } InsertObjectDlgInfo;
59 static INT_PTR CALLBACK UIInsertObjectDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
60 static LRESULT UIINSOBJDLG_OnWMCommand(HWND hwnd, WPARAM wParam, LPARAM lParam);
61 static void UIINSERTOBJECTDLG_InitDialog(InsertObjectDlgInfo* pdlgInfo);
62 static void UIINSERTOBJECTDLG_SelectCreateCtrl(InsertObjectDlgInfo* pdlgInfo);
63 static void UIINSERTOBJECTDLG_SelectCreateFromFile(InsertObjectDlgInfo* pdlgInfo);
64 static void UIINSERTOBJECTDLG_SelectCreateNew(InsertObjectDlgInfo* pdlgInfo);
65 static BOOL UIINSERTOBJECTDLG_PopulateObjectTypes(InsertObjectDlgInfo* pdlgInfo);
66 static void UIINSERTOBJECTDLG_FreeObjectTypes(InsertObjectDlgInfo* pdlgInfo);
67 static void UIINSERTOBJECTDLG_SelChange(InsertObjectDlgInfo* pdlgInfo);
68 static BOOL UIINSERTOBJECTDLG_OnOpen(InsertObjectDlgInfo* pdlgInfo);
69 static void UIINSERTOBJECTDLG_BrowseFile(InsertObjectDlgInfo* pdlgInfo);
70 static void UIINSERTOBJECTDLG_AddControl(InsertObjectDlgInfo* pdlgInfo);
72 typedef HRESULT (*DLLREGISTER) (void);
74 extern HINSTANCE OLEDLG_hInstance;
75 static const char OleUIInsertObjectInfoStr[] = "OleUIInsertObjectInfoStr";
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 = (InsertObjectDlgInfo*) GetPropA(hwnd,OleUIInsertObjectInfoStr);
129 switch(uMsg)
131 case WM_INITDIALOG:
133 InsertObjectDlgInfo* pdlgInfo = (InsertObjectDlgInfo*)lParam;
135 pdlgInfo->hwndSelf = hwnd;
137 SetPropA(hwnd, OleUIInsertObjectInfoStr, (HANDLE) 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 RemovePropA(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 WORD wNotifyCode = HIWORD(wParam);
167 WORD wID = LOWORD(wParam);
168 InsertObjectDlgInfo* pdlgInfo = (InsertObjectDlgInfo*) GetPropA(hwnd,OleUIInsertObjectInfoStr);
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);
199 case IDC_OBJTYPELIST:
201 if (wNotifyCode == LBN_SELCHANGE)
202 UIINSERTOBJECTDLG_SelChange(pdlgInfo);
203 break;
206 return 0;
210 /***********************************************************************
211 * UIINSERTOBJECTDLG_InitDialog
213 * Initialize dialog display
215 static void UIINSERTOBJECTDLG_InitDialog(InsertObjectDlgInfo* pdlgInfo)
217 /* Initialize InsertObjectDlgInfo data structure */
218 pdlgInfo->hwndObjTypeLB = GetDlgItem(pdlgInfo->hwndSelf, IDC_OBJTYPELIST);
219 pdlgInfo->hwndObjTypeLBL = GetDlgItem(pdlgInfo->hwndSelf, IDC_OBJTYPELBL);
220 pdlgInfo->hwndFileLBL = GetDlgItem(pdlgInfo->hwndSelf, IDC_FILELBL);
221 pdlgInfo->hwndFileTB = GetDlgItem(pdlgInfo->hwndSelf, IDC_FILE);
222 pdlgInfo->hwndCreateCtrlCB = GetDlgItem(pdlgInfo->hwndSelf, IDC_CREATECONTROL);
223 pdlgInfo->hwndCreateNewCB = GetDlgItem(pdlgInfo->hwndSelf, IDC_CREATENEW);
224 pdlgInfo->hwndCreateFromFileCB = GetDlgItem(pdlgInfo->hwndSelf, IDC_CREATEFROMFILE);
225 pdlgInfo->hwndDisplayIconCB = GetDlgItem(pdlgInfo->hwndSelf, IDC_ASICON);
226 pdlgInfo->hwndAddCtrlBTN = GetDlgItem(pdlgInfo->hwndSelf, IDC_ADDCONTROL);
227 pdlgInfo->hwndBrowseBTN = GetDlgItem(pdlgInfo->hwndSelf, IDC_BROWSE);
228 pdlgInfo->hwndResultDesc = GetDlgItem(pdlgInfo->hwndSelf, IDC_RESULTDESC);
230 /* Setup dialog controls based on flags */
231 if (pdlgInfo->lpOleUIInsertObject->lpszCaption)
232 SetWindowTextA(pdlgInfo->hwndSelf, pdlgInfo->lpOleUIInsertObject->lpszCaption);
234 ShowWindow(pdlgInfo->hwndCreateCtrlCB, (pdlgInfo->lpOleUIInsertObject->dwFlags &
235 IOF_SHOWINSERTCONTROL) ? SW_SHOW : SW_HIDE);
236 ShowWindow(pdlgInfo->hwndDisplayIconCB, (pdlgInfo->lpOleUIInsertObject->dwFlags &
237 IOF_CHECKDISPLAYASICON) ? SW_SHOW : SW_HIDE);
238 EnableWindow(pdlgInfo->hwndDisplayIconCB, (pdlgInfo->lpOleUIInsertObject->dwFlags &
239 IOF_DISABLEDISPLAYASICON) ? FALSE : TRUE);
241 if (pdlgInfo->lpOleUIInsertObject->dwFlags & IOF_SELECTCREATECONTROL)
242 UIINSERTOBJECTDLG_SelectCreateCtrl(pdlgInfo);
243 else if (pdlgInfo->lpOleUIInsertObject->dwFlags & IOF_SELECTCREATEFROMFILE)
244 UIINSERTOBJECTDLG_SelectCreateFromFile(pdlgInfo);
245 else /* (pdlgInfo->lpOleUIInsertObject->dwFlags & IOF_SELECTCREATENEW) */
246 UIINSERTOBJECTDLG_SelectCreateNew(pdlgInfo);
250 /***********************************************************************
251 * UIINSERTOBJECTDLG_SelectCreateCtrl
253 * Select Create Control Radio Button
255 static void UIINSERTOBJECTDLG_SelectCreateCtrl(InsertObjectDlgInfo* pdlgInfo)
257 ShowWindow(pdlgInfo->hwndDisplayIconCB, SW_HIDE);
258 ShowWindow(pdlgInfo->hwndFileLBL, SW_HIDE);
259 ShowWindow(pdlgInfo->hwndFileTB, SW_HIDE);
260 ShowWindow(pdlgInfo->hwndBrowseBTN, SW_HIDE);
262 ShowWindow(pdlgInfo->hwndObjTypeLBL, SW_SHOW);
263 ShowWindow(pdlgInfo->hwndObjTypeLB, SW_SHOW);
264 ShowWindow(pdlgInfo->hwndAddCtrlBTN, SW_SHOW);
266 SendMessageA(pdlgInfo->hwndCreateCtrlCB, BM_SETCHECK, BST_CHECKED, 0);
268 /* Populate object type listbox */
269 if (!pdlgInfo->bObjListInit)
270 UIINSERTOBJECTDLG_PopulateObjectTypes(pdlgInfo);
274 /***********************************************************************
275 * UIINSERTOBJECTDLG_SelectCreateNew
277 * Select Create New Radio Button
279 static void UIINSERTOBJECTDLG_SelectCreateNew(InsertObjectDlgInfo* pdlgInfo)
281 ShowWindow(pdlgInfo->hwndFileLBL, SW_HIDE);
282 ShowWindow(pdlgInfo->hwndFileTB, SW_HIDE);
283 ShowWindow(pdlgInfo->hwndAddCtrlBTN, SW_HIDE);
284 ShowWindow(pdlgInfo->hwndBrowseBTN, SW_HIDE);
286 if (pdlgInfo->lpOleUIInsertObject->dwFlags & IOF_CHECKDISPLAYASICON)
287 ShowWindow(pdlgInfo->hwndDisplayIconCB, SW_SHOW);
289 ShowWindow(pdlgInfo->hwndObjTypeLBL, SW_SHOW);
290 ShowWindow(pdlgInfo->hwndObjTypeLB, SW_SHOW);
292 SendMessageA(pdlgInfo->hwndCreateNewCB, BM_SETCHECK, BST_CHECKED, 0);
294 if (!pdlgInfo->bObjListInit)
295 UIINSERTOBJECTDLG_PopulateObjectTypes(pdlgInfo);
297 UIINSERTOBJECTDLG_SelChange(pdlgInfo);
301 /***********************************************************************
302 * UIINSERTOBJECTDLG_SelectCreateFromFile
304 * Select Create From File Radio Button
306 static void UIINSERTOBJECTDLG_SelectCreateFromFile(InsertObjectDlgInfo* pdlgInfo)
308 char resstr[MAX_PATH];
310 ShowWindow(pdlgInfo->hwndAddCtrlBTN, SW_HIDE);
311 ShowWindow(pdlgInfo->hwndObjTypeLBL, SW_HIDE);
312 ShowWindow(pdlgInfo->hwndObjTypeLB, SW_HIDE);
314 if (pdlgInfo->lpOleUIInsertObject->dwFlags & IOF_CHECKDISPLAYASICON)
315 ShowWindow(pdlgInfo->hwndDisplayIconCB, SW_SHOW);
317 ShowWindow(pdlgInfo->hwndFileLBL, SW_SHOW);
318 ShowWindow(pdlgInfo->hwndFileTB, SW_SHOW);
319 ShowWindow(pdlgInfo->hwndBrowseBTN, SW_SHOW);
321 SendMessageA(pdlgInfo->hwndCreateFromFileCB, BM_SETCHECK, BST_CHECKED, 0);
323 if (LoadStringA(OLEDLG_hInstance, IDS_RESULTFILEOBJDESC, resstr, MAX_PATH))
324 SendMessageA(pdlgInfo->hwndResultDesc, WM_SETTEXT, 0, (LPARAM)resstr);
328 /***********************************************************************
329 * UIINSERTOBJECTDLG_PopulateObjectTypes
331 * Populate Object Type listbox
333 static BOOL UIINSERTOBJECTDLG_PopulateObjectTypes(InsertObjectDlgInfo* pdlgInfo)
335 DWORD i;
336 LONG len;
337 HKEY hkclsids;
338 HKEY hkey;
339 CLSID clsid;
340 HRESULT ret;
341 CHAR szclsid[128];
342 CHAR keydesc[MAX_PATH];
343 CHAR keyname[MAX_PATH];
344 WCHAR wszclsid[128];
345 DWORD index = 0;
347 UIINSERTOBJECTDLG_FreeObjectTypes(pdlgInfo);
349 RegOpenKeyExA(HKEY_CLASSES_ROOT, "CLSID", 0, KEY_READ, &hkclsids);
351 while (ERROR_SUCCESS == (ret = RegEnumKeyA(hkclsids, index, szclsid, MAX_PATH)))
353 index++;
355 RegOpenKeyExA(hkclsids, szclsid, 0, KEY_READ, &hkey);
357 len = MAX_PATH;
358 if (ERROR_SUCCESS != RegQueryValueA(hkey, "Insertable", keyname, &len))
359 continue;
361 len = MAX_PATH;
362 if (ERROR_SUCCESS == RegQueryValueA(hkey, "NotInsertable", keyname, &len))
363 continue;
365 RtlMultiByteToUnicodeN(wszclsid, MAX_PATH, NULL, szclsid, MAX_PATH);
366 CLSIDFromString(wszclsid, &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 = MAX_PATH;
376 if (ERROR_SUCCESS == RegQueryValueA(hkey, NULL, keydesc, &len))
378 CLSID* lpclsid = HeapAlloc(GetProcessHeap(), 0, sizeof(CLSID));
379 memcpy(lpclsid, &clsid, sizeof(CLSID));
381 len = SendMessageA(pdlgInfo->hwndObjTypeLB, LB_ADDSTRING, 0, (LPARAM)keydesc);
382 SendMessageA(pdlgInfo->hwndObjTypeLB, LB_SETITEMDATA, (WPARAM)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, (WPARAM)0, (LPARAM)0);
403 for (i = 0; i < count; i++)
405 CLSID* lpclsid = (CLSID*) SendMessageA(pdlgInfo->hwndObjTypeLB,
406 LB_GETITEMDATA, (WPARAM)i, (LPARAM)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 CHAR objname[MAX_PATH];
421 CHAR objdesc[MAX_PATH];
422 CHAR resstr[MAX_PATH];
424 TRACE("\n");
426 if (LoadStringA(OLEDLG_hInstance, IDS_RESULTOBJDESC, resstr, MAX_PATH) &&
427 ((index = SendMessageA(pdlgInfo->hwndObjTypeLB, LB_GETCURSEL, 0, 0)) >= 0) &&
428 SendMessageA(pdlgInfo->hwndObjTypeLB, LB_GETTEXT, (WPARAM)index, (LPARAM)objname))
429 sprintf(objdesc, resstr, objname);
430 else
431 objdesc[0] = 0;
433 SendMessageA(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, (WPARAM)index, 0);
455 memcpy(&pdlgInfo->lpOleUIInsertObject->clsid, clsid, sizeof(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 char fname[MAX_PATH];
476 if (pdlgInfo->lpOleUIInsertObject->lpszFile)
478 HRESULT hres;
479 WCHAR wcsFile[MAX_PATH];
481 SendMessageA(pdlgInfo->hwndFileTB, WM_GETTEXT, (WPARAM)MAX_PATH, (LPARAM)fname);
482 lstrcpynA(pdlgInfo->lpOleUIInsertObject->lpszFile, fname, pdlgInfo->lpOleUIInsertObject->cchFile);
484 RtlMultiByteToUnicodeN(wcsFile, MAX_PATH, NULL, fname, MAX_PATH);
485 if (ERROR_SUCCESS == (hres = GetClassFile(wcsFile, &pdlgInfo->lpOleUIInsertObject->clsid)))
487 if (pdlgInfo->lpOleUIInsertObject->dwFlags & IOF_CREATEFILEOBJECT)
489 hres = OleCreateFromFile(
490 &pdlgInfo->lpOleUIInsertObject->clsid,
491 wcsFile,
492 &pdlgInfo->lpOleUIInsertObject->iid,
493 pdlgInfo->lpOleUIInsertObject->oleRender,
494 pdlgInfo->lpOleUIInsertObject->lpFormatEtc,
495 pdlgInfo->lpOleUIInsertObject->lpIOleClientSite,
496 pdlgInfo->lpOleUIInsertObject->lpIStorage,
497 pdlgInfo->lpOleUIInsertObject->ppvObj);
500 bret = TRUE;
502 pdlgInfo->lpOleUIInsertObject->sc = hres;
506 return bret;
510 /***********************************************************************
511 * UIINSERTOBJECTDLG_BrowseFile
513 * Browse for the file
515 static void UIINSERTOBJECTDLG_BrowseFile(InsertObjectDlgInfo* pdlgInfo)
517 OPENFILENAMEA fn;
518 char fname[MAX_PATH];
519 char title[32];
521 fn.lStructSize = sizeof(OPENFILENAMEA);
522 fn.hwndOwner = pdlgInfo->hwndSelf;
523 fn.hInstance = 0;
524 fn.lpstrFilter = "All Files\0*.*\0\0";
525 fn.lpstrCustomFilter = NULL;
526 fn.nMaxCustFilter = 0;
527 fn.nFilterIndex = 0;
529 SendMessageA(pdlgInfo->hwndFileTB, WM_GETTEXT, (WPARAM)MAX_PATH, (LPARAM)fname);
530 fn.lpstrFile = fname;
531 fn.nMaxFile = MAX_PATH;
533 fn.lpstrFileTitle = NULL;
534 fn.nMaxFileTitle = 0;
535 fn.lpstrInitialDir = NULL;
537 LoadStringA(OLEDLG_hInstance, IDS_BROWSE, title, 32);
538 fn.lpstrTitle = title;
540 fn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST |
541 OFN_HIDEREADONLY | OFN_LONGNAMES;
542 fn.nFileOffset = 0;
543 fn.nFileExtension = 0;
544 fn.lpstrDefExt = NULL;
545 fn.lCustData = 0;
546 fn.lpfnHook = NULL;
547 fn.lpTemplateName = NULL;
549 if (GetOpenFileNameA(&fn))
550 SendMessageA(pdlgInfo->hwndFileTB, WM_SETTEXT, (WPARAM)0, (LPARAM)fn.lpstrFile);
554 /***********************************************************************
555 * UIINSERTOBJECTDLG_AddControl
557 * Add control to Object Type
559 static void UIINSERTOBJECTDLG_AddControl(InsertObjectDlgInfo* pdlgInfo)
561 OPENFILENAMEA fn;
562 char fname[MAX_PATH];
563 char title[32];
565 fn.lStructSize = sizeof(OPENFILENAMEA);
566 fn.hwndOwner = pdlgInfo->hwndSelf;
567 fn.hInstance = 0;
568 fn.lpstrFilter = "OLE Controls\0*.ocx\0Libraries\0*.dll\0All Files\0*.*\0\0";
569 fn.lpstrCustomFilter = NULL;
570 fn.nMaxCustFilter = 0;
571 fn.nFilterIndex = 0;
573 fname[0] = 0;
574 fn.lpstrFile = fname;
575 fn.nMaxFile = MAX_PATH;
577 fn.lpstrFileTitle = NULL;
578 fn.nMaxFileTitle = 0;
579 fn.lpstrInitialDir = NULL;
581 LoadStringA(OLEDLG_hInstance, IDS_BROWSE, title, 32);
582 fn.lpstrTitle = title;
584 fn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST |
585 OFN_HIDEREADONLY | OFN_LONGNAMES;
586 fn.nFileOffset = 0;
587 fn.nFileExtension = 0;
588 fn.lpstrDefExt = NULL;
589 fn.lCustData = 0;
590 fn.lpfnHook = NULL;
591 fn.lpTemplateName = NULL;
593 if (GetOpenFileNameA(&fn))
595 HMODULE hMod;
596 BOOL bValid = FALSE;
598 hMod = LoadLibraryA(fn.lpstrFile);
600 if (hMod)
602 DLLREGISTER regproc;
604 regproc = (DLLREGISTER) GetProcAddress(hMod, "DllRegisterServer");
605 if (regproc)
607 if (S_OK == regproc())
609 UIINSERTOBJECTDLG_PopulateObjectTypes(pdlgInfo);
610 bValid = TRUE;
614 FreeLibrary(hMod);
617 if (!bValid)
619 char title[32];
620 char msg[256];
622 LoadStringA(OLEDLG_hInstance, IDS_NOTOLEMODCAPTION, title, 32);
623 LoadStringA(OLEDLG_hInstance, IDS_NOTOLEMOD, msg, 256);
625 MessageBoxA(pdlgInfo->hwndSelf, msg, title, MB_ICONEXCLAMATION);