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

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

  
'From:   "Manuel Candela"  Tue Jul 1, 2003  1:24 am
'Subject:  [rapidq]Re: RichEdit line numbering

     DECLARE FUNCTION SetFocus LIB "user32" ALIAS "SetFocus" (hWnd AS LONG) AS LONG
'SetFocus is a function that tells Windows to make what it is passed
'(hWnd) active (in our case, put the blinking | in RichEdit).

     DECLARE SUB RichEdit_onClick
     DECLARE SUB RichEdit_Change (key AS BYTE)
     DECLARE SUB LineNumbers_Click
     DECLARE SUB Enumerate

     DEFBYTE CR = 13 'The enter key chracter

     CREATE Form AS QFORM
      Width = 300
      Height = 150
      Center
      keyPreview = 1
      onKeyUp = RichEdit_change 'Let it add a new line
      CREATE RichEdit AS QRICHEDIT
       Left = 5
       Top = 5
       Text = "abcde"
      END CREATE
      CREATE Button AS QBUTTON
       Left = 195
       Top = 5
       onclick = LineNumbers_Click
      END CREATE
     END CREATE


'DIM StringList1 AS QSTRINGLIST
     Form.SHOWMODAL

     SUB RichEdit_onClick
      RichEdit.SelectAll
      SetFocus(RichEdit.Handle)
' Make RichEdit active so we see what is selected
     END SUB

     SUB LineNumbers_Click
      Enumerate
      setfocus(RichEdit.handle)
     END SUB

     SUB RichEdit_Change (key AS BYTE)
'Adds a new line by default
'for i= 1 to Richedit.LineCount
' showMessage Str$(i-1) & " " + RichEdit.line(i-1)
'next

      IF Key = CR THEN
       IF (richEdit.whereX +richEdit.whereY-1) > 0 THEN EXIT SUB
       Enumerate
      END IF
     END SUB


     SUB Enumerate
      FOR i = 1 TO Richedit.LineCount
       line$ = RichEdit.Line(i-1)
       has% = INSTR("123456789", LEFT$(line$,1))
       RichEdit.Line(i-1) = STR$(i) & " " &_
        IIF(has%>0, RIGHT$(line$, LEN(line$)-INSTR(line$," ")), line$)
      NEXT
     END SUB
掌柜推荐
 
 
¥317.00 ·
 
 
¥470.00 ·
 
 
¥880.00 ·
 
 
¥1,480.00 ·
 
 
¥1,380.00 ·
 
 
¥294.00 ·
© Mon 2024-11-25  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2003-07-01 04:20:18