tbohon Posted August 27, 2011 Posted August 27, 2011 Is there a way to center the data value in an input box control? Tried $ES_CENTER but that only works on multiline input boxes according to the doc and, indeed, it doesn't work on a single line one ... trust me, I tried it ... TIA. Tom
somdcomputerguy Posted August 27, 2011 Posted August 27, 2011 (edited) Is this for a regular Input Box control, or a GUI one? I use $ES_CENTER on a GUI Input Box and it works fine. Make sure you've included EditConstants.au3 too.<br><br>edit: I just tried myself, and it seems the es_center style can't be used with a regular input box control. If it can though, I have no idea how to..<br> Edited August 27, 2011 by somdcomputerguy - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
Moderators Melba23 Posted August 27, 2011 Moderators Posted August 27, 2011 tbohon,$ES_CENTER will not work with an InputBox command as the GUI is generated internally by AutoIt - and as you can only vary those parameters available within the function call itself there is no way to apply the style. If you want a centred input you will have to create your own GUI to hold it: #include <GUIConstantsEx.au3> #include <EditConstants.au3> $hGUI = GUICreate("Centred Input", 220, 80) $hInput = GUICtrlCreateInput("", 10, 10, 200, 20, $ES_CENTER) $hButton_1 = GUICtrlCreateButton("Cancel", 10, 40, 80, 30) $hButton_2 = GUICtrlCreateButton("Read", 130, 40, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $hButton_2 MsgBox(0, "Input", GUICtrlRead($hInput)) ContinueCase Case $GUI_EVENT_CLOSE, $hButton_1 Exit EndSwitch WEndFor me at least, $ES_CENTER works fine with an Input control - which is actually a single line Edit control. M23 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: Reveal hidden contents ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
funkey Posted August 27, 2011 Posted August 27, 2011 You can hook the internal InputBox to make it look like you want. expandcollapse popup#include <WinAPI.au3> #include <Constants.au3> Local $hProcInputBox = DllCallbackRegister("CbtHookProcInputBox", "int", "int;int;int") Local $TIDInputBox = _WinAPI_GetCurrentThreadId() Local $hHookInputBox = _WinAPI_SetWindowsHookEx($WH_CBT, DllCallbackGetPtr($hProcInputBox), 0, $TIDInputBox) Local $answer = InputBox("Question", "Where were you born?", "Planet Earth", "", -1, -1, 0, 0) _WinAPI_UnhookWindowsHookEx($hHookInputBox) DllCallbackFree($hProcInputBox) #region Just for fun(key)!! ;########################################################## Func CbtHookProcInputBox($nCode, $wParam, $lParam) Static $iWindowIndex = 0 Local $RET = 0, $hBitmap = 0, $xWnd = 0 If $nCode < 0 Then $RET = _WinAPI_CallNextHookEx($hHookInputBox, $nCode, $wParam, $lParam) Return $RET EndIf Switch $nCode Case 3 ;3=HCBT_CREATEWND If $iWindowIndex = 2 Then _WinAPI_SetWindowLong($wParam, $GWL_STYLE, 0x50010081) EndIf $iWindowIndex += 1 Case 5 ;5=HCBT_ACTIVATE _WinAPI_SetDlgItemText($wParam, 1, "Accept") _WinAPI_SetDlgItemText($wParam, 2, "Abort") EndSwitch Return EndFunc ;==>CbtHookProcInputBox Func _WinAPI_SetDlgItemText($hDlg, $nIDDlgItem, $lpString) Local $aRet = DllCall('user32.dll', "int", "SetDlgItemText", _ "hwnd", $hDlg, _ "int", $nIDDlgItem, _ "str", $lpString) Return $aRet[0] EndFunc ;==>_WinAPI_SetDlgItemText ;########################################################## #endregion Just for fun(key)!! Programming today is a race between software engineers striving tobuild bigger and better idiot-proof programs, and the Universetrying to produce bigger and better idiots.So far, the Universe is winning.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now