ryantollefson Posted May 26, 2007 Posted May 26, 2007 (edited) I want to make as screen that fills the monitor for a few seconds and looks like static (you know how a TV looks when it can't tune a channel). I can make an avi file of static, but when I make it big enough to fill the screen it becomes huge - is there a way that I could have just a small avi, maybe 50x50, and just tile it across the gui? I know this might be wishful thinking... The other thing I was thinking is trying to use GUICtrlCreateLabel to make a bunch of pixels across the gui, and then try to change their color to one of several shades of grey using Random. Is this a far fetched plan, or does this seem like it would work? Also is there a way I could tile the Labels so that I don't have to go and make thousands of them by hand to fill the screen? - The thing that I would like with this solution is that I wouldn't need to include an .avi file for it to work. Edited May 26, 2007 by ryantollefson
Zedna Posted May 26, 2007 Posted May 26, 2007 It's rather slow. #include <GUIConstants.au3> GUICreate("My Draw", 300,200) GuiCtrlCreateGraphic(0, 0, 300, 200) For $i = 1 To 300 For $j = 1 To 200 $color = Random(0,0xffffff,1) GUICtrlSetGraphic(-1,$GUI_GR_COLOR, $color) GUICtrlSetGraphic(-1,$GUI_GR_DOT, $i,$j) Next Next GuiSetState() Do $msg = GUIGetMsg() Until $msg=$GUI_EVENT_CLOSE Resources UDF ResourcesEx UDF AutoIt Forum Search
Zedna Posted May 26, 2007 Posted May 26, 2007 (edited) Optimized repainting (from internal hidden bitmap). Still slow. expandcollapse popup#include <GUIConstants.au3> Global Const $WM_PAINT = 0x000F $Form1 = GUICreate("My Draw", 300,200) $hdc = DllCall("user32.dll","int","GetDC","hwnd",$Form1) $hdc = $hdc[0] ; create memory DC with size = size of client area of main window Global $client_rect = WinGetClientSize($Form1) Global $memory_dc = _CreateCompatibleDC( $hdc) Global $memory_bm = _CreateCompatibleBitmap( $hdc, $client_rect[0], $client_rect[1]) _SelectObject( $memory_dc, $memory_bm) For $i = 0 To $client_rect[0] For $j = 0 To $client_rect[1] $color = Random(0,0xffffff,1) _SetPixel($memory_dc,$i,$j,$color) Next Next GUIRegisterMsg($WM_PAINT, 'MY_WM_PAINT') GuiSetState() Do $msg = GUIGetMsg() Until $msg=$GUI_EVENT_CLOSE Func OnAutoItExit ( ) DLLCall("user32.dll","int","ReleaseDC","hwnd",$Form1,"int",$hdc) ;~ DLLCall("user32.dll","int","ReleaseDC","hwnd",$Form1,"int",$memory_dc) _DeleteObject( $memory_bm) _DeleteDC( $memory_dc) EndFunc Func MY_WM_PAINT($hwnd, $msg, $wparam, $lparam) ;~ If $hwnd = $Form1 Then ;~ Switch $msg ;~ Case $WM_PAINT _RePaint() ;~ Return ;~ EndSwitch ;~ EndIf Return $GUI_RUNDEFMSG EndFunc Func _RePaint() ; copy content of memory DC to Window DC _BitBlt( $hdc, 0, 0, $client_rect[0], $client_rect[1], $memory_dc, 0, 0) EndFunc Func _CreateCompatibleDC( $hdc, $dll_h = 'gdi32.dll') ;~ http://msdn.microsoft.com/library/en-us/gdi/devcons_499f.asp Local $ret = DllCall( $dll_h, 'ptr', 'CreateCompatibleDC', 'ptr', $hdc) Return $ret[0] EndFunc Func _CreateCompatibleBitmap( $hdc, $w, $h, $dll_h = 'Gdi32.dll') ;~ http://msdn.microsoft.com/library/en-us/gdi/bitmaps_1cxc.asp Local $ret = DllCall( $dll_h, 'ptr', 'CreateCompatibleBitmap', _ 'ptr', $hdc, _ 'int', $w, _ 'int', $h) Return $ret[0] EndFunc Func _BitBlt( $destination_hdc, $destination_x, $destination_y, $destination_width, $destination_height, _ $source_hdc, $source_x, $source_y, $code = 0xCC0020, $dll_h = 'Gdi32.dll') ;~ Const $SRCCOPY = 0xCC0020 ;~ http://msdn.microsoft.com/library/en-us/gdi/bitmaps_0fzo.asp Local $ret = DllCall( $dll_h, 'int', 'BitBlt', _ 'ptr', $destination_hdc, _ 'int', $destination_x, _ 'int', $destination_y, _ 'int', $destination_width, _ 'int', $destination_height, _ 'ptr', $source_hdc, _ 'int', $source_x, _ 'int', $source_y, _ 'int', $code) Return $ret[0] EndFunc Func _SelectObject( $hdc, $hgdiobj, $dll_h = 'Gdi32.dll') ;~ http://msdn.microsoft.com/library/en-us/gdi/devcons_9v3o.asp Local $ret = DllCall( $dll_h, 'hwnd', 'SelectObject', 'ptr', $hdc, 'hwnd', $hgdiobj) Return $ret[0] EndFunc Func _DeleteObject( $hObject, $dll_h = 'Gdi32.dll') ;~ http://msdn.microsoft.com/library/en-us/gdi/devcons_1vsk.asp Local $ret = DllCall( $dll_h, 'int', 'DeleteObject', 'hwnd', $hObject) Return $ret[0] EndFunc Func _DeleteDC( $hdc, $dll_h = 'Gdi32.dll') ;~ http://msdn.microsoft.com/library/en-us/gdi/devcons_2p2b.asp Local $ret = DllCall( $dll_h, 'int', 'DeleteDC', 'ptr', $hdc) Return $ret[0] EndFunc Func _SetPixel($dc,$x,$y,$color) DllCall ("gdi32.dll", "long", "SetPixel", "long", $dc, "long", $x, "long", $y, "long", $color) EndFunc Edited May 26, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Siao Posted May 27, 2007 Posted May 27, 2007 (edited) Tile like this? #include <GUIConstants.au3> Global Const $timer = 5000 Global Const $avifile = @WindowsDir&"\clock.avi" Dim $avisize[2]=[321,321] ;avi width,height $size = WinGetClientSize("Program Manager") $ix = Floor($size[0] / $avisize[0]) $iy = Floor($size[1] / $avisize[1]) $x=0 $y=0 $Form2 = GUICreate("Form2", $size[0], $size[1], 0, 0, $WS_POPUP) GUISetBkColor(0x000000) GUISetCursor(16) GUIStartGroup($Form2) For $j = 0 to $iy Step 1 $y = $j * $avisize[1] For $i = 0 to $ix Step 1 $x = $i * $avisize[0] $Avi = GUICtrlCreateAvi($avifile, -1, $x, $y, $avisize[0], $avisize[1], $ACS_AUTOPLAY) Next Next GUISetState(@SW_SHOW) Sleep($timer) Exit Edited May 27, 2007 by Siao "be smart, drink your wine"
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now