Jump to content

Recommended Posts

Posted

How To Make Center Title Gui in This Script ? :mellow:

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

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("   For Windows XP", 300, 300,  -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION)) ;<=== How To Make Center  This Title
$label = GUICtrlCreateLabel(" Only For Windows XP", 0, 100, 300, 30,$SS_CENTER)
GUICtrlSetFont(-1, 10, 400, 0, "Comic Sans MS")
$button = GUICtrlCreateButton("Exit", 130, 140, 40, 25)
GUICtrlSetFont(-1, 10, 400, 0, "Comic Sans MS")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $button
            Exit
    EndSwitch
WEnd
Posted

An example

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

$guiwid = 600;initial width of window
$Title = " Some other Caption";caption for window

$hG = GUICreate("My GUI", $guiwid, 400, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS)) ; will create a dialog box that when displayed is centered
GUISetState(@SW_SHOW) ; will display an empty dialog box
SetCentreTitle($hG, $Title)
GUIRegisterMsg($WM_SIZE, "ReTitle")

While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()

Func SetCentreTitle($hWnd, $sTitle)
    Local $wp = WinGetPos($hWnd)
    $hDC = _WinAPI_GetDC($hWnd)

    Do
        $sTitle = ' ' & $sTitle & ' '
        $size = _WinAPI_GetTextExtentPoint32($hDC, $sTitle)
    Until DllStructGetData($size, 1) > $wp[2] - 110;110 was by trial and error
    WinSetTitle($hWnd, "", $sTitle)
EndFunc ;==>SetCentreTitle


Func ReTitle($hWnd, $msg, $wParam, $lParam)
    SetCentreTitle($hWnd, $Title)
EndFunc ;==>reTitle
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Posted (edited)

thanks You Martin Has answered my question :mellow: but not constant..

So change value manually..

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <winapi.au3>

$guiwid = 200;initial width of window
$Title = "V";caption for window

$hG = GUICreate("", $guiwid, 300, -1, -1, BitOR($WS_MINIMIZEBOX, $WS_CAPTION))
$label = GUICtrlCreateLabel("^", 0, 0, $guiwid, 30,$SS_CENTER)
GUISetState(@SW_SHOW) ; will display an empty dialog box
SetCentreTitle($hG, $Title)
GUIRegisterMsg($WM_SIZE, "ReTitle")

While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()

Func SetCentreTitle($hWnd, $sTitle)
    Local $wp = WinGetPos($hWnd)
    $hDC = _WinAPI_GetDC($hWnd)

    Do
        $sTitle = " "& $sTitle &" "
        $size = _WinAPI_GetTextExtentPoint32($hDC, $sTitle)
    Until DllStructGetData($size, 1) > $wp[2] + 26;110 was by trial and error
    WinSetTitle($hWnd, "", $sTitle)
EndFunc ;==>SetCentreTitle


Func ReTitle($hWnd, $msg, $wParam, $lParam)
    SetCentreTitle($hWnd, $Title)
EndFunc ;==>reTitle
Edited by eri

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
  • Recently Browsing   0 members

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