Jump to content
ManneMoses

Change The Size Of The Gui Title Bar?

Recommended Posts

ManneMoses

Hello Guys,

I want to create a simple gui, but with a bigger title bar ( e.g. 2x bigger) Is that possible in any way? I searched the forum but I found nothing. Hope you understand what I mean. Nothing special with the gui, only the size of the title bar should change. Any ideas? Thanks in Advance :D

Edited by ManneMoses

Share this post


Link to post
Share on other sites
Yukoshoo

Are you talking about the Height or the Width of the title bar. Width is easy as you just change the width of the window and the title bar expands with it. I am unsure of how to, and also unsure of why you would want a taller title bar.

Share this post


Link to post
Share on other sites
UEZ

You can use a workaround / proof of concept version like this here:

;build 2015-07-17 beta
#include <GDIPlus.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPIShellEx.au3>


_GDIPlus_Startup()

;example 1
Global $iHeight_Border = 64
Global $a_hGUI_new = _GDIPlus_BitmapCreateGUITitlebar("Windows 8 Style", 600, 7 * $iHeight_Border, -1, -1, $iHeight_Border, 1, 0, 0, 1, 0xFF2271B3, 0) ;create green titlebar (default is blue)
GUISetBkColor(0x404040)
GUICtrlCreateLabel("This is a test GUI", 10, $iHeight_Border + 8, 380, $iHeight_Border) ;don't forget to calculate the titlebar -> titlebar is from 0 to 64
GUICtrlSetFont(-1, 24, 400, 0, "", 4)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlCreateButton("OK", 500, 7 * $iHeight_Border - 80, 64, 64)
Global $iLV = GUICtrlCreateListView("col1  |col2|col3  ", 16, $iHeight_Border * 2, 568, 3 * $iHeight_Border)
For $i = 1 to 50
    GUICtrlCreateListViewItem("item" & $i + 1 & "|col2" & $i + 1 & "|col2" & $i + 1, $iLV)
Next
GUISetState()

Do
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $a_hGUI_new[1]
            GUIDelete($a_hGUI_new[0])
            ExitLoop
        Case $a_hGUI_new[2]
            GUISetState(@SW_MINIMIZE, $a_hGUI_new[0])
    EndSwitch
Until False

;example 2
$iHeight_Border = 48
$a_hGUI_new = _GDIPlus_BitmapCreateGUITitlebar("Windows XP Style", 600, 7 * $iHeight_Border, -1, -1, $iHeight_Border, 0)
GUISetBkColor(0x404040)
GUICtrlCreateLabel("This is a test GUI", 10, $iHeight_Border + 8, 380, $iHeight_Border)
GUICtrlSetFont(-1, 24, 400, 0, "", 4)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlCreateButton("OK", 500, 7 * $iHeight_Border - 80, 64, 64)
Global $iLV = GUICtrlCreateListView("col1  |col2|col3  ", 16, $iHeight_Border * 2, 568, 3 * $iHeight_Border)
For $i = 1 to 50
    GUICtrlCreateListViewItem("item" & $i + 1 & "|col2" & $i + 1 & "|col2" & $i + 1, $iLV)
Next
GUISetState()

Do
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $a_hGUI_new[1]
            GUIDelete($a_hGUI_new[0])
            _GDIPlus_Shutdown()
            Exit
        Case $a_hGUI_new[2]
            GUISetState(@SW_MINIMIZE, $a_hGUI_new[0])
    EndSwitch
Until False

