Solved

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

Posted on 2002-07-27
11
634 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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
 
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 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that extends its U/I with a flyout panel -- a window that pops out next to the gadget.  The example gadget shows several additional techniques:  How to automatically resize a gadget or flyout panel t…
After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

617 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