Guidance
指路人
g.yi.org
software / rapidq / examples / gui / Edit & Richedit / Win32API RichEdit / QRICHEDIT_api.bas

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

  
'From:   "Andrew Shelkovenko"  Fri May 2, 2003  5:34 am
'Subject:  RichEdit component using API

'try to create RichEdit component using API
'(
'using source
'From: "dragon_html" <dragon_html@y...>
'Subject: Re: Help me,Example Source of Windows API function to replace
'QRichEdit
'and dominique glodt <dominique.glodt@l...> QProgress
')

'Result
'1. Without this trick not stable program executing . Sometimes it's all
'right, sometimes richedit is not visible, sometimes cause "Program error "
'--
'print RichEdit1.handle ' trick ;-))) '
'--
'2. Do not work " CREATE RichEdit1 AS QRICHEDIT_api"

'"dim RichEdit1 AS QRICHEDIT_api " is needed

'3. As ordinarily program (not custom component) it's working fine.

'----------------------QRICHEDIT_api -----
' Copy and paste into your program
     $INCLUDE "Rapidq.inc"
     $IFNDEF TRUE
      $DEFINE True 1
     $ENDIF
     $IFNDEF FALSE
      $DEFINE False 0
     $ENDIF
     $IFNDEF boolean
      $DEFINE boolean INTEGER
     $ENDIF

     DECLARE FUNCTION LoadLibrary LIB "KERNEL32" ALIAS "LoadLibraryA" _
      (LibFileName AS STRING) AS LONG
     DIM hInst AS LONG
     $DEFINE HWND INTEGER

     CONST WS_EX_CLIENTEDGE = &H200 ' Just some of the many API constants
     CONST WS_CHILD = &H40000000
     CONST WS_VISIBLE = &H10000000
     CONST WS_BORDER = &H800000

     CONST SW_HIDE = 0
     CONST SW_SHOW = 5

     DECLARE FUNCTION CreateRichEdit LIB "USER32" ALIAS "CreateWindowExA" _
      (ExStyle&, ClassName$, WindowName$, Style&, X&, Y&, _
      Width&, Height&, WndParent&, hMenu&, hInstance&, Param&) AS LONG
     DECLARE FUNCTION MoveRichEdit LIB "user32" ALIAS "MoveWindow" _
      (hwnd AS LONG,x AS INTEGER,y AS INTEGER,nWidth AS INTEGER, _
      nHeight AS INTEGER,bRepaint AS LONG) AS LONG
     DECLARE FUNCTION ShowRichEdit LIB "user32" ALIAS "ShowWindow" _
      (hwnd AS LONG,nCmdShow AS LONG) AS LONG
     hInst = LoadLibrary("RICHED32.DLL")

     TYPE QRichEdit_api EXTENDS QOBJECT
PUBLIC:
      PARENT AS INTEGER PROPERTY SET SetParent
      left AS SHORT PROPERTY SET SetLeft
      Top AS SHORT PROPERTY SET SetTop
      Width AS SHORT PROPERTY SET SetWidth
      Height AS SHORT PROPERTY SET SetHeight
      Visible AS boolean PROPERTY SET SetVisible
      Handle AS INTEGER
      PROPERTY SET SetVisible(visible AS boolean)
       QRichedit_api.visible=visible
       IF visible=0 THEN
        ShowRichedit(QRichEdit_api.Handle,SW_HIDE)
       ELSE
        ShowRichedit(QRichEdit_api.Handle,SW_SHOW)
       END IF
      END PROPERTY

      PROPERTY SET SetLeft(left AS SHORT)
       QRichEdit_api.Left=left

       MoveRichEdit(QRichEdit_api.Handle,QRichEdit_api.Left,QRichEdit_api.Top,QRichEdit_api.Width,QRichEdit_api.Height,true)
      END PROPERTY

      PROPERTY SET SetTop(top AS SHORT)
       QRichEdit_api.Top=top

       MoveRichEdit(QRichEdit_api.Handle,QRichEdit_api.Left,QRichEdit_api.Top,QRichEdit_api.Width,QRichEdit_api.Height,true)
      END PROPERTY

      PROPERTY SET SetWidth(width AS SHORT)
       QRichEdit_api.Width=width

       MoveRichEdit(QRichEdit_api.Handle,QRichEdit_api.Left,QRichEdit_api.Top,QRichEdit_api.Width,QRichEdit_api.Height,true)
      END PROPERTY

      PROPERTY SET SetHeight(height AS SHORT)
       QRichEdit_api.Height=height

       MoveRichEdit(QRichEdit_api.Handle,QRichEdit_api.Left,QRichEdit_api.Top,QRichEdit_api.Width,QRichEdit_api.Height,true)
      END PROPERTY

      PROPERTY SET SetParent(PARENT AS INTEGER)
       QRichEdit_api.PARENT = PARENT
       QRichEdit_api.Handle =CreateRichEdit(WS_EX_CLIENTEDGE,"RichEdit","RichEdit_API", _
        WS_CHILD OR WS_VISIBLE OR WS_BORDER, _
        QRichEdit_api.left, QRichEdit_api.top, QRichEdit_api.width,QRichEdit_api.height, _
        QRichEdit_api.PARENT, 0, Application.hInstance,0)

       QRichEdit_api.visible=0
      END PROPERTY

      CONSTRUCTOR
       Left=65
       Top=5
       Width=200
       Height=100
' visible=1
      END CONSTRUCTOR

     END TYPE

     CREATE Form AS QFORM
      CAPTION = "Form1"
      top=300
      Width = 300
      Height = 200
'' CREATE RichEdit1 AS QRICHEDIT_api
'' Left = 10
'' Top = 10
'' visible=1
'' END CREATE
     END CREATE

'Insert your initialization code here

     DIM RichEdit1 AS QRICHEDIT_api
     RichEdit1.PARENT=form.handle

     PRINT RichEdit1.handle ' trick ;-))) '

'' RichEdit1.visible=0
     Form.SHOWMODAL
掌柜推荐
 
 
¥1,480.00 ·
 
 
¥908.00 ·
 
 
¥1,580.00 ·
 
 
¥1,450.00 ·
 
 
¥1,290.00 ·
 
 
¥1,370.00 ·
© Mon 2024-11-25  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2003-05-02 08:48:15