Func _GDIPlus_BitmapCreateGUITitlebar($sTitle, $iWidth, $iHeight, $iLeft = -1, $iRight = -1, $iHeight_Border = 29, $iTitleAlign = 1, $iHue = 0, $iAmount = 0, $bFlatColor = False, $iFlatColor = 0xFF2271B3, $bRoundTopCorners = True, $iBorderTextColor = 0xFFF0F0F0, $hParent = Null)
    $iHue = $iHue > 180 ? 180 : $iHue < -180 ? -180 : $iHue
    $iAmount = $iAmount > 100 ? 100 : $iAmount < -100 ? -100 : $iAmount
    $iLeft = Int($iLeft)
    $iRight = Int($iRight)
    $iTitleAlign = $iTitleAlign > 2 ? 2 : $iTitleAlign < 0 ? 0 : $iTitleAlign
    Local Const $_hGUI = GUICreate($sTitle, $iWidth, $iHeight, $iLeft, $iRight, $WS_POPUPWINDOW, Default, $hParent)
    Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight_Border)
    Local Const $hGraphic = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    _GDIPlus_GraphicsSetInterpolationMode($hGraphic, 7)
    _GDIPlus_GraphicsSetTextRenderingHint($hGraphic, 4)
    _GDIPlus_GraphicsSetSmoothingMode($hGraphic, 4)
    Local $iCornerWidth = Ceiling($iHeight_Border / 6)
    If Not $bFlatColor Then
        Local $hBmp = _GDIPlus_BitmapCreateFromMemory(_WTB())
        Local Const $iW = _GDIPlus_ImageGetWidth($hBmp), $iH = _GDIPlus_ImageGetHeight($hBmp)
        If $bRoundTopCorners Then _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hBmp, 0, 0, $iCornerWidth, $iH, 0, 0, $iCornerWidth, $iHeight_Border)
        _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hBmp, $iCornerWidth, 0, $iW - 2 * $iCornerWidth, $iH, $iCornerWidth * $bRoundTopCorners, 0, $iWidth - 2 * $iCornerWidth * $bRoundTopCorners, $iHeight_Border)
        If $bRoundTopCorners Then _GDIPlus_GraphicsDrawImageRectRect($hGraphic, $hBmp, $iW - $iCornerWidth, 0, $iCornerWidth, $iH, $iWidth - $iCornerWidth, 0, $iCornerWidth, $iHeight_Border)
    Else
        Local $hBrush_Flat = _GDIPlus_BrushCreateSolid($iFlatColor)
        _GDIPlus_GraphicsFillRect($hGraphic, 0, 0, $iWidth, $iHeight_Border, $hBrush_Flat)
        _GDIPlus_BrushDispose($hBrush_Flat)
    EndIf
    If @OSBuild > 7599 And Not $bFlatColor Then
        Local Const $hEffect = _GDIPlus_EffectCreateTint($iHue, $iAmount)
        _GDIPlus_BitmapApplyEffect($hBitmap, $hEffect)
        _GDIPlus_EffectDispose($hEffect)
    EndIf
    Local Const $hBrush_Text = _GDIPlus_BrushCreateSolid($iBorderTextColor)
    Local $tLayout = _GDIPlus_RectFCreate(3.5 * $iCornerWidth, $iCornerWidth / 2, $iWidth - 10.5 * $iCornerWidth, $iHeight_Border - $iCornerWidth)
    Local Const $hFormat = _GDIPlus_StringFormatCreate()
    _GDIPlus_StringFormatSetAlign($hFormat, $iTitleAlign)
    _GDIPlus_StringFormatSetLineAlign($hFormat, 1)
    Local Const $hFamily = _GDIPlus_FontFamilyCreate("Arial")
    Local Const $hFont = _GDIPlus_FontCreate($hFamily, $iHeight_Border / 3)
    Local $c = -1
    Do
        $c += 1
    Until _GDIPlus_GraphicsMeasureString($hGraphic, StringMid($sTitle, 1, StringLen($sTitle) - $c), $hFont, $tLayout, $hFormat)[2] = 1
    _GDIPlus_GraphicsDrawStringEx($hGraphic, StringMid($sTitle, 1, StringLen($sTitle) - $c - 3 * (Not $c ? 0 : 1)) & ($c > 0 ? "..." : ""), $hFont, $tLayout, $hFormat, $hBrush_Text)
    Local $hHBitmap_WinTitlebar = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
    _GDIPlus_GraphicsDispose($hGraphic)
    If Not $bFlatColor Then _GDIPlus_BitmapDispose($hBmp)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_BrushDispose($hBrush_Text)
    _GDIPlus_FontDispose($hFont)
    _GDIPlus_FontFamilyDispose($hFamily)
    _GDIPlus_StringFormatDispose($hFormat)
    Local Const $iPic_Titlebar = GUICtrlCreatePic("", 0, 0, $iWidth, $iHeight_Border)
    GUICtrlSetState(-1, $GUI_DISABLE)
    _WinAPI_DeleteObject(GUICtrlSendMsg($iPic_Titlebar, 0x0172, $IMAGE_BITMAP, $hHBitmap_WinTitlebar)) ; $STM_SETIMAGE = 0x0172
    If $bRoundTopCorners Then
        Local Const $iYCap = _WinAPI_GetSystemMetrics($SM_CYCAPTION), $iFrame = _WinAPI_GetSystemMetrics($SM_CXDLGFRAME)
        Local Const $hRegion = _WinAPI_CreateRoundRectRgn(0, 0, $iWidth + $iFrame, $iHeight + 2 * $iYCap, $iCornerWidth * 4, $iCornerWidth * 4)
        _WinAPI_SetWindowRgn($_hGUI, $hRegion)
        _WinAPI_DeleteObject($hRegion)
    EndIf
    _WinAPI_DeleteObject($hHBitmap_WinTitlebar)
    Local Const $iX_Right = 44
    Local $iLbl_Move = GUICtrlCreateLabel("", 0, 0, $iWidth - $iX_Right - 58, $iHeight_Border, -1, $GUI_WS_EX_PARENTDRAG)
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    Local Const $iClose = GUICtrlCreateLabel("x", $iWidth - $iX_Right, 4, ($bFlatColor ? 40 : 24), 24, BitOR($SS_CENTERIMAGE, $SS_CENTER), (Not $bFlatColor ? $WS_EX_STATICEDGE : -1))
    GUICtrlSetBkColor(-1, 0xE04343)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetFont(-1, 14, 800, 0, "", 4)
    Local Const $iMax = GUICtrlCreateLabel(ChrW(0x274F), $iWidth - $iX_Right - 32, 2, 24, 24, BitOR($SS_CENTERIMAGE, $SS_CENTER), (Not $bFlatColor ? $WS_EX_STATICEDGE : -1))
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetFont(-1, 16, 400, 0, "", 4)
    GUICtrlSetState(-1, $GUI_DISABLE)
    Local Const $iMin = GUICtrlCreateLabel(ChrW(822), $iWidth - $iX_Right - 56, 6, 24, 20, BitOR($SS_CENTERIMAGE, $SS_CENTER), (Not $bFlatColor ? $WS_EX_STATICEDGE : -1))
    GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
    GUICtrlSetColor(-1, 0xFFFFFF)
    GUICtrlSetFont(-1, 16, 800, 0, "", 4)
    Local Const $hIcon = _WinAPI_ShellExtractIcon(@AutoItExe, 0, 16, 16)
    Local Const $iPic_WinIcon = GUICtrlCreatePic("", 1.5 * $iCornerWidth, 1.5 * $iCornerWidth, 16, 16)
    $hBmp = _GDIPlus_BitmapCreateFromHICON32($hIcon)
    Local Const $hHBitmap_WinTitlebar_Icon = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBmp)
    _WinAPI_DeleteObject(GUICtrlSendMsg($iPic_WinIcon, 0x0172, $IMAGE_BITMAP, $hHBitmap_WinTitlebar_Icon)) ; $STM_SETIMAGE = 0x0172
    _GDIPlus_BitmapDispose($hBmp)
    _WinAPI_DeleteObject($hHBitmap_WinTitlebar_Icon)
    Local Const $a_hGUI[5] = [$_hGUI, $iClose, $iMin, $iMax, $iPic_WinIcon]
    _WinAPI_DestroyIcon($hIcon)
    Return $a_hGUI
