Guidance
指路人
g.yi.org
software / rapidq / examples / gui / Edit & Richedit / Right Text / right text.rqb

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

  
     $OPTIMIZE ON
     $TYPECHECK ON
     $INCLUDE "rapidq.inc"
     $ESCAPECHARS ON

'********************************
'* Begin Win32 API Declarations *
'********************************
     DECLARE FUNCTION CreateWindowEx LIB "USER32" ALIAS "CreateWindowExA" (ExStyle&, ClassName$, WindowName$, Style&, X&, Y&, Width&, Height&, WndParent&, hMenu&, hInstance&, Param&) AS LONG
'The following is needed because the RapidQ keyword SendMessage doesn't return anything
     DECLARE FUNCTION SendMessageR LIB "user32" ALIAS "SendMessageA" (hwnd AS LONG, wMsg AS LONG, wParam AS LONG, lParam AS LONG) AS LONG
     DECLARE FUNCTION SetWindowText LIB "user32" ALIAS "SetWindowTextA" (hwnd AS LONG, lpString AS STRING) AS LONG
'The following is from the GetText.dll
     DECLARE FUNCTION GetText LIB "GetText" ALIAS "GetText" (hwnd AS LONG, iMaxCount AS LONG) AS STRING

     CONST WS_EX_CLIENTEDGE = &H200 'Sunken Border
     CONST WS_CHILD = &H40000000    'Child Windows (it resides inside another window)
     CONST WS_VISIBLE = &H10000000
     CONST WS_BORDER = &H800000

     CONST WM_GETTEXTLENGTH = &HE   'When this message is sent, SendMessage return the length of the text in the control w/o the null

     CONST ES_RIGHT = &H2           'Right Aligned Text
     CONST ES_MULTILINE = &H4       'Multiple lines
'******************************
'* End Win32 API Declarations *
'******************************

     DECLARE SUB Button_OnClick

     DIM hwndEdit(2) AS LONG
     DEFSTR Window1Text$ = "Right", Window2Text$ = "Right\r\nand\r\nMulti\r\nLine"

     DIM Form AS QFORM

     hwndEdit(1) = CreateWindowEx(WS_EX_CLIENTEDGE,"edit", Window1Text$, WS_CHILD OR WS_VISIBLE OR WS_BORDER OR ES_RIGHT,                 5,  5, 121,     21, Form.Handle, 0, Application.hInstance, 0)
     hwndEdit(2) = CreateWindowEx(WS_EX_CLIENTEDGE,"edit", Window2Text$, WS_CHILD OR WS_VISIBLE OR WS_BORDER OR ES_RIGHT OR ES_MULTILINE, 5, 31, 121, 5 * 21, Form.Handle, 0, Application.hInstance, 0)

     DIM Button AS QBUTTON
     Button.PARENT = Form
     Button.Top = 151
     Button.Left = 5
     Button.CAPTION = "&Push Me!"
     Button.Default = True
     Button.OnClick = Button_OnClick

     Form.SHOWMODAL

     SUB Button_OnClick
      DIM LEN& AS LONG

      LEN& = SendMessageR(hwndEdit(1), WM_GETTEXTLENGTH, 0, 0)
      SHOWMESSAGE GetText(hwndEdit(1), LEN& + 1)

      LEN& = SendMessageR(hwndEdit(2), WM_GETTEXTLENGTH, 0, 0)
      SHOWMESSAGE GetText(hwndEdit(2), LEN& + 1)

      SetWindowText(hwndEdit(1), "Left? No!")
      LEN& = SendMessageR(hwndEdit(1), WM_GETTEXTLENGTH, 0, 0)
      SHOWMESSAGE GetText(hwndEdit(1), LEN& + 1)
     END SUB
掌柜推荐
 
 
¥370.00 ·
 
 
¥264.00 ·
 
 
¥648.00 ·
 
 
¥380.00 ·
 
 
¥289.00 ·
 
 
¥1,068.00 ·
© Mon 2024-11-25  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0 Last modified:2003-01-12 21:45:34