Hallo,
wenn ich mit GDI+ ein Quadrat zeichnen lasse, kann man es mit einem anderem Fenster "Wegwischen".
Kann ich das irgendwie verhindern?
Hallo,
wenn ich mit GDI+ ein Quadrat zeichnen lasse, kann man es mit einem anderem Fenster "Wegwischen".
Kann ich das irgendwie verhindern?
Beispiel ?
Du musst WM_PAINT-message verwenden.
Windows sendet diese message an dein GUI, wenn es sich neuzeichnen soll.
[autoit]#include <GDIPlus.au3>
#include <WindowsConstants.au3>
_GDIPlus_Startup()
$hGUI = GUICreate("GUI")
GUISetState()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
_GDIPlus_GraphicsDrawRect($hGraphic, 50, 50, 100, 100)
GUIRegisterMsg($WM_PAINT, "WM_PAINT")
[/autoit][autoit][/autoit][autoit]While GUIGetMsg() <> -3
WEnd
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
Func WM_PAINT($hWnd, $Msg, $wParam, $lParam)
_GDIPlus_GraphicsDrawRect($hGraphic, 50, 50, 100, 100)
EndFunc ;==>WM_PAINT
lgE
So wird's auch beim wiederherstellen neugezeichnet:
#include <GDIPlus.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_Startup()
$hGUI = GUICreate("GUI")
GUISetOnEvent($GUI_EVENT_CLOSE, "_Ende")
GUISetOnEvent($GUI_EVENT_RESTORE, "WM_PAINT")
GUISetState()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI)
_GDIPlus_GraphicsDrawRect($hGraphic, 50, 50, 100, 100)
GUIRegisterMsg($WM_PAINT, "WM_PAINT")
[/autoit] [autoit][/autoit] [autoit]While 1
Sleep(10000)
WEnd
Func WM_PAINT($hWnd, $Msg, $wParam, $lParam)
_GDIPlus_GraphicsDrawRect($hGraphic, 50, 50, 100, 100)
EndFunc ;==>WM_PAINT
Func _Ende()
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
Exit
EndFunc
funkey
Ich hatte das Problem immer, wenn ich mit GDI+ einen .png anzeige! Das hilft mir bestimmt, wenn es geht habs nich nit probiert
ähm sorry wenn ich hier meine frage reinposte
ich wollte nur wissen wie ich eine mit _GDIPlus_GraphicsDrawLine "gemalte" linie wieder kürzer mache?
ich blick da iwie net durch^^ (noch nicht)
Padmak
In der Hintergrundfarbe drübermalen
omg^^
hört sich iwie nach der holzhammermethode an-.-^^
Padmak
Warum übermalst du nicht die Stellen die du nicht brauchst?
naja weils bei mir so ausschaut
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <GuiStatusBar.au3>
#include <String.au3>
#include <GUIConstantsEx.au3>
#include-once
#RequireAdmin
#NoTrayIcon
;Scripted by Padmak, http://www.autoit.de
Local $StatusBar1_PartsWidth[4] = [85, 225, 380, 200]
_GDIPlus_Startup()
;Standardzeugs
$Form1 = GUICreate("Slider Test", 550, 400, 193, 125)
$hWnd = WinGetHandle("Slider Test")
$Slider1 = GUICtrlCreateSlider(8, 8, 484, 45)
$Progress1 = GUICtrlCreateProgress(8, 64, 484, 17)
$Label1 = GUICtrlCreateLabel("Aktueller Stand in %:", 8, 96, 101, 17)
$Input1 = GUICtrlCreateInput("", 8, 120, 97, 21)
$Label2 = GUICtrlCreateLabel("Selbst ändern:", 152, 96, 72, 17)
$Input2 = GUICtrlCreateInput("", 152, 120, 73, 21)
$Button1 = GUICtrlCreateButton("Go", 264, 120, 75, 25, 0)
$Button2 = GUICtrlCreateButton("Beenden", 344, 120, 75, 25, 0)
$Label3 = GUICtrlCreateLabel("0 %", 8, 160, 61, 17)
$Label4 = GUICtrlCreateLabel("", 8, 184, 500, 28)
$slider = GUICtrlRead($Slider1)
GUICtrlSetFont(-1, 10, 800, 0, "Comic Sans MS")
GUICtrlCreateUpdown($Input2)
GUICtrlSetLimit($Input2, 100, 0)
GUICtrlSetData($Input2, "0")
GUICtrlSetState($Input2, $GUI_FOCUS)
;Standartzeugs ende
;Statusbar
$StatusBar1 = _GUICtrlStatusBar_Create($Form1)
_GUICtrlStatusBar_SetParts($StatusBar1, $StatusBar1_PartsWidth)
_GUICtrlStatusBar_SetText($StatusBar1, "Aktuelle %: " & $slider)
_GUICtrlStatusBar_SetText($StatusBar1, "Aktuelle Uhrzeit: " & @HOUR & ":" & @MIN & ":" & @SEC, 1)
_GUICtrlStatusBar_SetText($StatusBar1, "Aktuelles Datum: " & @MDAY & ":" & @MON & ":" & @YEAR, 2)
_GUICtrlStatusBar_SetText($StatusBar1, "Aktueller Benutzer: " & @UserName, 3)
;Statusbar ende
;Gdi+
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
$hPen = _GDIPlus_PenCreate(0xFF000000, 2)
$Pen = _GDIPlus_PenCreate(0xFFFFFFFF, 2)
_GDIPlus_PenSetWidth($hPen, 6)
_GDIPlus_GraphicsDrawLine($hGraphic, 10, 250, 10, 250, $hPen)
;Gdi+ ende
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
_GDIPlus_Shutdown()
Case $Button1
$data = GUICtrlRead($Input2)
If $data > 100 Then
$data = 100
GUICtrlSetData($Input2, $data)
EndIf
GUICtrlSetData($Progress1, $data)
GUICtrlSetData($Slider1, $data)
Case $Button2
Exit
EndSwitch
$slider = GUICtrlRead($Slider1)
$test = GUICtrlRead($Progress1)
If $slider <> $test Then
GUICtrlSetData($Progress1, $slider)
GUICtrlSetData($Input1, $slider)
$data = GUICtrlRead($Input2)
If $data > 100 Then
GUICtrlSetData($Input2, 100)
ElseIf $data < 0 Then
GUICtrlSetData($Input2, 0)
EndIf
GUICtrlSetData($Label3, $slider & " %")
GUICtrlSetData($Label4, _StringRepeat("|", $slider))
_GUICtrlStatusBar_SetText($StatusBar1, "Aktuelle %: " & $slider)
_GUICtrlStatusBar_SetText($StatusBar1, "Aktuelle Uhrzeit: " & @HOUR & ":" & @MIN & ":" & @SEC, 1)
_GUICtrlStatusBar_SetText($StatusBar1, "Aktuelles Datum: " & @MDAY & ":" & @MON & ":" & @YEAR, 2)
_GUICtrlStatusBar_SetText($StatusBar1, "Aktueller Benutzer: " & @UserName, 3)
_GDIPlus_GraphicsDrawLine($hGraphic, 10, 250, $slider * 5, 250, $hPen)
_GDIPlus_GraphicsDrawLine($hGraphic, _GDIPlus_PenGetWidth($hPen), 250, _GDIPlus_PenGetWidth($hPen), 250, $Pen)
EndIf
Sleep(50)
WEnd
is son bisschen übung^^
und nun möchte ich dass die linie unten mit dem rest mitwandert
im moment wird sie nur größer
dankeschön schonmal^^
Padmak
Probiers ma mit dem:
[autoit]$hPenBk = _GDIPlus_PenCreate(_GetBkColor(), 2)
_GDIPlus_PenSetWidth($hPenBk, 6)
_GDIPlus_GraphicsDrawLine($hGraphic, 10+($Slider * 5), 250, 10+(100*5) , 250, $hPenBk)
_GDIPlus_GraphicsDrawLine($hGraphic, 10, 250, 10 + ($Slider * 5), 250, $hPen)
Func _GetBkColor()
Local $Color=Hex(BitAND(BitShift(String(Binary(_WinAPI_GetSysColor($COLOR_3DFACE))), 8), 0xFFFFFF))
Return "0xFF" & StringTrimLeft($Color,2)
EndFunc
lgE
jo dankeschön so funktionierts^^
Padmak