Jump to content

Recommended Posts

Posted

Hello all,

I am relatively new with Autoit (6 month).

Thanks to this forum I have been able to develop scripts with Autoit but today I post a message because I found a problem, but did not find the solution in the forum.

I want to display a window with an image inside, and do a kind of image display as the Windows One. I want to display .wmf files.

So I am using GDI+ UDF to display them in a window. The problem is the repainting. If the image I load is a jpg, the repainting is working correctly. If the image is a wmf, it happens that, when the window must repaint the image, the wmf image is not completely repainted and areas of the previous foreground is stil visible. What is the problem ?

Attach is the test program and an image of the issue.

Thanks for your help !

Laurent

Global Const $SP_WS_CAPTION = 0x00C00000
Global Const $SP_WS_POPUP = 0x80000000
Global Const $SP_WS_MINIMIZEBOX = 0x00020000
Global Const $SP_WS_VISIBLE = 0x10000000
Global Const $SP_WS_SYSMENU = 0x00080000
Global Const $SP_DS_SETFOREGROUND = 0x00000200

#include <StaticConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#Include <WinAPI.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>

Global $InstallDir = @ScriptDir & "\"

; GDI+ variables
Global $SlidesGraphics, $SlideImage

; Main window
$SlideWindowID = GUICreate("Background vs GDI+", 800, 660, -1, -1, BitOr($SP_WS_CAPTION, $SP_WS_POPUP, $SP_WS_MINIMIZEBOX, $SP_WS_VISIBLE, $SP_DS_SETFOREGROUND, $SP_WS_SYSMENU) )  ; will create a dialog box that when displayed is centered
GUISetBkColor(0x00FF00)
GUISetState(@SW_SHOW)

_GDIPlus_StartUp()

; Graphics creation
$SlidesGraphics = _GDIPlus_GraphicsCreateFromHWND($SlideWindowID)

; Procedure to redraw if necessary
GUIRegisterMsg($WM_PAINT, "RepaintSlide")

; Load WMF image
$SlideImage = _GDIPlus_ImageLoadFromFile("image.wmf")
_GDIPlus_GraphicsDrawImageRect($SlidesGraphics, $SlideImage, 0, 0, 800, 600)


; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

; Draw GDI image
Func RepaintSlide($hWnd, $Msg, $wParam, $lParam)
    _WinAPI_RedrawWindow($SlideWindowID, 0, 0, $RDW_UPDATENOW)
    _GDIPlus_GraphicsDrawImageRect($SlidesGraphics, $SlideImage, 0, 0, 800, 600)
    _WinAPI_RedrawWindow($SlideWindowID, 0, 0, $RDW_VALIDATE)
    Return $GUI_RUNDEFMSG
EndFunc

post-62288-0-01215800-1294651093_thumb.j

Posted

Still no idea ?

I have writen a simple example that works with Jpeg images but NOT WMF ? Why ?

Is anybody displaying WMF or EMF with Autoit ? If not with GDI+, then how to make a simple wmf viewer with autoit ?

#include <GuiConstantsEx.au3>
#include <GDIPlus.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>

Global $InstallDir = @ScriptDir & "\"
Global $SlideDir = $InstallDir &  "Slides\"

Global $SlidesGraphics, $SlideImage, $SlideWindowID

; Create main GUI
$SlideWindowID = GUICreate("GDI+", 400, 300)
GUISetBkColor(0xFF0000,$SlideWindowID)
GUISetState(@SW_SHOW,$SlideWindowID)

; Initialize GDI+ library
_GDIPlus_Startup ()

; Loading
;$SlideImage = _GDIPlus_ImageLoadFromFile($SlideDir & "IMG_000.JPG")
$SlideImage = _GDIPlus_ImageLoadFromFile($SlideDir & "Accueil.wmf")

; Graphics from Window
$SlidesGraphics = _GDIPlus_GraphicsCreateFromHWND($SlideWindowID)

; Drawing in the graphics
_GDIPlus_GraphicsDrawImageRect($SlidesGraphics, $SlideImage, 0, 0, 800, 600)

GUIRegisterMsg($WM_PAINT, "RepaintSlide"); Register PAINT-Event 0x000F = $WM_PAINT (WindowsConstants.au3)

; Loop until user exits
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

; Shut down GDI+ library
_GDIPlus_ShutDown ()

Func RepaintSlide($hWnd, $Msg, $wParam, $lParam)

    _GDIPlus_GraphicsDrawImageRect($SlidesGraphics, $SlideImage, 0, 0, 800, 600)
    _WinAPI_RedrawWindow($SlideWindowID, "", "", $RDW_VALIDATE)

    Return $GUI_RUNDEFMSG

EndFunc

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
  • Recently Browsing   0 members

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