Страница: 1 |
Страница: 1 |
Вопрос: Работа с курсором
Добавлено: 31.10.05 12:27
Автор вопроса:
ПтирЯ
Кто-нибудь работал с системным курсором в VB.NET?
пробовал через свойства контролов .Cursor - не работает.
Ответы
Всего ответов: 11
Номер ответа: 1
Автор ответа: GSerg
Вопросов: 0
Ответов: 1876
Профиль | | #1
Добавлено: 31.10.05 13:20
У каждого контрола свой курсор, а что неправильно?
Номер ответа: 2
Автор ответа: ПтирЯ
Вопросов: 11
Ответов: 71
Профиль | | #2
Добавлено: 31.10.05 13:26
да нет все правильно.
просто мне для задачи нужно изменить курсор, даже когда он не находится над контролом ....
ты работал с этим?
Номер ответа: 3
Автор ответа: GSerg
Вопросов: 0
Ответов: 1876
Профиль | | #3
Добавлено: 31.10.05 14:48
Курсор всегда находится над каким-то контролом.
Рабочий стол - это тоже контрол. ListView.
Что за задача?
Номер ответа: 4
Автор ответа: ПтирЯ
Вопросов: 11
Ответов: 71
Профиль | | #4
Добавлено: 31.10.05 14:55
идет фоновый процес и пока он исполняется надо показать что процесс идет. раньше выводил формочку в это время. но это "тяжело" и медленно и захотел показывать это через курсор.
хорошо попробую ListView
Номер ответа: 5
Автор ответа: AgentFire
ICQ: 192496851
Вопросов: 75
Ответов: 3178
Профиль | | #5
Добавлено: 31.10.05 15:16
ну ты блин даешь...
)
апишка такая есть... SetCursor называется
Номер ответа: 6
Автор ответа: ПтирЯ
Вопросов: 11
Ответов: 71
Профиль | | #6
Добавлено: 31.10.05 15:59
может одаришь примерчиком?
Номер ответа: 7
Автор ответа: GSerg
Вопросов: 0
Ответов: 1876
Профиль | | #7
Добавлено: 31.10.05 16:05
:roll:
Просто установить ждущий курсор всей форме - не?
Справка.
Использование API в .NET требует наличия у сборки максимальных привилегий (fully trusted). При их отсутствии код запущен не будет. Установка такой сборки требует конфигурирования локальной политики безопасности компьютера в части управления сборками .NET.
Номер ответа: 8
Автор ответа: GSerg
Вопросов: 0
Ответов: 1876
Профиль | | #8
Добавлено: 31.10.05 16:18
MSDN:
Номер ответа: 9
Автор ответа: ПтирЯ
Вопросов: 11
Ответов: 71
Профиль | | #9
Добавлено: 31.10.05 16:48
спасибо, помогло!
Номер ответа: 10
Автор ответа: Павел
Администратор
ICQ: 326066673
Вопросов: 368
Ответов: 5968
Web-сайт:
Профиль | | #10
Добавлено: 01.11.05 18:06
MSDN рулит.
Gets or sets a cursor object that represents the mouse cursor.
Public Shared Property Current As Cursor
Property Value
A Cursor that represents the mouse cursor. The default is a null reference (Nothing in Visual Basic) if the mouse cursor is not visible.
Remarks
Setting the Current property changes the cursor currently displayed, and the application stops listening for mouse events. For example, you might set the Current property to Cursors.WaitCursor before you start filling a TreeView, DataGrid, or ListBox control with a large amount of data. After the loop is completed, set this property back to Cursors.Default to display the appropriate cursor for each control.
Note If you call Application.DoEvents before resetting the Current property back to the Cursors.Default cursor, the application will resume listening for mouse events and will resume displaying the appropriate Cursor for each control in the application.
Example
The following example displays customer information in a TreeView control. The root tree nodes display customer names, and the child tree nodes display the order numbers assigned to each customer. In this example, 1,000 customers are displayed with 15 orders each. The repainting of the TreeView is suppressed by using the BeginUpdate and EndUpdate methods, and a wait Cursor is displayed while the TreeView creates and paints the TreeNode objects. This example assumes you have a cursor file named MyWait.cur in the application directory. It also assumes you have a Customer object that can hold a collection of Order objects. It also assumes that you have created an instance of a TreeView control on a Form.
' Create a new ArrayList to hold the Customer objects.
Private customerArray As New ArrayList()
Private Sub FillMyTreeView()
' Add customers to the ArrayList of Customer objects.
 im x As Integer
