Bonjour,
Voici mon problème, j'ai une application windowsform dans laquelle j'ai une userform avec une progressbar créé à partir du mode design de sharpdevelop:
J'ai créé une classe dans laquelle j'ai une fonction de callback qui est appelée par une dll CscApi.dll qui permet de voir la progression de mise à jour d'un firmware sur un periphereique
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69 Partial Class MainForm Inherits System.Windows.Forms.Form ''' <summary> ''' Designer variable used to keep track of non-visual components. ''' </summary> Private components As System.ComponentModel.IContainer ''' <summary> ''' Disposes resources used by the form. ''' </summary> ''' <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> Protected Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If components IsNot Nothing Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub ''' <summary> ''' This method is required for Windows Forms designer support. ''' Do not change the method contents inside the source code editor. The Forms designer might ''' not be able to load this method if it was changed manually. ''' </summary> Private Sub InitializeComponent() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(MainForm)) ... Me.progressBarFirmwareUpdate = New System.Windows.Forms.ProgressBar() ... ' 'progressBarFirmwareUpdate ' Me.progressBarFirmwareUpdate.Location = New System.Drawing.Point(143, 177) Me.progressBarFirmwareUpdate.Name = "progressBarFirmwareUpdate" Me.progressBarFirmwareUpdate.Size = New System.Drawing.Size(300, 15) Me.progressBarFirmwareUpdate.Step = 1 Me.progressBarFirmwareUpdate.TabIndex = 0 ' 'MainForm ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6!, 13!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(489, 262) Me.Controls.Add(Me.tabControl1) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D Me.Icon = CType(resources.GetObject("$this.Icon"),System.Drawing.Icon) Me.MaximizeBox = false Me.Name = "MainForm" Me.Text = "Thales Reader V4 Tools" AddHandler Load, AddressOf Me.MainFormLoad Me.tabControl1.ResumeLayout(false) Me.tabPage1.ResumeLayout(false) Me.tabPage1.PerformLayout Me.ResumeLayout(false) End Sub ... Private progressBarFirmwareUpdate As System.Windows.Forms.ProgressBar ... Sub ButtonUpdateClick(sender As Object, e As EventArgs) MyReader.CSCReaderFirmwareUpdate() End Sub End Class
Dans cette fonction de callback , ratio correspond au pourcentage d'avancement de mise à jour du firmware, hCsc correspond au handle du peripherique, et pArg est un paramètre laissé libre à l'utilisateur.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12 Public Class CscApi ... <UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)> Private Delegate Sub fHookInstall (ByVal hCsc As System.UInt32, ByVal ratio As System.uint32, ByVal pArg As System.IntPtr) ... 'fonction FirmwareUpdateCallback Public Sub ProcfHookInstallFunc (ByVal hCsc As System.UInt32, ByVal ratio As System.uint32, ByVal pArg As System.IntPtr) .... .... End Sub End Class
J'aurai souhaité faire quelquechose du genre
Mais ca ne fonctionne pas car progressBarFirmwareUpdate ne fait pas partie ma class CscApi
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4 Public Sub ProcfHookInstallFunc (ByVal hCsc As System.UInt32, ByVal ratio As System.uint32, ByVal pArg As System.IntPtr) progressBarFirmwareUpdate.value = ratio End Sub
J'ai tenté en déclarant progressBarFirmwareUpdate en public shared, mais j'ai le warning suivant:
Du coup je ne vois vraiment pas comment faire pour mettre à jour la progressbar de maniere propre.Access of shared member, constant member, enum member or nested type through an instance; qualifying expression will not be evaluated. (BC42025)
Merci pour votre aide ou vos pistes.
Cdt,
yaume91
Partager