Страница: 1 |
|
Вопрос: графика
|
Добавлено: 13.04.09 16:51
|
|
Автор вопроса: Tolya
|
На VB надо, что бы по нажатию кнопки сохранялась часть формы в графическом файле.
Ответить
|
Номер ответа: 9 Автор ответа:
Arvitaly
     
ICQ: 301746136 
Вопросов: 28 Ответов: 549
|
Web-сайт: okazani.ru Профиль | | #9
|
Добавлено: 17.04.09 00:08
|
смит был прав, достаточно hdc формы
- [source][source]Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
-
- Private Sub command1_Click()
- Dim Ret As Long, iLeft As Long, iTop As Long, iWidth As Long, iHeight As Long
- picture1.ScaleMode = 1
- If (image1.Left <= image2.Left) Then
- iLeft = (image1.Left) / Screen.TwipsPerPixelX
- iWidth = (Abs(image2.Left - image1.Left) + image2.Width) / Screen.TwipsPerPixelX
- Else
- iLeft = (image2.Left) / Screen.TwipsPerPixelX
- iWidth = (Abs(image1.Left - image2.Left) + image1.Width) / Screen.TwipsPerPixelX
- End If
- If (image1.Top <= image2.Top) Then
- iTop = (image1.Top) / Screen.TwipsPerPixelY
- iHeight = (Abs(image2.Top - image1.Top) + image2.Height) / Screen.TwipsPerPixelY
- Else
- iTop = (image2.Top) / Screen.TwipsPerPixelY
- iHeight = (Abs(image1.Top - image2.Top) + image1.Height) / Screen.TwipsPerPixelY
- End If
- If iWidth <> 0 And iHeight <> 0 Then
- picture1.Width = iWidth * Screen.TwipsPerPixelX
- picture1.Height = iHeight * Screen.TwipsPerPixelY
- If BitBlt(picture1.hdc, 0, 0, iWidth, iHeight, Me.hdc, iLeft, iTop, vbSrcCopy) = 1 Then
- SavePicture picture1.Image, "d:\1.bmp"
- picture1.Refresh
- End If
- End If
- End Sub
[/source]
[/source]
Ответить
|
Номер ответа: 11 Автор ответа:
Smith
   
ICQ: adamis@list.ru 
Вопросов: 153 Ответов: 3632
|
Профиль | | #11
|
Добавлено: 23.04.09 00:54
|
Arvitaly, Smith знал что прав
Просто решил написать свой примерчик
- Option Explicit
-
- Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
-
- Private Sub SaveQuad(ByRef X As Long, ByRef Y As Long, ByRef X2 As Long, ByRef Y2 As Long, ByRef Pathfile As String)
- ScaleMode = vbPixels
- With Picture1
- .Move 120, 120, X2 - X, Y2 - Y
- .AutoRedraw = True
- BitBlt .hDC, 0, 0, .Width, .Height, hDC, X, Y, vbSrcCopy
- SavePicture .Image, Pathfile
- End With
- End Sub
-
- Private Sub Command1_Click()
- SaveQuad 10, 10, 120, 120, "D:\Shot1.bmp"
- End Sub
Координаты в пикселях если кто невъехал.
Ответить
|
Страница: 1 |
Поиск по форуму