EndFunc

;Code below was generated by: 'File to Base64 String' Code Generator v1.20 Build 2015-03-02

Func _WTB($bSaveBinary = False, $sSavePath = @ScriptDir)
    Local $WTB
    $WTB &= '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'
    $WTB &= '4+PO01bAGgGVqaFZ5UAI64pR4N5Wqa06KgheUPVIJ3wbPBykonBK7ROUw8cDy8RbyUXDmLAppoLso8Acbhz+WIbQ2QbeAE/3G2cYEkxhAcGJGBsKCNaEyYtg3WSIG9ColpGWg+nsYQBp0NDoIaRNrzIUqgKihmJFslIo57LrtAl+Ze227G+z7Tm2PmtNkHRaao5gFZsrizX0Db4DwYsgXtCamIiuSUpWtCRgHiUVsGqtsLYt1p2p6EaUSnO1Y4DsI0zVpzSY7iQpc76UoYUelMHBEzDk8nTuRWxhQ5ccKYJbQJAWhJK1SVs2hCYFj70eaKG1G6Tp52iv8LOuTcyw6VvUxVUtc622q8wZb2WczdpDzUlKX+KWZGVVpH486ZKgSFYD4VZ/wlej6c1UWoIceJPcCHmbzu42zEvz45z99rr+OLcmWuHG2gD5sueTzmltiBZaJjI+KziPLEnNetjqFqvOyaH+aTwGMc/6slb3l3oTIlYxNz20l17hKLnX84XkA17nJYSlKUMWA6Qq8pJhKklvf1TLP3Ikx5L3bCy8AJH2AKZWMLtFGwDSvp9x1Mqs35ljiRy3iPvwAFOhYoKUSl4REjwF/Pi0Jm/eb5q1Y2+MjmWKqPUaLXCoHTqy/qcslZokZyulK6tUbSz2wWHzrylr081q1A8l+rQH37Fn6OLrutzHB/gZ8NM/YfSIyLKXPJxWHfehKf2Dpchtpun10Dq6HbukEkQ8W8HuXaBpyqSuYWr+nzbZac5rNbo0b4u4z7pG6vEE3D/TFRj9YgkteuDm82GSIjeYuvwh0t8vj8vK6YVe7A9qFG6Mte9uu3Z3zf35BI+fDAE38V8l6bEWS8bogQAAAABJRU5ErkJggg=='
    Local $bString = _WinAPI_Base64Decode($WTB)
    If @error Then Return SetError(1, 0, 0)
    $bString = Binary($bString)
    If $bSaveBinary Then
        Local Const $hFile = FileOpen($sSavePath & "\Windows Title Bar1.png", 18)
        If @error Then Return SetError(2, 0, $bString)
        FileWrite($hFile, $bString)
        FileClose($hFile)
    EndIf
    Return $bString
