Qt 4.8
Classes | Macros | Functions | Variables
qaxwidget.cpp File Reference
#include "qaxwidget.h"
#include <ActiveQt/qaxaggregated.h>
#include <qabstracteventdispatcher.h>
#include <qapplication.h>
#include <private/qapplication_p.h>
#include <qdockwidget.h>
#include <qevent.h>
#include <qlayout.h>
#include <qmainwindow.h>
#include <qmenu.h>
#include <qmenubar.h>
#include <qmetaobject.h>
#include <qpainter.h>
#include <qpointer.h>
#include <qregexp.h>
#include <quuid.h>
#include <qwhatsthis.h>
#include <windowsx.h>
#include <ocidl.h>
#include <olectl.h>
#include <docobj.h>
#include "../shared/qaxtypes.h"

Go to the source code of this file.

Classes

class  QAxClientSite
 
class  QAxHostWidget
 

Macros

#define AX_DEBUG(x)   ;
 

Functions

bool axc_FilterProc (void *m)
 
static int menuItemEntry (HMENU menu, int index, MENUITEMINFO item, QString &text, QPixmap &)
 
static Qt::KeyboardModifiers translateModifierState (int s)
 
static Qt::MouseButtons translateMouseButtonState (int s)
 

Variables

static int filter_ref = 0
 
static const ushort mouseTbl []
 
static QAbstractEventDispatcher::EventFilter previous_filter = 0
 
bool qax_runsInDesignMode = false
 
Q_GUI_EXPORT bool qt_win_ignoreNextMouseReleaseEvent
 

Macro Definition Documentation

◆ AX_DEBUG

#define AX_DEBUG (   x)    ;

Function Documentation

◆ axc_FilterProc()

bool axc_FilterProc ( void *  m)

Definition at line 471 of file qaxwidget.cpp.

Referenced by QAxWidget::createHostWindow().

472 {
473  MSG *msg = (MSG*)m;
474  const uint message = msg->message;
475  if ((message >= WM_MOUSEFIRST && message <= WM_MOUSELAST) || (message >= WM_KEYFIRST && message <= WM_KEYLAST)) {
476  HWND hwnd = msg->hwnd;
477  QAxWidget *ax = 0;
478  QAxHostWidget *host = 0;
479  while (!host && hwnd) {
480  QWidget *widget = QWidget::find(hwnd);
481  if (widget && widget->inherits("QAxHostWidget"))
482  host = qobject_cast<QAxHostWidget*>(widget);
483  hwnd = ::GetParent(hwnd);
484  }
485  if (host)
486  ax = qobject_cast<QAxWidget*>(host->parentWidget());
487  if (ax && msg->hwnd != host->winId()) {
488  if (message >= WM_KEYFIRST && message <= WM_KEYLAST) {
489  QAxClientSite *site = host->clientSite();
490  site->eventTranslated = true; // reset in QAxClientSite::TranslateAccelerator
491  HRESULT hres = S_FALSE;
492  if (site && site->inPlaceObject() && site->translateKeyEvent(msg->message, msg->wParam))
493  hres = site->inPlaceObject()->TranslateAccelerator(msg);
494  // if the object calls our TranslateAccelerator implementation, then continue with normal event processing
495  // otherwise the object has translated the accelerator, and the event should be stopped
496  if (site->eventTranslated && hres == S_OK)
497  return true;
498  } else {
499  int i;
500  for (i = 0; (UINT)mouseTbl[i] != message && mouseTbl[i]; i += 3)
501  ;
502 
503  if (mouseTbl[i]) {
505  int button = mouseTbl[++i];
506  if (type != QEvent::MouseMove || ax->hasMouseTracking() || button) {
507  if (type == QEvent::MouseMove)
508  button = 0;
509 
510  DWORD ol_pos = GetMessagePos();
511  QPoint gpos(GET_X_LPARAM(ol_pos), GET_Y_LPARAM(ol_pos));
512  QPoint pos = ax->mapFromGlobal(gpos);
513 
514  QMouseEvent e(type, pos, gpos, (Qt::MouseButton)button,
515  translateMouseButtonState(msg->wParam),
516  translateModifierState(msg->wParam));
517  QApplication::sendEvent(ax, &e);
518  }
519  }
520  }
521  }
522  }
523 
524  if (previous_filter)
525  return previous_filter(m);
526 
527  return false;
528 }
QWidget * parentWidget() const
Returns the parent of this widget, or 0 if it does not have any parent widget.
Definition: qwidget.h:1035
int type
Definition: qmetatype.cpp:239
QPointer< QWidget > widget
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
static Qt::KeyboardModifiers translateModifierState(int s)
Definition: qaxwidget.cpp:447
T * qobject_cast(QObject *object)
Definition: qobject.h:375
IOleInPlaceActiveObject * inPlaceObject() const
Definition: qaxwidget.cpp:181
static QWidget * find(WId)
Returns a pointer to the widget with window identifer/handle id.
Definition: qwidget.cpp:2517
static QAbstractEventDispatcher::EventFilter previous_filter
Definition: qaxwidget.cpp:460
#define GET_X_LPARAM(lp)
unsigned int uint
Definition: qglobal.h:996
The QAxWidget class is a QWidget that wraps an ActiveX control.
Definition: qaxwidget.h:60
static bool sendEvent(QObject *receiver, QEvent *event)
Sends event event directly to receiver receiver, using the notify() function.
bool eventTranslated
Definition: qaxwidget.cpp:377
bool inherits(const char *classname) const
Returns true if this object is an instance of a class that inherits className or a QObject subclass t...
Definition: qobject.h:275
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
QAxClientSite * clientSite() const
Definition: qaxwidget.cpp:120
struct tagMSG MSG
long HRESULT
Type
This enum type defines the valid event types in Qt.
Definition: qcoreevent.h:62
bool hasMouseTracking() const
Definition: qwidget.h:993
The QPoint class defines a point in the plane using integer precision.
Definition: qpoint.h:53
bool translateKeyEvent(int message, int keycode) const
Definition: qaxwidget.cpp:367
static Qt::MouseButtons translateMouseButtonState(int s)
Definition: qaxwidget.cpp:434
QPoint mapFromGlobal(const QPoint &) const
Translates the global screen coordinate pos to widget coordinates.
WId winId() const
Returns the window system identifier of the widget.
Definition: qwidget.cpp:2557
#define GET_Y_LPARAM(lp)
static const ushort mouseTbl[]
Definition: qaxwidget.cpp:420
MouseButton
Definition: qnamespace.h:150

