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

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

  
'From:  "taplang" <wasaywasay@e...> Fri Nov 1, 2002  9:30 pm

' It's a demonstration to show that even without APIs (except
'for SetFocus in this case) RQ has enough versatility to solve
'unconventional problems using its simple commands.


     DECLARE SUB Scroll(Sender AS QSCROLLBAR)
     DECLARE SUB Arrows(key AS BYTE)
     DECLARE FUNCTION SetFocus LIB "USER32" ALIAS "SetFocus" (HWnd AS LONG) AS LONG

     DIM arrowed AS BYTE

     CREATE Form AS QFORM
      Center
      CREATE RichEdit1 AS QRICHEDIT
       hideselection=false
       Left = 15
       Top = 15
       Width = 117
       Height = 100
       OnKeydown = Arrows
      END CREATE
      CREATE Scroll1 AS QSCROLLBAR
       Kind = 1
       Left = 132
       Top = 15
       Height = 100
       OnChange = Scroll
      END CREATE
      CREATE RichEdit2 AS QRICHEDIT
       hideselection=false
       Left = 163
       Top = 15
       Width = 117
       Height = 100
       OnKeydown = Arrows
      END CREATE
      CREATE Scroll2 AS QSCROLLBAR
       Kind = 1
       Left = 280
       Top = 15
       Height = 100
       OnChange = Scroll
      END CREATE
     END CREATE

     FOR x = 1 TO 20
      RichEdit1.Addstrings STR$(x)
      RichEdit2.Addstrings STR$(x)
     NEXT
     RichEdit1.SelStart = 1
     RichEdit2.SelStart = 1

     SUB Arrows
      arrowed = 1
      IF key = 38 THEN
       Scroll1.Position = Scroll1.Position - 100\RichEdit1.LineCount
       Scroll2.Position = Scroll1.Position
      ELSEIF key = 40 THEN
       Scroll1.Position = Scroll1.Position + 100\RichEdit1.LineCount
       Scroll2.Position = Scroll1.Position
      END IF
     END SUB

     SUB Scroll
      IF arrowed = 1 THEN
       arrowed = 0
       EXIT SUB
      END IF
      IF Sender.Handle = Scroll1.Handle THEN
       Scroll2.Position = Scroll1.Position
       SetFocus(RichEdit1.Handle)
       Scroll1.SmallChange = 100\RichEdit1.LineCount
       IF Scroll1.SmallChange = 0 THEN Scroll1.SmallChange = 1
       IF posthen > Scroll1.Position OR arrow = -1 THEN
        updown = -1
       ELSEIF posthen < Scroll1.Position OR arrow = 1 THEN
        updown = 1
       END IF
       posthen = Scroll1.Position
       remaining = LEN(RichEdit1.Line(RichEdit1.WhereY)) + 1
       IF posthen = Scroll1.Min THEN
        RichEdit1.SelStart = 0
       ELSEIF posthen = Scroll1.Max THEN
        RichEdit1.SelStart = LEN(RichEdit1.Text)
       ELSE
        RichEdit1.SelStart = ABS(RichEdit1.SelStart + updown*remaining)
       END IF
       SetFocus(RichEdit2.Handle)
       Scroll2.SmallChange = 100\RichEdit2.LineCount
       IF Scroll2.SmallChange = 0 THEN Scroll2.SmallChange = 1
       remaining2 = LEN(RichEdit2.Line(RichEdit2.WhereY)) + 1
       IF posthen = Scroll2.Min THEN
        RichEdit2.SelStart = 0
       ELSEIF posthen = Scroll2.Max THEN
        RichEdit2.SelStart = LEN(RichEdit2.Text)
       ELSE
        RichEdit2.SelStart = ABS(RichEdit2.SelStart + updown*remaining2)
       END IF
       SetFocus(RichEdit1.Handle)
      ELSE
       Scroll1.Position = Scroll2.Position
      END IF
     END SUB

     Form.SHOWMODAL
掌柜推荐
 
 
¥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:2002-11-02 13:07:38