EndFunc   ;==>_WTB

Func _WinAPI_Base64Decode($sB64String)
    Local $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(1, 0, "")
    Local $bBuffer = DllStructCreate("byte[" & $aCrypt[5] & "]")
    $aCrypt = DllCall("Crypt32.dll", "bool", "CryptStringToBinaryA", "str", $sB64String, "dword", 0, "dword", 1, "struct*", $bBuffer, "dword*", $aCrypt[5], "ptr", 0, "ptr", 0)
    If @error Or Not $aCrypt[0] Then Return SetError(2, 0, "")
    Return DllStructGetData($bBuffer, 1)
EndFunc   ;==>_WinAPI_Base64Decode

This looks like the old WinXP titlebar and I tested it only on Win8. The hover has to be implemented manually.

 

The tint effect reqires GDIPlus v1.1!

Edited by UEZ
Example extended a little bit more

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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
ManneMoses

Are you talking about the Height or the Width of the title bar. Width is easy as you just change the width of the window and the title bar expands with it. I am unsure of how to, and also unsure of why you would want a taller title bar.

I mean the height, sorry i forgot to say

Share this post


Link to post
Share on other sites
ManneMoses

Thank you Uez, it works! But is there no easier way to do this? 

Share this post


Link to post
Share on other sites
UEZ

This is a fake title bar. I don't know whether it is possible to change that height for default GUI!
At the first glance it might look complicated but if you spend some time to understand the idea behind this fake title bar it will be much easier to understand.
If you have question don't hesitate to ask here.


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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites
JohnOne

Thank you Uez, it works! But is there no easier way to do this? 

GUICreate("GUI", 200, 200, 100, 100, 0x80880000) ; 0x80880000 = $WS_POPUPWINDOW
GUICtrlCreateLabel("Title Bar", 0, 0, 160, 40, -1, 0x00100000) ; 0x00100000 = $GUI_WS_EX_PARENTDRAG
GUICtrlSetBkColor(-1, 0x0000FF)
GUICtrlSetColor(-1, 0xFFFFFF)
$Close = GUICtrlCreateButton("X", 160, 0, 40, 40)
GUICtrlSetBkColor(-1, 0xFF0000)
GUICtrlSetColor(-1, 0xFFFFFF)
GUISetState(@SW_SHOW)

While 3
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $Close
            Exit
    EndSwitch
WEnd

You wanted easy.

Alternatively, use a picture instead of a label and or button.

  • Like 1

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
reb

@JohnOne

I like that.

Centered text in label

;~ Name:   JohnOne
;~ URL:    https://www.autoitscript.com/forum/topic/173672-change-the-size-of-the-gui-title-bar/#comment-1257450
#include <WindowsConstants.au3>