◆ menuItemEntry()

static int menuItemEntry ( HMENU  menu,
int  index,
MENUITEMINFO  item,
QString text,
QPixmap  
)
static

Definition at line 1197 of file qaxwidget.cpp.

1198 {
1199  if (item.fType == MFT_STRING && item.cch) {
1200  wchar_t *titlebuf = new wchar_t[item.cch + 1];
1201  item.dwTypeData = titlebuf;
1202  item.cch++;
1203  ::GetMenuItemInfo(menu, index, true, &item);
1204  text = QString::fromWCharArray(titlebuf);
1205  delete [] titlebuf;
1206  return MFT_STRING;
1207  }
1208 #if 0
1209  else if (item.fType == MFT_BITMAP) {
1210  HBITMAP hbm = (HBITMAP)LOWORD(item.hbmpItem);
1211  SIZE bmsize;
1212  GetBitmapDimensionEx(hbm, &bmsize);
1213  QPixmap pixmap(1,1);
1214  QSize sz(MAP_LOGHIM_TO_PIX(bmsize.cx, pixmap.logicalDpiX()),
1215  MAP_LOGHIM_TO_PIX(bmsize.cy, pixmap.logicalDpiY()));
1216 
1217  pixmap.resize(bmsize.cx, bmsize.cy);
1218  if (!pixmap.isNull()) {
1219  HDC hdc = ::CreateCompatibleDC(pixmap.handle());
1220  ::SelectObject(hdc, hbm);
1221  BOOL res = ::BitBlt(pixmap.handle(), 0, 0, pixmap.width(), pixmap.height(), hdc, 0, 0, SRCCOPY);
1222  ::DeleteObject(hdc);
1223  }
1224 
1225  icon = pixmap;
1226  }
1227 #endif
1228  return -1;
1229 }
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
#define MAP_LOGHIM_TO_PIX(x, ppli)
Definition: qaxtypes.h:73
#define SIZE(large, small, mini)
quint16 index
The QPixmap class is an off-screen image representation that can be used as a paint device...
Definition: qpixmap.h:71
The QSize class defines the size of a two-dimensional object using integer point precision.
Definition: qsize.h:53

◆ translateModifierState()

static Qt::KeyboardModifiers translateModifierState ( int  s)
static

Definition at line 447 of file qaxwidget.cpp.

Referenced by axc_FilterProc().

448 {
449  Qt::KeyboardModifiers bst = 0;
450  if (s & MK_SHIFT)
451  bst |= Qt::ShiftModifier;
452  if (s & MK_CONTROL)
453  bst |= Qt::ControlModifier;
454  if (GetKeyState(VK_MENU) < 0)
455  bst |= Qt::AltModifier;
456 
457  return bst;
458 }

◆ translateMouseButtonState()

static Qt::MouseButtons translateMouseButtonState ( int  s)
static

Definition at line 434 of file qaxwidget.cpp.

Referenced by axc_FilterProc().

435 {
436  Qt::MouseButtons bst = 0;
437  if (s & MK_LBUTTON)
438  bst |= Qt::LeftButton;
439  if (s & MK_MBUTTON)
440  bst |= Qt::MidButton;
441  if (s & MK_RBUTTON)
442  bst |= Qt::RightButton;
443 
444  return bst;
445 }

Variable Documentation

◆ filter_ref

int filter_ref = 0
static

Definition at line 465 of file qaxwidget.cpp.

Referenced by QAxWidget::clear(), and QAxWidget::createHostWindow().

◆ mouseTbl

const ushort mouseTbl[]
static

◆ previous_filter

QAbstractEventDispatcher::EventFilter previous_filter = 0
static

Definition at line 460 of file qaxwidget.cpp.

Referenced by axc_FilterProc(), QAxWidget::clear(), and QAxWidget::createHostWindow().

◆ qax_runsInDesignMode

bool qax_runsInDesignMode = false

Definition at line 836 of file qaxwidget.cpp.

Referenced by QAxClientSite::Invoke().

◆ qt_win_ignoreNextMouseReleaseEvent

Q_GUI_EXPORT bool qt_win_ignoreNextMouseReleaseEvent

Definition at line 434 of file qapplication_win.cpp.

Referenced by QAxClientSite::qt_metacall().