エディットボックスのフォーマット矩形を設定          <TOP>


SendMessage ウィンドウにメッセージを送信

EM_GETRECT(&HB2) エディットコントロール長方形の座標を取得する
EM_SETRECT(&HB3) MLEの書式化長方形を設定する
 

参照

文字列の表示領域を設定

 

'================================================================
'= エディットボックスのフォーマット矩形を設定
'=    (SendMessage11.bas)
'================================================================
#include "Windows.bi"

Type RECT
    Left   As Long
    Top    As Long
    Right  As Long
    Bottom As Long
End Type

#define EM_GETRECT &HB2                 'エディットコントロール長方形の座標を取得する
#define EM_SETRECT &HB3                 'MLEの書式化長方形を設定する

' ウィンドウにメッセージを送信
Declare Function Api_SendMessage& Lib "user32" Alias "SendMessageA" (ByVal hWnd&, ByVal wMsg&, ByVal wParam&, lParam As Any)

Var Shared Edit1 As Object
Var Shared Button1 As Object

Edit1.Attach GetDlgItem("Edit1") : Edit1.SetFontSize 14
Button1.Attach GetDlgItem("BUtton1") : Button1.SetFontSize 14

Var Shared txt As String

'================================================================
'=
'================================================================
Declare Sub MainForm_Start edecl ()
Sub MainForm_Start()
    txt = "January February March April May June July August September October November December"
    Edit1.SetWindowText txt
End Sub

'================================================================
'=
'================================================================
Declare Sub Button1_on edecl ()
Sub Button1_on()
    Var rc As RECT
    Var Ret As Long

    'フォーマット矩形を取得
    Ret = Api_SendMessage(Edit1.GethWnd, EM_GETRECT, 0, rc)

    '新しいフォーマット矩形を指定
    rc.Top = rc.Top + 5
    rc.Left = rc.Left + 5

    '新しいフォーマット矩形を設定
    Ret = Api_SendMessage(Edit1.GethWnd, EM_SETRECT, 0, rc)

    'テキストボックスを更新
    Edit1.SetWindowtext txt
End Sub

'================================================================
'=
'================================================================
While 1
    WaitEvent
Wend
Stop
End