Jump to content

New embedded component - Preview


kjactive
 Share

Recommended Posts

Well just another small example to embed an activeX component . Microsoft Preview - this little fellow can rotate, zoom and print out any graphics...

; Author:    Kåre Johansson
; AutoIt Version: 3.1.1.55
; Description: Very Simple example: Embedding Preview object
; Date:    3 jul 2005

#include <GUIConstants.au3>
$oRP = ObjCreate("Preview.Preview.1")

GUICreate ("Embedded Preview control Test", 620, 425, -1, -1,BitOr($WS_OVERLAPPEDWINDOW,$WS_VISIBLE,$WS_CLIPSIBLINGS))
$TagsPageC = GuiCtrlCreateLabel('Visit Tags Page', 5, 405, 100, 15, $SS_CENTER)
GuiCtrlSetFont($TagsPageC,9,400,4)
GuiCtrlSetColor($TagsPageC,0x0000ff)
GuiCtrlSetCursor($TagsPageC,0)
$AboutC = GUICtrlCreateButton('Empty',105,400,70,20)
$PrefsC = GUICtrlCreateButton('Empty',175,400,70,20)
$StatC = GUICtrlCreateButton('Empty',245,400,70,20)

$GUIActiveX    = GUICtrlCreateObj( $oRP, 10, 10 , 600 , 385 )
$LinkoRP = ObjEvent($oRP,"IEEvent_","Preview"); this is a dummy event handle

With $oRP; Object tag pool
    .Show('C:\Pics\Bali.jpg') 
    ;.Zoom(150) I didn't figurate this out yet!!!
EndWith

GUISetState ();Show GUI

While 1
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $TagsPageC
            Run(@ComSpec & ' /c start http://www.myplugins.info/guids/typeinfo/typeinfo.php?clsid={50F16B26-467E-11D1-8271-00C04FC3183B}','', @SW_HIDE)
    EndSelect
WEnd

GUIDelete ()
Exit

This is just an example code and no functions is included but a information link is provided to get the feeling with this component that include a slideshow, graphic editor and printout...

kjactive :)

Edited by kjactive
Link to comment
Share on other sites

Cool! :)

This is useful for showing images.

but you should use a pic everybody has as an example.

; Author:   Kåre Johansson
; AutoIt Version: 3.1.1.55
; Description: Very Simple example: Embedding Preview object
; Date: 3 jul 2005

#include <GUIConstants.au3>
$oRP = ObjCreate("Preview.Preview.1")

GUICreate ("Embedded Preview control Test", 620, 425, -1, -1,BitOr($WS_OVERLAPPEDWINDOW,$WS_VISIBLE,$WS_CLIPSIBLINGS))
$TagsPageC = GuiCtrlCreateLabel('Visit Tags Page', 5, 405, 100, 15, $SS_CENTER)
GuiCtrlSetFont($TagsPageC,9,400,4)
GuiCtrlSetColor($TagsPageC,0x0000ff)
GuiCtrlSetCursor($TagsPageC,0)
$AboutC = GUICtrlCreateButton('Empty',105,400,70,20)
$PrefsC = GUICtrlCreateButton('Empty',175,400,70,20)
$StatC = GUICtrlCreateButton('Empty',245,400,70,20)

$GUIActiveX = GUICtrlCreateObj( $oRP, 10, 10 , 600 , 385 )
$LinkoRP = ObjEvent($oRP,"IEEvent_","Preview"); this is a dummy event handle

With $oRP; Object tag pool
    .Show(@WindowsDir & "\Sandstone.bmp") 
   ;.Zoom(150) I didn't figurate this out yet!!!
EndWith

GUISetState ();Show GUI

While 1
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $TagsPageC
            Run(@ComSpec & ' /c start http://www.myplugins.info/guids/typeinfo/typeinfo.php?clsid={50F16B26-467E-11D1-8271-00C04FC3183B}','', @SW_HIDE)
    EndSelect
WEnd

GUIDelete ()
Exit
HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Link to comment
Share on other sites

This looks awesome, but no picture shows up and the window says "No file selected"... I even replaced the file path with a picture that I know exists! Any ideas on the problem? Thanks! :)

FootbaG
Link to comment
Share on other sites

Here is an example using the object. It does a slideshow with all the JPEGs in your

"My Pictures" folder.

#include <GUIConstants.au3>
$oRP = ObjCreate("Preview.Preview.1")

$GUI = GUICreate ("Embedded Preview control Test", 620, 425, -1, -1,BitOr($WS_OVERLAPPEDWINDOW,$WS_VISIBLE,$WS_CLIPSIBLINGS))
$TagsPageC = GuiCtrlCreateLabel('Visit Tags Page', 5, 405, 100, 15, $SS_CENTER)
GuiCtrlSetFont($TagsPageC,9,400,4)
GuiCtrlSetColor($TagsPageC,0x0000ff)
GuiCtrlSetCursor($TagsPageC,0)


