GTWVG - Modal dialogs - plz for help

500 views
Skip to first unread message

Zoran Sibinovic

unread,
Mar 15, 2012, 9:03:22 AM3/15/12
to Harbour Users
Hi,

I have a main window, from the menubar, one option starts a modal
dialog window (MyDiala()). By pressing the OK button, in the dialog, I
want to open an existing pdf file in a new modal dialog window that
use an activex object (ExecuteActiveX()) and than, after closing it,
to return the control to the MyDiala() window.

Look simple, but i cant achieve it in a right way.

The maximum that I achieved is: pressing the OK button the control
returns to my starting dialog (MyDiala()) immediately. No second
"activex" window is created, but if I close the MyDiala() dialog, the
missing dialog window, with the activex object and the opened pdf
file, popups as a new thread, as it have to, but in the wrong time.
Also i cant find a way, in this case, to start the dialog window with
the activex object as modal.
The dialog window with the activex object that opens the pdf file is a
modified part of the Pritpal wvgactivex.prg.

Another tip, If I use

Wapi_ShellExecute( nil,,myharu)
instead of
Hb_ThreadStart(HB_THREAD_INHERIT_PUBLIC, { || ExecuteActiveX() } )

the thing are almost all ok the pdf starts with adobe reader with no
wait to close the Mydiala window but the popup-ed window can't be
modal because is used a winapi to open the pdf file.

I think I've missed something and that the solution maybe is trivial
but I cant see it.


PROCEDURE MAIN
.......
oMenu:AddItem( "Title", {|| MENU1() } )
...
PROCEDURE MENU1
MyDiala()
.......
PROCEDURE MyDiala()
LOCAL hDlg, aDlg, nStyle

