3 simpatiche funzioni ;)

« Older   Newer »
  Share  
iBiscottino
CAT_IMG Posted on 22/12/2012, 21:07     +3   +1   -1




La prima è IsOver che verifica se il mouse è sopra ad un controllo.. Esempio un Label :)
CODICE
Func IsOver($hWnd, $hCtrl)
       If $hWnd = "" Or $hCtrl = "" Then
               SetError(1)
               Return False
       Else
               $CI = GUIGetCursorInfo($hWnd)
               If $CI[4] = $hCtrl Then
                       Return True
               Else
                       Return False
               EndIf
       EndIf
EndFunc   ;==>IsOver

Le altre due sono funzioni grafiche; la prima è ApplyWinFrame che estende lo stile Windows su tutta la GUI:
CODICE
Func ApplyWinFrame($hWnd)
       $Struct = DllStructCreate("int wCoord; int hCoord; int lCoord; int tCoord")
       DllStructSetData($Struct, "wCoord", -1)
       DllStructSetData($Struct, "hCoord", -1)
       DllStructSetData($Struct, "lCoord", -1)
       DllStructSetData($Struct, "tCoord", -1)
       $Ptr = DllStructGetPtr($Struct)
       GUISetBkColor(0x000000, $hWnd)
       DllCall("dwmapi.dll", "int", "DwmExtendFrameIntoClientArea", "hwnd", $hWnd, "ptr", $Ptr)
EndFunc   ;==>ApplyWinFrame

Infine c'è ApplyBlurFrame, che come ApplyWinFrame modifica la grafica della GUI mettendo però uno stile sfocato:
CODICE
Func ApplyBlurFrame($hWnd)
       $Struct = DllStructCreate("dword;int;ptr;int")
       DllStructSetData($Struct, 1, 0x00000001)
       DllStructSetData($Struct, 2, "1")
       DllStructSetData($Struct, 3, -1)
       DllStructSetData($Struct, 4, "1")
       $Ptr = DllStructGetPtr($Struct)
       GUISetBkColor(0x000000, $hWnd)
       DllCall("dwmapi.dll", "int", "DwmEnableBlurBehindWindow", "hwnd", $hWnd, "ptr", $Ptr)
EndFunc   ;==>ApplyBlurFrame

Non ho tempo per postare gli esempi delle funzioni ma mi sembrano abbastanza intuitive e.e
Provatele e ditemi se vi piacciono :)
 
Top
th1sk
CAT_IMG Posted on 23/12/2012, 00:13     +1   -1




Sei un grande
 
Top
iBiscottino
CAT_IMG Posted on 23/12/2012, 09:46     +1   -1




Grazie :)
 
Top
»Master
CAT_IMG Posted on 23/12/2012, 14:08     +1   -1




Bravissimo, comunque la prima funzione ritengo un po banale xD
 
Top
CAT_IMG Posted on 23/12/2012, 16:00     +1   -1

So implementare gli object

Group:
Admin
Posts:
1,215
Reputazione:
+150

Status:


Beh le altre due sono solo chiamate ad API :asd:
Comunque, bel lavoro :)
 
Top
iBiscottino
CAT_IMG Posted on 23/12/2012, 20:44     +1   -1




Si la prima è abbastanza banale però può rivelarsi utile.. come in un mio caso in cui dovevo creare un bottone-immagine in stile è quella funzione si è rivelata parecchio comoda :)
Ormai ero abituato alla funzione che estende completamente lo stile di Windows (sempre per un progetto) e mi sono scordato di postare quella in cui si possono settare i margini:
CODICE
Func ApplyWinFrameArea($hWnd, $Left, $Right, $Top, $Bottom)
       $Struct = DllStructCreate("int Left; int Right; int Top; int Bottom")
       DllStructSetData($Struct, "Left", $Left)
       DllStructSetData($Struct, "Right", $Right)
       DllStructSetData($Struct, "Top", $Top)
       DllStructSetData($Struct, "Bottom", $Bottom)
       $Ptr = DllStructGetPtr($Struct)
       GUISetBkColor(0x000000, $hWnd)
       DllCall("dwmapi.dll", "int", "DwmExtendFrameIntoClientArea", "hwnd", $hWnd, "ptr", $Ptr)
EndFunc   ;==>ApplyWinFrameArea


Ora già che ci sono posto un paio di esempi:
CODICE
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
HotKeySet("{ESC}", "_Exit")
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("", 287, 220, 192, 146, BitOR($WS_MINIMIZEBOX,$WS_GROUP))
ApplyWinFrameArea($Form1, 3, 3, 40, 40)
ApplyBlurFrame($Form1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
WEnd

Func _Exit()
       Exit
EndFunc

Func ApplyWinFrameArea($hWnd, $Left, $Right, $Top, $Bottom)
       $Struct = DllStructCreate("int Left; int Right; int Top; int Bottom")
       DllStructSetData($Struct, "Left", $Left)
       DllStructSetData($Struct, "Right", $Right)
       DllStructSetData($Struct, "Top", $Top)
       DllStructSetData($Struct, "Bottom", $Bottom)
       $Ptr = DllStructGetPtr($Struct)
       GUISetBkColor(0x000000, $hWnd)
       DllCall("dwmapi.dll", "int", "DwmExtendFrameIntoClientArea", "hwnd", $hWnd, "ptr", $Ptr)
EndFunc   ;==>ApplyWinFrameArea

Func ApplyBlurFrame($hWnd)
       $Struct = DllStructCreate("dword;int;ptr;int")
       DllStructSetData($Struct, 1, 0x00000001)
       DllStructSetData($Struct, 2, "1")
       DllStructSetData($Struct, 3, -1)
       DllStructSetData($Struct, 4, "1")
       $Ptr = DllStructGetPtr($Struct)
       GUISetBkColor(0x000000, $hWnd)
       DllCall("dwmapi.dll", "int", "DwmEnableBlurBehindWindow", "hwnd", $hWnd, "ptr", $Ptr)
EndFunc   ;==>ApplyBlurFrame

CODICE
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("", 190, 120, -1, -1, BitOR($WS_MINIMIZEBOX,$WS_GROUP))
$Label1 = GUICtrlCreateLabel("Questo label cambia colore!", 25, 35, 200, 15)
$Button1 = GUICtrlCreateButton("Esci", 80, 60, 50, 20)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
       While IsOver($Form1, $Label1)
               GUICtrlSetColor($Label1, 0x0000FF)
               While IsOver($Form1, $Label1)
                       If GUIGetMsg() = $Label1 Then MsgBox(0, "", "Label premuto")
               WEnd
               GUICtrlSetColor($Label1, 0x000000)
       WEnd
       $nMsg = GUIGetMsg()
       Switch $nMsg
               Case $Button1
                       Exit
       EndSwitch
WEnd

Func IsOver($hWnd, $hCtrl = Default)
       If $hWnd = "" Or $hCtrl = "" Then
               SetError(1)
               Return False
       Else
               $CI = GUIGetCursorInfo($hWnd)
               If $CI[4] = $hCtrl Then
                       Return True
               Else
                       Return False
               EndIf
       EndIf
EndFunc   ;==>IsOver
 
Top
5 replies since 22/12/2012, 21:07   308 views
  Share