Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2002-07-27
11
Medium Priority
?
639 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
Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

 
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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

660 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