Ich möchte eine Art Sprechblase auf dem Bildschirm zeigen. Also eine Tooltip mit dem aussehen eines TrayTips.
Dazu sollte es graphisch gut aussehen.
Ich ging die Sache so an, das ich die rechte Seite und die linke Seite des Ballons als Bitmap über GDi+ und
; ===============================================================================================================================
; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image.
; ===============================================================================================================================
Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
if ($hWnd = $hGUI2) and ($iMsg = $WM_NCHITTEST) then Return $HTCAPTION
EndFunc
; ===============================================================================================================================
; SetBitMap
; ===============================================================================================================================
Func SetBitmap($hGUI, $hImage, $iOpacity)
Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
$hScrDC = _WinAPI_GetDC(0)
$hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
$hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
$tSize = DllStructCreate($tagSIZE)
$pSize = DllStructGetPtr($tSize )
DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth ($hImage))
DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
$tSource = DllStructCreate($tagPOINT)
$pSource = DllStructGetPtr($tSource)
$tBlend = DllStructCreate($tagBLENDFUNCTION)
$pBlend = DllStructGetPtr($tBlend)
DllStructSetData($tBlend, "Alpha" , $iOpacity )
DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
_WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
_WinAPI_ReleaseDC (0, $hScrDC)
_WinAPI_SelectObject($hMemDC, $hOld)
_WinAPI_DeleteObject($hBitmap)
_WinAPI_DeleteDC ($hMemDC)
EndFunc
zeige.
Dann müsste ich noch die Länge des Textes ausrechnen und so viel wie nötig Zwischenelemte zwischen Anfangs-Ballon und End-Ballon schieben.
Und dann den Text mit GDI noch dazufügen.
Da ich aber keine Ahnung von GDI habe und auch nicht mehr weiter weiß brauch ich euer Hilfe.
Source:
Spoiler anzeigen
#include
#include
#include
#include
#include
; ===============================================================================================================================
; Description ...: Shows how to create an alpha blended form
; Author ........: Paul Campbell (PaulIA)
; Notes .........: The images used for this demo MUST be 32 bpp with alpha channel
; Credits .......: Thanks to lod3n for supplying links to the technical documentation that was necessary to build this demo
; ===============================================================================================================================
; ===============================================================================================================================
; Global constants
; ===============================================================================================================================
Global Const $AC_SRC_ALPHA = 1
; ===============================================================================================================================
; Global variables
; ===============================================================================================================================
Global $hGUI1, $hGUI2, $iLabel1, $iLabel2, $iSlider, $hImage
; Create GUI
$hGUI1 = GUICreate("Alpha Blend", 400, 100)
$iLabel1 = GUICtrlCreateLabel ("Adjust slider to change opacity level: (0-255)", 84, 10, 380, 20)
$iSlider = GUICtrlCreateSlider(10, 32, 380, 40)
$iLabel2 = GUICtrlCreateLabel ("Drag the layered window around your desktop" , 80, 74, 380, 20)
GUICtrlSetLimit($iSlider, 255, 0)
GUICtrlSetData ($iSlider, 255)
GUISetState()
; Create layered child window
$hGUI2 = GUICreate("Test", 400, 400, -1, -1, -1, $WS_EX_LAYERED, $hGUI1)
GUISetState()
;===================================================================================================================================
[/autoit] [autoit][/autoit] [autoit]; Load layered image
_GDIPlus_Startup()
$x = 20
$y = 200
$pix = 320 ;die Zahl muss duch 20 teilbar sein
; Erstellt vom kompletten Bildschirm einen Screenshot
$hBitmap1 = _ScreenCapture_Capture("", 0, 0, 400, 400)
$hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBitmap1)
$hGraphic = _GDIPlus_ImageGetGraphicsContext($hImage1)
; Lädt die Bitmaps
$lb = _GDIPlus_ImageLoadFromFile(@scriptdir & "\img\lballon.png")
$mb = _GDIPlus_ImageLoadFromFile(@scriptdir & "\img\mballon.png")
$rb = _GDIPlus_ImageLoadFromFile(@scriptdir & "\img\rballon.png")
; Zeichnet ein Bild in ein anderes
_GDIPlus_GraphicsDrawImageRect($hGraphic, $lb, $x, $y, 20, 40) ;left
For $i = 20 To $pix Step 20
_GDIPlus_GraphicsDrawImageRect($hGraphic, $mb, $i + 20, $y, 20, 40) ;middle
next
_GDIPlus_GraphicsDrawImageRect($hGraphic, $rb, $x + 20 + $pix , $y, 20, 40) ;right
;Zeigt das fertige Bild
SetBitMap($hGUI2, $hImage1, 255)
;===================================================================================================================================
[/autoit] [autoit][/autoit] [autoit]; Register notification messages
GUIRegisterMsg($WM_HSCROLL , "WM_HSCROLL" )
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
; Loop until user exits
do
until GUIGetMsg() =$GUI_EVENT_CLOSE
; Release resources
_GDIPlus_ImageDispose($hImage1)
_GDIPlus_Shutdown()
; ===============================================================================================================================
; Handle the WM_HSCROLL notificaton so that we can change the opacity in real time
; ===============================================================================================================================
Func WM_HSCROLL($hWnd, $iMsg, $iwParam, $ilParam)
SetBitMap($hGUI2, $hImage1, GUICtrlRead($iSlider))
EndFunc
; ===============================================================================================================================
; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image.
; ===============================================================================================================================
Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
if ($hWnd = $hGUI2) and ($iMsg = $WM_NCHITTEST) then Return $HTCAPTION
EndFunc
; ===============================================================================================================================
; SetBitMap
; ===============================================================================================================================
Func SetBitmap($hGUI, $hImage, $iOpacity)
Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend
$hScrDC = _WinAPI_GetDC(0)
$hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
$hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
$tSize = DllStructCreate($tagSIZE)
$pSize = DllStructGetPtr($tSize )
DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth ($hImage))
DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
$tSource = DllStructCreate($tagPOINT)
$pSource = DllStructGetPtr($tSource)
$tBlend = DllStructCreate($tagBLENDFUNCTION)
$pBlend = DllStructGetPtr($tBlend)
DllStructSetData($tBlend, "Alpha" , $iOpacity )
DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
_WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
_WinAPI_ReleaseDC (0, $hScrDC)
_WinAPI_SelectObject($hMemDC, $hOld)
_WinAPI_DeleteObject($hBitmap)
_WinAPI_DeleteDC ($hMemDC)
EndFunc
Bitmaps und Script hängen auch an: