Jump to content
Sign in to follow this  
jercfd

[SOLVED] Center a window title

Recommended Posts

jercfd

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.

Edited by jercfd

Share this post


Link to post
Share on other sites
martin

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.

Share this post


Link to post
Share on other sites
jercfd

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.

Share this post


Link to post
Share on other sites
martin

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.

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.