文字列のグレー表示(U)          <TOP>


DrawState イメージを加工して表示
GetPixel 指定された座標のピクセルのRGB値を取得
SetBkColor デバイスコンテキストの背景色を設定
GetDC 指定されたウィンドウのデバイスコンテキストのハンドルを取得
ReleaseDC デバイスコンテキストを解放
 

 

'================================================================
'= 文字列のグレー表示(U)
'=    (DrawState3.bas)
'================================================================
#include "Windows.bi"

' イメージを加工して表示
Declare Function Api_DrawState& Lib "user32" Alias "DrawStateA" (ByVal hDC&, ByVal hBrush&, ByVal lpOutputFunc&, ByVal lData$, ByVal wData&, ByVal X&, ByVal Y&, ByVal cx&, ByVal cy&, ByVal fuFlags&)

' システムの背景色を取得
Declare Function Api_GetSysColor& Lib "user32" Alias "GetSysColor" (ByVal nIndex&)

' 指定された座標のピクセルのRGB値を取得
Declare Function Api_GetPixel& Lib "gdi32" Alias "GetPixel" (ByVal hDC&, ByVal X&, ByVal Y&)

' デバイスコンテキストの背景色を設定
Declare Function Api_SetBkColor& Lib "gdi32" Alias "SetBkColor" (ByVal hDC&, ByVal crColor&)

' 指定されたウィンドウのデバイスコンテキストのハンドルを取得
Declare Function Api_GetDC& Lib "user32" Alias "GetDC" (ByVal hWnd&)

' デバイスコンテキストを解放
Declare Function Api_ReleaseDC& Lib "user32" Alias "ReleaseDC" (ByVal hWnd&, ByVal hDC&)

#define TXT_DISABLED &H20
#define TXT_PREFIXTEXT &H2
#define TXT_TEXT &H1
#define COLOR_BTNFACE 15      'コマンドボタンの表面色

Var SHared Button1 As Object

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

Var Shared flg As Integer
Var Shared rgbColor As Long
Var Shared hDC As Long
Var Shared txt As String

'================================================================
'=
'================================================================
Declare Sub MainForm_Start edecl ()
Sub MainForm_Start()
    Var BkCol As Long

    hDC = Api_GetDC(GethWnd)
    txt = "F-Basic Programming Tips"

    rgbColor = RGB(192, 192, 192)

    'フォームの背景色取得
    BkCol = Api_GetPixel(hDC, 0, 0)

    '文字の背景色を設定
    Ret = Api_SetBkColor(hDC, BkCol)
                         
    Cls

    'Mainformを表示
    ShowWindow -1                                               
End Sub

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

    '交互に切り替え
    flg = Not flg

    If flg = 0 Then lDrawStateFlag = TXT_DISABLED

    Cls

    Ret = Api_DrawState(hDC, 0, 0, txt, Len(txt), 30, 34, 0, 0, TXT_TEXT Or lDrawStateFlag)
End Sub

'================================================================
'=
'================================================================
Declare Sub MainForm_QueryClose edecl ()
Sub MainForm_QueryClose()
    Var Ret As Long

    Ret = Api_ReleaseDC(GethWnd, hDC)
End Sub

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