
NHD
Members-
Posts
11 -
Joined
-
Last visited
Recent Profile Visitors
464 profile views
NHD's Achievements

Seeker (1/7)
19
Reputation
-
jaberwacky reacted to a post in a topic: True AutoIt multi-threading!
-
dmob reacted to a post in a topic: True AutoIt multi-threading!
-
milos83 reacted to a post in a topic: True AutoIt multi-threading!
-
robertocm reacted to a post in a topic: Chromium Embedded Framework for AutoIt3
-
yuser reacted to a post in a topic: True AutoIt multi-threading!
-
GreeNerO reacted to a post in a topic: True AutoIt multi-threading!
-
Loc reacted to a post in a topic: True AutoIt multi-threading!
-
Gianni reacted to a post in a topic: True AutoIt multi-threading!
-
This is my experiment to achieve multi-threading in AutoIt 😅 Source code, usage and examples in this github repo: https://github.com/nomi-san/true-autoit-multi-threading
-
mLipok reacted to a post in a topic: Chromium Embedded Framework for AutoIt3
-
Parsix reacted to a post in a topic: MetroGUI UDF v5.1 - Windows 10 style buttons, toggles, radios, menu etc.
-
CefApp should use for one application, but CefClient (includes many event handles from this) should use each browser. You can see, https://github.com/small-autoit/mb/blob/master/mini_browser.au3 I used two CefClient for two browser handle ($browser_client and $toolbar_client). And the browser window is created after toolbar created, via OnAfterCreated event. func toolbar_onAfterCreated($browser) if ($toolbar_hwnd==0) then $toolbar_frame = $browser.GetMainFrame() $toolbar_hwnd = ptr($browser.GetHost().GetWindowHandle()) _MoveWindow($toolbar_hwnd, 0, 0, $width, $toolbar_height, 1) _ShowWindow($toolbar_hwnd) $cef.CreateBrowser($cef_winfo.__ptr, $browser_client.__ptr, $url, $cef_bs.__ptr, null) endif endfunc On the other hand, one client can create multiple browser windows via $cef.CreateBrowser; after created, browser handle, browser host and frame will be difference, you should identify for each one. $client.OnAfterCreated = func_; $client.OnBeforeClose = func_;
-
You can check here https://github.com/small-autoit/mb/blob/master/mini_browser.au3 global $cef_winfo = $cef.new('WindowInfo') $cef_winfo.parent_window = $hMainGUI ; // HWND (gui handle) $cef_winfo.style = 0x40000000 ; // WS_CHILD (needed for embed as child)
-
@subtlelonging AutoIt can not run multiprocess, so it can't access full features from CEF.
-
Hi, I'm developing CefAu3 project, it embed Chromium browser to your AutoIt program. I'm busy and can stop it. If you want to contribute, you can fork my project and build it yourself. Some Features: - Easy create CEF window - Multi-message loop - Interaction between AutoIt and JavaScript - Supports AutoIt binding - Supports user events... Github: https://github.com/wy3/cefau3 MiniBrowser: https://github.com/small-autoit/mb CEF project: https://bitbucket.org/chromiumembedded/cef Learn more: http://magpcss.org/ceforum/
-
Double draw close button. ;Create Close Button========================================================================================================== If $ButtonsToCreate_Array[0] Then If $CloseButtonOnStyle Then _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen5) _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen5) Else _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen) _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) _GDIPlus_GraphicsDrawLine($Button_Close_Graphic1[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen) _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen4) _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) _GDIPlus_GraphicsDrawLine($Button_Close_Graphic3[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen4) EndIf _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 17 * $cbDPI, 9 * $cbDPI, 27 * $cbDPI, 19 * $cbDPI, $hPen3) _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) _GDIPlus_GraphicsDrawLine($Button_Close_Graphic2[0], 27 * $cbDPI, 9 * $cbDPI, 17 * $cbDPI, 19 * $cbDPI, $hPen3) EndIf ;=============================================================================================================================
- 303 replies
-
- metro
- windows 10
-
(and 2 more)
Tagged with:
-
Hi, If $iAlpha <> -1, don't set windows theme to Classic. WS_EX_LAYERED something error when work in Windows 7/Vista.
- 6 replies
-
- wi3smenu
- slide menu
-
(and 3 more)
Tagged with:
-
[Sorry, I'm not good English] Wi3SMenu UDF v1.0: Create a slide menu with win 10 style. Supports color, icon and opacity. Work fine with AutoIt v3 GUI and WinAPI GUI. Fast, easy and high performance. Note: Opacity only work in Windows 8 later. Download: Wi3SMenuUDF.zip Demo:
- 6 replies
-
- wi3smenu
- slide menu
-
(and 3 more)
Tagged with:
-
Hi, Static control (Label and Pic) of AutoIt v3 GUI can't change text/title with style SS_BITMAP (0x00E). If you remove this style, it can't display bitmap. Eg: #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> $Form = GUICreate("Test", 350, 200, -1, -1) GUISetState(@SW_SHOW) ;=========================================================== ; it work correctly, but it can't display bitmap $Label = GUICtrlCreateLabel("No title", 10, 10, 75, 25) GUICtrlSetData($Label, "New title") ; yeah GUICtrlSendMsg($Label, 0x0172, 0, _WinAPI_CreateSolidBitmap(0, 0x4F5F6F, 10, 10)) MsgBox(0, "", WinGetTitle(GUICtrlGetHandle($Label))) ; returned the old title ;=========================================================== ; with SS_BITMAP $Label2 = GUICtrlCreateLabel("No title", 10, 50, 75, 25, BitOR(0xE, $GUI_SS_DEFAULT_LABEL)) ; SS_BITMAP = 0xE ; not work GUICtrlSetData($Label2, "New title") WinSetTitle(GUICtrlGetHandle($Label2), '', "New title") _WinAPI_SetWindowText(GUICtrlGetHandle($Label2), "New title") GUICtrlSendMsg($Label2, 0x0172, 0, _WinAPI_CreateSolidBitmap(0, 0x4F5F6F, 10, 10)) ; returned the old title MsgBox(0, "Get title", WinGetTitle(GUICtrlGetHandle($Label2))) ; problem MsgBox(0, "Get text", _WinAPI_GetWindowText(GUICtrlGetHandle($Label2))) MsgBox(0, "Get text", WinGetText(GUICtrlGetHandle($Label2))) ;=========================================================== ; same with Pic $Pic = GUICtrlCreatePic("", 10, 100, 75, 25) GUICtrlSetData($Pic, "New title") GUICtrlSendMsg($Pic, 0x0172, 0, _WinAPI_CreateSolidBitmap(0, 0x4F5F6F, 10, 10)) MsgBox(0, "", WinGetTitle(GUICtrlGetHandle($Pic))) Do Until GUIGetMsg() = -3 My Solution: Add input data to Userdata of control. I should you use this way for any control, not recommended use array, @BBs19 #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <Array.au3> $Form = GUICreate("Form", 350, 200, -1, -1) GUISetState(@SW_SHOW) ; create tag for DllStruct... Global Const $tagMyOwnType = 'WCHAR sText[255];' & _ 'UINT iColor;' & _ 'LONG iWidth;' & _ 'LONG iHeight' $Data = DllStructCreate($tagMyOwnType) ; remember store it into memory, i'll add to array below ;Global $__aData[1] = [0] ;_ArrayAdd($__aData, $Data) ; set data $Data.sText = 'Example' $Data.iColor = 0x2D2D2D $Data.iWidth = 50 $Data.iHeight= 50 $Label = GUICtrlCreateLabel($Data.sText, 10, 10, $Data.iWidth, $Data.iHeight, 0xE) $hLabel = GUICtrlGetHandle($Label) GUICtrlSendMsg($Label, 0x0172, 0, _WinAPI_CreateSolidBitmap(0, $Data.iColor, $Data.iWidth, $Data.iHeight)) ; Set pointer to Userdata _WinAPI_SetWindowLong($hLabel, $GWL_USERDATA, DllStructGetPtr($Data)) ; Get Userdata from control, it return pointer $Ptr = _WinAPI_GetWindowLong($hLabel, $GWL_USERDATA) $DataGet = DllStructCreate($tagMyOwnType, $Ptr) ; add pointer to struct MsgBox(0, 'Data from Label', $DataGet.sText & @CRLF & _ $DataGet.iColor & @CRLF & _ $DataGet.iWidth & @CRLF & _ $DataGet.iHeight ) ; Set new value for Userdata $DataGet.sText = 'New text' $Data2 = DllStructCreate($tagMyOwnType, _WinAPI_GetWindowLong($hLabel, $GWL_USERDATA)) MsgBox(0, 'Data changed', $DataGet.sText) Do Until GUIGetMsg() = -3
- 303 replies
-
- metro
- windows 10
-
(and 2 more)
Tagged with:
-
Hi, I've been translated code from FreeBasic to AutoIt. And it didn't work correctly. Please help me! FreeBasic: #Include Once "windows.bi" #Define _RGB(r,g,b) BGR(b,g,r) CONST GRADIENT_FILL_RECT_H = 0 CONST GRADIENT_FILL_RECT_V = 1 Dim Shared hInstance As HINSTANCE ' This dll is located in Windows directory DECLARE FUNCTION Gradientfill Lib "MSIMG32" ALIAS "GradientFill" _ (hDC AS HDC, pVertex As PTRIVERTEX, dwNumVertex As Integer,pMesh AS PGRADIENT_RECT, dwNumMesh As Integer, dwMode As Integer) As Integer '******************************************************************** ' A FB Control Template '******************************************************************** Declare Function NiceButt(ByVal hWnd as HWND,byval Msg as UINT,byval wParam as WPARAM,byval lParam as LPARAM) as LRESULT Declare FUNCTION IsMouseOver (hWnd As HWND )As Integer Declare SUB Draw_Gradient (hdc as HDC, x As Integer, y As integer, w As integer, h As Integer, r As integer, g As integer, b As integer) Declare FUNCTION Register_NiceButt()As Integer ' 'Windows calls this function when the dll is loaded. /'Function DllMain alias "MAIN"(byval hModule as HMODULE,byval reason as Integer,byval lpReserved as LPVOID) as BOOL Select case reason case DLL_PROCESS_ATTACH hInstance=hModule Register_NiceButt() MessageBox(GetActiveWindow(),"OK","OK",MB_OK) Return 0 case DLL_PROCESS_DETACH ' end select return TRUE end function '/ FUNCTION Register_NiceButt()As Integer Export DIM wc AS WNDCLASSEX DIM szClassName As String szClassName = "NiceButt" wc.cbSize = SIZEOF(WNDCLASSEX) wc.style = CS_HREDRAW OR CS_VREDRAW OR CS_GLOBALCLASS wc.hInstance = GetmoduleHandle(0) 'hInstance wc.hbrBackground = Cast(HBRUSH,COLOR_BTNFACE+1) wc.lpszClassName = StrPtr(szClassName) wc.lpfnWndProc = @NiceButt wc.cbClsExtra = 0 wc.cbWndExtra = 0 wc.hIcon = 0 wc.hCursor = 0 wc.lpszMenuName = 0 wc.hIconSm = 0 FUNCTION = RegisterClassEx(@wc) END FUNCTION '******************************************************************** ' Custom Control Procedure '******************************************************************** Function NiceButt(ByVal hWnd as HWND,byval Msg as UINT,byval wParam as WPARAM,byval lParam as LPARAM) as LRESULT STATIC As Integer ButtDown,mouseover STATIC Captured AS HWND SELECT Case Msg '************************** CASE WM_CREATE '************************** DIM Region AS HRGN DIM Rct AS RECT DIM As Integer x, y, w, h ButtDown = FALSE GetClientRect (hWnd,@Rct) ' <<-- Get the size of our control x = Rct.left y = Rct.top w = Rct.right - Rct.left h = Rct.bottom - Rct.top 'Region = CreateRoundRectRgn(10,10,w,h, h * 0.90 , h * 0.90 ) 'SetWindowRgn (hWnd,Region,True) InvalidateRect(hWnd,0,0) 'EXIT FUNCTION ' ******************* CASE WM_PAINT ' ******************* DIM hDC AS HDC DIM ps AS PAINTSTRUCT DIM hPen AS HPEN DIM hBrush AS HBRUSH DIM hOldBrush AS HBRUSH DIM Rct AS RECT DIM Size AS SIZE DIM T As ZString*2048 DIM As Integer i DIM As Integer XCtr DIM As Integer YCtr DIM As Integer x,y,w,h DIM As Integer r,g,b ' ******************* GetClientRect (hWnd,@Rct) ' <<-- Get the size of our control x = Rct.left y = Rct.top w = Rct.right - Rct.left h = Rct.bottom - Rct.top XCtr = (Rct.left + Rct.right) / 2 ' Horizontal center of our ctrl YCtr = (Rct.top + Rct.bottom) / 2 ' Vertical center of our ctrl GetWindowText(hWnd,T ,255) ' Grab a copy of control caption '********************************** ' Draw our control '********************************** hDC = BeginPaint (hWnd, @ps) GetTextExtentPoint32(hDC, T , LEN(T),@Size) ' Get caption size r = 30 : g = 90 : b = 90 Draw_Gradient (hDC, x, y, w, h, r, g, b) SetBkMode (hDC,TRANSPARENT) IF ButtDown THEN SetTextColor(hDC,_RGB(255,0,0)) TextOut(hDC, XCtr-(Size.cx/2)+1, YCtr-(Size.cy/2)+1,T,LEN(T)) ELSE SetTextColor(hDC,_RGB(0,0,255)) TextOut(hDC, XCtr-Size.cx/2, YCtr-Size.cy/2,T,LEN(T)) END IF EndPaint (hWnd,@ps) 'EXIT FUNCTION '****************************** CASE WM_LBUTTONUP '****************************** IF hWnd = Captured THEN DIM hParent AS HWND ReleaseCapture() ButtDown = FALSE InvalidateRect(hWnd,0,0) hParent=GetParent(hWnd) SendMessage(hParent,WM_COMMAND,MAKELONG(GetWindowLong(hWnd,GWL_ID), BN_CLICKED),Cast(LONG,hWnd)) END IF 'EXIT FUNCTION '****************************** CASE WM_LBUTTONDOWN '****************************** SetCapture(hWnd) Captured = hWnd ButtDown = TRUE SetFocus (hWnd) InvalidateRect(hWnd,0,0) 'EXIT FUNCTION '****************************** CASE WM_MOUSEMOVE '****************************** IF ButtDown THEN IF IsMouseOver(hWnd) THEN ButtDown = TRUE InvalidateRect(hWnd,0,0) ELSE ReleaseCapture() ButtDown = FALSE InvalidateRect(hWnd,0,0) END IF END IF 'EXIT FUNCTION '****************************** CASE WM_MOVING '****************************** ReleaseCapture() ButtDown = FALSE InvalidateRect(hWnd,0,0) 'EXIT FUNCTION '****************************** CASE WM_SIZE '****************************** ReleaseCapture() ButtDown = FALSE InvalidateRect(hWnd,0,0) 'EXIT FUNCTION END Select Return DefWindowProc(hwnd,Msg,wparam,lparam) END FUNCTION SUB Draw_Gradient (hdc as HDC, x As Integer, y As integer, w As integer, h As Integer, r As integer, g As integer, b As integer) DIM Vert(2) AS TRIVERTEX DIM Rect AS GRADIENT_RECT '****************************************************** Vert (0).x = 0 Vert (0).y = 0 Vert (0).Red = 65535-(65535-(r*256)) Vert (0).Green = 65535-(65535-(g*256)) Vert (0).Blue = 65535-(65535-(b*256)) Vert (0).Alpha = 0 '****************************************************** Vert (1).x = w Vert (1).y = h/2 Vert (1).Red = 65535-(65535-(255*256)) Vert (1).Green = 65535-(65535-(255*256)) Vert (1).Blue = 65535-(65535-(255*256)) Vert (1).Alpha = 0 '****************************************************** Rect.UpperLeft = 0 Rect.LowerRight = 1 '****************************************************** Gradientfill(hdc,@Vert(0),2,@Rect,1,GRADIENT_FILL_RECT_V) '****************************************************** Vert (0).x = 0 Vert (0).y = h/2 Vert (0).Red = 65535-(65535-(255*256)) Vert (0).Green = 65535-(65535-(255*256)) Vert (0).Blue = 65535-(65535-(255*256)) Vert (0).Alpha = 0 '****************************************************** Vert (1).x = w Vert (1).y = h Vert (1).Red = 65535-(65535-(r*256)) Vert (1).Green = 65535-(65535-(g*256)) Vert (1).Blue = 65535-(65535-(b*256)) Vert (1).Alpha = 0 '****************************************************** Rect.UpperLeft = 0 Rect.LowerRight = 1 '****************************************************** Gradientfill(hdc,@Vert(0),2,@Rect,1,GRADIENT_FILL_RECT_V) END SUB FUNCTION IsMouseOver (hWnd As HWND )As Integer DIM Rect As RECT DIM Pt As POINT GetWindowRect (hWnd, @Rect) GetCursorPos(@Pt) FUNCTION = PtInRect (@Rect, Pt) END FUNCTION AutoIt: #include-once #include <WinAPI.au3> #include <WinAPIGdi.au3> #include <WinAPISys.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ;~ #Include <windows.bi> Global Const $_tagRect = "struct;long left;long top;long right;long bottom;endstruct" Global Const $_tagSize = "struct;long cx;long cy;endstruct" Global Const $_tagGradient_Rect = "struct;ulong UpperLeft;ulong LowerRight;endstruct" Global Const $_tagPoint = "struct;long x;long y;endstruct" Global Const $_tagTrivertex = "struct;long x;long y;int Red;int Greed;int Blue;int Alpha;endstruct" Global Const $_tagPaintStruct = "struct;handle hdc;bool fErase;long left;long top;long right;long bottom;bool fRestore;bool fIncUpdate;byte rgbReserved[32];endstruct" Global Const $_tagWNDCLASSEX = "struct;uint cbSize;uint style;ptr lpfnWndProc;int cbClsExtra;int cbWndExtra;ptr hInstance;ptr hIcon;" & _ "ptr hCursor; ptr hbrBackground; ptr lpszMenuName;ptr lpszClassName;ptr hIconSm;endstruct" Global Const $CS_VREDRAW = 0x0001, $CS_HREDRAW =0x0002, $CS_GLOBALCLASS = 0x4000 Global Const $BN_CLICKED = 0 ;~ #Define _RGB(r,g,b) BGR(b,g,r) Global Const $GRADIENT_FILL_RECT_H = 0 Global Const $GRADIENT_FILL_RECT_V = 1 ;~ Dim Shared hInstance As HINSTANCE ;~ ' This dll is located in Windows directory ;~ DECLARE FUNCTION Gradientfill Lib "MSIMG32" ALIAS "GradientFill" _ ;~ (hDC AS HDC, pVertex As PTRIVERTEX, dwNumVertex As Integer,pMesh AS PGRADIENT_RECT, dwNumMesh As Integer, dwMode As Integer) As Integer ;~ '******************************************************************** ;~ ' A FB Control Template ;~ '******************************************************************** ;~ Declare Function NiceButt(ByVal hWnd as HWND,byval Msg as UINT,byval wParam as WPARAM,byval lParam as LPARAM) as LRESULT ;~ Declare FUNCTION IsMouseOver (hWnd As HWND )As Integer ;~ Declare SUB Draw_Gradient (hdc as HDC, x As Integer, y As integer, w As integer, h As Integer, r As integer, g As integer, b As integer) ;~ Declare FUNCTION Register_NiceButt()As Integer #cs ' 'Windows calls this function when the dll is loaded. /'Function DllMain alias "MAIN"(byval hModule as HMODULE,byval reason as Integer,byval lpReserved as LPVOID) as BOOL Select case reason case DLL_PROCESS_ATTACH hInstance=hModule Register_NiceButt() MessageBox(GetActiveWindow(),"OK","OK",MB_OK) Return 0 case DLL_PROCESS_DETACH ' end select return True end function '/ #ce #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 615, 437, 192, 124) RegisterButton() Global $Ctrl = _winapi_CreateWindowEx(0, "TestButton", "Test", BitOR($WS_VISIBLE, $WS_CHILD), 10, 10, 80, 30, $Form1) ConsoleWrite(@CRLF & $Ctrl) GUISetState(@SW_SHOW) _WinAPI_UpdateWindow($Form1) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func RegisterButton() Local $hDll = DllCallbackRegister('TestButtonProc', 'lresult', 'hwnd;uint;wparam;lparam') ;~ DIM wc AS WNDCLASSEX ;~ DIM szClassName As String Local $sClass = "TestButton" Local $wc = DllStructCreate($_tagWNDCLASSEX & ';wchar szClassName[' & (StringLen($sClass) + 1) & ']') ;~ szClassName = "NiceButt" ;~ wc.cbSize = SIZEOF(WNDCLASSEX) $wc.cbSize = DllStructGetPtr($wc, 'szClassName') - DllStructGetPtr($wc) ;~ wc.style = CS_HREDRAW OR CS_VREDRAW OR CS_GLOBALCLASS $wc.style = BitOR($CS_HREDRAW, $CS_VREDRAW, $CS_GLOBALCLASS) ;~ wc.hInstance = GetmoduleHandle(0) 'hInstance $wc.hInstance = _WinAPI_GetModuleHandle(0) ;~ wc.hbrBackground = Cast(HBRUSH,COLOR_BTNFACE+1) ;/// $wc.hbrBackground = _WinAPI_CreateSolidBrush(_WinAPI_GetSysColor($COLOR_BTNFACE)) ;~ wc.lpszClassName = StrPtr(szClassName) $wc.lpszClassName = DllStructGetPtr($wc, 'szClassName') ;~ wc.lpfnWndProc = @NiceButt $wc.lpfnWndProc = DllCallbackGetPtr($hDll) ;~ wc.cbClsExtra = 0 $wc.cbClsExtra = 0 ;~ wc.cbWndExtra = 0 $wc.cbWndExtra = 0 ;~ wc.hIcon = 0 $wc.hIcon = 0 ;~ wc.hCursor = 0 $wc.hCursor = 0 ;~ wc.lpszMenuName = 0 $wc.lpszMenuName = 0 ;~ wc.hIconSm = 0 $wc.hIconSm = 0 $wc.szClassName = $sClass ;~ FUNCTION = RegisterClassEx(@wc) Local $aRet = _WinAPI_RegisterClassEx($wc) Return $aRet ;~ END FUNCTION EndFunc ;******************************************************************** ; Custom Control Procedure ;******************************************************************** ;~ Function NiceButt(ByVal hWnd as HWND,byval Msg as UINT,byval wParam as WPARAM,byval lParam as LPARAM) as LRESULT Func TestButtonProc($hWnd, $iMsg, $wParam, $lParam) Static $bBtnDown, $bMouseOver, $hCaptured Switch $iMsg Case $WM_CREATE Local $Rct = DllStructCreate($_tagRect) Local $iX, $iY, $iW, $iH $bBtnDown = False GetClientRect($hWnd, $Rct) $iX = $Rct.left $iY = $Rct.top $iW = $Rct.right - $Rct.left $iH = $Rct.bottom - $Rct.top InvalidateRect($hWnd, 0, False) ;~ EXIT FUNCTION ;~ Return 0 Case $WM_PAINT Local $ps ;= DllStructCreate($_tagPaintStruct) Local $hPen, $hBrush, $hOldBrush Dim $Rct = DllStructCreate($_tagRect) Dim $Size = DllStructCreate($_tagSize) Dim $T = "", $i Dim $XCtr, $YCtr Dim $iX, $iY, $iW, $iH Dim $iR, $iG, $iB GetClientRect($hWnd, $Rct) $iX = $Rct.left $iY = $Rct.top $iW = $Rct.right - $Rct.left $iH = $Rct.bottom - $Rct.top $XCtr = ($Rct.left + $Rct.right) / 2 $YCtr = ($Rct.top + $Rct.bottom) / 2 ;~ GetWindowText(hWnd,T ,255) ' Grab a copy of control caption ;~ DllCall("user32.dll", "int", "GetWindowTextW", "hwnd", $hWnd, "LPTSTR ", $T, "int", 255) ; not work $T = "Test" ;********************************** ; Draw our control ;********************************** Local $hDC = BeginPaint($hWnd, $ps) ;~ GetTextExtentPoint32(hDC, T , LEN(T),@Size) ' Get caption size GetTextExtentPoint32($hDC, $T, StringLen($T), $Size) $iR = 30 $iG = 90 $iB = 90 Draw_Gradient($hDC, $iX, $iY, $iW, $iH, $iR, $iG, $iB) SetBkMode($hDC, $TRANSPARENT) If $bBtnDown Then ;~ SetTextColor(hDC,_RGB(255,0,0)) SetTextColor($hDC, Dec(0xFF0000)) TextOut($hDC, $XCtr-($Size.cx/2)+1, $YCtr-($Size.cy/2)+1, $T) Else ;~ SetTextColor(hDC,_RGB(0,0,255)) SetTextColor($hDC, Dec(0x0000FF)) TextOut($hDC, $XCtr-$Size.cx/2, $YCtr-$Size.cy/2, $T) EndIf EndPaint($hWnd, $ps) ;~ EXIT FUNCTION ;~ Return 0 Case $WM_LBUTTONUP If $hWnd = $hCaptured Then ReleaseCapture() $bBtnDown = False InvalidateRect($hWnd, 0, 0) Local $hParent = GetParent($hWnd) ;~ SendMessage(hParent,WM_COMMAND,MAKELONG(GetWindowLong(hWnd,GWL_ID), BN_CLICKED),Cast(LONG,hWnd)) DllCall("user32.dll", "LRESULT", "SendMessageW", _ "hwnd", $hParent, _ "uint", $WM_COMMAND, _ "WPARAM", _WinAPI_MakeLong(_WinAPI_GetWindowLong($hWnd, $GWL_ID), $BN_CLICKED), _ "LPARAM", $hWnd) EndIf ;~ EXIT FUNCTION Return 0 Case $WM_LBUTTONDOWN SetCapture($hWnd) $hCaptured = $hWnd $bBtnDown = True SetFocus($hWnd) InvalidateRect($hWnd, 0, False) ;~ EXIT FUNCTION Return 0 Case $WM_MOUSEMOVE If $bBtnDown Then If IsMouseOver($hWnd) Then $bBtnDown = True InvalidateRect($hWnd, 0, False) ELSE ReleaseCapture() $bBtnDown = False InvalidateRect($hWnd, 0, False) EndIf EndIf ;~ EXIT FUNCTION ;~ Return 0 Case $WM_MOVING ReleaseCapture() $bBtnDown = False InvalidateRect($hWnd, 0, False) ;~ EXIT FUNCTION ;~ Return 0 Case $WM_SIZE ReleaseCapture() $bBtnDown = False InvalidateRect($hWnd, 0, False) ;~ EXIT FUNCTION ;~ Return 0 EndSwitch ;~ Return _WinAPI_DefWindowProc($hWnd, $iMsg, $wParam, $lParam) Return DllCall("user32.dll", "lresult", "DefWindowProcW", "hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, _ "lparam", $lParam)[0] EndFunc ;~ SUB Draw_Gradient (hdc as HDC, x As Integer, y As integer, w As integer, h As Integer, r As integer, g As integer, b As integer) Func Draw_Gradient($hDC, $iX, $iY, $iW, $iH, $iR, $iG, $iB) ;~ DIM Vert(2) AS TRIVERTEX Local $Vert[2] $Vert[0] = DllStructCreate($_tagTrivertex) $Vert[1] = DllStructCreate($_tagTrivertex) ;~ DIM Rect AS GRADIENT_RECT Local $Rect = DllStructCreate($_tagGradient_Rect) ;~ Vert (0).x = 0 $Vert[0].x = 0 ;~ Vert (0).y = 0 $Vert[0].y = 0 ;~ Vert (0).Red = 65535-(65535-(r*256)) $Vert[0].Red = 65535-(65535-($iR*256)) ;~ Vert (0).Green = 65535-(65535-(g*256)) $Vert[0].Green = 65535-(65535-($iG*256)) ;~ Vert (0).Blue = 65535-(65535-(b*256)) $Vert[0].Blue = 65535-(65535-($iB*256)) ;~ Vert (0).Alpha = 0 $Vert[0].Alpha = 0 ;~ '****************************************************** ;~ Vert (1).x = w $Vert[1].x = $iW ;~ Vert (1).y = h/2 $Vert[1].y = $iH/2 ;~ Vert (1).Red = 65535-(65535-(255*256)) $Vert[1].Red = 65535-(65535-(255*256)) ;~ Vert (1).Green = 65535-(65535-(255*256)) $Vert[1].Green = 65535-(65535-(255*256)) ;~ Vert (1).Blue = 65535-(65535-(255*256)) $Vert[1].Blue = 65535-(65535-(255*256)) ;~ Vert (1).Alpha = 0 $Vert[1].Alpha = 0 ;~ '****************************************************** ;~ Rect.UpperLeft = 0 $Rect.UpperLeft = 0 ;~ Rect.LowerRight = 1 $Rect.LowerRight = 1 ;~ '****************************************************** ;~ Gradientfill(hdc,@Vert(0),2,@Rect,1,GRADIENT_FILL_RECT_V) GradientFill($hDC, $Vert[0], 2, $Rect, 1, $GRADIENT_FILL_RECT_V) ;~ '****************************************************** ;~ Vert (0).x = 0 $Vert[0].x = 0 ;~ Vert (0).y = h/2 $Vert[0].y = $iH/2 ;~ Vert (0).Red = 65535-(65535-(255*256)) $Vert[0].Red = 65535-(65535-(255*256)) ;~ Vert (0).Green = 65535-(65535-(255*256)) $Vert[0].Green = 65535-(65535-(255*256)) ;~ Vert (0).Blue = 65535-(65535-(255*256)) $Vert[0].Blue = 65535-(65535-(255*256)) ;~ Vert (0).Alpha = 0 $Vert[0].Alpha = 0 ;~ '****************************************************** ;~ Vert (1).x = w $Vert[1].x = $iW ;~ Vert (1).y = h $Vert[1].y = $iH ;~ Vert (1).Red = 65535-(65535-(r*256)) $Vert[1].Red = 65535-(65535-($iR*256)) ;~ Vert (1).Green = 65535-(65535-(g*256)) $Vert[1].Green = 65535-(65535-($iG*256)) ;~ Vert (1).Blue = 65535-(65535-(b*256)) $Vert[1].Blue = 65535-(65535-($iB*256)) ;~ Vert (1).Alpha = 0 $Vert[1].Alpha = 0 ;~ '****************************************************** ;~ Rect.UpperLeft = 0 $Rect.UpperLeft = 0 ;~ Rect.LowerRight = 1 $Rect.LowerRight = 1 ;~ '****************************************************** ;~ Gradientfill(hdc,@Vert(0),2,@Rect,1,GRADIENT_FILL_RECT_V) GradientFill($hDC, $Vert[0], 2, $Rect, 1, $GRADIENT_FILL_RECT_V) ;~ END SUB EndFunc Func IsMouseOver($hWnd) Local $Rect = DllStructCreate($_tagRect) Local $Pt = DllStructCreate($_tagPoint) GetWindowRect ($hWnd, $Rect) GetCursorPos($Pt) Return PtInRect($Rect, $Pt) EndFunc Func _RGB($iR, $iG, $iB) Return ('0x' & Hex($iR, 2) & Hex($iG, 2) & Hex($iB, 2)) EndFunc Func _BGR($iB, $iG, $iR) Return ('0x' & Hex($iB, 2) & Hex($iG, 2) & Hex($iR, 2)) EndFunc Func InvalidateRect($hWnd, $tRECT = 0, $bErase = True) DllCall("user32.dll", "bool", "InvalidateRect", "hwnd", $hWnd, "struct*", $tRECT, "bool", $bErase) EndFunc Func SetFocus($hWnd) DllCall("user32.dll", "hwnd", "SetFocus", "hwnd", $hWnd) EndFunc Func PtInRect($tRect, $tPoint) Local $aRet = DllCall("user32.dll", "bool", "PtInRect", "ptr", DllStructGetPtr($tRect), "struct*", $tPoint) If IsArray($aRet) Then Return $aRet[0] Return False EndFunc Func GetWindowRect($hWnd, ByRef $tRect) DllCall("user32.dll", "bool", "GetWindowRect", "hwnd", $hWnd, "struct*", $tRect) EndFunc Func GetCursorPos(ByRef $tPoint) DllCall("user32.dll", "bool", "GetCursorPos", "struct*", $tPoint) EndFunc Func SetCapture($hWnd) DllCall("user32.dll", "hwnd", "SetCapture", "hwnd", $hWnd) EndFunc Func ReleaseCapture() DllCall("user32.dll", "bool", "ReleaseCapture") EndFunc Func SetTextColor($hDC, $iColor) DllCall("gdi32.dll", "INT", "SetTextColor", "handle", $hDC, "INT", $iColor) EndFunc Func BeginPaint($hWnd, ByRef $tPAINTSTRUCT) $tPAINTSTRUCT = DllStructCreate($tagPAINTSTRUCT) Local $aRet = DllCall('user32.dll', 'handle', 'BeginPaint', 'hwnd', $hWnd, 'struct*', $tPAINTSTRUCT) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc Func GetTextExtentPoint32($hDC, $sText, $iTextLen, ByRef $tSize) DllCall("gdi32.dll", "bool", "GetTextExtentPoint32W", "handle", $hDC, "wstr", $sText, "int", $iTextLen, "struct*", $tSize) EndFunc Func GradientFill($hDC, $tVertex, $nVertex, $tMesh, $nMesh, $ulMode) DllCall("Msimg32.dll", "BOOL", "GradientFill", _ "handle", $hDC, _ "struct*", $tVertex, _ "ulong", $nVertex, _ "struct*", $tMesh, _ "ulong", $nMesh, _ "ulong", $ulMode) EndFunc Func GetParent($hWnd) Local $aResult = DllCall("user32.dll", "hwnd", "GetParent", "hwnd", $hWnd) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func SetBkMode($hDC, $iBkMode) Local $aResult = DllCall("gdi32.dll", "int", "SetBkMode", "handle", $hDC, "int", $iBkMode) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Func EndPaint($hWnd, ByRef $tPAINTSTRUCT) Local $aRet = DllCall('user32.dll', 'bool', 'EndPaint', 'hwnd', $hWnd, 'struct*', $tPAINTSTRUCT) If @error Then Return SetError(@error, @extended, False) Return $aRet[0] EndFunc Func GetClientRect($hWnd, ByRef $tRect) Local $aRet = DllCall("user32.dll", "bool", "GetClientRect", "hwnd", $hWnd, "struct*", $tRect) If @error Or Not $aRet[0] Then Return SetError(@error + 10, @extended, 0) Return $tRect EndFunc Func TextOut($hDC, $iX, $iY, $sText, $iTextLen = Default) If $iTextLen = Default Then $iTextLen = StringLen($sText) DllCall('gdi32.dll', 'bool', 'TextOutW', 'handle', $hDC, 'int', $iX, 'int', $iY, 'wstr', $sText, 'int', $iTextLen) EndFunc
-
Hi, Give you some solution for tab control from me. FlatTab.au3 #include-once #include <GDIPlus.au3> #include <Array.au3> #include "GUICtrlOnHover.au3" Global $FlatUIColor = DllStructCreate("struct;float back;float fore;float frame;endstruct;") $FlatUIColor.back = 0x3C4649 $FlatUIColor.fore = 0x23A86D ;0x3498db $FlatUIColor.frame = 0x2D2F31 Global Const $tObjTabEx = "hwnd hwnd;byte ctrl;byte ctab;" & _ "byte count;byte current;int next;" & _ "int width;int x;int y;" Global Const $tObjTabBtnEx = "byte ctrl;byte ctab;byte idtab;" & _ "wchar text[255];" Global $____aTabList[1] = [0] Global $____aTabBtnList[1] = [0] Func FlatTab_Create($hWnd, $Left, $Top, $Width, $Height) GUISwitch($hWnd) Local $oObj = DllStructCreate($tObjTabEx) _ArrayAdd($____aTabList, $oObj) $____aTabList[0] += 1 $oObj.hwnd = $hWnd $oObj.ctrl = GUICtrlCreatePic("", $Left, $Top+25, $Width, $Height-50) GUICtrlSetResizing($oObj.ctrl, 802) GUICtrlSetState($oObj.ctrl, 128) $oObj.ctab = GUICtrlCreateTab(-99, -99, 1, 1) GUICtrlSetState($oObj.ctab, 128) Local $aBmp = _GDIPlus_BitmapCreateFromScan0($Width, $Height-50) Local $hGfx = _GDIPlus_ImageGetGraphicsContext($aBmp) Local $hPen = _GDIPlus_PenCreate($FlatUIColor.frame+0xFF000000, 4) Local $hBrush = _GDIPlus_BrushCreateSolid($FlatUIColor.frame+0xFF000000) _GDIPlus_GraphicsDrawRect($hGfx, 0, 0, $Width, $Height-50, $hPen) _GDIPlus_GraphicsFillRect($hGfx, 0, 0, $Width, $Height-50, $hBrush) _GDIPlus_GraphicsClear($hGfx, $FlatUIColor.frame+0xFF000000) Local $hBmp = _GDIPlus_BitmapCreateDIBFromBitmap($aBmp) _GDIPlus_BitmapDispose($aBmp) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_PenDispose($hPen) _WinAPI_DeleteObject(GUICtrlSendMsg($oObj.ctrl, 0x0172, 0, $hBmp)) _WinAPI_DeleteObject($hBmp) $oObj.width = $Width $oObj.x = $Left $oObj.y = $Top $oObj.current = "" $oObj.count = 0 $oObj.next = $Left Return $oObj EndFunc Func FlatTab_AddTab($Ctrl, $Text) GUISwitch($Ctrl.hwnd) GUICtrlCreateTabItem("") Local $oObj = DllStructCreate($tObjTabBtnEx) _ArrayAdd($____aTabBtnList, $oObj) $____aTabBtnList[0] += 1 $oObj.ctrl = GUICtrlCreatePic("", $Ctrl.next, $Ctrl.y, 80, 25) GUICtrlSetResizing($oObj.ctrl, 802) _GUICtrl_OnHoverRegister($oObj.ctrl, 'FlatTab_EventHover', 'FlatTab_EventHover', 'FlatTab_EventClick', 'FlatTab_EventClick') $oObj.count +=1 $oObj.idtab = GUICtrlCreateTabItem($oObj.count) $oObj.text = $Text If $Ctrl.current <> "" Then Local $Prev = FlatTab_GetObjTabBtnFromCtrl($Ctrl.current) FlatTab_Draw($Prev.ctrl, $Prev.text, 0xFFFFFFFF, $FlatUIColor.fore+0xFF000000) EndIf FlatTab_Draw($oObj.ctrl, $Text, 0xFFFFFFFF, $FlatUIColor.frame+0xFF000000) $Ctrl.current = $oObj.ctrl $oObj.ctab = $Ctrl.ctab $Ctrl.next += 80 GUICtrlSetState($oObj.idtab, 16) Return $oObj.idtab EndFunc Func FlatTab_EventHover($Ctrl, $Mode) Local $Obj1 = FlatTab_GetObjTabFromCtrl($Ctrl) If $Obj1.current = $Ctrl Then Return Local $Obj2 = FlatTab_GetObjTabBtnFromCtrl($Ctrl) Switch $Mode Case 1 FlatTab_Draw($Ctrl, $Obj2.text, 0xFFFFFFFF, $FlatUIColor.fore+0xFF151515) Case 2 FlatTab_Draw($Ctrl, $Obj2.text, 0xFFFFFFFF, $FlatUIColor.fore+0xFF000000) EndSwitch EndFunc Func FlatTab_EventClick($Ctrl, $Mode) If $Mode = 2 Then Local $Obj1 = FlatTab_GetObjTabFromCtrl($Ctrl) If $Obj1.current = $Ctrl Then Return Local $Obj2 = FlatTab_GetObjTabBtnFromCtrl($Ctrl) Local $Obj3 = FlatTab_GetObjTabBtnFromCtrl($Obj1.current) FlatTab_Draw($Ctrl, $Obj2.text, 0xFFFFFFFF, $FlatUIColor.frame+0xFF000000) FlatTab_Draw($Obj3.ctrl, $Obj3.text, 0xFFFFFFFF, $FlatUIColor.fore+0xFF000000) GUICtrlSetState($Obj2.idtab, 16) $Obj1.current = $Ctrl EndIf EndFunc Func FlatTab_GetObjTabFromCtrl($Ctrl) Local $Obj2, $Index Local $Obj = FlatTab_GetObjTabBtnFromCtrl($Ctrl) If $____aTabList[0] = 0 Then Return False For $Index = $____aTabList[0] To 1 Step -1 $Obj2 = $____aTabList[$Index] If $Obj2.ctab == $Obj.ctab Then Return $____aTabList[$Index] Next Return False EndFunc Func FlatTab_GetObjTabBtnFromCtrl($Ctrl) Local $Obj, $Index If $____aTabBtnList[0] = 0 Then Return False For $Index = $____aTabBtnList[0] To 1 Step -1 $Obj = $____aTabBtnList[$Index] If $Obj.ctrl == $Ctrl Then Return $____aTabBtnList[$Index] Next Return False EndFunc Func FlatTab_Draw($iCtrl, $Text, $Color = 0xFFFFFFFF, $BgColor = 0x00FFFFFF) Local $hWnd = _WinAPI_GetParent(GUICtrlGetHandle($iCtrl)) Local $aPos = ControlGetPos($hWnd, "", $iCtrl) Local $hFormat = _GDIPlus_StringFormatCreate() Local $hFamily = _GDIPlus_FontFamilyCreate("Segoe UI Semibold") Local $hFont = _GDIPlus_FontCreate($hFamily, 10, 0) Local $tLayout = _GDIPlus_RectFCreate(0, 0, $aPos[2], $aPos[3]) _GDIPlus_StringFormatSetAlign($hFormat, 1) _GDIPlus_StringFormatSetLineAlign($hFormat, 1) Local $aBitmaps = _GDIPlus_BitmapCreateFromScan0($aPos[2], $aPos[3]) Local $aGfxCtxt = _GDIPlus_ImageGetGraphicsContext($aBitmaps) _GDIPlus_GraphicsSetSmoothingMode($aGfxCtxt, 2) _GDIPlus_GraphicsSetTextRenderingHint($aGfxCtxt, 5) _GDIPlus_GraphicsClear($aGfxCtxt, $BgColor) Local $hBrushColor = _GDIPlus_BrushCreateSolid($Color) _GDIPlus_GraphicsDrawStringEx($aGfxCtxt, $Text, $hFont, $tLayout, $hFormat, $hBrushColor) Local $aHBitmaps = _GDIPlus_BitmapCreateDIBFromBitmap($aBitmaps) _GDIPlus_BrushDispose($hBrushColor) _GDIPlus_FontDispose($hFont) _GDIPlus_BitmapDispose($aBitmaps) _GDIPlus_GraphicsDispose($aGfxCtxt) _GDIPlus_FontFamilyDispose($hFamily) _GDIPlus_StringFormatDispose($hFormat) _WinAPI_DeleteObject(GUICtrlSendMsg($iCtrl, 0x0172, 0, $aHBitmaps)) _WinAPI_DeleteObject($aHBitmaps) EndFunc FlatTab_Example.au3 #include "FlatTabEx.au3" #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> _GDIPlus_Startup(); Global $hGUI = GUICreate("FlatTab Example", 450, 290); GUISetBkColor(0x3C4649, $hGUI); GUISetFont(10, 400, 0, "Segoe UI", $hGUI, 5); Global $Tab = FlatTab_Create($hGUI, 10, 10, 430, 290); ;================================================= FlatTab_AddTab($Tab, "Tab 1"); GUICtrlCreateLabel("This is Tab 1", 30, 50); GUICtrlSetColor(-1, 0xFFFFFF); GUICtrlCreateButton("Button 1", 30, 100, 75, 25); GUICtrlCreateButton("Button 2", 120, 100, 75, 25); ;================================================= FlatTab_AddTab($Tab, "Tab 2"); GUICtrlCreateLabel("This is Tab 2", 30, 50); GUICtrlSetColor(-1, 0xFFFFFF); GUICtrlCreateButton("Button 3", 210, 100, 75, 25); GUICtrlCreateButton("Button 4", 30, 150, 75, 25); ;================================================= FlatTab_AddTab($Tab, "Tab 3"); GUICtrlCreateLabel("This is Tab 3", 30, 50); GUICtrlSetColor(-1, 0xFFFFFF); GUICtrlCreateButton("Button 5", 120, 150, 75, 25); GUICtrlCreateButton("Button 6", 210, 150, 75, 25); ;================================================= GUICtrlCreateTabItem(""); GUISetState(); Do Sleep(10); Until GUIGetMsg() = -3;
- 303 replies
-
- metro
- windows 10
-
(and 2 more)
Tagged with: