Jump to content

create a larger than normal close button?


kor
 Share

Recommended Posts

I'm updating a script to work with Windows 8. Since our users will be using touch on the windows 8 tablets I'd like to make the close button in the top right corner of the GUI larger than normal to make it easier to close with a finger. Here is my code, is there anyway to make the close button / title bar larger than normal to accommodate a larger close button?

Select ; Read IP Address
        Case StringInStr(@IPAddress1, "10.0") ; look for any adapater that has 10.0 IP octets
            $sIP = @IPAddress1
        Case StringInStr(@IPAddress2, "10.0") ; case statements are processed in order
            $sIP = @IPAddress2
        Case StringInStr(@IPAddress3, "10.0") ; so the first available IP address will be used
            $sIP = @IPAddress3
        Case Else
            $sIP = @IPAddress1 ; if you can't find any valid IP's then default back to @IPAddress1
    EndSelect
    Local $sRemoteID = StringReplace(StringReplace($sIP, "10.0.", ""), ".", " . ")
    Local $hGUI = GUICreate(" Remote ID", 280, 100, -1, -1, BitOR($WS_CAPTION, $WS_SYSMENU), $WS_EX_DLGMODALFRAME)
    Local $hIcon = _WinAPI_GetClassLongEx($hGUI, $GCL_HICON)
    _WinAPI_DestroyIcon($hIcon)
    _WinAPI_SetClassLongEx($hGUI, $GCL_HICON, 0)
    _WinAPI_SetClassLongEx($hGUI, $GCL_HICONSM, 0)
    ;$hGUIPic = GUICtrlCreatePic(@ScriptDir & "\background.jpg", 0, 0, 0, 0) ; background
    $cRemoteID = GUICtrlCreateLabel($sRemoteID, 0, 0, 280, 100) ; remote id
    GUICtrlSetBkColor($cRemoteID, $GUI_BKCOLOR_TRANSPARENT) ; set label backgroud transparent
    GUICtrlSetColor($cRemoteID, 0x0D2C4F)
    GUICtrlSetFont($cRemoteID, 39, 400, 0, "Quartz MS", 6)
    GUICtrlSetStyle($cRemoteID, $SS_CENTER + $SS_CENTERIMAGE) ; center image horz and vert
    GUISetState(@SW_SHOW, $hGUI)
    While 1
        If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit
    WEnd
    GUIDelete($hGUI)
Link to comment
Share on other sites

Why not just make a button on the GUI that says "Exit" that closes the GUI?

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

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

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

Link to comment
Share on other sites

Why not just make a button on the GUI that says "Exit" that closes the GUI?

want to keep the GUI as clean and minimal as possible. Hoping to accomplish using built in windows close button. Setting title bar pixels height or something.

Link to comment
Share on other sites

Have you tried searching for this? Because I seem to remember this being asked a few times here.

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

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

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

Link to comment
Share on other sites

Have you tried searching for this? Because I seem to remember this being asked a few times here.

I have

I've tried searching for window title, titlebar size, close box size, and a few others.

Nothing coming up that's relevant. 

Link to comment
Share on other sites

  • 4 weeks later...

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Local $hGUI = GUICreate(" Remote ID", 480, 200, -1, -1, BitOR($WS_popup, $WS_SYSMENU), $WS_EX_DLGMODALFRAME)
$cRemoteID = GUICtrlCreateLabel("$sRemoteID", 0, 20, 380, 100) ; remote id
$Exit = GUICtrlCreateLabel("X", 450, 0, 80, 40) ; Exit
GUICtrlSetBkColor(-1, 0x00ff00)
GUICtrlSetColor(-1, 0xff0000)
GUICtrlSetFont(-1, 28)
GUICtrlSetBkColor($cRemoteID, $GUI_BKCOLOR_TRANSPARENT) ; set label backgroud transparent
GUICtrlSetColor($cRemoteID, 0x0D2C4F)
GUICtrlSetFont($cRemoteID, 39, 400, 0, "Quartz MS", 6)
GUISetState(@SW_SHOW, $hGUI)
While 1
$nMsg = GUIGetMsg()
    Switch $nMsg
        Case $Exit
            ExitLoop
    EndSwitch
WEnd
GUIDelete($hGUI)

Link to comment
Share on other sites

You could do a picture button like this:

#region
#AutoIt3Wrapper_Run_Tidy=y
#AutoIt3Wrapper_Tidy_Stop_OnError=n
#endregion

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

DirCreate(@TempDir & "\images")
FileInstall("images\header.gif", @TempDir & "\images\header.gif", 1)
FileInstall("images\x_close_1.gif", @TempDir & "\images\x_close_1.gif", 1)
FileInstall("images\x_close_2.gif", @TempDir & "\images\x_close_2.gif", 1)

Global $GUI_BGC = "0xacacac", $main, $pic_exit

$main = GUICreate("Test titlebar button", 615, 422, -1, -1, $WS_POPUP)
GUISetBkColor($GUI_BGC)

GUICtrlCreatePic(@TempDir & "\images\header.gif", 0, 0, 615, 20)
GUICtrlSetState(-1, $GUI_DISABLE)

$pic_exit = GUICtrlCreatePic(@TempDir & "\images\x_close_1.gif", 580, 0, 30, 18)

GUIRegisterMsg($WM_NCHITTEST, "_MY_NCHITTEST")

GUISetState(@SW_SHOW, $main)

$Icon1UnderCursor = False

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $pic_exit
            DirRemove(@TempDir & "\images", 1)
            Exit
    EndSwitch
    $cursor = GUIGetCursorInfo($main)
    If Not @error Then
        Select
            Case $cursor[4] = $pic_exit And $Icon1UnderCursor = False
                GUICtrlSetImage($pic_exit, @TempDir & "\images\x_close_2.gif")
                $Icon1UnderCursor = True
            Case $cursor[4] <> $pic_exit And $Icon1UnderCursor
                GUICtrlSetImage($pic_exit, @TempDir & "\images\x_close_1.gif")
                $Icon1UnderCursor = False
        EndSelect
    EndIf
WEnd

Func _MY_NCHITTEST($hWnd, $uMsg, $wParam, $lParam)
    Switch $hWnd
        Case $main
            Local $aPos = WinGetPos($hWnd) ; Check if mouse is over top 50 pixels
            If Abs(BitAND(BitShift($lParam, 16), 0xFFFF) - $aPos[1]) < 20 Then Return $HTCAPTION
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc
Edited by Fraser
Link to comment
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
 Share

  • Recently Browsing   0 members

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