Public Const IDM_BUTTON1 = &H100
Public Sub Main()
Dim wcl As WNDCLASSEX, msg As Message
Dim rc As Long
Dim hDlg As Long
With wcl
.cbSize = Len(wcl)
.lpszClassName = "test Class Name"
.lpfnWndProc = ChangeAddressOf(AddressOf WndProc)
.style = 0
.cbClsExtra = 0
.cbWndExtra = 0
.lpszMenuName = 0
.hbrBackground = GetStockObject(WHITE_BRUSH)
.hInstance = App.hInstance
.hIcon = LoadIcon(0, ByVal 32512)
.hCursor = LoadCursor(0, ByVal 32512)
End With
Call RegisterClassEx(wcl)
hDlg = CreateWindowEx(WS_EX_CLIENTEDGE, wcl.lpszClassName, "ただいま再描画の実験中!", _
WS_CAPTION Or WS_VISIBLE Or WS_SYSMENU Or WS_MINIMIZEBOX, _
CW_USEDEFAULT, CW_USEDEFAULT, 370, 80, 0, 0, App.hInstance, 0)
Call CreateWindowEx(0, "Button", "押す", WS_CHILD Or BS_PUSHLIKE Or WS_VISIBLE, _
300, 10, 50, 30, hDlg, IDM_BUTTON1, App.hInstance, 0)
Call ShowWindow(hDlg, SW_SHOW)
Do While (GetMessage(msg, 0, 0, 0))
Call TranslateMessage(msg)
Call DispatchMessage(msg)
Loop
End Sub
Public Function WndProc(ByVal hWnd As Long, ByVal msg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Dim hdc As Long, temp As String, rc As Long
Select Case msg
Case WM_COMMAND
Select Case LWORD(wParam)
Case IDM_BUTTON1
hdc = GetDC(hWnd)
temp = "他のウィンドウを重ねてみてください!"
rc = LenB(StrConv(temp, vbFromUnicode))
Call TextOut(hdc, 10, 10, temp, rc)
Call ReleaseDC(hWnd, hdc)
End Select
Case WM_CLOSE
Call DestroyWindow(hWnd)
Call PostQuitMessage(0)
Case Else
WndProc = DefWindowProc(hWnd, msg, wParam, lParam)
End Select
End Function
Public Function ChangeAddressOf(ByVal Address As Long) As Long
ChangeAddressOf = Address
End Function
Public Function HWORD(ByVal LongValue As Long) As Integer
HWORD = (LongValue And &HFFFF0000) \ &H10000
End Function
Public Function LWORD(ByVal LongValue As Long) As Integer
If (LongValue And &HFFFF&) > &H7FFF Then
LWORD = (LongValue And &HFFFF&) - &H10000
Else
LWORD = LongValue And &HFFFF&
End If
End Function
Public Function GetLong(ByVal UpperWord As Integer, ByVal LowerWord As Integer) As Long
GetLong = (LowerWord And &HFFFF&) Or (UpperWord * &H10000)
End Function
|