Jump to content

[SOLVED] Center a window title


jercfd
 Share

Recommended Posts

How can I center the title of a window without spaces. I don't want to use any custom labels or controls but the regular default windows theme.

Search for DrawCaption, it might do what you want.
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.
Link to comment
Share on other sites

I can't find the function. I assume it used to be part of A3LWinAPI but I don't have it and it isn't available anymore.

The _API are now _WINAPI

Here's another way to do it

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

$guiwid = 600;initial width of window
$Title = " Some 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.
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...