Страница: 1 |
|
Вопрос: Вопрос по PictureBox
|
Добавлено: 17.09.04 00:17
|
|
Автор вопроса: Reborn
|
Человеки, помогите. Незнаю как и обьяснить.
Есть picturebox и надо, чтобы картинка там ездила, хм...
ну типа что-то вроде scroolbarов там было. Т.е. не использовать strech, а использовать normal, но свободно "бродить" по картинке, как карта мира в Follaut или Arcanum, если кто знает....
Ответить
|
Номер ответа: 3 Автор ответа: Mihalыch
ICQ: 373-509-101
Вопросов: 56 Ответов: 330
|
Профиль | | #3
|
Добавлено: 17.09.04 18:22
|
Сразу скажу, что NET в глаза не видел, но думаю можно это адаптировать под него.
Помести на форму контейнер, допустим Frame, а в него уже PictureBox. Дальше попробуй адаптировать под NET этот код.
Option Explicit
 im picLeft As Single
 im picTop As Single
 im DownFlag As Boolean
Private Sub pic_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
picLeft = X: picTop = Y
 ownFlag = True
End Sub
Private Sub pic_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'PicView.MousePointer = 99
'сюда поместишь, какой нить курсор типа рука
If DownFlag = True Then
pic.Top = pic.Top + Y - picTop
pic.Left = pic.Left + X - picLeft
End If
End Sub
Private Sub pic_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
 ownFlag = False
End Sub
Надеюсь, что помог.
Ответить
|
Номер ответа: 5 Автор ответа: K&M
Вопросов: 14 Ответов: 39
|
Профиль | | #5
|
Добавлено: 18.09.04 19:21
|
Говоришь, оперативки не хватит, ну я чё сделал не знаю но после обновления на .NET получился вот-такой код:
Option Strict Off
Option Explicit On
Friend Class Form1
Inherits System.Windows.Forms.Form
#Region "Windows Form Designer generated code "
Public Sub New()
MyBase.New()
If m_vb6FormDefInstance Is Nothing Then
If m_InitializingDefInstance Then
m_vb6FormDefInstance = Me
Else
Try
'For the start-up form, the first instance created is the default instance.
If System.Reflection.Assembly.GetExecutingAssembly.EntryPoint.DeclaringType Is Me.GetType Then
m_vb6FormDefInstance = Me
End If
Catch
End Try
End If
End If
'This call is required by the Windows Form Designer.
InitializeComponent()
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean)
If Disposing Then
If Not components Is Nothing Then
components.Dispose()
End If
End If
MyBase.Dispose(Disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
Public ToolTip1 As System.Windows.Forms.ToolTip
Public WithEvents Pic As System.Windows.Forms.PictureBox
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.components = New System.ComponentModel.Container()
Me.ToolTip1 = New System.Windows.Forms.ToolTip(components)
Me.ToolTip1.Active = True
Me.Pic = New System.Windows.Forms.PictureBox
Me.Text = "Form1"
Me.ClientSize = New System.Drawing.Size(312, 206)
Me.Location = New System.Drawing.Point(4, 30)
Me.StartPosition = System.Windows.Forms.FormStartPosition.WindowsDefaultLocation
Me.Font = New System.Drawing.Font("Arial", 8!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.SystemColors.Control
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Sizable
Me.ControlBox = True
Me.Enabled = True
Me.KeyPreview = False
Me.MaximizeBox = True
Me.MinimizeBox = True
Me.Cursor = System.Windows.Forms.Cursors.Default
Me.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.ShowInTaskbar = True
Me.HelpButton = False
Me.WindowState = System.Windows.Forms.FormWindowState.Normal
Me.Name = "Form1"
Me.Pic.Size = New System.Drawing.Size(297, 193)
Me.Pic.Location = New System.Drawing.Point(8, 8)
Me.Pic.TabIndex = 0
Me.Pic.Font = New System.Drawing.Font("Arial", 8!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Pic.Dock = System.Windows.Forms.DockStyle.None
Me.Pic.BackColor = System.Drawing.SystemColors.Control
Me.Pic.CausesValidation = True
Me.Pic.Enabled = True
Me.Pic.ForeColor = System.Drawing.SystemColors.ControlText
Me.Pic.Cursor = System.Windows.Forms.Cursors.Default
Me.Pic.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.Pic.TabStop = True
Me.Pic.Visible = True
Me.Pic.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Normal
Me.Pic.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.Pic.Name = "Pic"
Me.Controls.Add(Pic)
End Sub
#End Region
#Region "Upgrade Support "
Private Shared m_vb6FormDefInstance As Form1
Private Shared m_InitializingDefInstance As Boolean
Public Shared Property DefInstance() As Form1
Get
If m_vb6FormDefInstance Is Nothing OrElse m_vb6FormDefInstance.IsDisposed Then
m_InitializingDefInstance = True
m_vb6FormDefInstance = New Form1()
m_InitializingDefInstance = False
End If
DefInstance = m_vb6FormDefInstance
End Get
Set
m_vb6FormDefInstance = Value
End Set
End Property
#End Region
'UPGRADE_ISSUE: Declaring a parameter 'As Any' is not supported. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1016"'
Private Declare Function SendMessage Lib "USER32" Alias "SendMessageA"ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByRef lParam As Any) As Integer
Private Declare Function ReleaseCapture Lib "USER32" () As Integer
Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
Dim strPic As Object
' set form size
Me.Width = VB6.TwipsToPixelsX(10500)
Me.Height = VB6.TwipsToPixelsY(7590)
Me.Top = VB6.TwipsToPixelsY(20)
Me.Left = VB6.TwipsToPixelsX(20)
'UPGRADE_NOTE: Object Pic.Picture may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1029"'
Pic.Image = Nothing
'UPGRADE_WARNING: Couldn't resolve default property of object strPic. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
Pic.Image = System.Drawing.Image.FromFile(strPic) 'strPic - picture path Form1.Picture1.Picture
End Sub
Private Sub pic_MouseDown(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.MouseEventArgs) Handles pic.MouseDown
Dim Button As Short = eventArgs.Button \ &H100000
Dim Shift As Short = System.Windows.Forms.Control.ModifierKeys \ &H10000
Dim X As Single = VB6.PixelsToTwipsX(eventArgs.X)
Dim Y As Single = VB6.PixelsToTwipsY(eventArgs.Y)
If Button = 1 Then
Pic.Cursor = System.Windows.Forms.Cursors.SizeAll
Call ReleaseCapture()
Call SendMessage(Pic.Handle.ToInt32, &HA1s, 2, 0)
Pic.Cursor = System.Windows.Forms.Cursors.Arrow
End If
End Sub
End Class
Ответить
|
Страница: 1 |
Поиск по форуму