Страница: 1 |
|
Вопрос: Помогите с графикой в VBA
|
Добавлено: 16.03.09 17:47
|
|
Автор вопроса: SergSSA
|
Помогите как рисовать линии, точки и т.д. на форме созданной в VBA под Excel. Вроде должны работать методы Line, Pset, Circle но никак не могу их прицепить к форме. Через APi функции тоже немогу разобраться где взять значения контекст устройств hDC и hwnd.
Ответить
|
Номер ответа: 1 Автор ответа: fAndOrIn
Вопросов: 5 Ответов: 344
|
Профиль | | #1
|
Добавлено: 17.03.09 12:13
|
- Option Explicit
- Private hWnd As Long
- Private hDC As Long
- Private Type POINTAPI
- x As Long
- y As Long
- End Type
- Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
- Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long
- Private Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal hDC As Long) As Long
- Private Declare Function Rectangle Lib "gdi32.dll" (ByVal hDC As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
- Private Declare Function MoveToEx Lib "gdi32.dll" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long, lpPoint As POINTAPI) As Long
- Private Declare Function LineTo Lib "gdi32.dll" (ByVal hDC As Long, ByVal x As Long, ByVal y As Long) As Long
-
- Private Sub CommandButton1_Click()
- Dim RetVal As Long
- Dim pt As POINTAPI
- RetVal = Rectangle(hDC, 20, 10, 200, 100)
- RetVal = MoveToEx(hDC, 20, 10, pt)
- RetVal = LineTo(hDC, 200, 100)
- End Sub
-
- Private Sub UserForm_Initialize()
- hWnd = FindWindow(vbNullString, Me.Caption)
- hDC = GetDC(hWnd)
- End Sub
-
- Private Sub UserForm_Terminate()
- Dim RetVal As Long
- RetVal = ReleaseDC(hWnd, hDC)
- End Sub
Ответить
|
Номер ответа: 2 Автор ответа: SergSSA
Вопросов: 1 Ответов: 1
|
Профиль | | #2
|
Добавлено: 17.03.09 12:41
|
Огромное СПАСИБО.
Ответить
|
Страница: 1 |
Поиск по форуму