Sign in to follow this  
Followers 0
schmelle

[SOLVED]InputBox: Cursor set to Pos. 1 after leaving Box

8 posts in this topic

#1 ·  Posted (edited)

Hi all,

does anybody knows how to set the cursor back to position 1 within an Inputbox after leaving the Inputbox?

Example:

Inputbox ist to small to see whole given text.

Text given: 1234567890abcdefghijklmnopqrstuvwxyz

Text seen: abcdefghijklmnopqrstuvwxyz

After leaving the Inputbox the user should see: 1234567890abcdefghijklmnop

Function should work if Inputbox loose focus.

Has anybody an idea?

Thanks schmelle

Edited by schmelle

[font="Courier New"]Tell it - and I will forget it...Show it - and I will remember me...Share it - and I will understand it![/font]

Share this post


Link to post
Share on other sites



This?

Share this post


Link to post
Share on other sites

Hi rasim,

I tried it out but it doen't work in my case, perhaps an edit control is not the same as an inputbox. I don't know.

Leaving the Inputbox: nothing happens.

Here is my code:

#include <GUIConstants.au3>
Dim $iCUSTNAME = ""
Dim $iCUSTGROUP = ""
$Form1_1 = GUICreate("TestGUI", 565, 584, 190, 123)
$Label1 = GUICtrlCreateLabel("Customer Name", 24, 20, 79, 17)
$CUSTNAME = GUICtrlCreateInput($iCUSTNAME, 24, 40, 177, 21)
GUICtrlSetTip(-1, "Test Tooltip")
GUICtrlSetCursor (-1, 4)
$CUSTGROUP = GUICtrlCreateInput($iCUSTGROUP, 24, 88, 177, 21)
GUICtrlSetTip(-1, "Test Tooltip")
GUICtrlSetCursor (-1, 4)
GUISetState(@SW_SHOW)

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

Pressing the "TAB" Button or loosing the focus of the Inputbox should set the given input left aligned.

Thanks for help.

Peter


[font="Courier New"]Tell it - and I will forget it...Show it - and I will remember me...Share it - and I will understand it![/font]

Share this post


Link to post
Share on other sites

Here is a "small" Solution:

If you copy a string into a InputBox you should use "ControlSetText" instead of "GUICrtlSetData".

If you use "ControlSetText" the Text is left aligned!

Peter


[font="Courier New"]Tell it - and I will forget it...Show it - and I will remember me...Share it - and I will understand it![/font]

Share this post


Link to post
Share on other sites

This?

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

Dim $iCUSTNAME = ""
Dim $iCUSTGROUP = ""

$Form1_1 = GUICreate("TestGUI", 565, 584, 190, 123)

$Label1 = GUICtrlCreateLabel("Customer Name", 24, 20, 79, 17)

$CUSTNAME = GUICtrlCreateInput($iCUSTNAME, 24, 40, 177, 21)
GUICtrlSetTip(-1, "Test Tooltip")
GUICtrlSetCursor (-1, 4)

$CUSTGROUP = GUICtrlCreateInput($iCUSTGROUP, 24, 88, 177, 21)
GUICtrlSetTip(-1, "Test Tooltip")
GUICtrlSetCursor (-1, 4)

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

GUISetState(@SW_SHOW)

ControlSetText($Form1_1, "", $CUSTNAME, "Hello world!")

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

Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    Local $IDFrom, $iCode
    
    $IDFrom = BitAND($wParam, 0xFFFF)
    $iCode = BitShift($wParam, 16)
    
    Switch $IDFrom
        Case $CUSTNAME, $CUSTGROUP
            Switch $iCode
                Case $EN_SETFOCUS
                    GUICtrlSendMsg($IDFrom, $EM_SETSEL, 0, 0)
            EndSwitch
    EndSwitch
    
    Return $GUI_RUNDEFMSG
EndFunc

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Hi rasim,

thanks for your help.

Now I've got the following situation:

When I enter text which is longer than the InputBox then text is right aligned.

Leaving the InputBox: nothing happens (the text is still right aligned) :)

Moving back into the InputBox with Mouseclick or TAB: Text will be automatically left aligned :)

If you now find a solution that the text within the InputBox will be automatically left aligned when I left the Box with TAB or ENTER I'll be very glad. :)

Thanks and BR

schmelle

Edited by schmelle

[font="Courier New"]Tell it - and I will forget it...Show it - and I will remember me...Share it - and I will understand it![/font]

Share this post


Link to post
Share on other sites

Try this:

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

Dim $iCUSTNAME = ""
Dim $iCUSTGROUP = ""

$Form1_1 = GUICreate("TestGUI", 565, 584, 190, 123)

$Label1 = GUICtrlCreateLabel("Customer Name", 24, 20, 79, 17)

$CUSTNAME = GUICtrlCreateInput($iCUSTNAME, 24, 40, 177, 21)
GUICtrlSetTip(-1, "Test Tooltip")
GUICtrlSetCursor (-1, 4)

$CUSTGROUP = GUICtrlCreateInput($iCUSTGROUP, 24, 88, 177, 21)
GUICtrlSetTip(-1, "Test Tooltip")
GUICtrlSetCursor (-1, 4)

GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

GUISetState(@SW_SHOW)

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

Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
    Local $IDFrom, $iCode
    
    $IDFrom = BitAND($wParam, 0xFFFF)
    $iCode = BitShift($wParam, 16)
    
    Switch $IDFrom
        Case $CUSTNAME, $CUSTGROUP
            Switch $iCode
                Case $EN_SETFOCUS, $EN_KILLFOCUS
                    GUICtrlSendMsg($IDFrom, $EM_SETSEL, 0, 0)
            EndSwitch
    EndSwitch
    
    Return $GUI_RUNDEFMSG
EndFunc

Share this post


Link to post
Share on other sites

Hi rasim,

excellent!

You are a really grayscripter!!!! :)

Thanks in advance.

BR Peter


[font="Courier New"]Tell it - and I will forget it...Show it - and I will remember me...Share it - and I will understand it![/font]

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