Ich hatte die letzte Stunde Langeweile, und so ist ein Notitzzettel herausgekommen, der ausschließlich mit GDI+ gezeichnet wird.
Ist zwar nichts besonderes, aber vieleicht hilft es jemandem, der sich noch nicht so gut mit GDI+ auskennt.
Das ganze wird per Traymenü gesteuert.
Kretik ist gerne gesehen.
Edit:
- Rechtschreibfehler beseitigt. - Zacharja
- Editfeld direkt über den Zettel gelegt. - Idee von UEZ
- X zum schließen hinzugefügt.
Wie ich die Fontauswahl einbinden könnte, weiß ich noch nicht so genau, bin aber am überlegen.
GDI+ Notitzzettel
#include <GDIPlus.au3>
#include <Misc.au3>
HotKeySet("{ESC}", "_Close")
[/autoit] [autoit][/autoit] [autoit]Opt("GUIOnEventMode", 1)
[/autoit] [autoit][/autoit] [autoit]Global $hWnd, $EditGUI, $Edit, $hGraphic, $hBitmap, $backbuffer, $brush1, $brush2, $pen1, $pen2, $pen3, $hFormat, $hFamily, $hFont, $tLayout, $aInfo
Global $ScreenDc, $dc, $tSize, $pSize, $tSource, $pSource, $tBlend, $pBlend, $tPoint, $pPoint, $gdibitmap
Global $title = "Notizzettel", _
$user32 = DllOpen("user32.dll"), _
$width = 150, _
$height = 200
Global $notice = "Durch drücken und ziehen des Eselohrs, können Sie die Fensterposition ändern. " & @CRLF & @CRLF & _
"Wenn Sie die Notiz ändern wollen, klicken Sie auf die bereits vorhandene Notiz. " & @CRLF & @CRLF & _
"Um den Notizzettel zu schließen, klicken Sie auf das rote X. "
Global $WinPos[4], $MousePos[2]
[/autoit] [autoit][/autoit] [autoit]Global $points[6][2]
[/autoit] [autoit][/autoit] [autoit]$points[0][0] = 5
$points[1][0] = 0
$points[1][1] = 20
$points[2][0] = 20
$points[2][1] = 0
$points[3][0] = 149
$points[3][1] = 0
$points[4][0] = 149
$points[4][1] = 199
$points[5][0] = 0
$points[5][1] = 199
$hWnd = GUICreate($title, $width, $height, -1, -1, 0x80000000, BitOR(0x00000080, 0x00080000, 0x00000008))
[/autoit] [autoit][/autoit] [autoit]_Startup()
[/autoit] [autoit][/autoit] [autoit]_DrawSheet()
[/autoit] [autoit][/autoit] [autoit]GUISetState(@SW_SHOW, $hWnd)
[/autoit] [autoit][/autoit] [autoit]$EditGUI = GuiCreate($title & " Edit", 110, 155, -1, -1, BitOr(0x80000000, 0x00000200), BitOR(0x00000080, 0x00000008))
$Edit = GUICtrlCreateEdit($notice, 0, 0, 110, 155, BitOR(0x1000, 0x0004, 0x0040), 0x00000204)
GUISetState(@SW_HIDE, $EditGUI)
[/autoit] [autoit][/autoit] [autoit]While 1
If _IsPressed("01") And WinActive($hWnd) Then
$WinPos = WinGetPos($hWnd)
$MousePos = MouseGetPos()
If $MousePos[0] >= $WinPos[0] And $MousePos[0] <= $WinPos[0] + 20 And $MousePos[1] >= $WinPos[1] And $MousePos[1] <= $WinPos[1] + 20 Then
GUISetState(@SW_HIDE, $EditGUI)
MouseMove($WinPos[0] + 10, $WinPos[1] + 10, 0)
GUISetCursor(9, 1, $hWnd)
While _IsPressed("01")
$MousePos = MouseGetPos()
WinMove($hWnd, "", $MousePos[0] - 10, $MousePos[1] - 10)
WEnd
GUISetCursor(2, 0, $hWnd)
ElseIf $MousePos[0] >= $WinPos[0] + 20 And $MousePos[0] <= $WinPos[0] + 130 And $MousePos[1] >= $WinPos[1] + 25 And $MousePos[1] <= $WinPos[1] + 185 Then
WinMove($EditGUI, "", $WinPos[0] + 20, $WinPos[1] + 25)
GUISetState(@SW_SHOW, $EditGUI)
ElseIf $MousePos[0] >= $WinPos[0] + 135 And $MousePos[0] <= $WinPos[0] + 145 And $MousePos[1] >= $WinPos[1] + 5 And $MousePos[1] <= $WinPos[1] + 15 Then
_Close()
Else
GUISetState(@SW_HIDE, $EditGUI)
EndIf
EndIf
If _IsPressed("0D") And _IsPressed("11") And WinActive($EditGUI) Then
$notice = GUICtrlRead($Edit)
GUISetState(@SW_HIDE, $EditGUI)
_DrawSheet()
EndIf
Sleep(10)
WEnd
Func _Startup()
_GDIPlus_Startup()
$hGraphic = _GDIPlus_GraphicsCreateFromHWND($hWnd)
$hBitmap = _GDIPlus_BitmapCreateFromGraphics($width, $height, $hGraphic)
$backbuffer = _GDIPlus_ImageGetGraphicsContext($hBitmap)
_GDIPlus_GraphicsSetSmoothingMode($backbuffer, 4)
$brush1 = _GDIPlus_BrushCreateSolid(0xFFF8F8FF)
$brush2 = _GDIPlus_BrushCreateSolid()
$pen1 = _GDIPlus_PenCreate(0xFF4169E1)
$pen2 = _GDIPlus_PenCreate(0x224169E1)
$pen3 = _GDIPlus_PenCreate(0xFFFF0000, 2)
$ScreenDc = _WinAPI_GetDC($hWnd)
$dc = _WinAPI_CreateCompatibleDC($ScreenDc)
$tSize = DllStructCreate($tagSIZE)
$pSize = DllStructGetPtr($tSize)
DllStructSetData($tSize, "X", $width)
DllStructSetData($tSize, "Y", $height)
$tSource = DllStructCreate($tagPOINT)
$pSource = DllStructGetPtr($tSource)
$tBlend = DllStructCreate($tagBLENDFUNCTION)
$pBlend = DllStructGetPtr($tBlend)
DllStructSetData($tBlend, "Alpha", 255)
DllStructSetData($tBlend, "Format", 1)
$tPoint = DllStructCreate($tagPOINT)
$pPoint = DllStructGetPtr($tPoint)
DllStructSetData($tPoint, "X", 0)
DllStructSetData($tPoint, "Y", 0)
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate("Arial")
$hFont = _GDIPlus_FontCreate($hFamily, 9, 0, 2)
$tLayout = _GDIPlus_RectFCreate(20, 25, 110, 155)
EndFunc
Func _Close()
GUISetState(@SW_MINIMIZE, $hWnd)
_GDIPlus_GraphicsDispose($backbuffer)
_GDIPlus_BitmapDispose($hBitmap)
_GDIPlus_GraphicsDispose($hGraphic)
_GDIPlus_Shutdown()
DllClose($user32)
Exit
EndFunc
Func _DrawSheet()
_GDIPlus_GraphicsFillPolygon($backbuffer, $points, $brush1)
_GDIPlus_GraphicsDrawPolygon($backbuffer, $points, $pen1)
[/autoit] [autoit][/autoit] [autoit]_GDIPlus_GraphicsDrawLine($backbuffer, $points[1][0], $points[1][1], 20, 20, $pen1)
_GDIPlus_GraphicsDrawLine($backbuffer, 20, 20, $points[2][0], $points[2][1], $pen1)
_GDIPlus_GraphicsDrawLine($backbuffer, 4, 16, 4, 199, $pen2)
_GDIPlus_GraphicsDrawLine($backbuffer, 9, 12, 9, 199, $pen2)
_GDIPlus_GraphicsDrawLine($backbuffer, 14, 6, 14, 199, $pen2)
For $i = 19 To $width Step +5
_GDIPlus_GraphicsDrawLine($backbuffer, $i, 0, $i, 199, $pen2)
Next
_GDIPlus_GraphicsDrawLine($backbuffer, 16, 4, 149, 4, $pen2)
_GDIPlus_GraphicsDrawLine($backbuffer, 12, 9, 149, 9, $pen2)
_GDIPlus_GraphicsDrawLine($backbuffer, 5, 14, 149, 14, $pen2)
For $i = 19 To $height Step +5
_GDIPlus_GraphicsDrawLine($backbuffer, 0, $i, 149, $i, $pen2)
Next
_GDIPlus_GraphicsDrawLine($backbuffer, 135, 5, 145, 15, $pen3)
_GDIPlus_GraphicsDrawLine($backbuffer, 135, 15, 145, 5, $pen3)
$aInfo = _GDIPlus_GraphicsMeasureString($backbuffer, $notice, $hFont, $tLayout, $hFormat)
_GDIPlus_GraphicsDrawStringEx($backbuffer, $notice, $hFont, $aInfo[0], $hFormat, $brush2)
$gdibitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
_WinAPI_SelectObject($dc, $gdibitmap)
_WinAPI_UpdateLayeredWindow($hWnd, $ScreenDc, 0, $pSize, $dc, $pSource, 0, $pBlend, 2)
_WinAPI_DeleteObject($gdibitmap)
EndFunc