Jump to content

Recommended Posts

Posted

1) How can i draw a label with the glow effect?

2) How can i create a TextBox with the effect of DwmExtendFrameIntoClientArea like this image? http://www.google.it/imgres?start=127&num=10&hl=it&tbo=d&biw=1366&bih=621&tbm=isch&tbnid=NasJSDbBKF4jfM:&imgrefurl=http://gabriele97.wordpress.com/creare-una-finestra-aero-in-vb-net/&docid=bMBWNcKbz5E2_M&imgurl=http://gabriele97.files.wordpress.com/2010/08/senza-nome1.png&w=1030&h=418&ei=EXDcUJWjOMnh4QTkoIDwCQ&zoom=1&iact=hc&vpx=633&vpy=293&dur=1034&hovh=143&hovw=353&tx=154&ty=84&sig=117168411240675118079&page=6&tbnh=100&tbnw=248&ndsp=26&ved=1t:429,r:31,s:100,i:97

  • Moderators
Posted

Steurendo,

A little bit of searching (the box is at top-right ;)) found this which should get you started. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted (edited)

I found this post about two weeks ago and i've tried a lot of ways to create a glowing label.. but my problem is not create only one label, i'm going to create about 4 labels with glow effect! This my test code (don't work):

#include <Constants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <GDIPlus.au3>

#region Variables
Global Const $DTT_GLOWSIZE = 0x00000800
Global Const $DTT_COMPOSITED = 0x00002000
Global Const $DTT_TEXTCOLOR = 0x00000001
If Not IsDeclared("tagDTTOPTS") Then Global Const $tagDTTOPTS = _
"uint Size;uint Flags;uint clrText;uint clrBorder;uint clrShadow;int TextShadowType;" & $tagPOINT & _
";int BorderSize;int FontPropId;int ColorPropId;int StateId;int ApplyOverlay;int GlowSize;ptr DrawTextCallback;int lParam;"
Global $hUxTheme = DllOpen("uxtheme.dll")
#endregion

_GDIPlus_Startup()

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate('', 303, 200, 192, 124)
Global $hTheme = _WinAPI_OpenThemeData($Form1, "globals", $hUxTheme)
_WinAPI_DwmExtendFrameIntoClientArea($Form1, -1, -1, -1, -1)
GUISetState(@SW_SHOW)
$hDC = _WinAPI_GetWindowDC($Form1)
$hGraphic = _GDIPlus_GraphicsCreateFromHDC($hDC)
$hBrush = _GDIPlus_BrushCreateSolid(0xFF000000)
$hFormat = _GDIPlus_StringFormatCreate()
$hFamily = _GDIPlus_FontFamilyCreate("Arial")
$hFont = _GDIPlus_FontCreate($hFamily, 10, 0)
$tClientRect1 = _WinAPI_GetClientRect($Form1)
DllStructSetData($tClientRect1, "Top", -30)
_DrawGlowingText($hDC, "First glowing label", $tClientRect1, $hTheme)
_WinAPI_DeleteObject($hFont)
_WinAPI_ReleaseDC($Form1, $hDC)
$hDC2 = _WinAPI_GetWindowDC($Form1)
$hGraphic2 = _GDIPlus_GraphicsCreateFromHDC($hDC2)
$hBrush2 = _GDIPlus_BrushCreateSolid(0xFF000000)
$hFormat2 = _GDIPlus_StringFormatCreate()
$hFamily2 = _GDIPlus_FontFamilyCreate("Arial")
$hFont2 = _GDIPlus_FontCreate($hFamily2, 10, 0)
$tClientRect2 = _WinAPI_GetClientRect($Form1)
DllStructSetData($tClientRect2, "Top", 10)
_DrawGlowingText($hDC2, "Second glowing label", $tClientRect2, $hTheme)
#EndRegion ### END Koda GUI section ###

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
_WinAPI_CloseThemeData($hTheme, $hUxTheme)
_GDIPlus_Shutdown()
Exit
EndSwitch
WEnd

Func _WinAPI_DwmExtendFrameIntoClientArea($hWnd, $iLeft, $iRight, $iTop, $iBottom)
$Struct = DllStructCreate("int iLeft; int iRight; int iTop; int iBottom")
DllStructSetData($Struct, "iLeft", $iLeft)
DllStructSetData($Struct, "iRight", $iRight)
DllStructSetData($Struct, "iTop", $iTop)
DllStructSetData($Struct, "iBottom", $iBottom)
GUISetBkColor(0x000000, $hWnd)
Local $Ret = DllCall("dwmapi.dll", "bool", "DwmExtendFrameIntoClientArea", "handle", $hWnd, "ptr", DllStructGetPtr($Struct))
If Not @error Then Return $Ret[0]
EndFunc

Func _DrawGlowingText($hDC, $sText, $tRc, $hTheme, $iGlowSize = 10, $hFont = 0, $iTextClr = -1)
Local $hCDC
Local $hBrush, $hOldBrush
Local $tRcText
Local $tBI, $tDTO
Local $hDIBBmp, $hOldBmp
Local $hOldFont
Local $tST
Local $iFlags = BitOR($DTT_GLOWSIZE, $DTT_COMPOSITED)

$hCDC = _WinAPI_CreateCompatibleDC($hDC)

$tBI = DllStructCreate($tagBITMAPINFO)
DllStructSetData($tBI, "Size", DllStructGetSize($tBI)-4)
DllStructSetData($tBI, "Width", DllStructGetData($tRc, "Right")-DllStructGetData($tRc, "Left"))
DllStructSetData($tBI, "Height", -(DllStructGetData($tRc, "Bottom")-DllStructGetData($tRc, "Top")))
DllStructSetData($tBI, "Planes", 1)
DllStructSetData($tBI, "BitCount", 32)
DllStructSetData($tBI, "Compression", 0) ; BI_RGB

$hDIBBmp = _WinAPI_CreateDIBSection($hDC, $tBI)
$hOldBmp = _WinAPI_SelectObject($hCDC, $hDIBBmp)
If $hFont Then $hOldFont = _WinAPI_SelectObject($hCDC, $hFont)

$tDTO = DllStructCreate($tagDTTOPTS)
DllStructSetData($tDTO, "Size", DllStructGetSize($tDTO))

If $iTextClr <> -1 Then
$iFlags = BitOR($iFlags, $DTT_TEXTCOLOR)
DllStructSetData($tDTO, "clrText", $iTextClr)
EndIf


DllStructSetData($tDTO, "Flags", $iFlags)
DllStructSetData($tDTO, "GlowSize", $iGlowSize)

_WinAPI_DrawThemeTextEx($hTheme, $hCDC, 0, 0, $sText, _
BitOR($DT_SINGLELINE, $DT_CENTER, $DT_VCENTER, $DT_NOPREFIX), $tRc, $tDTO)

_WinAPI_BitBlt($hDC, DllStructGetData($tRc, "Left"), DllStructGetData($tRc, "Top"), _
DllStructGetData($tRc, "Right")-DllStructGetData($tRc, "Left"), _
DllStructGetData($tRc, "Bottom")-DllStructGetData($tRc, "Top"), $hCDC, 0, 0, 0xCC0020) ; SRCCOPY

_WinAPI_SelectObject($hCDC, $hOldBmp)
If $hFont Then _WinAPI_SelectObject($hCDC, $hOldFont)
_WinAPI_DeleteObject($hDIBBmp)
_WinAPI_DeleteDC($hCDC)
EndFunc

Func _WinAPI_CreateDIBSection($hDC, Const ByRef $tBmpInfo, $iUsage = 0, $pBits = 0, $hSecond = 0, $iOffset = 0)
Local $aResult = DllCall("gdi32.dll", "hwnd", "CreateDIBSection", "hwnd", $hDC, "ptr", DllStructGetPtr($tBmpInfo), _
"uint", $iUsage, "ptr", $pBits, "hwnd", $hSecond, "uint", $iOffset)

If @error Then Return SetError(@error, @extended, 0)
If $aResult[0] = 87 Then Return SetError(1, 1, 0); 87 = ERROR_INVALID_PARAMETER
If $aResult[0] = 0 Then Return SetError(1, 2, 0)
Return SetError(0, 0, $aResult[0])
EndFunc

Func _WinAPI_OpenThemeData($hWnd, $sClassList, $hDll = "uxtheme.dll")
Local $aResult = DllCall($hDll, "hwnd", "OpenThemeData", "hwnd", $hWnd, "wstr", $sClassList)

If @error Then Return SetError(@error, @extended, 0)
Return SetError(0, 0, $aResult[0])
EndFunc

Func _WinAPI_CloseThemeData($hTheme, $hDll = "uxtheme.dll")
Local $aResult = DllCall($hDll, "int", "CloseThemeData", "hwnd", $hTheme)

If @error Then Return SetError(@error, @extended, 0)
Return SetError(0, $aResult[0], $aResult[0] = 0)
EndFunc

Func _WinAPI_DrawThemeTextEx($hTheme, $hDC, $iPartId, $iStateId, $sText, $iFlags, ByRef $tRect, Const ByRef $tDTTOPTS)
Local $aResult = DllCall("uxtheme.dll", "int", "DrawThemeTextEx", "ptr", $hTheme, "hwnd", $hDC, "int", $iPartId, "int", $iStateId, _
"wstr", $sText, "int", -1, "uint", $iFlags, "ptr", DllStructGetPtr($tRect), "ptr", DllStructGetPtr($tDTTOPTS))

If @error Then Return SetError(@error, @extended, 0)
If $aResult[0] <> 0 Then Return SetError(1, 0, 0)
Return SetError(0, 0, $aResult[0] = 0)
EndFunc

It doesn't draw the two labels.. how can i do?

Edited by Steurendo
Posted

Is it possible that the reason you're only getting the second label is because it covers the first label? You are using the same sized label for both because you're using the same code to get the clientrect area.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

  Reveal hidden contents

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

  • 3 years later...
Posted
  On 12/28/2012 at 10:00 PM, Steurendo said:

And then how can i do? I'm noob with GDI :(

Expand  

ehm, noob to noob since no reply.

#include <GUIConstantsEx.au3>
#include <GDIPlus.au3>
#include <GUIConstants.au3>
#include <WinAPIGdi.au3>
;#include <Array.au3>
    ;AutoItSetOption("GUIOnEventMode", 1)
    Opt("GUIOnEventMode", 1)
    Global  $iFontSize = 76 ,$iW = $iFontSize-4, $nBorder=Mod($iFontSize, 14), $iH = $iFontSize+($nBorder*3)
    ;
    Global  $_afontData =StringSplit('QWERTYUIOPASDFGHJKL/ZXCVBNM.,`', "")
    Global  $nKeys=ubound($_afontData)
    Global  $_aGDIdraw[$nKeys][3]
    ;_ArrayDisplay($_afontData, '_WinAPI_EnumFontFamilies')
    ;_ArrayDisplay($_aGDIdraw, '_WinAPI_EnumFontFamilies')
    ;msgbox(0,0,$nKeys)
        Global  $sTTFont="Bauhaus 93"
 ;$sTTFont="Swiss921 BT"
    ;$sTTFont="Futura XBlkCnIt BT"
    ;$sTTFont="Balloon"
    ;$sTTFont="Stencil"
    ;$sTTFont="Showcard Gothic"
    ;$sTTFont="Ravie"
    ;$sTTFont="Cooper Black"
    ;$sTTFont="Bauhaus 93"
    ;$sTTFont="Algerian"
    ;$sTTFont="Mistral"
    ;$sTTFont="Haettenschweiler"
    ;
Main()
Func Main() 
    Example()
    My_AP_MouseOnMove()
    While Sleep(10)
    WEnd
EndFunc
;==>
Func Example()
;
    Global  $hGUI = GUICreate("GDI+", $iW*10, $iH*4,200,150, _ 
     $WS_POPUP, BitOR($WS_EX_LAYERED,$WS_EX_NOACTIVATE,$WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit")
    GUISetOnEvent($GUI_EVENT_MOUSEMOVE, "My_AP_MouseOnMove")
 GUISetCursor(0)
                    Global  $hButton_ok = GUICtrlCreateButton("select",0,0,60)
                    Global  $hButton_Exit = GUICtrlCreateButton("_Exit",100,0,60)
                    Global  $_cfont = GUICtrlCreateLabel("carry that", 200, 0, 90, 20,-1, $GUI_WS_EX_PARENTDRAG)
                    GUISetState(@SW_SHOW)
                        GUISetBkColor(0xFFFFFF, $hGUI)
                        _WinAPI_SetLayeredWindowAttributes($hGUI, 0xFFFFFF, 95)
                    GUICtrlSetOnEvent($hButton_ok, "_select")
                    GUICtrlSetOnEvent($hButton_Exit, "_Exit")
; Initialize GDI+ library
                 _GDIPlus_Startup()
    Global $hGraphics =         _GDIPlus_GraphicsCreateFromHWND($hGUI)
    Global $hBmp_Buffer =   _GDIPlus_BitmapCreateFromGraphics($iW*10, $iH*3, $hGraphics)
    Global $hGfx_Bufffer =      _GDIPlus_ImageGetGraphicsContext($hBmp_Buffer)
                 _GDIPlus_GraphicsSetSmoothingMode($hGfx_Bufffer, $GDIP_SMOOTHINGMODE_HIGHQUALITY)
;
    Global $hBrush_NA =  _GDIPlus_BrushCreateSolid(0xFF000066)
    Global $hBrush_A =   _GDIPlus_BrushCreateSolid(0xFF00FF00)
    Global $hPen_NA =   _GDIPlus_PenCreate(0xFF666600, 1)
    Global $hPen_A =    _GDIPlus_PenCreate(0xFF00FF00, $nBorder)

    Global $hFormat =    _GDIPlus_StringFormatCreate()
                      _GDIPlus_StringFormatSetAlign($hFormat, 1);left
    Global $hFamily = _GDIPlus_FontFamilyCreate($sTTFont)
    ;
    local $row=0,$col=.3
    for $i=1 to $nKeys-1
                $_aGDIdraw[$i][1]= _GDIPlus_PathCreate()
                $_aGDIdraw[$i][2]= _GDIPlus_RectFCreate($iW*$row, $iH*$col, $iW, $iH);sleep(10)
                _GDIPlus_PathAddString($_aGDIdraw[$i][1], $_afontData[$i], $_aGDIdraw[$i][2], $hFamily, 0, $iFontSize, $hFormat)
                $row+=.9
                If Not Mod($i, 10) Then
                    $row=0
                    $col+=.7
                Endif
    next
EndFunc
;==> 
Func My_AP_MouseOnMove()
    Local $sInfo = ""
    Global  $aMouse = GUIGetCursorInfo()
    _GDIPlus_GraphicsClear($hGfx_Bufffer, 0x00003000)
    for $i=1 to $nKeys-1
        _GDIPlus_GraphicsFillPath($hGfx_Bufffer, $_aGDIdraw[$i][1], $hBrush_NA)
                                    GUICtrlSetCursor(-1, 7)
        _GDIPlus_GraphicsDrawPath($hGfx_Bufffer, $_aGDIdraw[$i][1], $hPen_NA)
                                    GUICtrlSetCursor(-1, 4)
        If _GDIPlus_PathIsOutlineVisiblePoint($_aGDIdraw[$i][1], $aMouse[0], $aMouse[1], $hPen_A, $hGfx_Bufffer) then
                _GDIPlus_GraphicsDrawPath($hGfx_Bufffer, $_aGDIdraw[$i][1], $hPen_A)
                $sInfo = "Cap; "&$_afontData[$i]
        Endif
        If _GDIPlus_PathIsVisiblePoint($_aGDIdraw[$i][1], $aMouse[0], $aMouse[1], $hGraphics) then
                _GDIPlus_GraphicsFillPath($hGfx_Bufffer, $_aGDIdraw[$i][1], $hBrush_A)
                $sInfo = StringLower($_afontData[$i])
        Endif
    next
    ToolTip($sInfo)
    _GDIPlus_GraphicsDrawImage($hGraphics, $hBmp_Buffer, 0, 0)
EndFunc   ;==>My_AP_MouseOnMove

Func _select()
 _Dispose()
    sleep(200)
    $sTTFont="Bauhaus 93"
    $iFontSize = 46
    $nBorder=Mod($iFontSize, 14)
    $iW = $iFontSize-4
    $iH = $iFontSize+($nBorder*3)
    tooltip($nBorder&" - "&$iH)
 Example()
EndFunc  
 ;==>
Func _Dispose()
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    for $i=1 to $nKeys-1
    _GDIPlus_PathDispose($_aGDIdraw[$i][1])
    next
    _GDIPlus_BrushDispose($hBrush_NA)
    _GDIPlus_BrushDispose($hBrush_A)
    _GDIPlus_PenDispose($hPen_NA)
    _GDIPlus_PenDispose($hPen_A)

    _GDIPlus_GraphicsDispose($hGfx_Bufffer)
    _GDIPlus_BitmapDispose($hBmp_Buffer)
    _GDIPlus_GraphicsDispose($hGraphics)
    _GDIPlus_Shutdown()
    GUIDelete($hGUI)
EndFunc  
 ;==>
Func _Exit()
 _Dispose()
    Exit
EndFunc   ;==>_Exit

 

Posted

This thread is over 3 1/2 years old, the original poster hasn't been here in over 3 years. Your solution isn't going to help him now.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

  Reveal hidden contents

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted (edited)
  On 6/13/2016 at 1:30 AM, BrewManNH said:

This thread is over 3 1/2 years old, the original poster hasn't been here in over 3 years. Your solution isn't going to help him now.

Expand  

Obviously, But! it helps seekers who search net at task base as i found that post like this way. my solution is task related.

lets see how many likes it.

Edited by guiltyking

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...