Jump to content

clipping problems while scrolling when using $WS_EX_LAYERED child windows


Recommended Posts

Hey! i have the following problem: when scrolling a window which has a WS_EX_LAYERED child window, i get clipping problems. I use _WinAPI_UpdateLayeredWindowEx to update  the child window with an image, which works fine, but when scrolling it happens from time to time that the content of the parent window (in this example the image of the child window) will pop out of the parent window for like 1 frame. It´s like the drawing and clipping is executed in the wrong order. Please take a look at the example code and make a test yourself, just load an image (better a larg one, so you can see the effect better) start and scroll fast up and down, you should see at some point that the image will clip out of  the parent window. I tried to disabled and enabled the drawing while scrolling by using _SendMessage($hParent, $WM_SETREDRAW, False), this will fix the out of parent clipping but sadly the whole window will flicker.

any ideas?

 

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPIConv.au3>
#include <GuiScrollBars.au3>
#include <GDIPlus.au3>
#include <WinAPISysWin.au3>

GUIRegisterMsg($WM_MOUSEWHEEL, "_WM_MOUSEWHEEL")

$hParent = GUICreate("Test", 900, 500, -1, -1)
GUISetState(@SW_SHOW, $hParent)

_GDIPlus_Startup()
$hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\texture.jpg")
$hChild = GUICreate("Child", 150, 150, 0, 0, $WS_CHILD, $WS_EX_LAYERED, $hParent)
_WinAPI_UpdateLayeredWindowEx($hChild, -1, -1, _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage), 255, true)
GUISetState(@SW_SHOW, $hChild)

_GUIScrollBars_Init($hParent, -1, 100)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop

    EndSwitch
WEnd


Func _WM_MOUSEWHEEL($hwnd, $Msg, $wParam, $lParam)

    Local $iCurScrollPos = _GUIScrollBars_GetScrollInfoPos($hWnd, $SB_VERT)

    Switch  _WinAPI_HiWord($wParam) / 120
        Case -1
            _GUIScrollBars_SetScrollInfoPos($hWnd, $SB_VERT, $iCurScrollPos + 5)

        Case 1
            _GUIScrollBars_SetScrollInfoPos($hWnd, $SB_VERT, $iCurScrollPos - 5)
    EndSwitch

EndFunc

 

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...