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

    • WoodGrain
      By WoodGrain
      Hi guys,
      I'm learning about GUI's, I'm trying the below code, the idea being if I press the letter "e" while I have the GUI open I want the label color to change to green (I'm using a UDF for label colors). But every time I press "e" on my keyboard I just get a "ding" sound from my speakers and nothing changes with the label.
      I've looked at using something like "While GUIGetMsg() <> $GUI_EVENT_CLOSE" as I've seen it in other code instead of "While 1", but I don't think it's relevant.
      #include <GUIConstantsEx.au3>; for GUI... #include <GUIRichLabel.au3>; UDF for rich text label fonts #include <Misc.au3>; for _IsPressed $myLetter = "e" $hGUI = GUICreate("test", 700, 60) $lbl2 = _GUICtrlRichLabel_Create($hGUI, '<font color="purple">' & $myLetter & '</font>', 10, 10); , 260, 25 GUISetState(@SW_SHOW) Local $hDLL = DllOpen("user32.dll") While 1 if _IsPressed(Hex($myLetter), $hDLL) Then While _IsPressed(Hex($myLetter), $hDLL) Sleep(250) WEnd _GUICtrlRichLabel_SetData($lbl2, '<font color="green">' & $myLetter & '</font>') Sleep(2000) DllClose($hDLL) Exit EndIf Sleep(50) WEnd DllClose($hDLL) I am using an array of letters that I'm wanting to do this for, but as I can't get it to work I've stripped it down to the simplest code I can think of to try and get this working first. Appreciate any help.
      Thanks!
    • nacerbaaziz
      By nacerbaaziz
      hi dears, i have an question please if you can help me.
      i maked an program to do some functions
      and this program works with the global hot keys
      i added an option to the users to change the hot keys
      when i searched about how to do that i found this UDF
      GUIHotkey.au3
      http://www.autoitscript.com/forum/index.php?showtopic=107965
      but the problem here that this UDF cant be detect the win key.
      can you help me to add it, or if there are any others UDFSS wich do that work please give me some.
      i hope that my question is clear for you.
      thanks in advance
    • Silas
      By Silas
      Hello everyone,
      I have a radio button ($Radio1), which I want to disable as soon as another one get's checked (Radio5). (The system fails if the radio button i'm troubling with also gets checked).
      I know how to disable him:
      If GUICtrlRead($Radio1)=1 And Not BitAND(GUICtrlGetState($Radio5), $GUI_DISABLE) Then GUICtrlSetState($Radio5, 128) But if i try to enable $Radio5 again, after $Radio1 isn't checked anymore, it fails:
      If GUICtrlRead($Radio1)=Not 1 And Not BitAND(GUICtrlGetState($Radio5), $GUI_ENABLE) Then GUICtrlSetState($Radio5, 64)  
      Anyone knows why?
    • Bllee
      By Bllee
      every time i press "delete button" delete a line, but i can't add new line with info. the id line write normally but i can't change or add new info
      obs: looking at the "includes" one realizes that already tried of everything that knew
      my code
      #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <GuiImageList.au3> #include <GuiListView.au3> #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <MsgBoxConstants.au3> #include <WinAPI.au3> #include <StringConstants.au3> #include <Array.au3> #include <GuiListBox.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 612, 480, 192, 154) $MenuItem1 = GUICtrlCreateMenu("&Arquivo") $MenuItem2 = GUICtrlCreateMenuItem("Salvar Ctrl+S", $MenuItem1, $SS_CENTER) $MenuItem4 = GUICtrlCreateMenuItem("Carregar Ctrl+O", $MenuItem1, $SS_CENTER) $MenuItem3 = GUICtrlCreateMenuItem("Salvar Como Shitft+Ctrl+S", $MenuItem1, $SS_CENTER) $Group1 = GUICtrlCreateGroup("", 21, 8, 569, 97, $SS_CENTER) $Input1 = GUICtrlCreateInput("ID COR", 122, 32, 97, 21, $SS_CENTER) $Input2 = GUICtrlCreateInput("REGIÃO", 138, 64, 249, 21, $SS_CENTER) $Input3 = GUICtrlCreateInput("Label", 264, 30, 121, 21, $SS_CENTER) $Label1 = GUICtrlCreateLabel("Label", 232, 32, 30, 17, $SS_CENTER) $Button1 = GUICtrlCreateButton("Capturar Cor", 42, 30, 75, 25, $SS_CENTER) $Button2 = GUICtrlCreateButton("Capturar Região", 42, 62, 91, 25, $SS_CENTER) $Button3 = GUICtrlCreateButton("ADD", 442, 24, 113, 33) $Button5 = GUICtrlCreateButton("Delet", 442, 64, 113, 33) $Group2 = GUICtrlCreateGroup("Editar ID selecionado", 8, 384, 601, 57, $SS_CENTER) $Input7 = GUICtrlCreateInput("ID", 10, 402, 40,21, $SS_CENTER) $Input4 = GUICtrlCreateInput("COR", 51, 402, 121, 21, $SS_CENTER) $Input5 = GUICtrlCreateInput("REGIÃO", 173, 402, 249, 21, $SS_CENTER) $Input6 = GUICtrlCreateInput("LABEL", 423, 402, 121, 21, $SS_CENTER) $Button4 = GUICtrlCreateButton("\/", 544, 400, 30, 25, $SS_CENTER) $Button6 = GUICtrlCreateButton("/\", 574, 400, 30, 25, $SS_CENTER) ; Add column Global $id = Int(0) $List1 = GUICtrlCreateListView("",5, 120, 601, 253, $SS_CENTER) _GUICtrlListView_AddColumn($List1, "ID",40) _GUICtrlListView_AddColumn($List1, "COR",100) _GUICtrlListView_AddColumn($List1, "COORDENADA",305) _GUICtrlListView_AddColumn($List1, "LABEL",150) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $MenuItem2 MsgBox($MB_SYSTEMMODAL, "ctrl + s", "Nothing Here",1) Case $MenuItem3 MsgBox($MB_SYSTEMMODAL, "shift+ctrl s", "Nothing Here",1) Case $MenuItem4 MsgBox($MB_SYSTEMMODAL, "ctrl + o", "Nothing Here",1) Case $Button1 MsgBox($MB_SYSTEMMODAL, "Capturar cor", "Aperte espaço para capturar a cor") GUICtrlSetData($Input1,MouseColor()) Case $Button2 MsgBox($MB_SYSTEMMODAL, "capturar região", "Aperte espaço para capturar a posição inicial") local $mouse = MouseGetPos() $x_init = $mouse[0] $y_init = $mouse[1] MsgBox($MB_SYSTEMMODAL, "capturar região", "Aperte espaço para capturar a posição final") local $mouse = MouseGetPos() $x_end = $mouse[0] $y_end = $mouse[1] GUICtrlSetData($Input2,$x_init&','&$y_init&' ; '&$x_end&','&$y_end) Case $Button3 _GUICtrlListView_AddItem($List1, $id, 1) ; id _GUICtrlListView_AddSubItem($List1, $id, GUICtrlRead($Input1), 1, 1) ;cor _GUICtrlListView_AddSubItem($List1, $id, GUICtrlRead($Input2), 2, 1) ;coordenada _GUICtrlListView_AddSubItem($List1, $id, GUICtrlRead($Input3), 3, 1) ;label $id= $id + 1 Case $Button4 $Item = _GUICtrlListView_GetSelectedIndices($List1) $Sid = _GUICtrlListView_GetItem($List1, Number($Item),0) $Scor = _GUICtrlListView_GetItem($List1, Number($Item),1) $Scord = _GUICtrlListView_GetItem($List1, Number($Item),2) $Slabel = _GUICtrlListView_GetItem($List1, Number($Item),3) ; get info GUICtrlSetData($Input7,$Sid[3]) GUICtrlSetData($Input4,$Scor[3]) GUICtrlSetData($Input5,$Scord[3]) GUICtrlSetData($Input6,$Slabel[3]) Case $Button5 _GUICtrlListView_DeleteItemsSelected($List1) Case $Button6 ; give back inf if GUICtrlRead($Input7) <> "ID" Then _GUICtrlListView_SetItem($List1, GUICtrlRead($Input4), GUICtrlRead($Input7),1) ;cor _GUICtrlListView_SetItem($List1, GUICtrlRead($Input5), GUICtrlRead($Input7),2) ;coordenada _GUICtrlListView_SetItem($List1, GUICtrlRead($Input6), GUICtrlRead($Input7),3) ;coordenada EndIf EndSwitch WEnd Func MouseColor() local $mouse = MouseGetPos() Return Hex(PixelGetColor($mouse[0],$mouse[1]), 6) EndFunc  
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good evening everyone
      First, I want to apologize with you for the title not very clear, but I thought a little bit on which title to set at the thread, and this is the one that came in mind.
      Now, let me explain what I'm trying to understand.

      I am making an application ( with n clients ), with an SQLite Database, which has a Main form, and n sub-forms... 
      Since these sub-forms are called several times, because they are used to add or update records to the Database, I put the code that generates the GUI of these sub-forms in Functions.
      There are two sub-forms which are "treated" as two main forms, since even them have n sub-forms, which perform various tasks.
      Where am I stucked?

      For the Main form I created a Status Bar, in order to display messages ( add/delete/update/search results ), and it works perfectly with all the forms which don't have other sub-forms.
      For the two forms, which indeed have n sub-forms, I created two separated Status Bars, which are (re)created everytime I call the function that then displays the form.
      Practically, I can't set icons to these two Status Bars, and I don't know why.
      I'm really sorry that I don't feel clear enough, so, here you are an example of what I am saying.
      I recreated exactly what my script does:
      #include <GuiButton.au3> #include <GUIConstantsEx.au3> #include <GuiStatusBar.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) Global $frmSubForm, _ $txtSubFormField, _ $sbSubFormStatusBar, _ $objSB_IconError = _WinAPI_LoadShell32Icon(109), _ $objSB_IconInformation = _WinAPI_LoadShell32Icon(277) #Region ### START Koda GUI section ### Form= $frmMainForm = GUICreate("Main Form", 300, 300, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, "ExitApplication") $sbMainStatusBar = _GUICtrlStatusBar_Create($frmMainForm) $btnCreateSubForm = GUICtrlCreateButton("Create Sub Form", 105, 110, 75, 41, BitOR($BS_CENTER,$BS_VCENTER,$BS_MULTILINE)) GUICtrlSetOnEvent(-1, "GenerateSubForm") GUICtrlSetFont(-1, 10, 400, 0, "Arial") _GUICtrlStatusBar_SetSimple($sbMainStatusBar) _GUICtrlStatusBar_SetText($sbMainStatusBar, "") GUISetState(@SW_SHOW, $frmMainForm) #EndRegion ### END Koda GUI section ### While 1 Sleep(100) WEnd Func ExitApplication() Exit EndFunc Func GenerateSubForm() #Region ### START Koda GUI section ### Form= $frmSubForm = GUICreate("Sub-Form", 300, 300, -1, -1, -1, -1, $frmMainForm) GUISetOnEvent($GUI_EVENT_CLOSE, "DeleteSubForm") $txtSubFormField = GUICtrlCreateInput("", 0, 0, 100, 20) $btnCheckSubFormField = GUICtrlCreateButton("Check Field", 105, 110, 75, 41, BitOR($BS_CENTER,$BS_VCENTER,$BS_MULTILINE)) GUICtrlSetOnEvent(-1, "CheckSubFormField") GUICtrlSetFont(-1, 10, 400, 0, "Arial") $sbSubFormStatusBar = _GUICtrlStatusBar_Create($frmSubForm) _GUICtrlStatusBar_SetSimple($sbSubFormStatusBar) _GUICtrlStatusBar_SetText($sbSubFormStatusBar, "") GUISetState(@SW_SHOW, $frmSubForm) GUISetState(@SW_DISABLE, $frmMainForm) #EndRegion ### END Koda GUI section ### EndFunc Func DeleteSubForm() ; Declared Globally => $frmSubForm GUIDelete($frmSubForm) GUISetState(@SW_ENABLE, $frmMainForm) EndFunc Func WriteToStatusBar($sbStatusBar, $objSB_Icon, $strText) _GUICtrlStatusBar_SetIcon($sbStatusBar, 0, $objSB_Icon) _GUICtrlStatusBar_SetText($sbStatusBar, $strText) ConsoleWrite("Icon Handle: " & $objSB_Icon & @CRLF) EndFunc Func CheckSubFormField() ; Declared Globally => $txtSubFormField If GUICtrlRead($txtSubFormField) = "" Then ; Declared Globally => $sbStatusBar WriteToStatusBar($sbSubFormStatusBar, $objSB_IconError, "Field NOK.") Else WriteToStatusBar($sbSubFormStatusBar, $objSB_IconInformation, "Field OK.") EndIf EndFunc The text is set, but icon is not.
      Could someone please tell me why?
      Thanks everyone in advance  

      Best Regards.
×