COM/ActiveX Technology in Qt and MFC
Lingfa Yang
-
Make an activeX control in Qt
-
Using the control in MS Office/IE
-
Reuse activeX control in MFC developed in Qt
-
How to customize an activeX control in MFC environment
-
ActiveX scripting: use of OLE interfaces in a scripting engines
-
Reuse activeX control in Qt developed in MFC
-
Make an activeX in Qt
-
Make a widget (draw/paint in GDI+)
class AnalogClock : public QWidget
|
How to draw an analog clock?
-
Generate uuid for classID, interfaceID and eventsID.
uuidgen >> uuid.txt // ms vs common tools
e4ff4700-d874-474b-9f88-c5bb263bb1f7
e6157a63-1a73-4bbc-b8f6-85c9c8bab4aa
efa38bb5-dcda-42fe-98a6-7767da42845a
|
-
Make an activeX control
class ActiveQtFactory : public QAxFactory
|
-
Using the control in MS Office/IE
Turn on developer tab in PowerPoint 2007
-
Right click on menu bar and choose "Customize Quick Access Toolbar..."
-
Select first tag "Popular"
-
Turn on "Show Developer tab in the Ribbon" (see snapshot)
-
More controls (see snapshot)
-
Insert a control into PowerPoint (see snapshot); Press F5 for slideshow to see clock tick
-
Reuse activeX control in MFC developed in Qt
-
New | MFC AppWizard (exe) | Project Name (QtAx) | Dialog based | Finish
(VS6.0 QtAx.zip)
||
File | New | Project | Visual C++ Projects | MFC |MFC Application | QtAxVs03
| Application Type (Dialog based) | Finish | View | Resource View | Double Click on IDD_QTAXVS03_DIALOG
(QtAxVs03.zip)
-
Right Click on Resource Dialog | Insert ActiveX Control... | AnalogClockAx Class
-
Compile and run
Runtime needs QtGui4.dll, QtCore4.dll, QtXml4.dll, qwt5.dll
...
-
How to customize an activeX control in MFC environment
-
Generate a wrapper
Hit "Add Variable" will trigger a dialog which will generate a wrapper automatically.
Then, in QtAxDlg.h you will find
#include "analogclockax.h"
CAnalogClockAx m_clock;
|
and the wrapper exposes all set and get functions
class CAnalogClockAx : public CWnd
{
// Attributes
public:
long GetLeft();
void SetLeft(long);
}
|
-
Initialization
Find OnInitDialog:
BOOL CQtAxDlg::OnInitDialog()
{
// TODO: Add extra initialization here
m_clock.SetLeft(500); // Customize
}
|
-
ListTreeTab example
QListWidge and QTreeWidget in QTabWidget as Qt's ListTreeAx control in MFC dialog.
(Project zip in VC++6.0 | VS2003 )
Synchronize the list view and the tree view in Qt.
connect(listWidget,
SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),
this, SLOT(currentListItem(QListWidgetItem *, QListWidgetItem *)));
connect(treeWidget,
SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
this, SLOT(currentTreeItem(QTreeWidgetItem *, QTreeWidgetItem *)));
|
Use of hash
void ListTreeTab::currentListItem(
QListWidgetItem *current, QListWidgetItem *previous)
{
treeWidget->setCurrentItem(treeToList.key(current));
}
void ListTreeTab::currentTreeItem(
QTreeWidgetItem *current, QTreeWidgetItem *previous)
{
listWidget->setCurrentItem(treeToList.value(current));
}
|
-
Bilateral talks between Qt controls and MFC controls
QWidget's signals are partially exposed, which you can in "Add Windows Message Handler..."
void CListWidgetDlg::OncurrentRowChangedListwidgetax1(long p_currentRow)
{
m_currentText = m_list.GetItemText();
this->UpdateData(FALSE); // TODIALOG
}
void CListWidgetDlg::OnChangeEditCurrent()
{
this->UpdateData(TRUE); // TOMEMBER
m_list.SetItemText(m_currentText);
}
|
Demo: Bilateral talks between Qt controls and MFC controls
(Project zip in VC++6.0)
Qt: My current item changed.
MFC: Yes I know. I'm displaying your change.
MFC: Look, I am in editing mode (delete, then, keyboard in).
Qt: Yes I know. I'm displaying your change.
Qt: List itself is editable (double-click, or press F2)
listItem->setFlags(listItem->flags() | Qt::ItemIsEditable);
|
-
ActiveX scripting: use of OLE interfaces in a scripting engines
(undercounstruction)
-
Reuse activeX control in Qt developed in MFC
(undercounstruction)
Home
| Qt
| C/C++
| Online Articles: Impressions on MFC vs Qt Programming
| Qt/COM
|