nStyle := DS_SETFONT + WS_VISIBLE + WS_POPUP + WS_CAPTION + WS_SYSMENU
+ WS_THICKFRAME + WS_MINIMIZEBOX
aDlg := Wvt_MakeDlgTemplate( -20, -30, 30, 90, {0,0,0,0},"Please press
the OK button"," Dialog !", nStyle )
...
nStyle := WS_CHILD + WS_VISIBLE + WS_TABSTOP + BS_PUSHBUTTON
aDlg := Wvt_AddDlgItem( aDlg, 25, 2, 1, 8, {-3,0,3,0}, ID_BTN_OK,
"BUTTON" , nStyle, "OK" )
Wvt_DialogBox( aDlg, "DyDlga", Wvt_GetWindowHandle() )
...
FUNCTION DyDlga( hDlg, nMsg, wParam, lParam )
LOCAL nIndex,i,hFont, aHFonts

Switch ( nMsg )
CASE WM_COMMAND
DO CASE
CASE wParam == ID_BTN_OK
Hb_ThreadStart(HB_THREAD_INHERIT_PUBLIC, { ||
ExecuteActiveX() } )
....
FUNCTION ExecuteActiveX()

Local oVrt, oCom
LOCAL oDA

HB_SYMBOL_UNUSED( oCom )

oVrt:= WvgDialog():new( , , { 30,30 }, { 800,600 }, , .t. )
oVrt:closable := .t.
oVrt:create()

hb_gtInfo( HB_GTI_RESIZABLE, .t. )
hb_gtInfo( HB_GTI_WINTITLE, 'Stampa' )
hb_gtInfo( HB_GTI_SPEC, HB_GTS_WNDSTATE, HB_GTS_WS_MAXIMIZED )

oDA:= oVrt:drawingArea
oDA:resize := {|| ResizeDialog( oVrt, oCom ) }

oCom := WvgActiveXControl():New( oDA, , { 0, 0 },
{ 100,100 }, , .t. )
oCom:CLSID := 'file://' + myharu
oCom:closable := .t.
oCom:create()

oVrt:sendMessage( WM_SIZE, 0, 0 )
oVrt:show()

DO WHILE .t.
IF inkey() == K_ESC ; EXIT ; ENDIF
ENDDO

oVrt:Destroy()

CLEAR TYPEAHEAD

RETURN NIL

//----------------------------------------------------------------------//

FUNCTION ResizeDialog( oVrt, oCom )
LOCAL aVrt
aVrt := oVrt:currentSize()
oCom:setPosAndSize( { 0, 0 }, { aVrt[1], aVrt[2] }, .t. )

RETURN 1



Thanks

Zoran

Massimo Belgrano

unread,
Mar 15, 2012, 10:09:24 AM3/15/12
to harbou...@googlegroups.com
I suggest write  complete main to made runnable your application
so  most user will try and undestrand
PROCEDURE MAIN
.......
 oMenu:AddItem( "Title", {|| MENU1()  } )
... 

--
Massimo Belgrano


Zoran Sibinovic

unread,
Mar 15, 2012, 3:35:45 PM3/15/12
to Harbour Users
Hi Massimo,

Ok

the goal of all of this is to open the pdf file in a modal dialog box


main.hbp

-inc
-mt
-w3
-es2
-gtwvg
-gui

main.prg
..\wvgutilities.prg


all the code below is in main.prg,
My 2 not complete solutions is marked at the end of lines as

// 1 solution
// 2 solution

probe.pdf is a pdf in the current dir


#include "inkey.ch"
#include "common.ch"
#include "wvtwin.ch"
#include "hbgtinfo.ch"
#include "hbgtwvg.ch"
#include "wvgparts.ch"
#include "hbthread.ch"

//-------------------------------------------------------------------//

PROCEDURE Main()

LOCAL aLastPaint, clr, scr, pGT
LOCAL aBlocks := {}, nKey
LOCAL aObjects := WvtSetObjects( {} )
LOCAL oError := ErrorBlock( {|o| MyError( o ) } )

Wvt_SetGui( .t. )
Wvt_SetMouseMove( .t. )
Wvt_SetFont( "Courier New", 16, 0, 0 )

CLS

Wvt_ShowWindow( SW_RESTORE )

BuildMainMenu()

SetMode( maxrow()+1, maxcol()+1 )

pGT := SetGT( 1, hb_gtSelect() )

aAdd( aBlocks, {|| Wvt_SetIcon( 1 ) } )
aAdd( aBlocks, {|| Wvt_SetTitle( "Main window" ) } )
aAdd( aBlocks, {|| Wvt_Mouse( -1000001 ) } )
aLastPaint := WvtSetBlocks( aBlocks )

scr := SaveScreen( 0,0,maxrow(),maxcol() )
clr := SetColor( "N/W" )
CLS
SetColor( "N/W,N/GR*,,,N/W*" )

SETCURSOR(0)

DO WHILE !( (nKey := inkey()) == 27 )
IF nKey == Wvt_SetMenuKeyEvent() .AND.
hb_isBlock( SetKey( nKey ) )
EVAL( SetKey( nKey ) )
ENDIF
ENDDO

WvtSetBlocks( aLastPaint )
WvtSetObjects( aObjects )
SetColor( clr )
RestScreen( 0,0,maxrow(),maxcol(), scr )

SetGT( 1, pGT )

ErrorBlock( oError )

RETURN

//-------------------------------------------------------------------//

FUNCTION BuildMainMenu()
LOCAL oMenu

LOCAL g_oMenuBar := WvgSetAppWindow():menuBar()

oMenu:= WvgMenu():new( g_oMenuBar, , .t. ):create()
oMenu:caption := "Print dialogs"
oMenu:AddItem( "Print dialog 1" , {|| MyDiala() } )
g_oMenuBar:addItem( { oMenu, "Print dialogs" } )

RETURN nil



#define ID_BTN_OK 100

*******************
PROCEDURE MyDiala()
LOCAL aDlg, nStyle

nStyle := DS_SETFONT + WS_VISIBLE + WS_POPUP + WS_CAPTION +
WS_SYSMENU + WS_THICKFRAME + WS_MINIMIZEBOX
aDlg := Wvt_MakeDlgTemplate( -20, -30, 30, 90, {0,0,0,0},"Print
print dialog 1"," Dialog !", nStyle )

nStyle := WS_CHILD + WS_VISIBLE + WS_TABSTOP + BS_PUSHBUTTON
aDlg := Wvt_AddDlgItem( aDlg, 25, 2, 1, 8, {-3,0,3,0},
ID_BTN_OK, "BUTTON" , nStyle, "OK" )

Wvt_DialogBox( aDlg, "DyDlga", Wvt_GetWindowHandle() )

***
FUNCTION DyDlga( hDlg, nMsg, wParam )

Switch ( nMsg )

CASE WM_COMMAND
IF wParam == ID_BTN_OK

*
Wapi_ShellExecute( nil,,"probe.pdf") //
1 solution
Hb_ThreadStart(HB_THREAD_INHERIT_PUBLIC, { ||
ExecuteActiveX(hb_DirBase()+"probe.pdf") } ) // 2 solution

ENDIF
EXIT

CASE WM_INITDIALOG

WVG_SetFocus(WVG_GetDlgItem(hDlg, ID_BTN_OK))
WVG_InvalidateRect( hDlg )
EXIT

CASE WM_DESTROY
EXIT
END

RETURN 0


*************************
FUNCTION ExecuteActiveX(cPdf)

Local oVrt, oCom
LOCAL oDA

HB_SYMBOL_UNUSED( oCom )

//--------------------------- Dialog -------------------------------
\\

oVrt:= WvgDialog():new( , , { 30,30 }, { 800,600 }, , .t. )
oVrt:closable := .t.
oVrt:create()

hb_gtInfo( HB_GTI_RESIZABLE, .t. )
hb_gtInfo( HB_GTI_WINTITLE, 'Print dialog 2' )

oDA:= oVrt:drawingArea
oDA:resize := {|| ResizeDialog( oVrt, oCom ) }

oCom := WvgActiveXControl():New( oDA, , { 0, 0 },
{ 100,100 }, , .t. )
oCom:CLSID := 'file:\\' + cPdf
oCom:closable := .t.
oCom:create()

oVrt:sendMessage( WM_SIZE, 0, 0 )
oVrt:show()

DO WHILE .t.
IF inkey() == K_ESC ; EXIT ; ENDIF
ENDDO

oVrt:Destroy()

CLEAR TYPEAHEAD

RETURN NIL

***********************************
FUNCTION ResizeDialog( oVrt, oCom )
LOCAL aVrt
aVrt := oVrt:currentSize()
oCom:setPosAndSize( { 0, 0 }, { aVrt[1], aVrt[2] }, .t. )

RETURN 1


************************************************************************************
COMMON PROCEDURES

***********************************************************************************
****************************
EXIT PROCEDURE CleanHandles()
LOCAL obj

FOR EACH obj IN SetFonts()
WVG_DeleteObject( obj )
obj := NIL
NEXT

FOR EACH obj IN SetIcons()
WVG_DeleteObject( obj )
obj := NIL
NEXT
RETURN
*******************
FUNCTION HB_GTSYS()
REQUEST HB_GT_WVG_DEFAULT
REQUEST HB_GT_WVT
REQUEST HB_GT_WGU
RETURN NIL


Thanks

Zoran
Message has been deleted

Massimo Belgrano

unread,
Mar 16, 2012, 2:17:24 PM3/16/12
to harbou...@googlegroups.com
I not able recompile (and please ignore prev messages)
.hbmk/win/mingw/probe.o:probe.c:(.data+0x2b8): undefined reference to `HB_FUN_WA
PI_SHELLEXECUTE'
.hbmk/win/mingw/wvgutilities.o:wvgutilities.c:(.data+0x28): undefined reference
to `HB_FUN_WVTNEXTGETS'
.hbmk/win/mingw/wvgutilities.o:wvgutilities.c:(.data+0x48): undefined reference
to `HB_FUN_WVTMYBROWSE'
.hbmk/win/mingw/wvgutilities.o:wvgutilities.c:(.data+0x68): undefined reference
to `HB_FUN_WVTPARTIALSCREEN'
.hbmk/win/mingw/wvgutilities.o:wvgutilities.c:(.data+0x78): undefined reference
to `HB_FUN_WVTLINES'
.hbmk/win/mingw/wvgutilities.o:wvgutilities.c:(.data+0x4d8): undefined reference
to `HB_FUN_WAPI_OUTPUTDEBUGSTRING'
C:/hb31/lib/win/mingw/libgtwvg.a(wvgpaint.o):wvgpaint.c:(.data+0x288): undefined
reference to `HB_FUN_WIN_GETOPENFILENAME'
C:/hb31/lib/win/mingw/libgtwvg.a(wvgpaint.o):wvgpaint.c:(.data+0x2c8): undefined
reference to `HB_FUN_WIN_GETSAVEFILENAME'
C:/hb31/lib/win/mingw/libgtwvg.a(wvggenrc.o):wvggenrc.c:(.data+0xc8): undefined
reference to `HB_FUN_WIN_N2P'
C:/hb31/lib/win/mingw/libgtwvg.a(wvgmenub.o):wvgmenub.c:(.data+0x368): undefined
reference to `HB_FUN_WIN_N2P'
C:/hb31/lib/win/mingw/libgtwvg.a(wvgax.o):wvgax.c:(.data+0x328): undefined refer
ence to `HB_FUN_WIN_OLEAUTO'
C:/hb31/lib/win/mingw/libgtwvg.a(wvgax.o):wvgax.c:(.data+0x338): undefined refer
ence to `HB_FUN_WIN_AXINIT'
C:/hb31/lib/win/mingw/libgtwvg.a(wvgax.o):wvgax.c:(.data+0x348): undefined refer
ence to `HB_FUN_WAPI_CREATEWINDOWEX'
C:/hb31/lib/win/mingw/libgtwvg.a(wvgax.o):wvgax.c:(.data+0x398): undefined refer
ence to `HB_FUN_WIN_N2P'
C:/hb31/lib/win/mingw/libgtwvg.a(wvgax.o):wvgax.c:(.data+0x3b8): undefined refer
ence to `HB_FUN_WIN_P2N'
C:/hb31/lib/win/mingw/libgtwvg.a(wvgax.o):wvgax.c:(.data+0x3d8): undefined refer
ence to `HB_FUN___AXGETCONTROL'
C:/hb31/lib/win/mingw/libgtwvg.a(wvgax.o):wvgax.c:(.data+0x418): undefined refer
ence to `HB_FUN___AXDOVERB'
C:/hb31/lib/win/mingw/libgtwvg.a(wvgax.o):wvgax.c:(.data+0x448): undefined refer
ence to `HB_FUN___AXREGISTERHANDLER'
C:/hb31/lib/win/mingw/libgtwvg.a(wvgax.o):wvgax.c:(.data+0x578): undefined refer
ence to `HB_FUN_WAPI_ISWINDOW'
C:/hb31/lib/win/mingw/libgtwvg.a(wvgax.o):wvgax.c:(.data+0x588): undefined refer
ence to `HB_FUN_WAPI_DESTROYWINDOW'
C:/hb31/lib/win/mingw/libgtwvg.a(wvgtoolb.o):wvgtoolb.c:(.data+0x338): undefined
reference to `HB_FUN_WAPI_IMAGELIST_CREATE'
C:/hb31/lib/win/mingw/libgtwvg.a(wvgtoolb.o):wvgtoolb.c:(.data+0x468): undefined
reference to `HB_FUN_WAPI_IMAGELIST_DESTROY'
C:/hb31/lib/win/mingw/libgtwvg.a(wvgtoolb.o):wvgtoolb.c:(.data+0x588): undefined
reference to `HB_FUN_WAPI_IMAGELIST_ADDMASKED'
C:/hb31/lib/win/mingw/libgtwvg.a(wvgtoolb.o):wvgtoolb.c:(.data+0x598): undefined
reference to `HB_FUN_WAPI_IMAGELIST_ADD'
C:/hb31/lib/win/mingw/libgtwvg.a(wvgwnd.o):wvgwnd.c:(.data+0x1038): undefined re
ference to `HB_FUN_WIN_N2P'


Il 16 marzo 2012 18:47, Massimo Belgrano <massimo....@gmail.com>
ha scritto:
> Afaik gtwvg.lib is windows only  (win9x,winNt) because use windos api
> I am not sure so will wait if samebody confirm

> --
> You received this message because you are subscribed to the Google
> Groups "Harbour Users" group.
> Unsubscribe: harbour-user...@googlegroups.com
> Web: http://groups.google.com/group/harbour-users

--
Massimo Belgrano

Delta Informatica S.r.l. (http://www.deltain.it/) (+39 0321 455962)
Analisi e sviluppo software per Lan e Web -  Consulenza informatica - Formazione

Zoran Sibinovic

unread,
Mar 16, 2012, 4:54:25 PM3/16/12
to Harbour Users
Hi Massimo

make a hbmk.hbm with below code

../gtwvg.hbc
../hbhpdf.hbc
../hbmisc.hbc

-w3 -es2

-lhbct



(I have added below the functions from wvgutilities.prg. )

Save all the below code in one file ex. main.prg and compile it with
hbmk2 main.prg


#include "inkey.ch"
#include "common.ch"
#include "wvtwin.ch"
#include "hbgtinfo.ch"
#include "hbgtwvg.ch"
#include "wvgparts.ch"
#include "hbthread.ch"


THREAD STATIC t_keys_:= { , , , , , , , , , , , , , , , , , , , }
THREAD STATIC t_pic_ := { , , , , , , , , , , , , , , , , , , , }
LOCAL aDlg, nStyle

nStyle := DS_SETFONT + WS_VISIBLE + WS_POPUP + WS_CAPTION +
WS_SYSMENU + WS_THICKFRAME + WS_MINIMIZEBOX
aDlg := Wvt_MakeDlgTemplate( -20, -30, 30, 90, {0,0,0,0},"Print
dialog 1"," Dialog !", nStyle )

nStyle := WS_CHILD + WS_VISIBLE + WS_TABSTOP + BS_PUSHBUTTON
aDlg := Wvt_AddDlgItem( aDlg, 25, 2, 1, 8, {-3,0,3,0},
ID_BTN_OK, "BUTTON" , nStyle, "OK" )

Wvt_DialogBox( aDlg, "DyDlga", Wvt_GetWindowHandle() )

***
FUNCTION DyDlga( hDlg, nMsg, wParam )

Switch ( nMsg )

CASE WM_COMMAND
IF wParam == ID_BTN_OK

Wapi_ShellExecute( nil,,"probe.pdf") // 1 solution

* Hb_ThreadStart(HB_THREAD_INHERIT_PUBLIC, { ||
ExecuteActiveX(hb_DirBase()+"probe.pdf") } ) // 2 solution

ENDIF
EXIT

CASE WM_INITDIALOG

WVG_SetFocus(WVG_GetDlgItem(hDlg, ID_BTN_OK))
WVG_InvalidateRect( hDlg )
EXIT

CASE WM_DESTROY
EXIT
END

RETURN 0

*************************
FUNCTION ExecuteActiveX(cPdf)

Local oVrt, oCom
LOCAL oDA

HB_SYMBOL_UNUSED( oCom )

//--------------------------- Dialog
------------------------------- \\

oVrt:= WvgDialog():new( , , { 30,30 }, { 800,600 }, , .t. )
oVrt:closable := .t.
oVrt:create()

hb_gtInfo( HB_GTI_RESIZABLE, .t. )
hb_gtInfo( HB_GTI_WINTITLE, 'Print dialog 2' )

oDA:= oVrt:drawingArea
oDA:resize := {|| ResizeDialog( oVrt, oCom ) }

oCom := WvgActiveXControl():New( oDA, , { 0, 0 },
{ 100,100 }, , .t. )
oCom:CLSID := 'file:\\' + cPdf
oCom:closable := .t.
oCom:create()

oVrt:sendMessage( WM_SIZE, 0, 0 )
oVrt:show()

DO WHILE .t.
IF inkey() == K_ESC ; EXIT ; ENDIF
ENDDO

oVrt:Destroy()

CLEAR TYPEAHEAD

RETURN NIL

***********************************
FUNCTION ResizeDialog( oVrt, oCom )
LOCAL aVrt
aVrt := oVrt:currentSize()
oCom:setPosAndSize( { 0, 0 }, { aVrt[1], aVrt[2] }, .t. )

RETURN 1

*************************************** COMMON PROCEDURES
***************************************
EXIT PROCEDURE CleanHandles()
LOCAL obj

FOR EACH obj IN SetFonts()
WVG_DeleteObject( obj )
obj := NIL
NEXT

FOR EACH obj IN SetIcons()
WVG_DeleteObject( obj )
obj := NIL
NEXT
RETURN
*******************
FUNCTION HB_GTSYS()
REQUEST HB_GT_WVG_DEFAULT
REQUEST HB_GT_WVT
REQUEST HB_GT_WGU
RETURN NIL







/*
* $Id: wvgutilities.prg 17127 2011-12-07 09:16:14Z vouchcac $
*/

/*
* Pritpal Bedi <bedip...@hotmail.com>
*/
/
*----------------------------------------------------------------------
*/

#include "inkey.ch"
#include "common.ch"
#include "wvtwin.ch"
#include "hbgtinfo.ch"
#include "hbgtwvg.ch"
#include "wvgparts.ch"

/
*----------------------------------------------------------------------
*/
//
// WvtSetObjects() array structure
//
#define WVT_OBJ_TYPE 1
#define WVT_OBJ_ID 2
#define WVT_OBJ_ROW 3
#define WVT_OBJ_COL 4
#define WVT_OBJ_ROWTO 5
#define WVT_OBJ_COLTO 6
#define WVT_OBJ_ONDISP 7
#define WVT_OBJ_ONMOUSEOVER 8
#define WVT_OBJ_ONBUTTONDOWN 9
#define WVT_OBJ_ONBUTTONUP 10
#define WVT_OBJ_TOOLTIP 11
#define WVT_OBJ_STATE 12
#define WVT_OBJ_DUMMY 13

#define WVT_OBJ_VRBLS 13

// WVT_OBJ_TYPE Constants
//
#define OBJ_TYPE_BUTTON 1

// WVT_OBJ_STATE
//
#define OBJ_STATE_HIDE 0
#define OBJ_STATE_DISP 1
#define OBJ_STATE_MOUSEOVER 2
#define OBJ_STATE_BUTTONDOWN 3
#define OBJ_STATE_BUTTONUP 4

/
*----------------------------------------------------------------------
*/
//-------------------------------------------------------------------//
// Wvt_Paint() must be a FUNCTION in your application
// as it is called when Window gets WM_PAINT message.
//-------------------------------------------------------------------//
FUNCTION Wvt_Paint()
LOCAL aBlocks := WvtSetBlocks()

aEval( aBlocks, {|e| eval( e ) } )

WvtPaintObjects()

RETURN 0
//-------------------------------------------------------------------//
// Wvt_SetFocus() must be a FUNCTION in your application
// needs to process messages sent through WM_SETFOCUS message
// received by the window.
//-------------------------------------------------------------------//
#if 0
FUNCTION Wvt_SetFocus()

LOCAL nRow := row()
LOCAL nCol := col()

DispOutAt( 1,3, "Focus Gained!", "R/W" )

DevPos( nRow, nCol )

RETURN nil
#endif
//-------------------------------------------------------------------//
// Wvt_KillFocus() must be a FUNCTION in your application
// needs to process messages sent through WM_KILLFOCUS message
// received by the window.
//-------------------------------------------------------------------//
#if 0
FUNCTION Wvt_KillFocus()
LOCAL nRow := row()
LOCAL nCol := col()

DispOutAt( 1,3, "Focus Lost...", "B/W" )

DevPos( nRow, nCol )

RETURN NIL
#endif

//-------------------------------------------------------------------//
//
// Wvt_Mouse() must be present if you want to catch and fire
// mouse call back outside of the inkey() loop.
//
//-------------------------------------------------------------------//

FUNCTION Wvt_Mouse( nKey, nRow, nCol )
LOCAL nLen, aObjects := WvtSetObjects()
LOCAL nObj

STATIC nLastObj := 0
STATIC nLastKey := 0

IF ( nLen := len( aObjects ) ) == 0
RETURN NIL
ENDIF

IF ! SetMouseCheck()
RETURN NIL
ENDIF

IF nKey == -1000001
FOR nObj := 1 TO nLen
DO CASE
CASE aObjects[ nObj, WVT_OBJ_STATE ] == OBJ_STATE_DISP
eval( aObjects[ nObj, WVT_OBJ_ONDISP ] )
CASE aObjects[ nObj, WVT_OBJ_STATE ] == OBJ_STATE_MOUSEOVER
eval( aObjects[ nObj, WVT_OBJ_ONMOUSEOVER ] )
CASE aObjects[ nObj, WVT_OBJ_STATE ] == OBJ_STATE_BUTTONDOWN
eval( aObjects[ nObj, WVT_OBJ_ONBUTTONDOWN ] )
CASE aObjects[ nObj, WVT_OBJ_STATE ] == OBJ_STATE_BUTTONUP
eval( aObjects[ nObj, WVT_OBJ_ONDISP ] )
CASE aObjects[ nObj, WVT_OBJ_STATE ] == OBJ_STATE_HIDE

ENDCASE
NEXT
RETURN NIL
ENDIF

nObj := ascan( aObjects, {|e_| e_[ WVT_OBJ_ROW ] <= nRow .AND. ;
e_[ WVT_OBJ_ROWTO ] >= nRow .AND. ;
e_[ WVT_OBJ_COL ] <= nCol .AND. ;
e_[ WVT_OBJ_COLTO ] >= nCol } )
IF nObj == 0
IF nLastObj > 0
aObjects[ nLastObj, WVT_OBJ_STATE ] := OBJ_STATE_DISP
eval( aObjects[ nLastObj, WVT_OBJ_ONDISP ] )
nLastObj := 0
ENDIF
RETURN NIL
ENDIF

IF nLastObj == nObj .and. nLastKey == nKey
RETURN NIL
ENDIF

nLastObj := nObj
nLastKey := nKey

DO CASE
CASE nKey == K_MOUSEMOVE
IF aObjects[ nLastObj, WVT_OBJ_STATE ] != OBJ_STATE_MOUSEOVER
aObjects[ nLastObj, WVT_OBJ_STATE ] := OBJ_STATE_MOUSEOVER
IF aObjects[ nObj, WVT_OBJ_ONMOUSEOVER ] != nil
eval( aObjects[ nObj, WVT_OBJ_ONMOUSEOVER ] )
ENDIF
ENDIF

CASE nKey == K_LBUTTONDOWN
aObjects[ nLastObj, WVT_OBJ_STATE ] := OBJ_STATE_BUTTONDOWN
IF aObjects[ nObj, WVT_OBJ_ONBUTTONDOWN ] != nil
eval( aObjects[ nObj, WVT_OBJ_ONBUTTONDOWN ] )
ENDIF

CASE nKey == K_LBUTTONUP
aObjects[ nLastObj, WVT_OBJ_STATE ] := OBJ_STATE_DISP
IF aObjects[ nObj, WVT_OBJ_ONBUTTONUP ] != nil
eval( aObjects[ nObj, WVT_OBJ_ONBUTTONUP ] )
ENDIF

ENDCASE

RETURN NIL

//-------------------------------------------------------------------//
// WvtSetBlocks() is a get/set FUNCTION to be used by Wvt_Paint()
//-------------------------------------------------------------------//

FUNCTION WvtSetBlocks( a_ )
LOCAL o
THREAD STATIC t := {}

o := aclone( t )

IF a_ != nil
t := aclone( a_ )
ENDIF

RETURN o

//-------------------------------------------------------------------//
// WvtSetObjects() is a get/set FUNCTION to be used by Wvt_Mouse()
//-------------------------------------------------------------------//

FUNCTION WvtSetObjects( aObject )
LOCAL oObjects

THREAD STATIC aObjects := {}

oObjects := aclone( aObjects )

IF aObject != NIL
IF empty( aObject )
aObjects := {}
ELSE
IF valtype( aObject[ 1 ] ) == "A"
aeval( aObject, {|e_| aadd( aObjects, e_ ) } )
ELSE
aSize( aObject, WVT_OBJ_VRBLS )

DEFAULT aObject[ WVT_OBJ_STATE ] TO OBJ_STATE_DISP

aadd( aObjects, aObject )
ENDIF
ENDIF
ENDIF

RETURN oObjects

//-------------------------------------------------------------------//

FUNCTION SetMouseCheck( lYes )
LOCAL lOYes
STATIC lSYes := .t.
lOYes := lSYes
IF lYes != NIL
lSYes := lYes
ENDIF
RETURN lOYes

//-------------------------------------------------------------------//

FUNCTION WvtWindowExpand( nUnits )

STATIC sUnits := 18

sUnits += nUnits

Wvt_setFont( "Courier New", sUnits )

RETURN .t.

//-------------------------------------------------------------------//

FUNCTION rgb( r,g,b )
RETURN r + ( g * 256 ) + ( b * 256 * 256 )

//-------------------------------------------------------------------//

FUNCTION VouChoice( aChoices )
LOCAL scr, clr, nChoice

DEFAULT aChoices TO
{ "One","Two","Three","Four","Five","Six","Seven" }

scr := SaveScreen( 7,48,13,55 )
clr := SetColor( "N/W*,GR+/B*,,,GR+/B" )

nChoice := aChoice( 7, 48, 13, 55, aChoices )

setColor( clr )
RestScreen( 7, 48, 13, 55, scr )

RETURN nChoice

//-------------------------------------------------------------------//

FUNCTION Hb_Clear()
CLS
RETURN .f.

//----------------------------------------------------------------------//

FUNCTION MyMenuProcedure( nID )
DO CASE
CASE nID == 101
alert( 'Procedure 101' )
CASE nID == 102
alert( 'Procedure 102' )
ENDCASE
RETURN .t.

//----------------------------------------------------------------------//

FUNCTION BuildWvgToolBar( oDA, nActiveX )
LOCAL oTBar

DEFAULT nActiveX TO 0

oTBar := WvgToolBar():new( oDA, , { 0,0 }, { oDA:currentSize()
[ 1 ], 30 }, , .T. )

oTBar:style := WVGTOOLBAR_STYLE_FLAT
oTBar:borderStyle := WVGFRAME_RECT

oTBar:buttonWidth := 40 //28
oTBar:buttonHeight := 26

oTBar:imageWidth := 26
oTBar:imageHeight := 24

oTBar:showToolTips := .t.

// After setting properties, create toolbar.
oTBar:create()

oTBar:addItem( "New" , hb_DirBase() + 'v_new.bmp' )
oTBar:addItem( "Select" , hb_DirBase() + 'v_selct1.bmp' )
oTBar:addItem( "Calendar" , hb_DirBase() + 'v_calend.bmp' )
oTBar:addItem( "Tools" , hb_DirBase() + 'v_lock.bmp' )
oTBar:addItem( "Index" , hb_DirBase() + 'v_index.bmp' )
oTBar:addItem( "Show" , hb_DirBase() + 'v_clclt.bmp' )
oTBar:addItem( "Hide" , hb_DirBase() + 'v_notes1.bmp' )

RETURN oTBar

//----------------------------------------------------------------------//

FUNCTION SetGT( nIndex, pGT )
LOCAL oldGT
STATIC pGT_:= { NIL, NIL, NIL }
oldGT := pGT_[ nIndex ]
IF PCount() == 2
pGT_[ nIndex ] := pGT
ENDIF
RETURN oldGT

/
*----------------------------------------------------------------------
*/

FUNCTION SetFonts( hFont )
LOCAL oldFont
THREAD STATIC t_ahFonts := {}
oldFont := t_ahFonts
IF !empty( hFont )
aadd( t_ahFonts, hFont )
ENDIF
RETURN oldFont

/
*----------------------------------------------------------------------
*/

FUNCTION SetIcons( hIcon )
LOCAL oldIcon
THREAD STATIC t_ahIcons := {}
oldIcon := t_ahIcons
IF !empty( hIcon )
aadd( t_ahIcons, hIcon )
ENDIF
RETURN oldIcon

/
*----------------------------------------------------------------------
*/

FUNCTION Popups( nID, lDestroy )
LOCAL hPop, hPop1
LOCAL nPrompt := MF_ENABLED+MF_STRING

THREAD STATIC hPop_:= { , , , , , , , , }

IF nID == NIL
Wvt_SetPopupMenu()
RETURN NIL
ENDIF

IF lDestroy != NIL
Wvt_DestroyMenu( hPop_[ nID ] )
RETURN NIL
ENDIF

hPop := hPop_[ nID ]

DO CASE
CASE nID == 1 // Data Entry Module

IF hPop == nil
hPop := Wvt_CreatePopupMenu()
Wvt_AppendMenu( hPop, nPrompt, K_F2, "Second Get Screen" )
Wvt_AppendMenu( hPop, nPrompt, K_F3, "Expand Window" )
Wvt_AppendMenu( hPop, nPrompt, K_F4, "Shrink Window" )
Wvt_AppendMenu( hPop, nPrompt, K_F5, "Browse" )
Wvt_AppendMenu( hPop, nPrompt, K_F6, "Minimize" )
Wvt_AppendMenu( hPop, nPrompt, K_F7, "Partial Screen" )
Wvt_AppendMenu( hPop, nPrompt, K_F8, "Lines" )
Wvt_AppendMenu( hPop, nPrompt, K_F9, "Choose Font" )
Wvt_AppendMenu( hPop, nPrompt, K_F10,"Choose Color" )

Wvt_AppendMenu( hPop, MF_SEPARATOR )

Wvt_AppendMenu( hPop, nPrompt, K_F5, "Browse" )

ENDIF

CASE nID == 2 // Browser

IF hPop == NIL
hPop := Wvt_CreatePopupMenu()
Wvt_AppendMenu( hPop, nPrompt, K_DOWN , "Down" )
Wvt_AppendMenu( hPop, nPrompt, K_UP , "Up" )
Wvt_AppendMenu( hPop, nPrompt, K_PGDN , "Page Down" )
Wvt_AppendMenu( hPop, nPrompt, K_PGUP , "Page Up" )
Wvt_AppendMenu( hPop, nPrompt, K_CTRL_PGUP, "Top" )
Wvt_AppendMenu( hPop, nPrompt, K_CTRL_PGDN, "Bottom" )

Wvt_AppendMenu( hPop, MF_SEPARATOR )

hPop1 := Wvt_CreatePopupMenu()
Wvt_AppendMenu( hPop1, nPrompt, K_RIGHT , "Right" )
Wvt_AppendMenu( hPop1, nPrompt, K_LEFT , "Left" )
Wvt_AppendMenu( hPop1, nPrompt, K_END , "End" )
Wvt_AppendMenu( hPop1, nPrompt, K_HOME , "Home" )

Wvt_AppendMenu( hPop, MF_ENABLED+MF_POPUP, hPop1, "Column
Movement" )

ENDIF

ENDCASE

hPop_[ nID ] := hPop

RETURN Wvt_SetPopupMenu( hPop_[ nID ] )

//-------------------------------------------------------------------//

FUNCTION DispStatusMsg( cMsg )

Wvt_DrawLabel( MaxRow(), 60, cMsg, 6, , 0, rgb(198,198,198),
"Arial", 18, , 900 )

RETURN .t.

//-------------------------------------------------------------------//

FUNCTION ClearStatusMsg()
LOCAL nRow := Row()
LOCAL nCol := Col()

DispOutAt( MaxRow(), 42, space( 37 ), "W/W" )

SetPos( nRow, nCol )

RETURN .t.

//-------------------------------------------------------------------//

FUNCTION WvtPictures( nSlot,cFilePic )

IF nSlot != NIL .AND. nSlot <= 20 .AND. file( cFilePic )
IF t_pic_[ nSlot ] != cFilePic
IF Wvt_LoadPicture( cFilePic, nSlot )
t_pic_[ nSlot ] := cFilePic
ENDIF
ENDIF
ENDIF

RETURN NIL

//-------------------------------------------------------------------//

FUNCTION WvtExePicture( nTop, nLeft, nBottom, nRight, nSlot, aOffset )

IF t_pic_[ nSlot ] != NIL
Wvt_DrawPicture( nTop, nLeft, nBottom, nRight, nSlot, aOffSet )
ENDIF

RETURN NIL

/
*----------------------------------------------------------------------
*/

FUNCTION GetResource( cName )
RETURN hb_dirBase() + cName

/
*----------------------------------------------------------------------
*/

FUNCTION uiDebug( ... )
LOCAL aP := hb_aParams()
LOCAL s := ""

aeval( aP, {|e| s += hb_valTOstr( e ) + " " } )

WAPI_OutputDebugString( s )

RETURN NIL

/
*----------------------------------------------------------------------
*/

FUNCTION MyError( oError )

? oError:description
? oError:operation

? procname( 1 ), procline( 1 )
? procname( 2 ), procline( 2 )
? procname( 3 ), procline( 3 )
? procname( 4 ), procline( 4 )
DO WHILE inkey() != 27; ENDDO

RETURN NIL



I'd be better to attach the files to my post as attachments, but i
dont know how.

Thanks

Zoran
Message has been deleted

Zoran Sibinovic

unread,
Mar 20, 2012, 6:17:15 AM3/20/12
to Harbour Users
Hi,

sorry to all, i had duplicate some text in my previous message.
I have almost achivied the goal.

in demowvg (wvgactivex.prg) we have the use of activex objects
through
the WvgDialog() class, by calling the function ExecuteActiveX() that
has to be called via hb_threadStart( {||
ExecuteActiveX( nActiveX ) } ).

The WvgDialog() works very well, but, we cant use as a modal window
so
I have extract some parts from wvgactivex.prg and make, below, a
new
ExecuteActiveX() function/procedure that can be modal. To try
different environments you have to modify the code where you want
ExecuteActiveX() to start, from the menu or from the Dyndlg dialog.
In
the example below it start from the Dyndlg dialog.

Why all this?

My printing system is based on previously made PDF-s for be viewed
and
then printed.
Sometimes I need to start the activex from menues, browse objects
and
some from dialogs.
The thing works very vell using the
Wapi_ShellExecute( nil,,STRTRAN(cLongTmp+myharu,"\" ,"/")), but it
take more time to popupu then using the activex method.

The problem that appears is that the adobe reader or other pdf app
rise
normally but is not modal to our app, so we cannot set our app in a
wait state till we finist with the pdf, our app returns to be
available immediately, what if we do not want to?

In wvgtbrowser.prg Pritpal have made a nice use of activex objects
but
that cant be used as an uniform function as we want. Also I have
noticed that using the WvgCrt() class with an activex object in it
we
have a problem of handle the background when resizing and also when
you move the window, dragging it with the mouse, the activex object
disappears, things solved in the WvgDialog() class.

I have tried to solve that issues using the WvgCrt() class in
ExecuteActiveX() and I think I've did to make it as an uniform
function, in some way, but I'm sure that this can be done in the
WvgCrt() class itself.

How to try the code:

1. save the code below in c:\hb31\contrib\gtwvg\tests\main.hbp

-3rd=hbide_version=1.0
-3rd=hbide_title=Demo&GTWVG
-3rd=hbide_output=main

-inc
-mt
-w3
-es2
-gtwvg

main.prg

2. save the code below in c:\hb31\contrib\gtwvg\tests\main.prg

#include "fileio.ch"
#include "inkey.ch"
#include "common.ch"
#include "wvtwin.ch"
#include "hbgtinfo.ch"
#include "hbgtwvg.ch"
#include "wvgparts.ch"
#include "hbthread.ch"

THREAD STATIC t_keys_:= { , , , , , , , , , , , , , , , , , , , }
THREAD STATIC t_pic_ := { , , , , , , , , , , , , , , , , , , , }

REQUEST DbfCdx
****************************
EXIT PROCEDURE CleanHandles()
LOCAL obj

FOR EACH obj IN SetFonts()
WVG_DeleteObject( obj )
obj := NIL
NEXT

FOR EACH obj IN SetIcons()
WVG_DeleteObject( obj )
obj := NIL
NEXT
RETURN
*******************
FUNCTION HB_GTSYS()
REQUEST HB_GT_WVG_DEFAULT
REQUEST HB_GT_WVT
REQUEST HB_GT_WGU
RETURN NIL

//-------------------------------------------------------------------//

PROCEDURE Main()

LOCAL aLastPaint, clr, scr, pGT
LOCAL aBlocks := {}, nKey
LOCAL aObjects := WvtSetObjects( {} )
LOCAL oError := ErrorBlock( {|o| MyError( o ) } )

SET( _SET_EVENTMASK, INKEY_ALL + HB_INKEY_GTEVENT )

Wvt_SetGui( .t. )
Wvt_SetMouseMove( .t. )
Wvt_SetFont( "Courier New", 16, 0, 0 )

CLS

Wvt_ShowWindow( SW_RESTORE )

BuildMainMenu()

SetMode( maxrow()+1, maxcol()+1 )

pGT := SetGT( 1, hb_gtSelect() )

aAdd( aBlocks, {|| Wvt_SetIcon( 1 ) } )
aAdd( aBlocks, {|| Wvt_SetTitle( "Proba" ) } )
aAdd( aBlocks, {|| Wvt_Mouse( -1000001 ) } )
aLastPaint := WvtSetBlocks( aBlocks )

scr := SaveScreen( 0,0,maxrow(),maxcol() )
clr := SetColor( "N/W" )
CLS
SetColor( "N/W,N/GR*,,,N/W*" )

SETCURSOR(0)

DO WHILE !( (nKey := inkey()) == 27 )
IF nKey == Wvt_SetMenuKeyEvent() .AND.
hb_isBlock( SetKey( nKey ) )
EVAL( SetKey( nKey ) )
ENDIF
ENDDO

// Restore Environment
//
WvtSetBlocks( aLastPaint )
WvtSetObjects( aObjects )
SetColor( clr )
RestScreen( 0,0,maxrow(),maxcol(), scr )

SetGT( 1, pGT )

ErrorBlock( oError )

RETURN

//-------------------------------------------------------------------//

FUNCTION BuildMainMenu()
LOCAL oMenu

LOCAL g_oMenuBar := WvgSetAppWindow():menuBar()

oMenu:= WvgMenu():new( g_oMenuBar, , .t. ):create()
oMenu:caption := "Licni dohodak"

oMenu:= WvgMenu():new( g_oMenuBar, , .t. ):create()
oMenu:caption := "Dialogs"
oMenu:AddItem( "Dialog 1" , {||
MyDiala() } )
g_oMenuBar:addItem( { oMenu, "Dialogs" } )

RETURN nil

#define ID_BTN_OK 100
/

*----------------------------------------------------------------------
*/

PROCEDURE MyDiala()
LOCAL aDlg, nStyle

nStyle := DS_SETFONT + WS_VISIBLE + WS_POPUP + WS_CAPTION +
WS_SYSMENU + WS_THICKFRAME + WS_MINIMIZEBOX
aDlg := Wvt_MakeDlgTemplate( -20, -30, 30, 90, {0,0,0,0},"Izbor
uslova pregleda/stampe"," Dialog !", nStyle )

nStyle := WS_CHILD + WS_VISIBLE + WS_TABSTOP + BS_PUSHBUTTON
aDlg := Wvt_AddDlgItem( aDlg, 25, 2, 1, 8, {-3,0,3,0},
ID_BTN_OK, "BUTTON" , nStyle, "Dialog 2" )

Wvt_DialogBox( aDlg, "DyDlg", Wvt_GetWindowHandle() )

//-------------------------------------------------------------------//

FUNCTION DyDlg( hDlg, nMsg, wParam )

Switch ( nMsg )

CASE WM_COMMAND

IF wParam == ID_BTN_OK
WVG_EnableWindow(hDlg,.f.)
ExecuteActiveX(hb_DirBase()+"myharu.pdf")
WVG_EnableWindow(hDlg,.T.)
WVG_SetFocus(hDlg)

ENDIF
EXIT

CASE WM_DESTROY
EXIT
END

RETURN 0

******************************
PROCEDURE ExecuteActiveX(cpdf)
LOCAL oCrt, oCom, oDA, aPosc,aPosc1
LOCAL aCrt
LOCAL aLastPaint := WvtSetBlocks( {} )

HB_SYMBOL_UNUSED( oCom )

oCrt := WvgCrt():new( , , { 0,0 }, { 42,126 }, , .t. )
oCrt:resizeMode := HB_GTI_RESIZEMODE_ROWS
oCrt:lModal := .t.
oCrt:resizable:=.t.
oCrt:title:="Dialog 2"
oCrt:closable := .t.
oCrt:icon := 1
oCrt:create()

oCrt:show()

SetCursor( 0 )

SetColor( 'N/W' )
CLS

hb_gtInfo( HB_GTI_SPEC, HB_GTS_WNDSTATE, HB_GTS_WS_MAXIMIZED )

aCrt := oCrt:currentSize()

oDA:= oCrt:drawingArea
oDA:resize := {|| ResizeDialog( oCrt, oCom, @aCrt ) }

oCom := WvgActiveXControl():New( oDA, , { 0, 0 }, { { ||
aCrt[1] } , { || aCrt[2] } }, , .T. )
oCom:CLSID := 'file://' + cpdf
oCom:create()

aPosc:=hb_gtInfo( HB_GTI_SPEC, HB_GTS_SETPOSITION )

DO WHILE .T.
IF INKEY() == K_ESC ; EXIT ; ENDIF

aPosc1:=hb_gtInfo( HB_GTI_SPEC, HB_GTS_SETPOSITION )

IF aPosc[1]<>aPosc1[1] .OR. aPosc1[2]<>aPosc1[2]
aPosc:=hb_gtInfo( HB_GTI_SPEC, HB_GTS_SETPOSITION )
oCom:refresh()
ENDIF

ENDDO

oCrt:Destroy()
WvtSetBlocks( aLastPaint )

//----------------------------------------------------------------------//

STATIC FUNCTION ResizeDialog(oCrt, oCom, aCrt)

aCrt := oCrt:currentSize()
oCom:setPosAndSize( { 0, 0 }, { aCrt[1], aCrt[2] }, .t. )

RETURN 1

*********** BELOW COMMON FUNC FROM wvgutilities.prg

#define WVT_OBJ_TYPE 1
#define WVT_OBJ_ID 2
#define WVT_OBJ_ROW 3
#define WVT_OBJ_COL 4
#define WVT_OBJ_ROWTO 5
#define WVT_OBJ_COLTO 6
#define WVT_OBJ_ONDISP 7
#define WVT_OBJ_ONMOUSEOVER 8
#define WVT_OBJ_ONBUTTONDOWN 9
#define WVT_OBJ_ONBUTTONUP 10
#define WVT_OBJ_TOOLTIP 11
#define WVT_OBJ_STATE 12
#define WVT_OBJ_DUMMY 13

#define WVT_OBJ_VRBLS 13
#define OBJ_TYPE_BUTTON 1

#define OBJ_STATE_HIDE 0
#define OBJ_STATE_DISP 1
#define OBJ_STATE_MOUSEOVER 2
#define OBJ_STATE_BUTTONDOWN 3
#define OBJ_STATE_BUTTONUP 4

*----------------------------------------------------------------------
*/

FUNCTION SetFonts( hFont )
LOCAL oldFont
THREAD STATIC t_ahFonts := {}
oldFont := t_ahFonts
IF !empty( hFont )
aadd( t_ahFonts, hFont )
ENDIF
RETURN oldFont

/

*----------------------------------------------------------------------
*/

FUNCTION SetIcons( hIcon )
LOCAL oldIcon
THREAD STATIC t_ahIcons := {}
oldIcon := t_ahIcons
IF !empty( hIcon )
aadd( t_ahIcons, hIcon )
ENDIF
RETURN oldIcon

//-------------------------------------------------------------------//

FUNCTION WvtSetObjects( aObject )
LOCAL oObjects

THREAD STATIC aObjects := {}

oObjects := aclone( aObjects )

IF aObject != NIL
IF empty( aObject )
aObjects := {}
ELSE
IF valtype( aObject[ 1 ] ) == "A"
aeval( aObject, {|e_| aadd( aObjects, e_ ) } )
ELSE
aSize( aObject, WVT_OBJ_VRBLS )

DEFAULT aObject[ WVT_OBJ_STATE ] TO OBJ_STATE_DISP

aadd( aObjects, aObject )
ENDIF
ENDIF
ENDIF

RETURN oObjects

/

*----------------------------------------------------------------------
*/

FUNCTION MyError( oError )

? oError:description
? oError:operation

? procname( 1 ), procline( 1 )
? procname( 2 ), procline( 2 )
? procname( 3 ), procline( 3 )
? procname( 4 ), procline( 4 )
DO WHILE inkey() != 27; ENDDO

RETURN NIL

//----------------------------------------------------------------------//

FUNCTION SetGT( nIndex, pGT )
LOCAL oldGT
STATIC pGT_:= { NIL, NIL, NIL }
oldGT := pGT_[ nIndex ]
IF PCount() == 2
pGT_[ nIndex ] := pGT
ENDIF
RETURN oldGT

FUNCTION WvtSetBlocks( a_ )
LOCAL o
THREAD STATIC t := {}

o := aclone( t )

IF a_ != nil
t := aclone( a_ )
ENDIF

RETURN o

//-------------------------------------------------------------------//

FUNCTION SetMouseCheck( lYes )
LOCAL lOYes
STATIC lSYes := .t.
lOYes := lSYes
IF lYes != NIL
lSYes := lYes
ENDIF
RETURN lOYes

/

*----------------------------------------------------------------------
*/

FUNCTION uiDebug( ... )
LOCAL aP := hb_aParams()
LOCAL s := ""

aeval( aP, {|e| s += hb_valTOstr( e ) + " " } )

WAPI_OutputDebugString( s )

RETURN NIL

3. compile it and try

lot of code in this example is just a common code to make the app
start without any other prg-s

Any suggestion or opinion is welcome

Thanks Zoran

Zoran Sibinovic

unread,
Mar 21, 2012, 6:52:38 AM3/21/12
to Harbour Users
Hi,

I've made a change to optimize the code for the ExecuteActiveX()
procedure as modal.

The example and purpose of it can be viewed by changing the code in c:
\hb31\contrib\gtwvg\tests\demowvg.prg

oMenu:AddItem("ActiveX - Visualize a PDF",{||ExecuteActiveX()})
oMenu:AddItem( "-")

instead of

oMenu:AddItem("ActiveX - Visualize a PDF",{||Hb_ThreadStart({||
ExecuteActiveX(3) })})
oMenu:AddItem( "-")

and replace all the code in c:\hb31\contrib\gtwvg\tests
\wvgactivex.prg

with the code below


#include "inkey.ch"
#include "common.ch"
#include "wvtwin.ch"
#include "hbgtinfo.ch"
#include "hbgtwvg.ch"
#include "wvgparts.ch"

**************************
PROCEDURE ExecuteActiveX()
LOCAL oCrt, oCom, oDA, aWinpos,aWinpos1,nResize,aCrt
LOCAL aLastPaint := WvtSetBlocks( {} )

HB_SYMBOL_UNUSED( oCom )

oCrt := WvgCrt():new( , , { 0,0 }, { 42,126 }, , .t. )
oCrt:resizeMode := HB_GTI_RESIZEMODE_ROWS
oCrt:lModal := .t.
oCrt:resizable:=.t.
oCrt:closable := .t.
oCrt:icon := 1
oCrt:create()

oCrt:show()

SetCursor( 0 )

SetColor( 'N/W' )
CLS

hb_gtInfo( HB_GTI_SPEC, HB_GTS_WNDSTATE, HB_GTS_WS_MAXIMIZED )

aCrt := oCrt:currentSize()

oDA:= oCrt:drawingArea
oDA:resize := {|| ResizeDialog( oCrt, oCom, @aCrt, @nResize ) }

oCom := WvgActiveXControl():New( oDA, , { 0, 0 }, { { ||
aCrt[1] } , { || aCrt[2] } }, , .T. )
hb_gtInfo( HB_GTI_WINTITLE, 'file://' + hb_DirBase() +
'myharu.pdf' )
oCom:CLSID := 'file://' + hb_DirBase() + 'myharu.pdf'
oCom:create()

aWinpos:=hb_gtInfo( HB_GTI_SPEC, HB_GTS_SETPOSITION )
nResize:=0

DO WHILE .T.
IF INKEY(0) == K_ESC ; EXIT ; ENDIF

aWinpos1:=hb_gtInfo( HB_GTI_SPEC, HB_GTS_SETPOSITION )

IF (aWinpos[1]<>aWinpos1[1] .OR. aWinpos[2]<>aWinpos1[2]) .AND.
nResize=0
aWinpos:=hb_gtInfo( HB_GTI_SPEC, HB_GTS_SETPOSITION )
oCom:refresh()
ENDIF

nResize=0

ENDDO

oCrt:Destroy()
WvtSetBlocks( aLastPaint )


//----------------------------------------------------------------------//

STATIC FUNCTION ResizeDialog(oCrt, oCom, aCrt, nResize )

aCrt:= oCrt:currentSize()
oCom:setPosAndSize( { 0, 0 }, { aCrt[1], aCrt[2] }, .t. )
nResize=1

RETURN 1

Suggestions, as always, are welcome.
It will be nice if it is useful to someone

Zoran
Reply all
Reply to author
Forward
0 new messages