Sign in to follow this  
Followers 0
ajit

Open PDF in GUI

4 posts in this topic

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <TabConstants.au3>


_IEErrorHandlerRegister ()

$oIE = _IECreateEmbedded ()
GUICreate("Embedded Web control Test", 640, 580, _
        (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _
        $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)

$GUI_Button_browse = GUICtrlCreateButton("Browse", 430, 530, 100, 30)

$tabs = GUICtrlCreateTab(10, 10, 600, 500, $TCS_FIXEDWIDTH)
GUICtrlSetResizing($tabs, $GUI_DOCKRIGHT + $GUI_DOCKTOP)

$PDF_TAB = GUICtrlCreateTabItem("TAB1")

$GUIActiveX = GUICtrlCreateObj($oIE, 30, 50, 480, 380)


GUISetState()       ;Show GUI

; Waiting for user to close the window
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $GUI_Button_browse
            $pdf_file = FileOpenDialog("Select Pdf File", @ScriptDir & "\", "Pdf files (*.pdf)", 1)
            _IENavigate ($oIE, $pdf_file, 0 )
    EndSelect
WEnd

Hi:

I am stuck with this unresponsive GUI. I am trying to open a pdf file in my GUI. The problem only occurs when I use the code in a GUI with tab control, not otherwise.

Please help me.

Ajit

Share this post


Link to post
Share on other sites



From help file with regards to tab controls > Don't forget to close your tabitem creation with GUICtrlCreateTabItem("").

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <IE.au3>
#include <TabConstants.au3>


_IEErrorHandlerRegister ()

$oIE = _IECreateEmbedded ()
GUICreate("Embedded Web control Test", 640, 580, _
        (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _
        $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_CLIPCHILDREN)

$GUI_Button_browse = GUICtrlCreateButton("Browse", 430, 530, 100, 30)

$tabs = GUICtrlCreateTab(10, 10, 600, 500, $TCS_FIXEDWIDTH)
GUICtrlSetResizing($tabs, $GUI_DOCKRIGHT + $GUI_DOCKTOP)

$PDF_TAB = GUICtrlCreateTabItem("TAB1")

$GUIActiveX = GUICtrlCreateObj($oIE, 30, 50, 480, 380)
GUICtrlCreateTabItem("")

GUISetState()       ;Show GUI

; Waiting for user to close the window
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $GUI_Button_browse
            $pdf_file = FileOpenDialog("Select Pdf File", @ScriptDir & "\", "Pdf files (*.pdf)", 1)
            _IENavigate ($oIE, $pdf_file, 0 )
    EndSelect
WEnd

GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

Share this post


Link to post
Share on other sites

Hi,

it seems you need a own GUI for that.

You can use tab on tab for that.

Attached an example.

best regards, Reinhard

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
; Example of TAB in TAB ctrl

Global $mainGUI,$ok_button,$cancel_button

; This window has 2 ok/cancel-buttons
$mainGUI        = GUICreate("Tab on Tab Resize",260+200,250+200,20,10,$WS_OVERLAPPEDWINDOW +$WS_CLIPCHILDREN + $WS_CLIPSIBLINGS)
    GUISetStyle(BitOR($WS_MINIMIZEBOX, $WS_MAXIMIZEBOX, $WS_CAPTION, $WS_SIZEBOX, $WS_POPUP, $WS_SYSMENU))
    GUISetBkColor(0x5686A9)
    $ok_button        = GUICtrlCreateButton("OK",40,220+200,70,20)
    $cancel_button    = GUICtrlCreateButton("Cancel",150,220+200,70,20)

; Create the first child window that is implemented into the main GUI
$child1            = GUICreate("",230+200,170+200,15,35,BitOr($WS_CHILD,$WS_TABSTOP),-1,$mainGUI)
    GUISetBkColor(0x56869c)
    $oIE = ObjCreate("Shell.Explorer.2")
    $GUIActiveX = GUICtrlCreateObj($oIE, 10, 10,400 ,350)
    $oIe.Navigate('C:\Test.pdf')
    GUISetState()
; Create the second child window that is implemented into the main GUI
$child2            = GUICreate("",230+200,170+200,15,35,BitOr($WS_CHILD,$WS_TABSTOP),-1,$mainGUI)
    GUISetBkColor(0x56869c)
    $listview2        = GUICtrlCreateListView("Col1|Col2",10,10,210+200,150+200,-1,$WS_EX_CLIENTEDGE)
        GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
        GUICtrlCreateListViewItem("ItemLong1|ItemLong12", $listview2)
        GUICtrlCreateListViewItem("ItemLong2|Item22", $listview2)
        ;GUISetState()

; Switch back the main GUI and create the tabs
GUISwitch($mainGUI)
$main_tab        = GUICtrlCreateTab(10,10,240+200,200+200)
    $child1tab        = GUICtrlCreateTabItem("Child1")
    $child2tab        = GUICtrlCreateTabItem("Child2")
    GUICtrlCreateTabItem("")
GUISetState()

GUIRegisterMsg($WM_SIZE, 'WM_SIZE')
DIM $tabItemLast = 0

While 1
    $msg = GUIGetMsg(1)
    Switch $msg[0]
        Case $GUI_EVENT_CLOSE, $cancel_button
            ExitLoop

        Case $main_tab
            $tabItem = GUICtrlRead($main_Tab)
            if $tabItem <> $tabItemLast then TabSwitch($tabItem)

    EndSwitch
WEnd

func TabSwitch($tabItem)
    GUISetState(@SW_HIDE,$child1)
    GUISetState(@SW_HIDE,$child2)

    if $tabItem = 0 then GUISetState(@SW_SHOW,$child1)
    if $tabItem = 1 then GUISetState(@SW_SHOW,$child2)
    $tabItemLast = $tabItem
EndFunc


Func WM_SIZE($hWnd, $iMsg, $iWParam, $iLParam)
    $aMGPos = WinGetClientSize ($mainGUI)
    Winmove($child1,"",15,35,+$aMGPos[0]-30,+$aMGPos[1]-80)
    Winmove($child2,"",15,35,+$aMGPos[0]-30,+$aMGPos[1]-80)
    ;Guictrlsetpos($child_tab,10,10,+$aMGPos[0]-50,+$aMGPos[1]-100)
    Guictrlsetpos($main_tab,10,10,+$aMGPos[0]-20,+$aMGPos[1]-50)
    Guictrlsetpos($listview2,10,10,+$aMGPos[0]-30-20,+$aMGPos[1]-80-20)

endfunc

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

@ReFran:

Thanks for your help. The script now works perfectly without the application getting stuck.

Thanks again.

Regards

Ajit

Edited by ajit

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0