Jump to content

Changing cursor in IE is making image flash/flicker


Recommended Posts

I have a script that changes cursor types in IE. It works fine without flashing until the window is resized. I am not sure why it’s happening or how to stop it. Is the only solution to completely reload the image?

Example:

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

$sFileName = FileOpenDialog("Please select file", "", "Image files (*.jpg;*.tif;*.gif;*.bmp;*.png;)");
If @Error Then Exit

$hGUI = GUICreate("", 500, 500, 0, 0, $WS_SIZEBOX + $WS_MAXIMIZEBOX, $WS_EX_COMPOSITED)

$oIE = ObjCreate("Shell.Explorer.2")

$g_idGUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 500, 500)
GUICtrlSetResizing($g_idGUIActiveX, $GUI_DOCKAUTO)

;navigate to image
$oIE.navigate($sFileName)

_IELoadWait($oIE)

;makes the HTML that will hold the image
$sHTML = "<HTML><HEAD><SCRIPT language=jscript for=document type=text/javascript defer event=oncontextmenu>;return false</SCRIPT></HEAD>"
$sHTML &= '<BODY style="BORDER-TOP: 0px; BORDER-RIGHT: 0px; BORDER-BOTTOM: 0px; MARGIN: 0px; BORDER-LEFT: 0px">'
$sHTML &= '<IMG width=100% height=100% src="' & $sFileName & '"></BODY></HTML>'

;save the HTML to IE
_IEDocWriteHTML($oIE, $sHTML)
_IELoadWait($oIE)

GUISetState(@SW_SHOW, $hGUI)

;remove the scroll bar
$oIE.document.body.scroll = "no"

;first loop does not flash
For $i = 10 To 1 Step -1
    ToolTip($i, 0, 0, "First Loop")
    $oIE.document.body.style.cursor = "move"
    Sleep(500)
    $oIE.document.body.style.cursor = "n-resize"
Next

;change window size
WinSetState($hGUI, "", @SW_MAXIMIZE)

;second loop flashes once there is change in the window size
For $i = 10 To 1 Step -1
    ToolTip($i, 0, 0, "Second Loop With Flashing")
    $oIE.document.body.style.cursor = "move"
    Sleep(500)
    $oIE.document.body.style.cursor = "n-resize"
Next

Link to comment
Share on other sites

For anyone that is interested.

Removing $WS_EX_COMPOSITED stopped the flickering for me but I needed the double-buffering for what I was doing.

I ended up having to disable the ActiveX control and then set the GUI’s cursor using GUISetCursor.

Here is a working example for anyone that may run into the same problem.

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

$sFileName = FileOpenDialog("Please select file", "", "Image files (*.jpg;*.tif;*.gif;*.bmp;*.png;)");
If @error Then Exit

$hGUI = GUICreate("", 500, 500, 0, 0, $WS_SIZEBOX + $WS_MAXIMIZEBOX, $WS_EX_COMPOSITED)

$oIE = ObjCreate("Shell.Explorer.2")

$g_idGUIActiveX = GUICtrlCreateObj($oIE, 0, 0, 500, 500)
GUICtrlSetResizing($g_idGUIActiveX, $GUI_DOCKAUTO)

;navigate to image
$oIE.navigate($sFileName)

_IELoadWait($oIE)

;makes the HTML that will hold the image
$sHTML = "<HTML><HEAD><SCRIPT language=jscript for=document type=text/javascript defer event=oncontextmenu>;return false</SCRIPT></HEAD>"
$sHTML &= '<BODY style="BORDER-TOP: 0px; BORDER-RIGHT: 0px; BORDER-BOTTOM: 0px; MARGIN: 0px; BORDER-LEFT: 0px">'
$sHTML &= '<IMG width=100% height=100% src="' & $sFileName & '"></BODY></HTML>'

;save the HTML to IE
_IEDocWriteHTML($oIE, $sHTML)
_IELoadWait($oIE)

GUICtrlSetState($g_idGUIActiveX, $GUI_DISABLE);<<<<<<<<<<disable

GUISetState(@SW_SHOW, $hGUI)

;remove the scroll bar
$oIE.document.body.scroll = "no"

;first loop does not flash
For $i = 10 To 1 Step -1
    ToolTip($i, 0, 0, "First Loop")
    GUISetCursor(9, 1, $hGUI)
    Sleep(500)
    GUISetCursor(2, 1, $hGUI)
Next

;change window size
WinSetState($hGUI, "", @SW_MAXIMIZE)

;second loop /w no flash
For $i = 10 To 1 Step -1
    ToolTip($i, 0, 0, "First Loop")
    GUISetCursor(9, 1, $hGUI)
    Sleep(500)
    GUISetCursor(2, 1, $hGUI)
Next

 

Edited by Herb191
Fixed formatting error.
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...