#include <WindowsConstants.au3>
#include <StaticConstants.au3>
;~ Local $GUI_WS_EX_PARENTDRAG
GUICreate("GUI", 200, 200, 100, 100, 0x80880000) ; 0x80880000 = $WS_POPUPWINDOW
$TitleBar = GUICtrlCreateLabel("Title Bar", 0, 0, 160, 40,BitOR($SS_CENTER,$SS_CENTERIMAGE),0x00100000) ;$GUI_WS_EX_PARENTDRAG) ; 0x00100000 = $GUI_WS_EX_PARENTDRAG  , -1
GUICtrlSetBkColor(-1, 0x0000FF)
GUICtrlSetColor(-1, 0xFFFFFF)
$Close = GUICtrlCreateButton("X", 160, 0, 40, 40,$WS_EX_TRANSPARENT)
GUICtrlSetBkColor(-1, 0xFF0000)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetFont($TitleBar,10,600)
GUISetState(@SW_SHOW)

While 3
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $Close
            Exit
    EndSwitch
WEnd

 

  • Like 1

MEASURE TWICE - CUT ONCE

Share this post


Link to post
Share on other sites
jguinch

I'm not sure, but you can try _WinAPI_DwmExtendFrameIntoClientArea

 

#include <GUIConstantsEx.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

If Not _WinAPI_DwmIsCompositionEnabled() Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later with enabled Aero theme.')
    Exit
EndIf

