Yashied Posted August 25, 2009 Posted August 25, 2009 (edited) Based on rover`s idea.This function will be also included in the next version WinAPIEx.au3 library.expandcollapse popup#Include <GUIConstantsEx.au3> #Include <FontConstants.au3> #Include <WinAPI.au3> #Include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Global Const $STM_SETIMAGE = 0x0172 Global Const $STM_GETIMAGE = 0x0173 Global $hForm, $Pic, $hPic, $tRECT, $Width, $Height, $hBmp, $hDC, $hBack, $hFront, $hFont, $hBitmap, $hObj $hForm = GUICreate('MyGUI', 400, 100) $Pic = GUICtrlCreatePic('', 20, 20, 360, 60) $hPic = GUICtrlGetHandle($Pic) $tRECT = _WinAPI_GetClientRect($hPic) $Width = DllStructGetData($tRECT, 3) - DllStructGetData($tRECT, 1) $Height = DllStructGetData($tRECT, 4) - DllStructGetData($tRECT, 2) $hDC = _WinAPI_GetDC($hPic) $hBack = _WinAPI_CreateCompatibleDC($hDC) $hBitmap = _WinAPI_CreateCompatibleBitmap($hDC, $Width, $Height) _WinAPI_SelectObject($hBack, $hBitmap) $hFront = _WinAPI_CreateCompatibleDC($hDC) $hFont = _WinAPI_CreateFont(65, 0, 0, 0, $FW_NORMAL , 0, 0, 0, $DEFAULT_CHARSET, $OUT_DEFAULT_PRECIS, $CLIP_DEFAULT_PRECIS, $ANTIALIASED_QUALITY, BitOR($DEFAULT_PITCH, $FF_DONTCARE), 'Arial') $hBmp = _WinAPI_CreateSolidBitmap($hPic, _WinAPI_GetSysColor($COLOR_3DFACE), $Width, $Height) _WinAPI_SelectObject($hFront, $hFont) _WinAPI_SelectObject($hFront, $hBmp) _WinAPI_DrawShadowText($hFront, 'Shadow Text', 0xF06000, 0x808080, 3, 3, $tRECT, BitOR($DT_CENTER, $DT_SINGLELINE, $DT_VCENTER)) _WinAPI_BitBlt($hBack, 0, 0, $Width, $Height, $hFront, 0, 0, $MERGECOPY) _WinAPI_ReleaseDC($hPic, $hDC) _WinAPI_DeleteDC($hBack) _WinAPI_DeleteDC($hFront) _WinAPI_DeleteObject($hFont) _WinAPI_DeleteObject($hBmp) _SendMessage($hPic, $STM_SETIMAGE, 0, $hBitmap) $hObj = _SendMessage($hPic, $STM_GETIMAGE) If $hObj <> $hBitmap Then _WinAPI_DeleteObject($hBitmap) EndIf GUISetState() Do Until GUIGetMsg() = -3 ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_DrawShadowText ; Description....: Draws formatted text in the specified rectangle with a drop shadow. ; Syntax.........: _WinAPI_DrawShadowText ( $hDC, $sText, $rgbText, $rgbShadow [, $iXOffset [, $iYOffset [, $tRECT [, $iFlags]]]] ) ; Parameters.....: $hDC - Handle to a device context. ; $sText - The string that contains the text to be drawn. ; $rgbText - The color of the text, in RGB. ; $rgbShadow - The color of the shadow, in RGB. ; $iXOffset - The x-coordinate of where the text should begin. ; $iYOffset - The y-coordinate of where the text should begin. ; $tRECT - $tagRECT structure that contains, in logical coordinates, the rectangle in which the text is to ; be drawn. If this parameter is 0, the size will be equal size of the device context ($hDC). ; $iFlags - The flags that specifies how the text is to be drawn. This parameter can be a combination of ; the formatting text constants ($DT_...). ; Return values..: Success - 1. ; Failure - 0 and sets the @error flag to non-zero. ; Author.........: Rover ; Modified.......: Yashied ; Remarks........: None ; Related........: ; Link...........: @@MsdnLink@@ DrawShadowText ; Example........: Yes ; =============================================================================================================================== Func _WinAPI_DrawShadowText($hDC, $sText, $rgbText, $rgbShadow, $iXOffset = 0, $iYOffset = 0, $tRECT = 0, $iFlags = 0) Local $Ret If Not IsDllStruct($tRECT) Then $tRECT = DllStructCreate($tagRECT) $Ret = DllCall('user32.dll', 'hwnd', 'WindowFromDC', 'hwnd', $hDC) $Ret = DllCall('user32.dll', 'int', 'GetClientRect', 'hwnd', $Ret[0], 'ptr', DllStructGetPtr($tRECT)) If (@error) Or ($Ret[0] = 0) Then Return SetError(1, 0, 0) EndIf EndIf $Ret = DllCall('comctl32.dll', 'int', 'DrawShadowText', 'hwnd', $hDC, 'wstr', $sText, 'uint', -1, 'ptr', DllStructGetPtr($tRECT), 'dword', $iFlags, 'int', _WinAPI_SwitchColor($rgbText), 'int', _WinAPI_SwitchColor($rgbShadow), 'int', $iXOffset, 'int', $iYOffset) If (@error) Or ($Ret[0] = 0) Then Return SetError(1, 0, 0) EndIf Return 1 EndFunc ;==>_WinAPI_DrawShadowText ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_SwitchColor ; Description....: Converts a color from BGR to RGB and back. ; Syntax.........: _WinAPI_SwitchColor ( $iColor ) ; Parameters.....: $iColor - The color to conversion. ; Return values..: Converted color (RGB or BGR - depends on the $iColor value, BGR > RGB > BGR etc). ; Author.........: Yashied ; Modified.......: ; Remarks........: None ; Related........: ; Link...........: None ; Example........: No ; =============================================================================================================================== Func _WinAPI_SwitchColor($iColor) Return BitOR(BitAND($iColor, 0x00FF00), BitShift(BitAND($iColor, 0x0000FF), -16), BitShift(BitAND($iColor, 0xFF0000), 16)) EndFunc ;==>_WinAPI_SwitchColor Edited August 26, 2009 by Yashied My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
Michel Claveau Posted August 26, 2009 Posted August 26, 2009 Hi! It is fun. Thanks. But, in your exemple, you forget _WinAPI_FreeObject()
UEZ Posted August 26, 2009 Posted August 26, 2009 (edited) Just add #include <WinAPIEx.au3> and remove Func _WinAPI_SwitchColor($iColor)!Nice work as usual Yashied >_<UEZ Edited August 26, 2009 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
Yashied Posted August 26, 2009 Author Posted August 26, 2009 Hi!It is fun. Thanks.But, in your exemple, you forget _WinAPI_FreeObject()Fixed. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
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