Jump to content

Inputbox text not center vertically


Recommended Posts

Hi guys,

I have searched around but i don't have find nothing about this:

The test script:

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

$Form1 = GUICreate("Form1", 237, 93, 192, 124)
$Input1 = GUICtrlCreateInput("Center vertically is correct", 16, 16, 201, 21)
$Input2 = GUICtrlCreateInput("I'm not center vertically", 16, 48, 201, 21, 0, $WS_EX_WINDOWEDGE)
GUISetState(@SW_SHOW)

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

If i remove the border for the 2° inputbox the text isn't vertically center. I have try some other syle without success, like $SS_CENTERIMAGE...work for label but not for inputbox

Some suggestion?

Thanks ;)

Edited by johnmcloud
Link to comment
Share on other sites

$ES_CENTER maybe? If this doesn't work, could you elaborate further? Thanks.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

  • Moderators

johnmcloud,

I have try some other syle without success, like $SS_CENTERIMAGE...work for label but not for inputbox

That style works fine for me when I use it: ;)

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

$Form1 = GUICreate("Form1", 237, 93, 192, 124)
GUISetBkColor(0xC4C4C4)
$Input1 = GUICtrlCreateInput("Center vertically is correct", 16, 16, 201, 21)
$Input2 = GUICtrlCreateInput("I'm not center vertically", 16, 48, 201, 21, 0, BitOr($WS_EX_WINDOWEDGE, $WS_EX_CLIENTEDGE)) ; <<<<<<<<<<<<<
GUISetState(@SW_SHOW)

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

How did you try to apply the style? :huh:

M23

Edit: Now shows the correct way to do it - what I had originally posted was a lucky mix of styles (thanks funkey). :>

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Hi guinness,

Not horizontal, but vertically

Posted Image

1° inputbox is correct

2° inputbox isn't, is more on the top side of the inputbox

EDIT: Melba, I have applied the style in this way, wrong:

$Input2 = GUICtrlCreateInput("I'm not center vertically", 16, 48, 201, 21, $SS_CENTERIMAGE, $WS_EX_WINDOWEDGE)

I don't have think to use BitOr :sweating:

Yes is vertically centered, thanks

Edited by johnmcloud
Link to comment
Share on other sites

Yeh, my bad I totally misunderstood and I couldn't see the difference on my machine.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

$Input2 = GUICtrlCreateInput("I'm not center vertically", 16, 48, 201, 21, 0, BitOr($WS_EX_WINDOWEDGE, $SS_CENTERIMAGE)) ; <<<<<<<<<<<<<

How did you try to apply the style? :huh:

M23

BitOr some Style and ExStyle is not right.

BitOr($WS_EX_WINDOWEDGE, $WS_EX_CLIENTEDGE) has the same effect and is afaik the correct use of it.

Edited by funkey

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

  • Moderators

funkey,

Oops! I just added the new style and did not notice that the existing style was an extended one. :>

Thanks for pointing out my stupid mistake - and providing the correct answer. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

I have a problem:

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

$Form1 = GUICreate("Form1", 209, 114, 192, 124)
GUISetBkColor(0x000000)
$Input1 = GUICtrlCreateInput("Not Vertical centered - No border", 16, 16, 177, 21, 0, $WS_EX_WINDOWEDGE)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0xff0000)
$Input2 = GUICtrlCreateInput("I see the border - Vertical OK", 18, 50, 186, 21, 0, BitOr($WS_EX_WINDOWEDGE, $WS_EX_CLIENTEDGE))
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x000000)
GUISetState(@SW_SHOW)

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

If i set a font color i see the border? :D

Edited by johnmcloud
Link to comment
Share on other sites

Try if this workaround fits your needs.

#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Global $hGui = GUICreate("Input without border", 215, 214, 192, 124)
;~ GUISetBkColor(0x000000)

Global $Input0 = GUICtrlCreateInput("Standard input control", 16, 10, 180, 20, $ES_CENTER)

