From 8e8fb37f3c6349a5c61c4a1b4d08a09b0d0f044c Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Mon, 24 Sep 2012 06:38:52 +0000 Subject: [PATCH] 2012-09-23 11:32 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbqt/tests/activex.hbp * contrib/hbqt/tests/activex.prg * contrib/hbqt/tests/activex.ui + Added: a demonstration applying HbQt's controvertial QWidget():winID() call to be used with Harbour's native ActiveX engine. The demo is less than 70 lines of code and blends Qt Creator, HbQt, hbWIN in a meaningful way. --- harbour/ChangeLog | 9 ++ harbour/contrib/hbqt/tests/activex.hbp | 20 ++++ harbour/contrib/hbqt/tests/activex.prg | 102 ++++++++++++++++ harbour/contrib/hbqt/tests/activex.ui | 159 +++++++++++++++++++++++++ 4 files changed, 290 insertions(+) create mode 100644 harbour/contrib/hbqt/tests/activex.hbp create mode 100644 harbour/contrib/hbqt/tests/activex.prg create mode 100644 harbour/contrib/hbqt/tests/activex.ui diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 4be5e16434..caf8fd65b2 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,15 @@ The license applies to all entries newer than 2009-04-28. */ +2012-09-23 11:32 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbqt/tests/activex.hbp + * contrib/hbqt/tests/activex.prg + * contrib/hbqt/tests/activex.ui + + Added: a demonstration applying HbQt's controvertial + QWidget():winID() call to be used with Harbour's native + ActiveX engine. The demo is less than 70 lines of code + and blends Qt Creator, HbQt, hbWIN in a meaningful way. + 2012-09-22 08:58 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbide/main.prg ! Fixed: regression - IdeDBU was not showing up auto when diff --git a/harbour/contrib/hbqt/tests/activex.hbp b/harbour/contrib/hbqt/tests/activex.hbp new file mode 100644 index 0000000000..5355b4ba85 --- /dev/null +++ b/harbour/contrib/hbqt/tests/activex.hbp @@ -0,0 +1,20 @@ +# +# $Id$ +# + +-3rd=hbide_version=1.0 +-3rd=hbide_title=ActiveX +-3rd=hbide_output=activex + +-inc +-w3 +-es2 + +hbqt.hbc +gtwvg.hbc + +activex.prg + +activex.ui + + diff --git a/harbour/contrib/hbqt/tests/activex.prg b/harbour/contrib/hbqt/tests/activex.prg new file mode 100644 index 0000000000..6619289577 --- /dev/null +++ b/harbour/contrib/hbqt/tests/activex.prg @@ -0,0 +1,102 @@ +/* + * $Id$ + */ + +/* W A R N I N G : Windows Only Code + * + * Demonstrate the usage of Windows ActiveX functionality + * available in HbQt via QWidget():winID() call. This demonstration + * is one of the many benefits :winID() facilitates without breaking + * compatilibility. The programmer ( me, here ) knows what he/she is + * doing. On the contrary, I am free TO do mathematical operations + * with :winID(), like, IF o:winID() > 99999999 ; WOW() ; ELSE sigh() + * + * To build I am inclusing GtWVG as it already has class to construct activex window. + * This is just to cut the time short. Anyway we will be using activeX on windows only + * + * This can be argued that if this all can be done in pure Windows, then why through HbQt ? + * + * The answer is simple: Harbour's WINAPI related infrastructure is so inadequate that it is + * extremely difficult IF not impossible. There are two reasons: 1. Harbour does not have + * any upper level GUI library, 2. Structure support in Harbour, as of current, is broken. + * So the effective GUI library is HbQt, complete with all GUI stuff, which can be exploited + * to harness the power of Windows exclusive functionality via winID() call. + * + * This less than 70 lines of code demonstrate what can be achieved with WINAPI in hundreds... + * + * Pritpal Bedi 23Sep2012 + */ + +/*----------------------------------------------------------------------*/ + +#include "hbqtgui.ch" +#include "hbtrace.ch" + +/*----------------------------------------------------------------------*/ + +FUNCTION Main() + LOCAL oUI, oActiveX + + hbqt_errorsys() + + oUI := hbqtui_activex() + + oActiveX := BuildActiveX( oUI ) + + oUI:connect( QEvent_Resize, {|| oActiveX:setSize( { oUI:frameActiveX:width(), oUI:frameActiveX:height() } ) } ) + oUI:editNavigate:setText( "http://hbide.vouch.info" ) + oUI:btnNavigate:connect( "clicked()", {|| HandleNavigation( oUI, oActiveX ) } ) + oUI:btnRefresh:connect( "clicked()" , {|| oActiveX:refresh() } ) + + oUI:treeUrls:setHeaderHidden( .T. ) + oUI:treeUrls:setTooltip( "Click on any url to navigate !" ) + oUI:treeUrls:connect( "itemPressed(QTreeWidgetItem*,int)", {|q,i| oActiveX:navigate( q:text( i ) ) } ) + + oUI:splitterOne:connect( "splitterMoved(int,int)", {|| oActiveX:setSize( { oUI:frameActiveX:width(), oUI:frameActiveX:height() } ) } ) + + oUI:editNavigate:connect( "returnPressed()", {|| oUI:btnNavigate:click() } ) + oUI:editNavigate:setFocus() + + oUI:show() + + oUI:btnNavigate:click() + oUI:resize( 1000, 500 ) + oUI:treeUrls:setFocus() + + QApplication():exec() + + RETURN oActiveX + +/*----------------------------------------------------------------------*/ + +FUNCTION BuildActiveX( oUI ) + LOCAL oXbp, oActiveX + + oXbp := WvgWindow():new( , , { 0, 0 }, { 640, 400 }, , .T. ) + oXbp:hWnd := oUI:frameActiveX:winID() + + oActiveX := WvgActiveXControl():new( oXbp, , { 0, 0 }, { 100, 100 }, , .t. ) + + oActiveX:CLSID := "Shell.Explorer.2" + oActiveX:mapEvent( 269, {|| oUI:labelStatus:setText( ' E X P L O R E R - 2 6 9' ) } ) + oActiveX:mapEvent( 105, {|| oUI:labelStatus:setText( ' E X P L O R E R - 105' ) } ) + + oActiveX:create() + + RETURN oActiveX + +/*----------------------------------------------------------------------*/ + +FUNCTION HandleNavigation( oUI, oActiveX ) + LOCAL qItm := QTreeWidgetItem() + + oActiveX:navigate( oUI:editNavigate:text() ) + + qItm:setText( 0, oUI:editNavigate:text() ) + + oUI:treeUrls:addTopLevelItem( qItm ) + + RETURN NIL + +/*----------------------------------------------------------------------*/ + diff --git a/harbour/contrib/hbqt/tests/activex.ui b/harbour/contrib/hbqt/tests/activex.ui new file mode 100644 index 0000000000..66b566bfd2 --- /dev/null +++ b/harbour/contrib/hbqt/tests/activex.ui @@ -0,0 +1,159 @@ + + + FormActiveX + + + + 0 + 0 + 607 + 569 + + + + ActiveX + + + + + + + 16777215 + 53 + + + + + + + + + + Navigate + + + + + + + + 300 + 0 + + + + + + + + Navigate + + + + + + + Refresh + + + + + + + + + + + 16777215 + 20 + + + + QFrame::StyledPanel + + + + + + + + + + QFrame::Panel + + + QFrame::Raised + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 0 + 0 + + + + Qt::Horizontal + + + + + 0 + 0 + + + + + 100 + 0 + + + + 5 + + + false + + + + 1 + + + + + + + 1 + 0 + + + + QFrame::Panel + + + QFrame::Raised + + + + + + + + + + + +