Sign in to follow this  
Followers 0
dabus

GuiCtrlCreateEdit: Go to first line / top

10 posts in this topic

#1 ·  Posted (edited)

Ok, this is kinda of stupid, but I cant find the solution:

I've got a textfile and dump it into an edit-control. How do I prevent the application to go down if it detects a linefeed? I could use controlsend to go up until I reach the top, but I thought there has to be a nicer way/a style I have missed.

#include <GuiConstants.au3>

_MsgBox('Dummy', 'Top||||||||||||||||||||||||||||||||||||||||||||Bottom')

Func _MsgBox($a, $B)
    Local $s=0
    $mGui = GuiCreate($a, 200, 175)
    GUICtrlCreateEdit(StringReplace($b, '|', @CRLF), 35, 50, 130, 70, $WS_VSCROLL+$ES_READONLY)
    $mButton1 = GUICtrlCreateButton('Next', 35, 120, 130, 20)
    GUISetState(@SW_SHOW, $mGui)
    While 1
        $mMsg = GUIGetMsg()
        If $mMsg = $mButton1 Then
            GUIDelete($mGui)
            Return 1
        EndIf
        Sleep(10)
    WEnd
EndFunc
Edited by dabus

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Sort of wierd, I thought everyone likes it the other way around, they want it to go down as text feeds. @YourQ I actually dont know, but that may be the best way until someone with more knowledge comes around.

EDIT: By the way, great idea, I actually might make that into a UDF! But, you will get some credit! great idea :)

Edited by Swift

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Well, I want to display a textfile with a bigger number of lines, so a label would not be suitable.

And I don't need credit for doing such a crappy gui. :)

It's just an example to play with.

Edited by dabus

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

A 'newbie' but...old newbie still needs his credit doesn't he? And well, So, you want to focus on the top line? like this:

| = cursor

|text...blah

blahhd..text...blah

or...

text...blah|

blahhd..text...blah

or...

text...blah

blahh...text...|

or...

text...blah..blah..text

|text...blah

If you do you could use:

GUICtrlSetState($Edit, $GUI_FOCUS)

then Send("{HOME}") or end

Home will bring the cursor to the front...END will put it at the back.

Edited by Swift

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

I don't care. I just has to be in the top-line.

Who would use Send? I also mentioned that I wouldn't like to use controlsend, so using send is out of question.

(I don't use Send if I can avoid it, and I think I've done that a few years now.)

Edited by dabus

Share this post


Link to post
Share on other sites

Then focus it. and send("{END}") :)

Share this post


Link to post
Share on other sites

Hey, I appreciate your desire to help, but just read what I asked for.

It's not Pos1/End that I need but a replacement for this:

Opt("SendKeyDelay", 1) 
...
$mEdit1 = GUICtrlCreateEdit(StringReplace($b, '|', @CRLF), 35, 50, 130, 70, $WS_VSCROLL+$ES_READONLY)
Controlsend($mGui, '', $mEdit1, '{PgUp 100}')
...

I ask this since I hate to use bruteforce-methods and it's killing some time.

Share this post


Link to post
Share on other sites

Like I Said:

Opt("SendKeyDelay", 1) 
...
$mEdit1 = GUICtrlCreateEdit(StringReplace($b, '|', @CRLF), 35, 50, 130, 70, $WS_VSCROLL+$ES_READONLY)
GUICtrlSetState(mEdit1, $GUI_FOCUS)
Controlsend($mGui, '', $mEdit1, '{UP}{END}')
...

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

C'mon, you haven't even tested this. :)

You need a lot more Ups than PgUps to get to the top. If I use you're example, I'm one line above the bottom. And that's a few lines from where I'd like to be.

Btw: GUICtrlSetState(mEdit1, $GUI_FOCUS) is totally useless here since controlsend sends the keystrokes directly to the control.

Edited by dabus

Share this post


Link to post
Share on other sites

What version are you using? When It's all selected, using GUI_FOCUS, and you press UP it will scroll to the top. If it's READ-ONLY, then im stuck :)

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