For x = 0 To 999
customerArray.Add(New Customer("Customer" + x.ToString()))
Next x
' Add orders to each Customer object in the ArrayList.
 im customer1 As Customer
For Each customer1 In customerArray
 im y As Integer
For y = 0 To 14
customer1.CustomerOrders.Add(New Order("Order" + y.ToString()))
Next y
Next customer1
' Display a wait cursor while the TreeNodes are being created.
Cursor.Current = New Cursor("MyWait.cur"
' Suppress repainting the TreeView until all the objects have been created.
treeView1.BeginUpdate()
' Clear the TreeView each time the method is called.
treeView1.Nodes.Clear()
' Add a root TreeNode for each Customer object in the ArrayList.
 im customer2 As Customer
For Each customer2 In customerArray
treeView1.Nodes.Add(New TreeNode(customer2.CustomerName))
' Add a child TreeNode for each Order object in the current Customer object.
 im order1 As Order
For Each order1 In customer2.CustomerOrders
treeView1.Nodes(customerArray.IndexOf(customer2)).Nodes.Add( _
New TreeNode(customer2.CustomerName + "." + order1.OrderID))
Next order1
Next customer2
' Reset the cursor to the default for all controls.
Cursor.Current = System.Windows.Forms.Cursors.Default
' Begin repainting the TreeView.
treeView1.EndUpdate()
End Sub 'FillMyTreeView
Номер ответа: 11
Автор ответа: Nikolai
Вопросов: 23
Ответов: 58
Профиль | | #11
Добавлено: 22.01.06 10:46
Что здесь не правильно?
Public Class Form1
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
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
'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.
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
 im resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.PictureBox1 = New System.Windows.Forms.PictureBox
Me.SuspendLayout()
'
'PictureBox1
'
Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image", System.Drawing.Image)
Me.PictureBox1.Location = New System.Drawing.Point(192, 24)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(120, 128)
Me.PictureBox1.TabIndex = 0
Me.PictureBox1.TabStop = False
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackgroundImage = CType(resources.GetObject("$this.BackgroundImage", System.Drawing.Image)
Me.ClientSize = New System.Drawing.Size(344, 302)
Me.Controls.Add(Me.PictureBox1)
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)
End Sub
#End Region
End Class
' Create a new ArrayList to hold the Customer objects.
Private customerArray As New ArrayList
Private Sub FillMyTreeView()
' Add customers to the ArrayList of Customer objects.
 im x As Integer
For x = 0 To 999
customerArray.Add(New Customer("Customer" + x.ToString()))
Next x
' Add orders to each Customer object in the ArrayList.
 im customer1 As Customer
For Each customer1 In customerArray
 im y As Integer
For y = 0 To 14
customer1.CustomerOrders.Add(New Order("Order" + y.ToString()))
Next y
Next customer1
' Display a wait cursor while the TreeNodes are being created.
Cursor.Current = New Cursor("MyWait.cur"
' Suppress repainting the TreeView until all the objects have been created.
treeView1.BeginUpdate()
' Clear the TreeView each time the method is called.
treeView1.Nodes.Clear()
' Add a root TreeNode for each Customer object in the ArrayList.
 im customer2 As Customer
For Each customer2 In customerArray
treeView1.Nodes.Add(New TreeNode(customer2.CustomerName))
' Add a child TreeNode for each Order object in the current Customer object.
 im order1 As Order
For Each order1 In customer2.CustomerOrders
treeView1.Nodes(customerArray.IndexOf(customer2)).Nodes.Add( _
New TreeNode(customer2.CustomerName + "." + order1.OrderID))
Next order1
Next customer2
' Reset the cursor to the default for all controls.
Cursor.Current = System.Windows.Forms.Cursors.Default
' Begin repainting the TreeView.
treeView1.EndUpdate()
End Sub 'FillMyTreeView
-Private customerArray As New ArrayList
-Private Sub FillMyTreeView()
Эти строчки подчёркнуты.
Надо что б при наведении курсора на картинку появлялся свой курсор.