Class HIRAI_PROGRESS
Private
hWnd As HWND
hDC As HDC
hMDC As HDC
hBmp As HBITMAP
rcc As RECT
hPen As HPEN
hBrs As HBRUSH
max As Long
min As Long
cur As Long
spo As Long
Public
Sub ~HIRAI_PROGRESS()
DeleteObject(hBrs)
DeleteObject(hPen)
DeleteObject(hBmp)
DeleteDC(hMDC)
ReleaseDC(hWnd, hDC)
End Sub

Sub Set(hWnd2 As HWND)
hWnd = hWnd2
GetClientRect(hWnd, rcc)
hDC = GetDC(hWnd)
hMDC = CreateCompatibleDC(hDC)
hBmp = CreateCompatibleBitmap(hDC, rcc.right, rcc.bottom)
hPen = CreatePen(PS_NULL, 0, 0)
hBrs = CreateSolidBrush(RGB(0, 0 , &HFF))
SelectObject(hMDC, hBmp)
SelectObject(hMDC, hPen)
SelectObject(hMDC, hBrs)
FillRect(hMDC, rcc, GetSysColorBrush(COLOR_3DFACE))
SetBkMode(hMDC, TRANSPARENT)
SetTextColor(hMDC, &h00FFFFFF)
max = 100
min = 0
cur = 0
spo = 1
End Sub

Sub Step()
cur = cur + spo
If cur > max Then cur = max
Draw()
End Sub

Sub Set(i As Long)
cur = i
If cur > max Then cur = max
If cur < min Then cur = min
Draw()
End Sub

Sub Draw()
Dim par[555] As Byte
FillRect(hMDC, rcc, GetSysColorBrush(COLOR_3DFACE))
Rectangle(hMDC, 0, 0, rcc.right*(cur/100), rcc.bottom)
wsprintf(par, "%d%%", cur)
DrawText(hMDC, par, -1, rcc, DT_CENTER or DT_SINGLELINE or DT_VCENTER)
InvalidateRect(hWnd, ByVal 0, 1)
BitBlt(hDC, 0, 0, rcc.right, rcc.bottom, hMDC, 0, 0, SRCCOPY)
End Sub
End Class


Set()でウインドウと関連付け。対象となるControlはイメージボックス。
Step()で1%進む
Set()で好きなところ0-100に行く
Drawで描写。