Solved

Examples/Snippets of Webbrowser/ActiveX in a dialog box using C Win32 API

Posted on 2002-07-27
11
622 Views
Last Modified: 2013-12-04
Hello!

I'm looking for working examples or working snippets of how to embed a webbrowser control (and any other ActiveX) into a dialog using C ,Win32 API SDK, non-MFC, non-ATL/WTL.


Thanks in advance!

Roland
0
Comment
Question by:RolandAZ
11 Comments
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 7251283
I got this information from EE
One friend quoted like this

TRY

Import the informations about ActiveX into your Project
eg:

#import "axBrowser.ocx" named_guids raw_interfaces_only \no_namespace rename_namespace ("Arch")

after that if you rebuild the project, you can see in intermediate directory (Debug, for example) two
files
with extension .tlh and .tli
after that you can use the COM objects.
You NEED to read carefully the reference about #import directive. Content of generated files is COM
class wrappers, GUID reference and so on , imported from specified DLL(for example) and depends on #import
. You can use that like usual C++ classes. Don't forget to COM Init/DeInit.

HRESULT hr  = S_OK;
hr  = CoInitialize(0);
hr = CoCreateInstance(CLSID_AxBrowser,
NULL,CLSCTX_INPROC_SERVER |CLSCTX_LOCAL_SERVER,
                   IID_IAxBrowser,(void **)
&spHandler);
CoUnitialize();

Good Luck
0
 
LVL 1

Author Comment

by:RolandAZ
ID: 7251423
Thanks, roshmon, for input!
I'll try to follow your tip, and see if i can get it working.

Roland
0
 
LVL 1

Author Comment

by:RolandAZ
ID: 7261299
roshmon and All, hello!

Using the import directive, as you suggested,

#import "axBrowser.ocx" named_guids raw_interfaces_only \
       no_namespace rename_namespace ("Arch") ,

the compiler reported "fatal error C1083: Cannot open type library file: 'axBrowser.ocx': No such file or directory ."

I want to use the IE browser control. I don't know what type library/ocx should I use in the import declaration.

//-----
With the result above, I decided to try RICHTX32.OCX, in lieu of the browser control, to see what happens. No error this time , but the Debug directory had a RICHTX32.tlh file but no .tli file.

Continuing, how do I use the info found in .tlh file, RICHTX32.tlh, like C++ classes and create a working control in a dialog box?

Please elaborate more on the details of using your technique to insert an activex control and the IE browser control into a dialog box.
Your help is greatly appreciated!
Thanks again in advance, Roshmon, and to all who replies to the question.

Regards,
Roland





0
 
LVL 6

Expert Comment

by:peterdownes
ID: 7263570
Hi RolandAZ,

From my understanding of your question, you don't want to use MFC.  Well, your in a world of pain!

BUT!  Look what I found ;-)

ftp://ftp.microsoft.com/softlib/mslfiles/webapp.exe

Good Luck.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 1

Author Comment

by:RolandAZ
ID: 7266783
hi, Peter,
Yes, no MFC on this one, and yes, it is a pain.
:)

Thanks for the link! Though I still need to make a child dialog(not on the main window) that contains the webbrowser, I think you deserve points for the info.
100 points? I'll post it on "points for peterdownes."

And I'll still leave this question open ...

Any other help on inserting that webbrowser into a dialog is greatly appreciated.

Regards,
Roland

 



0
 
LVL 6

Expert Comment

by:peterdownes
ID: 7271353
0
 
LVL 2

Expert Comment

by:cessi0g
ID: 7283466
This topic is very simple using Atl.

Just design your Dialog with Dialog Editor into Visual C++ and insert the WebBrowser ActiveX control.
Modify properties (Dialog Editor saves the control properties in your .rc file).

And in your code do not call DialogBox or relates functions. Use this code instead:


#pragma once

#define WIN32_LEAN_AND_MEAN             // Exclude rarely-used stuff from Windows headers
#define _WIN32_WINNT 0x0500

// Windows Header Files:
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>

// C RunTime Header Files
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stddef.h>
#include <limits.h>

// ATL Windows support Header files
#include <atlbase.h>
extern CComModule _Module;
#include <atlwin.h>
#include <atlctl.h>

// OLE-ActiveX support Header files
#include <objbase.h>
#include <ocidl.h>


/***************************************************************************/
/*                                                                         */
/*                                                                         */
/* CMyDialogBox class                                                    */
/*                                                                         */
/*                                                                         */
/***************************************************************************/
class CMyDialogBox : public CAxDialogImpl< CMyDialogBox >
{
public:

int        IDD;
HWND       m_hWndParent;
DLGPROC    m_DlgProc;

      CMyDialogBox( int Idd = NULL, HWND hWndParent = NULL, DLGPROC pDlgProc = NULL )
      {
           IDD = Idd;
           m_hWndParent = hWndParent;
           m_DlgProc = pDlgProc;
      }

      BOOL ProcessWindowMessage( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT& lResult, DWORD dwMsgMapID = 0 )
      {
           if( uMsg == WM_INITDIALOG ) CenterWindow( m_hWndParent );
           if( m_DlgProc ) return (BOOL)CallWindowProc( (WNDPROC)m_DlgProc, hWnd, uMsg, wParam, lParam );
           else return 0;
      }
};



/*****************************************/

And, when you want display the dialog, use:

CMyDialog*   dlg = new CMyDialog( IDD_DIALOG, hWndParent, (DLGPROC)MyDlgProc );

     LRESULT lResult = dlg.DoModal();
     return lRet;


In your Dialog Procedure, you can use AtlAxGetControl() function to get a IUnknown pointer to WebBrowser or whatever controls you insert in your dialog, and modify behaviour in your WM_INITDIALOG procedure.

See Atlhost.h in ATL library for reference. Is an incredible source or knowledge about these topis.

Hope this will help you.

Regards,
Jorge







0
 
LVL 1

Author Comment

by:RolandAZ
ID: 7308639
Thanks for input, Jorge.
I will try your suggestion and see if I can get it working on my non-MFC, non-ATL non-WTL app.

Will get back on this ...

Regards,
Roland
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 10787706
PAQed - no points refunded (of 500)

modulo
Community Support Moderator
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now