Guidance
指路人
g.yi.org
software / rapidq / examples / GUI / Edit & Richedit / Line Number.bas

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
'From:  "xmeanstsp" <dmeans@f...> Wed Nov 6, 2002  1:26 am
'Subject:  ReVisit Line Numbering

'I have been playing around with the line numbering code someone
'posted and I was woundering if it would be posible to to set up the
'for-next loop so it would add line numbers automaticaly based on the
'length of the program instead of being hard coded in as it is now.
'I.E., t = 0 to 200. This works ok but if you set the upper limit to
'say 2000 it would use memory up just being there also if someone
'wrote a program that had more than 2000 lines it would not allow the
'main richedit to scroll beyond line 2000.

     $INCLUDE "Rapidq.inc"

     CONST EM_GETFIRSTVISIBLELINE = &HCE
     CONST EM_SCROLLCARET = &HB7

     DECLARE FUNCTION SendMessagea LIB "user32" ALIAS "SendMessageA"_
      (BYVAL hwnd AS LONG,_
      BYVAL wMsg AS LONG,_
      BYVAL wParam AS LONG,_
      lParam AS LONG) AS LONG

     DECLARE SUB Sync

     DIM Font AS QFONT
     Font.COLOR = &HFFFFFF
     Font.Size = 10
     DIM Font1 AS QFONT
     Font1.Size = 10

     DIM OnScroll AS QTIMER
     Onscroll.Interval = 25
     Onscroll.OnTimer = Sync

     CREATE frmMain AS QFORM
      Center
      Height = 480
      Width = 640
     END CREATE

     CREATE rftEditor AS QRICHEDIT
      PARENT = frmMain
      BorderStyle = 0
      Font = Font1
      Align = alClient
      HideScrollBars = 0
      ScrollBars = 2
     END CREATE

     CREATE rftRuler AS QRICHEDIT
      PARENT = frmMain
      BorderStyle = 0
      Font = Font
      COLOR = &HCF9A9A
      Align = alLeft
      Width = 35
     END CREATE

     DIM t AS INTEGER
     FOR t = 0 TO 200
      rftRuler.Addstrings STR$(t)
     NEXT t

     frmMain.SHOWMODAL

     SUB Sync
      DIM Oldpos AS INTEGER
      DIM Position AS INTEGER
      Position = SendMessageA( rftEditor.Handle, &Hce, 0, 0)
      IF Oldpos <> Position THEN rftRuler.selstart = LEN( rftRuler.text )
      SendMessageA( rftRuler.Handle, &Hb7, 0, 0 )
      rftRuler.selstart = INSTR( rftRuler.Text, STR$( Position ))
      SendMessagea( rftRuler.Handle, &Hb7, 0, 0 )
      Oldpos = Position
''added From:  "Marco" <m.waterman@h...> Wed Nov 6, 2002  10:16 am
      DIM t AS INTEGER
      IF rftruler.linecount<>rfteditor.linecount THEN
       FOR t=rftruler.linecount TO rfteditor.linecount
        rftruler.addstrings STR$(t)
       NEXT
      END IF
     END SUB
掌柜推荐
 
 
¥900.00 ·
 
 
¥430.00 ·
 
 
¥1,580.00 ·
 
 
¥1,015.00 ·
 
 
¥750.00 ·
 
 
¥890.00 编辑
© Mon 2024-11-25  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2013-06-19 07:48:03