forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


API for GOTO Line number in EDIT box +LIST box (SOLVED)

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
vtol
Valued Contributor
Valued Contributor


Joined: 05 Feb 2004
Posts: 642
Location: Eastern Indiana

PostPosted: Tue Sep 08, 2020 12:50 am    Post subject: API for GOTO Line number in EDIT box +LIST box (SOLVED) Reply with quote

hello

Looking for below: <searched all day -- fail> Stupid
A command to GOTO certain Line number in
a EDIT box <and/OR> LIST box.
<hope I don't need line num's loaded in box(s)>

I'm thinking I used to have a API function for this, or maybe not.
Checked MAC's example {awesome} but not in there.
A solution would be highly appreciated. Smile

*Trying to create some bookmarks in my
homemade .slo editor for my old game.

hope everyone is doing well, by the way.
Thanks & cheers Cool


Last edited by vtol on Sun Nov 22, 2020 10:50 pm; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website
LiquidCode
Moderator Team


Joined: 05 Dec 2000
Posts: 1751
Location: Space and Time

PostPosted: Fri Sep 11, 2020 5:48 pm    Post subject: Reply with quote

Try this API code:

Windows = (Windows NT, Windows 95, Windows 98, Win32's)
wParam = (WPARAM) index;// item index
lParam = (LPARAM) fScroll; // flag for scrolling item
Message ID = $019E

Description: An application sends an LB_SETCARETINDEX message to set the focus rectangle to the item at the specified index in a multiple-selection list box. If the item is not visible, it is scrolled into view. This only shows the item it does not make it selected or clicked.

Parameters

WPARAM INDEX VALUES

Value of wParam. Specifies the zero-based index of the list box item that is to receive the focus rectangle.

LPARAM FSCROLL VALUES

Value of lParam. Specifies whether to scroll to the item or not.

Value Meaning
0 Item is scrolled until fully visible
1 Item is scrolled until partially visible
Return Value: If an error occurs, the return value is -1.

Sample Source Code


Code:
title TEST
   DIALOG CREATE,TEST,-1,0,213,215
   DIALOG ADD,BUTTON,BUTTON1,170,70,,,,DEFAULT
   DIALOG ADD,LIST,LIST1,10,12
   DIALOG SHOW
:evloop
   wait event
   goto @event()
:BUTTON1BUTTON
   list add,list1,Hello World
   list add,list1,VDS is Cool
   list add,list1,This is the API
   list add,list1,Reference made
   list add,list1,by S.A.D.E. s.a.r.l.
   list add,list1,I hope everyone
   list add,list1,uses this in their
   list add,list1,VDS Programs
   list add,list1,Later All
   list add,list1,Good Bye
   list add,list1,Hello World
   list add,list1,VDS is Cool
   list add,list1,This is the API
   list add,list1,Reference made
   list add,list1,by S.A.D.E. s.a.r.l.
   list add,list1,I hope everyone
   list add,list1,uses this in their
   list add,list1,VDS Programs
   list add,list1,Later All
   list add,list1,Good Bye
   %A = @sendmsg(@win(~LIST1),$019E,14,1)
   warn %A
   rem Sets the anchor index to index 14 and scrolls to make it partially visible
   rem This only sets the index to position 14 without making it selected.
   goto evloop
:CLOSE
   exit

_________________
Chris
Http://theblindhouse.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vtol
Valued Contributor
Valued Contributor


Joined: 05 Feb 2004
Posts: 642
Location: Eastern Indiana

PostPosted: Tue Sep 15, 2020 12:09 am    Post subject: Reply with quote

Thanks a million time LiquidCode.

VDS7 would be nice with a compatibility
option in the compile menu area Laughing

I've made my Win10 pro 64bit desktop look like win98.
*so now I'm spoiled not to use win98 or XP.

If I could have not compiled to exe without error
I was gonna try setting the exe to win98 mode.

But I knew all that was just a dream Cool

I thought of another non-API alternative the other day that
may do the job -- much rather have API though Smile

I have all that API stuff laying around, just
couldn't ever figure it out Embarassed
I have too many things to fix and not enough brains Rolling Eyes

I appreciate the SADE code though Wink
..and your fast help and time.

cheers -- thanks again
Back to top
View user's profile Send private message Visit poster's website
vtol
Valued Contributor
Valued Contributor


Joined: 05 Feb 2004
Posts: 642
Location: Eastern Indiana

PostPosted: Wed Sep 16, 2020 2:28 am    Post subject: Reply with quote

I got the LIST box way working thanks to LiquidCode, but it turns
out I need the EDIT box API before it will work. Insane

Below is a small EXAMPLE of the LIST box API:

Code:
#   previous code = S.A.D.E. for win98 <located by LiquidCode>
#   win10: HAVE TO GET THE LIST BOX 'ID number' FIRST
#   This works on LIST box, but not EDIT box.
#   
TITLE ListBox TEST
   DIALOG CREATE,ListBox TEST,-1,0,280,360
   DIALOG ADD,LIST,LIST1,10,10,260,310
   DIALOG ADD,BUTTON,RUN,328,120,40,24,,DEFAULT

   DIALOG SHOW

:evloop
   wait event
   goto @event()

:runBUTTON
   list add,list1,Hello World
   list add,list1,VDS is Cool
   list add,list1,This is the API
   list add,list1,Reference made
   list add,list1,by S.A.D.E. s.a.r.l.
   list add,list1,I hope everyone
   list add,list1,uses this in their
   list add,list1,VDS Programs
   list add,list1,Later All
   list add,list1,Good Bye
   list add,list1,Hello World
   list add,list1,VDS is Cool
   list add,list1,This is the API
   list add,list1,Reference made
   list add,list1,by S.A.D.E. s.a.r.l.
   list add,list1,I hope everyone
   list add,list1,uses this in their
   list add,list1,VDS Programs
   list add,list1,Later All
   list add,list1,Good Bye


%q = @winexists(~LIST1)
WAIT 0.2

# below PRED for zero counting:
%u = @sendmsg(%q,$019E,@PRED(14),1)
WAIT 0.2

# added visualality for testing purposes:
dialog focus,LIST1
WINDOW SEND,%q,@KEY(up)

 goto evloop

:close
EXIT


Thanks again LiquidCode Cool
Back to top
View user's profile Send private message Visit poster's website
cnodnarb
Professional Member
Professional Member


Joined: 11 Sep 2002
Posts: 762
Location: Rockeledge, GA

PostPosted: Sat Oct 03, 2020 3:48 am    Post subject: Reply with quote

EM_LINEINDEX As Int: = $BB

?
(use with @sendmsg)
Back to top
View user's profile Send private message AIM Address
vtol
Valued Contributor
Valued Contributor


Joined: 05 Feb 2004
Posts: 642
Location: Eastern Indiana

PostPosted: Sat Oct 03, 2020 6:58 am    Post subject: Reply with quote

Thanks a millionTrillion cnodnarb Very Happy


I'll give it a whirl asap Dancing Banana


cheers <appreciate it highly>

Smile
Back to top
View user's profile Send private message Visit poster's website
vtol
Valued Contributor
Valued Contributor


Joined: 05 Feb 2004
Posts: 642
Location: Eastern Indiana

PostPosted: Sat Oct 24, 2020 4:04 am    Post subject: Reply with quote

I guess I did something wrong, so the EDIT-box API fails.
So I created this simple test tool to try to get it working.

Code:

DIALOG CREATE,New Dialog,-1,0,290,190
DIALOG ADD,STYLE,STYLE1,calibri,12,b,,0|110|0
DIALOG ADD,STYLE,STYLE2,calibri,11,b,,140|10|10
DIALOG ADD,STYLE,STYLE3,calibri,10,b,27|27|27,yellow
DIALOG ADD,STYLE,STYLE4,Arial Black,12,b,,240|20|20

  DIALOG ADD,extTEXT,ListTXT,8,10,,,"LIST box",,STYLE1
  DIALOG ADD,extTEXT,EditTXT,8,120,,,"EDIT box",,STYLE1
  DIALOG ADD,extTEXT,resultTXT,10,184,,,"RESULT"<COLOR=white>" = ",,STYLE3
  dialog hide,resultTXT
  DIALOG ADD,extTEXT,result,6,238,,,,,STYLE4
  DIALOG ADD,LIST,LIST1,30,10,82,125
  DIALOG ADD,EDIT,EDIT1,30,100,180,125,,,,multi,scroll
  DIALOG ADD,BUTTON,List,160,10,,,"LIST test",,,HAND
  DIALOG ADD,BUTTON,Edit,160,120,,,"EDIT test",,,HAND
  DIALOG ADD,extTEXT,status,173,274,,,"00",,STYLE2
#>>>>>>>>>>
DIALOG SHOW
#>>>>>>>>>>

%%numLIST = @NEW(LIST)

:evloop
 wait event,0.1
goto @event()

:TIMER
goto evloop

:ListBUTTON
 dialog CLEAR,status
 %%LL = @winexists(~LIST1)
 WAIT 0.2
 LIST CLEAR,LIST1
 #  begin populate LIST field:
 %%count = 1
 REPEAT
  LIST add,LIST1,%%count
  %%count = @succ(%%count)
  WAIT 0.02
  dialog set,status,@PRED(%%count)
 UNTIL @greater(%%count,30)
 WAIT 0.1
 # below PRED for zero counting:
 %%msgLIST = @sendmsg(%%LL,$019E,@PRED(5),1)
 WAIT 0.1
 # must keep focus:
 dialog focus,LIST1
 WINDOW SEND,%%LL,@KEY(up)
goto evloop

:EditBUTTON
 dialog CLEAR,status
 dialog clear,EDIT1
 dialog hide,result
 dialog hide,resultTXT
 %%ED = @winexists(~EDIT1)
 WAIT 0.2
 # populate EDIT field:
 %%count = 1
 REPEAT
  LIST add,%%numLIST,%%count
  %%count = @succ(%%count)
  WAIT 0.02
  dialog set,status,@PRED(%%count)
 UNTIL @greater(%%count,30)
 dialog set,EDIT1,@TRIM(@TEXT(%%numLIST))
 WAIT 0.1
 # get topmost visible line in edit field
 rem %a = @sendmsg(%%ED,$0CE,0,0)
 WAIT 0.2
 #-----------------------------
 #   EM_LINEINDEX As Int: = $BB
 #   ?
 #   (use with @sendmsg)
 #-----------------------------
 dialog SHOW,result
 dialog SHOW,resultTXT
 # below PRED for zero counting:
 %%lineINDEX = @sendmsg(%%ED,$BB,7,0)
 rem %%lineIndex2 = @sendmsg(%%ED,$019E,@PRED(5),1)
 dialog set,result,%%lineINDEX
 WAIT 0.2
 # must keep focus:
 dialog focus,EDIT1
 rem WINDOW SEND,%%ED,@KEY(down)
goto evloop

:close
 LIST CLOSE,%%numLIST
 LIST CLOSE,LIST1
exit


It doesn't move to the EDIT-box RESULT line number.
Also, wondering why the result needs divided by 3 ?
If I were half as smart as you, I could fix it myself Laughing Don't know
Cool
Back to top
View user's profile Send private message Visit poster's website
vtol
Valued Contributor
Valued Contributor


Joined: 05 Feb 2004
Posts: 642
Location: Eastern Indiana

PostPosted: Tue Oct 27, 2020 11:18 pm    Post subject: Reply with quote

Concerning EDIT box below:
At first I thought maybe it was dividing the total lines by 3 for the result.
So I tried 10 at 100 lines and it equaled 31
So I tried 7 at 100 lines and it equaled 21
So I tried 10 at 50 lines and it equaled 31
So I tried 4 at 50 lines and it equaled 12

Looks like its just dividing the first number by approximately 3.
That tells me hex converting prolly won't do it.
I have not thought to nor know how to try.

hmm
Anyone have a hint or clue or resolution?
Thanks in advance..
Back to top
View user's profile Send private message Visit poster's website
NathanH
Valued Newbie


Joined: 05 Sep 2001
Posts: 32

PostPosted: Mon Nov 16, 2020 3:24 am    Post subject: Search list box Reply with quote

I wrote, and still use, a VDS program that pulls a list of 400+ computers/equipment IP addresses from an Excel spreadsheet, and then based on the unit selected, can connect to shares, remote to it, or pull up the MMC functions.

Part of the list function is to have it searchable, so as you type in the Search edit box, the original list feeds to the displayed list, and only the lines that match part of the search box are displayed.

I also have buttons, like 'Printers', that instantly narrow down the list to just show all the printers. There is an action column in the spreadsheet, so when you dbl-click anything in the list, based on the action it might remote to that PC, open a Web browser to that IP, or launch a certain program with the IP as a parameter. A single click updates a status bar with ping results and host name, if available.

You could probably do something like that for your shortcuts?

If you want a certain portion of the code I could pass it on.
Back to top
View user's profile Send private message
vtol
Valued Contributor
Valued Contributor


Joined: 05 Feb 2004
Posts: 642
Location: Eastern Indiana

PostPosted: Mon Nov 16, 2020 7:39 am    Post subject: Reply with quote

Thanks for the reply Nathan
Checking this every few days.

Quote:
Part of the list function is to have it searchable, so as you type in the Search edit box, the original list feeds to the displayed list, and only the lines that match part of the search box are displayed.


The above QUOTE is what I can't get it to do.

EXAMPLE:
When I go to line 7 in the EDIT box, I would like it to also go to
line 7 in the LIST box at the same time without much lag.

*it just seems like a simple API would do the above example.

Do you have API example of the above example please?

Thanks you very much Cool
Back to top
View user's profile Send private message Visit poster's website
vtol
Valued Contributor
Valued Contributor


Joined: 05 Feb 2004
Posts: 642
Location: Eastern Indiana

PostPosted: Fri Nov 20, 2020 5:48 am    Post subject: Reply with quote

SOLVED

I finally put it all together as a nice little example code below.

Code:

DIALOG CREATE,"GOTO Line EXAMPLE",-1,0,290,192
DIALOG ADD,STYLE,STYLE1,calibri,12,b,,0|110|0
DIALOG ADD,STYLE,STYLE2,calibri,11,b,,140|10|10
DIALOG ADD,STYLE,STYLE3,calibri,10,b,27|27|27,yellow
DIALOG ADD,STYLE,STYLE4,Arial Black,12,b,,240|20|20
DIALOG ADD,STYLE,STYLE5,calibri,11,b,,RED

DIALOG ADD,BUTTON,find,9,243,38,18,"FIND",,,HAND
DIALOG ADD,extTEXT,ListTXT,8,10,,,"LIST box",,STYLE1
DIALOG ADD,extTEXT,EditTXT,8,120,,,"EDIT box",,STYLE1
DIALOG ADD,extTEXT,resultTXT,10,184,,,"RESULT"<COLOR=white>" = ",,STYLE3
dialog hide,resultTXT
DIALOG ADD,extTEXT,result,6,238,,,,,STYLE4
DIALOG ADD,LIST,LIST1,30,10,82,20
DIALOG ADD,BUTTON,goto5,70,10,82,27,"GOTO line 5",,,HAND
DIALOG ADD,BUTTON,goto9,100,10,82,27,"GOTO line 9",,,HAND
DIALOG ADD,BUTTON,goto17,130,10,82,27,"GOTO line 17",,,HAND
DIALOG ADD,BUTTON,goto28,160,10,82,27,"GOTO line 28",,,HAND
DIALOG ADD,EDIT,EDIT1,30,100,180,126,,,,multi,scroll
DIALOG ADD,BUTTON,gotoTop,168,105,57,19,"Goto Top",,,HAND
DIALOG ADD,BUTTON,gotoBottom,168,167,80,19,"Goto Bottom",,,HAND
DIALOG ADD,extTEXT,stat2,171,253,,,"00",,STYLE5
DIALOG ADD,extTEXT,status,171,272,30,19,"00","TL lines",STYLE2

#>>>>>>>
DIALOG SHOW
#>>>>>>>

%q = @winexists(~LIST1)
WAIT 0.1
%u = @winexists(~EDIT1)
WAIT 0.1

%%numLIST = @NEW(LIST)
GOSUB Edit
GOSUB List
WAIT 0.02
dialog focus,EDIT1
WAIT 0.02

:evloop
 wait event,0.1
 %%LABEL = neutral
goto @event()

:TIMER
 # below get EDIT line number:
 %c = @sendmsg(%u,$BB,-1,0)
 %l = @succ(@sendmsg(%u,$0C9,%c,0))
 IF %c
  dialog set,stat2,%l
 END
 # below - unknown to me function:  <but needed>
 %%msgUNKNOWN = @sendmsg(%q,$019E,@PRED(%l),1)
goto evloop

:gotoTopBUTTON
 #------------------------------------------
 # get topmost visible line in EDIT field
 # %a = @sendmsg(%u,$0CE,0,0)
 # FAILS - just make GOTO line 1 LABEL
 #------------------------------------------
 dialog focus,EDIT1
 WAIT 0.02
 WINDOW SEND,%u,@CTRL(@key(HOME))
 WAIT 0.02
 rem -- Select text found --
 # below get EDIT line number:
 %c = @sendmsg(%u,$BB,-1,0)
 %l = @succ(@sendmsg(%u,$0C9,%c,0))
 %s = @pred(@pos(%l,@dlgtext(EDIT1)))
 %z = @sendmsg(%u,$0B1,%s,@sum(%s,@len(%l)))
goto evloop

:gotoBottomBUTTON
 dialog focus,EDIT1
 WAIT 0.02
 WINDOW SEND,%u,@CTRL(@key(END))
 WAIT 0.02
 rem -- Select text found --
 # below get EDIT line number:
 %c = @sendmsg(%u,$BB,-1,0)
 %l = @succ(@sendmsg(%u,$0C9,%c,0))
 %s = @pred(@pos(%l,@dlgtext(EDIT1)))
 %z = @sendmsg(%u,$0B1,%s,@sum(%s,@len(%l)))
goto evloop

:goto5BUTTON
 %%goto = 5
 %s = @pred(@pos(%%goto,@dlgtext(EDIT1)))
 IF @greater(%s,-1)
   rem -- Select text found --
   %z = @sendmsg(%u,$0B1,%s,@sum(%s,@len(%%goto)))
   rem -- Scroll selected text (caret) into view --
   %z = @sendmsg(%u,$0B7,0,0)
   WAIT 0.02
   dialog focus,EDIT1
  ELSE
   INFO "NOT found"
 END
goto evloop

:goto9BUTTON
 %%goto = 9
 %s = @pred(@pos(%%goto,@dlgtext(EDIT1)))
 IF @greater(%s,-1)
   rem -- Select text found --
   %z = @sendmsg(%u,$0B1,%s,@sum(%s,@len(%%goto)))
   rem -- Scroll selected text (caret) into view --
   %z = @sendmsg(%u,$0B7,0,0)
   WAIT 0.02
   dialog focus,EDIT1
  ELSE
   INFO "NOT found"
 END
goto evloop

:goto17BUTTON
 %%goto = 17
 %s = @pred(@pos(%%goto,@dlgtext(EDIT1)))
 IF @greater(%s,-1)
   rem -- Select text found --
   %z = @sendmsg(%u,$0B1,%s,@sum(%s,@len(%%goto)))
   rem -- Scroll selected text (caret) into view --
   %z = @sendmsg(%u,$0B7,0,0)
   WAIT 0.02
   dialog focus,EDIT1
  ELSE
   INFO "NOT found"
 END
goto evloop

:goto28BUTTON
 %%goto = 28
 %s = @pred(@pos(%%goto,@dlgtext(EDIT1)))
 IF @greater(%s,-1)
   rem -- Select text found --
   %z = @sendmsg(%u,$0B1,%s,@sum(%s,@len(%%goto)))
   rem -- Scroll selected text (caret) into view --
   %z = @sendmsg(%u,$0B7,0,0)
   WAIT 0.02
   dialog focus,EDIT1
  ELSE
   INFO "NOT found"
 END
goto evloop

:findBUTTON
 # %u  ==>  EDIT box
 %t = @input(Enter TEXT to search:)
 IF %t
  %s = @pred(@pos(%t,@dlgtext(EDIT1)))
   IF @greater(%s,-1)
    rem -- Select text found --
    %z = @sendmsg(%u,$0B1,%s,@sum(%s,@len(%t)))
    rem -- Scroll selected text (caret) into view --
    %z = @sendmsg(%u,$0B7,0,0)
    WAIT 0.02
    dialog focus,EDIT1
   ELSE
    INFO "NOT found"
  END
 END
GOTO evloop


:List
 dialog CLEAR,status
 WAIT 0.2
 LIST CLEAR,LIST1
 #  begin populate LIST field:
 %%count = 1
 REPEAT
  LIST add,LIST1,%%count
  %%count = @succ(%%count)
  dialog set,status,@PRED(%%count)
 UNTIL @greater(%%count,30)
 WAIT 0.1
 dialog focus,LIST1
 rem WINDOW SEND,%q,@KEY(up)
EXIT


:Edit
 dialog CLEAR,status
 dialog clear,EDIT1
 dialog hide,result
 dialog hide,resultTXT
 WAIT 0.2
 # populate EDIT field:
 %%count = 1
 REPEAT
  LIST add,%%numLIST,%%count
  %%count = @succ(%%count)
  dialog set,status,@PRED(%%count)
 UNTIL @greater(%%count,30)

 dialog set,EDIT1,@TRIM(@TEXT(%%numLIST))
 WAIT 0.1
EXIT


:close
 LIST CLOSE,%%numLIST
 LIST CLOSE,LIST1
EXIT


UPDATED <Nov 27 2020>
*I previously removed the last line in the TIMER because
I forgot where I got it and it worked with out it, but today
it would not work!
So while checking its code, I noticed it and I put it back
then bingo, and it now works now again.

LAST LINE IN THE TIMER:
# below - unknown to me function: <but needed>
%%msgUNKNOWN = @sendmsg(%q,$019E,@PRED(%l),1)

Thanks
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group