Sign in to follow this  
Followers 0
siva1612

Align Cursor to the bottom of the Inputbox

10 posts in this topic

I am trying to create a custom  "I AM SHERLOCKED" screen for my PC. As you can see below, in the first input box, the cursor in the input box is aligned at the bottom of the input box and the default for input box or edit box is that the cursor blinks vertically aligned.

Is there any way to achieve the below effect?

52175e6802540b6ad6d024fd80a9b467.jpg

 

 

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I'm not sure I understand.

Pictures don't always tell the whole story.

And here we like some code too, that we can work with.

Input boxes can be multiline.

The cursor seems to be at the start of the second line (or apparent second line).

All the text is in the middle of the image, so I see nothing at the bottom.

Nothing very AutoIt about what you've provided, and what you are asking seems confusing.

Edited by TheSaint

AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

He's talking about the cursor itself being under the first letter (aka bottom) vs. the cursor being vertical to the right of what you are typing.

Im not sure how you would achieve this, however I think I understand his question correctly :)

Share this post


Link to post
Share on other sites

Have a look to the function

_WinAPI_CreateCaret

in the help file.

Thanks for that UEZ.  Seems like I learn about a new func every week.

 

Question though...how does one create a bitmap that has a black line at the bottom and a white "mask" top?

 

Share this post


Link to post
Share on other sites

Either you use GDI or GDI+ to create a bitmap as desired with a line at the bottom.

Should I create an example?


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I'll see if I can spin up something. ;)

edit:  Good grief...my skill level with GDI = no.  I was thinking I had to create a bitmap then put into a graphics context to draw on it then revert back to bitmap, but I have no idea what I am doing.  I really have no idea how to go about it, less creating the bitmap manually in paint and importing...but it would be much better to gen it via code I would think.  I'm not sure where to learn about this sort of thing either...besides looking at examples.  I usually learn well from examples, but I think when it comes to GDI(+) some good old fashion documentation/tutorials would work best for me.

Edited by spudw2k

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Meanwhile there are plenty of GDI+ examples in this forum which is the best documentation / tutorial. ;)

Apropos doc / tut. On German and French AutoIt forum there are GDI+ tutorials. Maybe the Google / Bing translator is good enough to understand those. Further we have added a lot of additional GDI+ functions with examples - check out the help file.

Anyhow, here an example:

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

Global $g_vDuration = Default, $g_hBitmap = _GDIPlus_CreateHBitmapCaretLine()

OnAutoItExitRegister('OnAutoItExit')

Local $hForm = GUICreate('Test ' & StringReplace(@ScriptName, '.au3', '()'), 400, 93)
Local $idInput = GUICtrlCreateInput('', 20, 20, 360, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Lucida Console")
Local $idButton = GUICtrlCreateButton('Exit', 165, 59, 70, 23)
GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND')
GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE, $idButton
            ExitLoop
    EndSwitch
WEnd

Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
    #forceref $iMsg

    Switch $hWnd
        Case $hForm
            Switch _WinAPI_LoWord($wParam)
                Case $idInput
                    Switch _WinAPI_HiWord($wParam)
                        Case $EN_KILLFOCUS
                            _WinAPI_HideCaret($lParam)
                            _WinAPI_DestroyCaret()
                            _WinAPI_SetCaretBlinkTime($g_vDuration)
                            $g_vDuration = Default
                        Case $EN_SETFOCUS
                            $g_vDuration = _WinAPI_SetCaretBlinkTime(250)
                            _WinAPI_CreateCaret($lParam, $g_hBitmap)
                            _WinAPI_ShowCaret($lParam)
                    EndSwitch
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

Func OnAutoItExit()
    _WinAPI_DeleteObject($g_hBitmap)
    If Not IsKeyword($g_vDuration) Then
        _WinAPI_SetCaretBlinkTime($g_vDuration)
    EndIf
EndFunc   ;==>OnAutoItExit

Func _GDIPlus_CreateHBitmapCaretLine($iW = 9, $iH = 14, $iLineSize = 3, $iCaretColor = 0xFF000000, $iBGColor = 0xFFFFFFFF)
    _GDIPlus_Startup()
    Local Const $hBitmap = _GDIPlus_BitmapCreateFromScan0($iW, $iH)
    Local Const $hGfx = _GDIPlus_ImageGetGraphicsContext($hBitmap)
    Local Const $hBrush = _GDIPlus_BrushCreateSolid(BitXOR(0x00FFFFFF, $iCaretColor))
    _GDIPlus_GraphicsClear($hGfx, BitXOR(0x00FFFFFF, $iBGColor))
    _GDIPlus_GraphicsFillRect($hGfx, 0, $iH - $iLineSize, $iW, $iLineSize, $hBrush)
    Local Const $hHBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap)
    _GDIPlus_GraphicsDispose($hGfx)
    _GDIPlus_BrushDispose($hBrush)
    _GDIPlus_BitmapDispose($hBitmap)
    _GDIPlus_Shutdown()
    Return $hHBitmap
EndFunc

The tricky thing is that the brush / bg color must be inverted otherwise you will see the caret inverse.

Edited by UEZ
1 person likes this

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Very nice.  Thanks for taking the time to do that.  I was close, but didn't know how to create a bitmap of a specified size.  Reading the help file for _GDIPlus_BitmapCreateFromScan0 makes perfect sense.  I would have used a line/pen instead of fill/brush had I made it that far.  Are fill/brush methods typically better to use or in this crude example would a line/pen method suit as well?

Share this post


Link to post
Share on other sites

I think in this example a pen would do also the job whereas you have to set the pen size appropriately.


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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  
Followers 0