Jump to content

GuiCtrlCreateEdit: Go to first line / top


dabus
 Share

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
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.

Link to comment
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}')
...
Link to comment
Share on other sites

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...