Jump to content

desktop WM_PAINT hook


rusibla
 Share

Recommended Posts

hello forum,

after i spent a very long night with google, msdn and of course with lots of articles in this forum, i still haven't found any working solotions for this problem:

i finally managed to draw on the desktop behind the icons with this code (just an example with black bg):

CODE

#include <GDIPlus.au3>

#Include <WinAPI.au3>

Func _Main()

$hWnd = ControlGetHandle("[Class:Progman]", "", "[Class:SysListView32]")

$hDC = _WinAPI_GetWindowDC($hWnd)

; Fill a rectangle

_GDIPlus_Startup ()

$hGraphic = _GDIPlus_GraphicsCreateFromHDC ($hDC)

_GDIPlus_GraphicsFillRect($hGraphic, 0, 0, @DesktopWidth, @DesktopHeight)

_WinAPI_RedrawWindow($hWnd, 0, 0, BitOR($RDW_INVALIDATE, $RDW_NOERASE, $RDW_UPDATENOW))

; Clean up resources

_WinAPI_ReleaseDC($hWnd, $hDC)

_GDIPlus_GraphicsDispose ($hGraphic)

_GDIPlus_Shutdown ()

EndFunc

_Main()

wich was inspired by this tool i found http://www.angelcode.com/dev/desktopdraw/

now the obvious problem is that the old desktop background reapears when the desktop window gets redrawn. so what i need is some hook wich tells me when the desktop is redrawn so i can redraw my own content. as far as i found out i need a hook with $WH_GETMESSAGE (integer value = 3) and i'm looking for the $WM_PAINT message. first i tried to use dllcall to use the windows api directly, but after lots of trying i red somewhere that i can't acces messages from other windows if the functions are not within a dll because of some security shit. then i found the hook.dll here in this forum which quite a a few people used for hooks. cound't get it to work with WH_GETMESSAGE. the last thing i tried was the winhook.dll from the angelcode project mentioned above (they used it for slightly different reasons) and rebiuld their system of sending back messages to the parent window. didn't work. well that might be because i'm not that good with reading c++ code ;-)

any ideas?

thanks.

Link to comment
Share on other sites

hello forum,

after i spent a very long night with google, msdn and of course with lots of articles in this forum, i still haven't found any working solotions for this problem:

i finally managed to draw on the desktop behind the icons with this code (just an example with black bg):

CODE

#include <GDIPlus.au3>

#Include <WinAPI.au3>

Func _Main()

$hWnd = ControlGetHandle("[Class:Progman]", "", "[Class:SysListView32]")

$hDC = _WinAPI_GetWindowDC($hWnd)

; Fill a rectangle

_GDIPlus_Startup ()

$hGraphic = _GDIPlus_GraphicsCreateFromHDC ($hDC)

_GDIPlus_GraphicsFillRect($hGraphic, 0, 0, @DesktopWidth, @DesktopHeight)

_WinAPI_RedrawWindow($hWnd, 0, 0, BitOR($RDW_INVALIDATE, $RDW_NOERASE, $RDW_UPDATENOW))

; Clean up resources

_WinAPI_ReleaseDC($hWnd, $hDC)

_GDIPlus_GraphicsDispose ($hGraphic)

_GDIPlus_Shutdown ()

EndFunc

_Main()

wich was inspired by this tool i found http://www.angelcode.com/dev/desktopdraw/

now the obvious problem is that the old desktop background reapears when the desktop window gets redrawn. so what i need is some hook wich tells me when the desktop is redrawn so i can redraw my own content. as far as i found out i need a hook with $WH_GETMESSAGE (integer value = 3) and i'm looking for the $WM_PAINT message. first i tried to use dllcall to use the windows api directly, but after lots of trying i red somewhere that i can't acces messages from other windows if the functions are not within a dll because of some security shit. then i found the hook.dll here in this forum which quite a a few people used for hooks. cound't get it to work with WH_GETMESSAGE. the last thing i tried was the winhook.dll from the angelcode project mentioned above (they used it for slightly different reasons) and rebiuld their system of sending back messages to the parent window. didn't work. well that might be because i'm not that good with reading c++ code ;-)

any ideas?

thanks.

Welcome to the forums. :)

Maybe Siao's shellhook in example scripts.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

thanks martin!

i'm still wondering why i haven't found this one yet with doing all that research. it uses a method I've never thought of before. but it doesn't seem to do what i need. it just signals when the full window is redrawn and that only with "Normal" windows. i haven't got the time yet to try havier modyfiing yet so if im lucky i'll find a way to make it work but it doesen't look like it. i need every single draw event when just a small part is redrawn (i think in C they call it window expose or something), for exaple when you move desktop icons (if you use my code you will see the black bg color disapear). but this shellhook might be very usefull for something else i'm doing ;-)

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