Global $Input1 = _CreateInputWithoutBorderAndVerticalCenteredWithBgColor($hGui, "This is an input control", 16, 40, 180, 20, 0xFF0000, $ES_CENTER)
Global $Input2 = _CreateInputWithoutBorderAndVerticalCenteredWithBgColor($hGui, "and there is no border", 16, 70, 180, 51, 0x00FF00, $ES_CENTER)
Global $Input3 = _CreateInputWithoutBorderAndVerticalCenteredWithBgColor($hGui, "and it is vertical centered ;)", 16, 130, 180, 31, 0x00FFFF, $ES_CENTER)

Global $Input4 = GUICtrlCreateInput("Standard input control", 16, 170, 180, 36, $ES_CENTER)

Global $nTabFix = GUICtrlCreateDummy()
Global $AccelKeys[1][2] = [["{TAB}", $nTabFix]]

GUISetAccelerators($AccelKeys)

ControlFocus($hGui, "", $Input0)
GUICtrlSendMsg($Input0, $EM_SETSEL, 0, -1)

GUISetState(@SW_SHOW)

Global $nMsg, $nFocused

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $nTabFix
            $nFocused = _WinAPI_GetDlgCtrlID(ControlGetHandle($hGui, "", ControlGetFocus($hGui)))
            Switch $nFocused
                Case $Input0
                    ControlFocus($hGui, "", $Input1)
                    GUICtrlSendMsg($Input1, $EM_SETSEL, 0, -1)
                Case $Input1
                    ControlFocus($hGui, "", $Input2)
                    GUICtrlSendMsg($Input2, $EM_SETSEL, 0, -1)
                Case $Input2
                    ControlFocus($hGui, "", $Input3)
                    GUICtrlSendMsg($Input3, $EM_SETSEL, 0, -1)
                Case $Input3
                    ControlFocus($hGui, "", $Input4)
                    GUICtrlSendMsg($Input4, $EM_SETSEL, 0, -1)
                Case Else
                    GUISetAccelerators(0)
                    Send("{TAB}")
                    GUISetAccelerators($AccelKeys)
            EndSwitch
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _CreateInputWithoutBorderAndVerticalCenteredWithBgColor($hParent, $sText, $iX, $iY, $iW, $iH, $iColor, $iStyle = -1, $iExStyle = 0)
    GUICreate("", $iW, $iH, $iX, $iY, $WS_CHILD, 0, $hParent)
    GUISetBkColor($iColor)
    Local $nInput = GUICtrlCreateInput($sText, 0, $iH / 2 - 6, $iW, 20, $iStyle, $iExStyle)
    GUICtrlSetBkColor(-1, $iColor)
    GUISetState()
    GUISwitch($hParent)
    Return $nInput
EndFunc   ;==>_CreateInputWithoutBorderAndVerticalCenteredWithBgColor

Edit: Show how to handle the TAB message.

Edited by funkey

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Link to comment
Share on other sites

Thanks funkey

You have forgot the font color :D

Func _GUICtrlCreateInput($hParent, $sText, $iX, $iY, $iW, $iH, $iColorBackground, $iColorFont, $iStyle = -1, $iExStyle = 0)
    GUICreate("", $iW, $iH, $iX, $iY, $WS_CHILD, 0, $hParent)
    GUISetBkColor($iColorBackground)
    Local $nInput = GUICtrlCreateInput($sText, 0, $iH / 2 - 6, $iW, 20, $iStyle, $iExStyle)
    GUICtrlSetBkColor(-1, $iColorBackground)
GUICtrlSetColor(-1, $iColorFont)
    GUISetState()
    GUISwitch($hParent)
    Return $nInput
EndFunc   ;==>_GUICtrlCreateInput
Link to comment
Share on other sites

Thanks funkey

You have forgot the font color :D

I knew you can do this alone. :D

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

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

×
×
  • Create New...