픽처박스와 프로그래스 바를 하나 생성하고, 픽처박스에 프로그래스바를 넣고, 픽처박스에 프로그래바를 포함한 내용을 다시 그리다음, 픽처박스의 image를 이미지리스트에 추가하고 이것을 리스트뷰와 연결해 주면 된다.
다음은 초기 이미지이다.
진행 프로그래스바 표시 버튼을 눌르면 리스트뷰에 진행율 프로그래스바가 표시된다.
프로그래스바와, 픽처박스는 감춰줘있다.
다음은 소스이다.
' 리스트 뷰에 프로그래스 표시
Option Explicit
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long ' 메세지를 보낸다.
Private Const WM_PAINT = &HF
Private Const WM_PRINT = &H317
Private Const PRF_CHILDREN = &H10&
Private Const PRF_CLIENT = &H4&
Private Sub Command1_Click()
Dim NewItem As ListItem
ListView1.ListItems.Clear
ImageList1.ListImages.Clear
Set NewItem = ListView1.ListItems.Add(, vbNullString)
NewItem.SubItems(1) = "테스트"
NewItem.SubItems(2) = vbNullString
ImageList1.ListImages.Add , , Picture1.Image
NewItem.ListSubItems(2).ReportIcon = ImageList1.ListImages.Count
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
With ListView1
.ColumnHeaders.Add 1, , vbNullString, 0, 0
.ColumnHeaders.Add 2, , "테스트", 120, 0
.ColumnHeaders.Add 3, , "진행률", 250, 0
End With
With Picture1
Picture1.Line (.ScaleTop, .ScaleLeft)-(.ScaleWidth - 1, .ScaleHeight - 1), vbBlack, B
ProgressBar1.Move .ScaleTop, .ScaleLeft, .ScaleWidth, .Height
ProgressBar1.Max = .ScaleWidth
End With
End Sub
Private Sub Timer1_Timer()
Static CountNumber As Long
ProgressBar1.Value = (ProgressBar1.Max - ProgressBar1.Min) * (CountNumber * 0.01)
SendMessage Picture1.hwnd, WM_PAINT, Picture1.hDC, 0 ' 소스 픽처박스의 클라이언트 영역을 픽처박스에 그린다, 이미지는 윈도우가 아니라 클라이언트 영역의 일부를 사용하므로, 이미지 컨트롤의 이미지가 그려진다. 화면과,Image 속성에도 그려진다.
SendMessage Picture1.hwnd, WM_PRINT, Picture1.hDC, PRF_CHILDREN Or PRF_CLIENT ' 이번에 픽처박스 클라이언트 위의 컨트롤들을 메모리(Image 속성)에 그린다.
With Picture1
Picture1.Line (.ScaleTop, .ScaleLeft)-(.ScaleWidth - 1, .ScaleHeight - 1), vbBlack, B
End With
ImageList1.ListImages.Add , , Picture1.Image
ListView1.ListItems(1).ListSubItems(2).ReportIcon = ImageList1.ListImages.Count
ListView1.ListItems(1).ListSubItems(2).Text = CountNumber & " %"
If CountNumber >= 100 Then
Timer1.Enabled = False
Else
CountNumber = CountNumber + 5
If CountNumber > 100 Then CountNumber = 100
End If
End Sub
'VB6' 카테고리의 다른 글
시리얼 포트 에물레이터를 사용한 한 PC에서 시리얼 포트 입출력 테스트 (0) | 2011.10.10 |
---|---|
WMI를 사용한 프로세스 강제 종료 (0) | 2011.10.07 |
시리얼 포트 에물레이터 (0) | 2011.10.02 |
수치 출력시 모자란 자릿수 다른 문자로 채우기 (0) | 2011.10.01 |
vb에서 유니코드와 Asc,AscB,AscW 차이 (0) | 2011.10.01 |