$GUIActiveX = GUICtrlCreateObj( $oRP, 10, 10 , 600 , 385 )
$LinkoRP = ObjEvent($oRP,"IEEvent_","Preview"); this is a dummy event handle


GUISetState ();Show GUI
$Search=FileFindFirstFile(@MyDocumentsDir & "\My Pictures\*.jpg")
While 1
    
    $File=@MyDocumentsDir & "\My Pictures\" &  FileFindNextFile($Search)
    If @Error then ExitLoop 
    WinSetTitle($GUI,"","Viewing Image:" & $File)
    $oRP.Show($File)
    Sleep(3000)
WENd



While 1
    $msg = GUIGetMsg()
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        
        Case $msg = $TagsPageC
            Run(@ComSpec & ' /c start [url=http://www.myplugins.info/guids/typeinfo/typeinfo.php?clsid={50F16B26-467E-11D1-8271-00C04FC3183B}','']http://www.myplugins.info/guids/typeinfo/t...#39;,''[/url], @SW_HIDE)
    EndSelect
WEnd

GUIDelete ()
Exit
Edited by SolidSnake
HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Link to comment
Share on other sites

Now that worked :D That's actually amazing!!! :) I just found out where to find objects from applications, so I;m going to go experiment or play counter-strtike! :evil:

<{POST_SNAPBACK}>

yeah! :D I can't wait to see what other possiblities this awesome object has.

P.S. fixed the CodeBox.

HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Link to comment
Share on other sites

  • 4 weeks later...

It's BETA, there is bound to be plenty of crashes. I'm no COM expert, but there is a function around here to get the last COM error, someone else can probabl;y help better though,

Cheers

FootbaG
Link to comment
Share on other sites

Change the script like this:

Select

Case $msg = $GUI_EVENT_CLOSE

$oRP = 0 ; Close the object !!!!

ExitLoop

and it will not crash anymore (I hope)

The object has to be closed and this is done with setting it to zero.

Link to comment
Share on other sites

It's BETA, there is bound to be plenty of crashes. I'm no COM expert, but there is a function around here to get the last COM error, someone else can probabl;y help better though,

Cheers

<{POST_SNAPBACK}>

See the helpfile... Function Reference -> Obj/COM Reference -> in the mail help here find "COM Error Handling". Shows you how to set up a special error handler for COM.

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Link to comment
Share on other sites

hi,

I cannot run this slideshow script as there is an error on the @comspec line...?

Can you help?

Thanks, Randall

<{POST_SNAPBACK}>

Here is an updated version.It should work now. Thats weird it used to work fine. :evil: It is like the bug just appeared out of no where. :)

It now lets you close while the slideshow is being shown.

#include <GUIConstants.au3>
Opt("GuiOnEventMode",1)
$oRP = ObjCreate("Preview.Preview.1")

$GUI = GUICreate ("Embedded Preview control Test", 620, 425, -1, -1,BitOr($WS_OVERLAPPEDWINDOW,$WS_VISIBLE,$WS_CLIPSIBLINGS))
$TagsPageC = GuiCtrlCreateLabel('Visit Tags Page', 5, 405, 100, 15, $SS_CENTER)
GuiCtrlSetFont($TagsPageC,9,400,4)
GuiCtrlSetColor($TagsPageC,0x0000ff)
GuiCtrlSetCursor($TagsPageC,0)
GuiSetOnEvent($GUI_Event_Close,"Quit")
GuiCtrlSetOnEvent($TagsPageC,"TagsPage")


$GUIActiveX    = GUICtrlCreateObj( $oRP, 10, 10 , 600 , 385 )
$LinkoRP = ObjEvent($oRP,"IEEvent_","Preview"); this is a dummy event handle


GUISetState ();Show GUI
$Search=FileFindFirstFile(@MyDocumentsDir & "\My Pictures\*.jpg")
While 1
    
    $File=@MyDocumentsDir & "\My Pictures\" &  FileFindNextFile($Search)
    If @Error then ExitLoop 
    WinSetTitle($GUI,"","Viewing Image:" & $File)
    $oRP.Show($File)
    Sleep(3000)
WENd
While 1
    Sleep(100)
WEnd


Func TagsPage()
            Run(@ComSpec & ' /c start http://www.myplugins.info/guids/typeinfo/typeinfo.php?clsid={50F16B26-467E-11D1-8271-00C04FC3183B}','', @SW_HIDE)
EndFunc

Func Quit()
    GuiCtrlDelete($GUIActiveX)
    $oORP=0    
    Exit
EndFunc

GUIDelete ()
Exit

Edit:Put up right code becuase I put up the wrong one by mistake.

Edited by SolidSnake
HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Link to comment
Share on other sites

Sorry,

I meant in the slideshow script; I have just now used the dos line from the other to fix it and its OK; there is a ";" in that line in the thread above, Num4

pic

Randall

<{POST_SNAPBACK}>

Oops. :"> Posted wrong script. Sorry.

Just put up the proper one now.

Edited by SolidSnake
HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...