Local $hForm = GUICreate('Test', 400, 400)
GUICtrlCreateLabel("", 0, 82, 400, 318, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetBkColor(-1, 0xffffff)
GUICtrlSetState(-1, $GUI_DISABLE)

GUICtrlCreateButton("Button", 10, 100, 200, 25)

GUISetBkColor(0)
_WinAPI_DwmExtendFrameIntoClientArea($hForm, _WinAPI_CreateMargins(0, 0, 82, 2))


GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

 

Edited by jguinch
  • Like 1

Share this post


Link to post
Share on other sites
ManneMoses

I'm not sure, but you can try _WinAPI_DwmExtendFrameIntoClientArea

 

#include <GUIConstantsEx.au3>
#include <WinAPIGdi.au3>
#include <WindowsConstants.au3>

If Not _WinAPI_DwmIsCompositionEnabled() Then
    MsgBox(BitOR($MB_ICONERROR, $MB_SYSTEMMODAL), 'Error', 'Require Windows Vista or later with enabled Aero theme.')
    Exit
EndIf

Local $hForm = GUICreate('Test', 400, 400)
GUICtrlCreateLabel("", 0, 82, 400, 318, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetBkColor(-1, 0xffffff)
GUICtrlSetState(-1, $GUI_DISABLE)

GUICtrlCreateButton("Button", 10, 100, 200, 25)

GUISetBkColor(0)
_WinAPI_DwmExtendFrameIntoClientArea($hForm, _WinAPI_CreateMargins(0, 0, 82, 2))


GUISetState(@SW_SHOW)

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

 

Thank you man, this is awesome! Exactly what i wanted, thanks!!

Share this post


Link to post
Share on other sites
ManneMoses

I modified the script from jguinch a little a this came out ( Not useful, but in my opinion this looks awesome )

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPIGdi.au3>
#include <SendMessage.au3>




Local $GUI = GUICreate('ok', 700, 700, -1, -1, BitXOR($WS_SIZEBOX, $WS_POPUP, $WS_MINIMIZEBOX), -1, WinGetHandle(AutoItWinGetTitle()))
Global Const $SC_DRAGMOVE = 0xF012
GUICtrlSetState(-1, $GUI_DISABLE)
WinSetOnTop( "ok", "", 1 )
GUISetBkColor(0)
_WinAPI_DwmExtendFrameIntoClientArea($gui, _WinAPI_CreateMargins(0, 0, 2000, 2))

    GUISetState(@SW_SHOW, $GUI)

    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                ExitLoop
         Case $GUI_EVENT_PRIMARYDOWN
             _SendMessage($GUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0)
        EndSwitch
    WEnd

 

Share this post


Link to post
Share on other sites
UEZ

That will work only properly on Vista / Win7 when Aero is enabled.


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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

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

  • Similar Content

    • Sven-Seyfert
      By Sven-Seyfert
      Hi Community,

      I use a UDF by @smashly to play a video in a GUI. That works fine for my main monitor.
      But when I change the X and Y positions of the GUI (also for the video) to my second or third monitor, the video plays, I can hear the sound of it, but I don't see the video.

      I debugged the UDF and checked the Microsoft description for MCI Command Strings which are used in the UDF (docs.microsoft...) - everything is fine, so I got no clue why the video isn't displayed.

      PlayVideoTest.au3:
       
      VideoInGui_by_Smashky.au3 (UDF):
       
      The example video:
       
      It would be great when anyone can help .
      Is there maybe a other way to play (display videos in GUI)?

      Thanks for any suggestion - I'm grateful!
      Sven
    • UEZ
      By UEZ
      Following script shows a parent GUI with a child GUI initialized as MDICHILD.
      #include <Constants.au3> #include <GUIConstantsEx.au3> #include <GuiReBar.au3> #include <GuiScrollBars.au3> #include <GuiToolbar.au3> #include <ScreenCapture.au3> #include <ScrollBarConstants.au3> #include <WindowsConstants.au3> _GDIPlus_Startup() Global Enum $idNew = 1000, $idOpen, $idSave, $idHelper Global Const $iImageW = @DesktopWidth, $iImageH = @DesktopHeight Global Const $hBMP_ScreenCapture = _ScreenCapture_Capture("", 0, 0, $iImageW, $iImageH, False) Global Const $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hBMP_ScreenCapture) Sleep(50) Global Const $iW = 1500, $iH = 700, $SC_DRAGMOVE = 0xF012 Global Const $hGUI = GUICreate("Move child GUI within GUI", $iW, $iH) Global Const $hToolbar = _GUICtrlToolbar_Create($hGUI) Global Const $hReBar = _GUICtrlRebar_Create($hGUI, BitOR($CCS_TOP, $RBS_VARHEIGHT, $RBS_AUTOSIZE, $RBS_BANDBORDERS)) Global Const $height_delta = 37 Global Const $idPic = GUICtrlCreatePic("", 0, $height_delta + 2, $iW, $iH) Global $hBitmap_tmp, $hHBitmap_tmp $hBitmap_tmp = _GDIPlus_BitmapCreateFromScan0($iW, $iH) Global $hGfx_Context = _GDIPlus_ImageGetGraphicsContext($hBitmap_tmp) _GUICtrlToolbar_AddBitmap($hToolbar, 1, -1, $IDB_STD_LARGE_COLOR) _GUICtrlToolbar_AddButton($hToolbar, $idNew, $STD_FILENEW) _GUICtrlToolbar_AddButton($hToolbar, $idOpen, $STD_FILEOPEN) _GUICtrlToolbar_AddButton($hToolbar, $idSave, $STD_FILESAVE) _GUICtrlToolbar_AddButtonSep($hToolbar) _GUICtrlToolbar_AddButton($hToolbar, $idHelper, $STD_HELP) _GUICtrlRebar_AddToolBarBand($hReBar, $hToolbar, "", 0) Global Const $iVSscroll = _WinAPI_GetSystemMetrics(2) Global Const $iHSscroll = _WinAPI_GetSystemMetrics(3) Global Const $iYCaption = _WinAPI_GetSystemMetrics(4) Global Const $iYFixedFrame = _WinAPI_GetSystemMetrics(8) Global Const $iXFixedFrame = _WinAPI_GetSystemMetrics(7) Global Const $iMetricsSumX = $iVSscroll + $iXFixedFrame * 2 Global Const $iMetricsSumY = $iHSscroll + $iYCaption + $iYFixedFrame _GUIScrollBars_Init($hGUI) _GUIScrollBars_SetScrollInfoMin($hGUI, $SB_HORZ, 0) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_HORZ, $iImageW - $iW + 61 + $iMetricsSumX) _GUIScrollBars_SetScrollInfoMin($hGUI, $SB_VERT, 0) _GUIScrollBars_SetScrollInfoMax($hGUI, $SB_VERT, $iImageH - $iH + $iMetricsSumY + $height_delta - 1) GUISetState(@SW_SHOW, $hGUI) Global Const $STM_SETIMAGE = 0x0172 _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hBMP_ScreenCapture)) Global $IE_offset_x = 0, $IE_offset_y = 0 DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL_IE") GUIRegisterMsg($WM_VSCROLL, "WM_VSCROLL_IE") Global $iPosX_Crop = 0, $iPosY_Crop = 0, $iW_crop = 200, $iH_crop = 200, $bMove_Crop = True Global $hGUI_IE_Crop = GUICreate("", $iW_crop, $iH_crop, $iPosX_Crop, $iPosY_Crop) GUISetStyle(BitOR($WS_BORDER, $WS_POPUP), $WS_EX_MDICHILD) _WinAPI_SetParent($hGUI_IE_Crop, $hGUI) WinSetTrans($hGUI_IE_Crop, "", 0xA0) Global $iLable_CropMove = GUICtrlCreateLabel("", 0, 0, $iW_crop, $iH_crop, -1, $GUI_WS_EX_PARENTDRAG) GUISetState(@SW_SHOW, $hGUI_IE_Crop) GUIRegisterMsg($WM_MOVE, "WM_MOVE_IE_GUI_Crop") ;~ GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch Until False GUIRegisterMsg($WM_HSCROLL, "") GUIRegisterMsg($WM_VSCROLL, "") GUIRegisterMsg($WM_MOVE, "") GUIRegisterMsg($WM_LBUTTONDOWN, "") _WinAPI_DeleteObject($hBMP_ScreenCapture) _GDIPlus_BitmapDispose($hBitmap_tmp) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hGfx_Context) _GDIPlus_Shutdown() Exit Func WM_HSCROLL_IE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $Min, $Max, $Page, $TrackPos ; Get all the horizontal scroll bar information Local $tSCROLLINFO_X = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $Min = DllStructGetData($tSCROLLINFO_X, "nMin") $Max = DllStructGetData($tSCROLLINFO_X, "nMax") $Page = DllStructGetData($tSCROLLINFO_X, "nPage") ; Save the position for comparison later on $IE_offset_x = DllStructGetData($tSCROLLINFO_X, "nPos") $TrackPos = DllStructGetData($tSCROLLINFO_X, "nTrackPos") #forceref $Min, $Max Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Switch $nScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x - $Page) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO_X, "nPos", $IE_offset_x + $Page) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO_X, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO_X, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO_X) $IE_offset_x = DllStructGetData($tSCROLLINFO_X, "nPos") DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) $hHBitmap_tmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_tmp) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap_tmp)) _WinAPI_DeleteObject($hHBitmap_tmp) $bMove_Crop = False ConsoleWrite($iPosX_Crop & ", " & $iPosY_Crop & " / " & $IE_offset_x & ", " & $IE_offset_y & @CRLF) WinMove($hGUI_IE_Crop, "", -$IE_offset_x + $iPosX_Crop, -$IE_offset_y + $iPosY_Crop) ;~ DllCall("user32.dll", "bool", "MoveWindow", "hwnd", $hGUI_IE_Crop, "int", -$IE_offset_x + $iPosX_Crop, "int", -$IE_offset_y + $iPosY_Crop, "int", $iW_crop, "int", $iH_crop, "bool", True) $bMove_Crop = True Return "GUI_RUNDEFMSG" EndFunc ;==>WM_HSCROLL_IE Func WM_VSCROLL_IE($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $Min, $Max, $Page, $TrackPos ;~ ; Get all the horizontal scroll bar information Local $tSCROLLINFO_Y = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_VERT) $Min = DllStructGetData($tSCROLLINFO_Y, "nMin") $Max = DllStructGetData($tSCROLLINFO_Y, "nMax") $Page = DllStructGetData($tSCROLLINFO_Y, "nPage") ; Save the position for comparison later on $IE_offset_y = DllStructGetData($tSCROLLINFO_Y, "nPos") $TrackPos = DllStructGetData($tSCROLLINFO_Y, "nTrackPos") #forceref $Min, $Max Local $nScrollCode = BitAND($wParam, 0x0000FFFF) Switch $nScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y - $Page) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO_Y, "nPos", $IE_offset_y + $Page) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO_Y, "nPos", $TrackPos) EndSwitch DllStructSetData($tSCROLLINFO_Y, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_VERT, $tSCROLLINFO_Y) $IE_offset_y = DllStructGetData($tSCROLLINFO_Y, "nPos") DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) $bMove_Crop = False ConsoleWrite($iPosX_Crop & ", " & $iPosY_Crop & " / " & $IE_offset_x & ", " & $IE_offset_y & @CRLF) WinMove($hGUI_IE_Crop, "", -$IE_offset_x + $iPosX_Crop, -$IE_offset_y + $iPosY_Crop) ;~ DllCall("user32.dll", "bool", "MoveWindow", "hwnd", $hGUI_IE_Crop, "int", -$IE_offset_x + $iPosX_Crop, "int", -$IE_offset_y + $iPosY_Crop, "int", $iW_crop, "int", $iH_crop, "bool", True) $bMove_Crop = True Return "GUI_RUNDEFMSG" EndFunc ;==>WM_VSCROLL_IE Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) _SendMessage($hGUI_IE_Crop, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndFunc ;==>_WM_LBUTTONDOWN Func WM_MOVE_IE_GUI_Crop($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam If $hWnd = $hGUI_IE_Crop And $bMove_Crop Then $iPosX_Crop = _WinAPI_LoWord($lParam) $iPosY_Crop = _WinAPI_HiWord($lParam) EndIf Return "GUI_RUNDEFMSG" EndFunc ;==>WM_MOVE_IE_GUI_Crop Func WM_SIZE_IE_GUI_Crop($hWnd, $iMsg, $wParam, $lParam) Return $GUI_RUNDEFMSG EndFunc ;==>WM_SIZE_IE_GUI_Crop Func DrawImage($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH) _GDIPlus_GraphicsDrawImageRectRect($hGfx_Context, $hBitmap, $IE_offset_x, $IE_offset_y, $iW, $iH, 0, 0, $iW, $iH) $hHBitmap_tmp = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_tmp) _WinAPI_DeleteObject(GUICtrlSendMsg($idPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap_tmp)) _WinAPI_DeleteObject($hHBitmap_tmp) EndFunc  
      My problem: if you move the child window at left upper corner to another place and move either H or V scrollbar the child GUI will be moved properly. BUT if you have scrolled the scrollbars to the right bottom of the image and move the child GUI to that corner, too then the child GUI jumps if you click on one of the scrollbars.
      Is there something that I didn't consider?
    • Emmhor1
      By Emmhor1
      Hi All,

      MAIN QUESTION:
      Is it possible to Call specific function within a GUI

      So I have a script with multiple functions although I don't want to use every function every time.
      My Idea is to create a simple GUI which allows me to select what functions I want to use then run the funtions by clicking a button.
      I have already made a GUI which allows me to select specific .exe's I would like to run after selection it runs the .exe one by one.
      This script is on my work laptops and cannot access it right now.
       
      Who can help me with this?
      GUIcreate
      Func1 
      Func2
      Func3
      Then have a boxes which allows me to select the specif Func.(I used GUIChecked and Unchecked in my other script)
      Then a button which executes/calls the selected functions
    • Blois
      By Blois
      Hi Guis,
       
      I need to create keyboard shortcut to navigate the tabs and activate them, but I could not use the code below:
      #include <TabConstants.au3> #include <WindowsConstants.au3> #include <GuiTab.au3> #include <GUIConstantsEx.au3> HotKeySet("^{TAB}", "_TabRight") HotKeySet("^+{TAB}", "_TabLeft") $gui = GUICreate("test",450, 300) $Tab1 = GUICtrlCreateTab(20, 24, 425, 201) $TabSheet1 = GUICtrlCreateTabItem("Tabsheet 1") $lbContagemGrupos2 = GUICtrlCreateLabel("aaaa", 50, 50) GUICtrlSetColor(-1, 0x0000FF) GUICtrlCreateTabItem("") $TabSheet2 = GUICtrlCreateTabItem(" ") $TabSheet3 = GUICtrlCreateTabItem(" ") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func _TabRight() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos + 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Func _TabLeft() $CurPos = _GUICtrlTab_GetCurSel($Tab1) _GUICtrlTab_SetCurSel($Tab1, $CurPos - 1) $tab = "$TabSheet" & $CurPos GUICtrlSetState($TabSheet1 + $CurPos, $GUI_SHOW) Return EndFunc Exit  
      can you help me?
    • Pricehacker
      By Pricehacker
      Hello again!
      I have tried searching for quite some time now but couldn´t find a single working way to change the class of your GUI that doesn´t include changing it manually after its compilation.
      First or "AutoIt v3 GUI" is a pretty boring name tbh and i would like to spice it up a bit, also, and more importantly, I would like to identify my windows by something other than its title as it will change depending on some factors and im using two different programs independently as multi threading isn't supported.
      Any help is appreciated! Thank you!
×