|
Hey
I have two big problems with my project.
I will post the whole code down under my question
What you will need to reproduce this code is a UserControl, on this usercontrol has to be a PictureBox and a Label
The problems are:
1) The mouseLeave Event is fired, even if I don't leave the usercontrol
2) After finishing the Animation, the picture box pops up to full size.
Maybe somone can help me? Here ist the code (VB2005)
<code>
Imports System.ComponentModel
Imports System.Reflection
Imports System.Threading
Public Class ISHilfe
#Region "Properties des Eigenschaftsfensters"
Dim _Bild As Image
< _
Description("Bild für Animation"), _
Category("Misc")> _
Public Property Bild() As Image
Get
Return (_Bild)
End Get
Set(ByVal value As Image)
Try
_Bild = value
pctBox.Image = value
pctBox.SizeMode = PictureBoxSizeMode.StretchImage
Catch
End Try
End Set
End Property
Dim _Labeltext As String
< _
Description("Text des Hilfelabels mit Mini Markup"), _
Category("Misc")> _
Public Property LabelText() As String
Get
Return _Labeltext
End Get
Set(ByVal value As String)
_Labeltext = value
End Set
End Property
#End Region
Dim pctAusblenden As New ThreadStart(AddressOf pctBoxVerkleinern)
Dim pctEinblenden As New ThreadStart(AddressOf pctBoxVergrößern)
Dim lblAusblenden As New ThreadStart(AddressOf lblVerkleinern)
Dim lblEinblenden As New ThreadStart(AddressOf lblVergrößern)
Dim pctFadeOut As New Thread(pctAusblenden)
Dim pctFadeIn As New Thread(pctEinblenden)
Dim lblFadeOut As New Thread(lblAusblenden)
Dim lblFadeIn As New Thread(lblEinblenden)
Private Sub ISHilfe_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
_ControlLabel = Me.lblInfo
_ControlPctBox = Me.pctBox
End Sub
Private Sub ISHilfe_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseEnter
lblOriginalSchrift = lblInfo.ForeColor
If pctFadeIn.ThreadState = ThreadState.Running Then
pctFadeIn.Abort()
End If
If lblFadeOut.ThreadState = ThreadState.Running Then
lblFadeOut.Abort()
End If
pctFadeOut.Start()
lblFadeIn.Start()
End Sub
Private Sub ISHilfe_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.MouseLeave
If pctFadeOut.ThreadState = ThreadState.Running Then
pctFadeOut.Abort()
End If
If lblFadeIn.ThreadState = ThreadState.Running Then
lblFadeIn.Abort()
End If
pctFadeIn.Start()
lblFadeOut.Start()
End Sub
#Region "Sub pctBoxVerkleinern"
Private Sub pctBoxVerkleinern()
Dim picGröße As Integer = Me.pctBox.Width
PicGrößeOriginalX = pctBox.Size.Width
PicLocationOriginalX = pctBox.Location.X
For i As Integer = pctBox.Location.X To 0 Step -1
Monitor.Enter(Me)
PctBoxNeueLocation(New Point(i, pctBox.Location.Y))
Monitor.Exit(Me)
System.Threading.Thread.Sleep(10) : ctrlPctBoxRefesh()
System.Windows.Forms.Application.DoEvents()
Next
Dim picEndGröße As Integer = Me.Width / 5
For i As Integer = picGröße To picEndGröße Step -1
Monitor.Enter(Me)
PctBoxNeueGröße(New Size(i, i))
PctBoxNeueLocation(New Point(pctBox.Location.X, (Me.Height - pctBox.Height) / 2))
Monitor.Exit(Me)
System.Threading.Thread.Sleep(10) : ctrlPctBoxRefesh()
System.Windows.Forms.Application.DoEvents()
Next
End Sub
#End Region
#Region "Sub pctBoxVergrößern"
Private Sub pctBoxVergrößern()
Dim picGröße As Integer = Me.pctBox.Width
For i As Integer = picGröße To PicGrößeOriginalX Step 1
Monitor.Enter(Me)
PctBoxNeueGröße(New Size(i, i))
PctBoxNeueLocation(New Point(pctBox.Location.X, (Me.Height - pctBox.Height) / 2))
Monitor.Exit(Me)
System.Threading.Thread.Sleep(10) : ctrlPctBoxRefesh()
System.Windows.Forms.Application.DoEvents()
Next
For i As Integer = 0 To PicLocationOriginalX Step 1
Monitor.Enter(Me)
PctBoxNeueLocation(New Point(i, pctBox.Location.Y))
Monitor.Exit(Me)
System.Threading.Thread.Sleep(10) : ctrlPctBoxRefesh()
System.Windows.Forms.Application.DoEvents()
Next
End Sub
#End Region
#Region "Sub lblVergrößern"
Private Sub lblVergrößern()
Dim Schriftfarbe As Color = lblOriginalSchrift
Dim Rot, Grün, Blau As Byte
Rot = Schriftfarbe.R
Grün = Schriftfarbe.G
Blau = Schriftfarbe.B
lblNeueGröße(Me.Width / 2)
For c As Integer = 0 To 255
Monitor.Enter(Me)
lblNeueFarbe(Color.FromArgb(c, Rot, Grün, Blau))
Monitor.Exit(Me)
System.Threading.Thread.Sleep(1)
System.Windows.Forms.Application.DoEvents()
Next
End Sub
#End Region
#Region "Sub lblVerkleinern"
Private Sub lblVerkleinern()
Dim Schriftfarbe As Color = lblOriginalSchrift
Dim Rot, Grün, Blau As Byte
Rot = Schriftfarbe.R
Grün = Schriftfarbe.G
Blau = Schriftfarbe.B
For c As Integer = 255 To 0 Step -1
Monitor.Enter(Me)
lblNeueFarbe(Color.FromArgb(c, Rot, Grün, Blau))
Monitor.Exit(Me)
System.Threading.Thread.Sleep(1)
System.Windows.Forms.Application.DoEvents()
Next
lblNeueGröße(0) : ctrlLabelRefresh()
End Sub
#End Region
Private Sub ISHilfe_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
If Me.Width <> Me.Height Then
Me.Size = New Size(Me.Width, Me.Width)
End If
Me.Refresh()
Me.pctBox.Size = New Size(Me.Width / 2, Me.Height / 2)
Me.pctBox.Location = New Point((Me.Width - Me.pctBox.Width) / 2, _
(Me.Height - Me.pctBox.Height) / 2)
Me.pctBox.Refresh()
PicGrößeOriginalX = pctBox.Size.Width
PicLocationOriginalX = pctBox.Location.X
End Sub
#Region "Private Properties"
Private _ControlLabel As Control
Private _ControlPctBox As Control
Private ReadOnly Property ControlPctBox() As Control
Get
Return _ControlPctBox
End Get
End Property
Private ReadOnly Property ControlLabel() As Control
Get
Return _ControlLabel
End Get
End Property
' Speichert den hinzuzufügenden Text.
Private _lblNeueGröße As Integer
Private Sub lblNeueGröße(ByVal NeueGröße As Integer)
SyncLock Me
Me._lblNeueGröße = NeueGröße
ControlLabel.Invoke(New MethodInvoker(AddressOf ThreadSafeNeueGröße))
End SyncLock
End Sub
Private Sub ThreadSafeNeueGröße()
Me.ControlLabel.Width = _lblNeueGröße
End Sub
Dim _lblNeueFarbe As Color
Private Sub lblNeueFarbe(ByVal NeueFarbe As Color)
SyncLock Me
Me._lblNeueFarbe = NeueFarbe
ControlLabel.Invoke(New MethodInvoker(AddressOf ThreadSafeNeueFarbe))
End SyncLock
End Sub
Private Sub ThreadSafeNeueFarbe()
Me.ControlLabel.ForeColor = _lblNeueFarbe
End Sub
Dim _lblOriginalSchrift As Color
Private Property lblOriginalSchrift() As Color
Get
Return _lblOriginalSchrift
End Get
Set(ByVal value As Color)
_lblOriginalSchrift = value
End Set
End Property
Private Sub ctrlLabelRefresh()
SyncLock Me
ControlLabel.Invoke(New MethodInvoker(AddressOf ThreadSafeLabelRefresh))
End SyncLock
End Sub
Private Sub ThreadSafeLabelRefresh()
Me.ControlLabel.Refresh()
End Sub
Private Sub ctrlPctBoxRefesh()
SyncLock Me
ControlPctBox.Invoke(New MethodInvoker(AddressOf ThreadsafePctBoxRefresh))
End SyncLock
End Sub
Private Sub ThreadsafePctBoxRefresh()
Me.ControlPctBox.Refresh()
End Sub
Private _PctBoxNeueLocation As Point
Private Sub PctBoxNeueLocation(ByVal NeueLocation As Point)
SyncLock Me
Me._PctBoxNeueLocation = NeueLocation
ControlPctBox.Invoke(New MethodInvoker(AddressOf ThreadSafePctBoxNeueLocation))
End SyncLock
End Sub
Private Sub ThreadSafePctBoxNeueLocation()
Me.ControlPctBox.Location = _PctBoxNeueLocation
End Sub
Private _PctBoxNeueGröße As Size
Private Sub PctBoxNeueGröße(ByVal NeueGröße As Size)
SyncLock Me
Me._PctBoxNeueGröße = NeueGröße
ControlPctBox.Invoke(New MethodInvoker(AddressOf ThreadSafePctBoxNeueGröße))
End SyncLock
End Sub
Private Sub ThreadSafePctBoxNeueGröße()
Me.ControlPctBox.Size = Size
End Sub
Dim _PicGrößeOriginalX As Integer
Private Property PicGrößeOriginalX() As Integer
Get
Return _PicGrößeOriginalX
End Get
Set(ByVal value As Integer)
_PicGrößeOriginalX = value
End Set
End Property
Dim _PicLocationOriginalX As Integer
Private Property PicLocationOriginalX() As Integer
Get
Return _PicLocationOriginalX
End Get
Set(ByVal value As Integer)
_PicLocationOriginalX = value
End Set
End Property
#End Region
Private Sub lblInfo_ForeColorChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles lblInfo.ForeColorChanged
lblOriginalSchrift = lblInfo.ForeColor
End Sub
End Class
</code>
|
|
|
|
|
Zero-G. wrote: I will post the whole code down under my question
Just the relevant parts will do. I don't think most people actually have the time to read it all.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
Ready to Give up - Your help will be much appreciated.
My website
|
|
|
|
|
Colin Angus Mackay wrote: I don't think most people actually have the time to read it all.
I just did a quick glance, and now I will just walk away for awhile
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I believe the UserControl is firing it's mouseleave event when the mouse goes over the label or picturebox. This is normal. When the event fires you might be able to just check the mouselocation and if it's within the bounds of your control, exit the method. You could also try to get around the problem by doing all the drawing yourself instead of using a picturebox and label.
**EDIT**
The reason it pops up is because of the second loop in this method 'pctBoxVerkleinern'.
Also I believe your going to have some threading issues because you can't start a thread once it's been aborted. In the mouseenter and leave events you need to create a new instance of the thread and then start it.
|
|
|
|
|
Hey
Thanks for taking the time, and take a look to the code.
I will try to change the code, like you told me. - I will answer my progress.
THX
|
|
|
|
|
Hi
I have been playing around with a password hashing scheme for my application
But i keep getting an error message when it executes the command object
i get the error
Unable to cast object of type 'System.byte[]' to type 'system.inconvertible'
Any suggestions?
Sub CreateAccount(ByVal sender As Object, ByVal e As EventArgs)
Dim literror As New LiteralControl
'1. Create a connection
'Create connection string to pass database, string holds login information to mySQL,
Dim connectionString As String
connectionString = "Server=localhost; ;database=ftp1;"
'Builds .net mysql connection and passes connection string into method
Dim connection As New MySqlConnection(connectionString)
Try
'2. Create a command object for the query
Dim strSQL As String = _
"INSERT INTO Useraccount(Username,Password) " & _
"VALUES(?Username, ?Password)"
Dim objCmd As New MySqlCommand(strSQL, connection)
'3. Create parameters
Dim paramUsername As MySqlParameter
paramUsername = New MySqlParameter("?Username", SqlDbType.VarChar, 25)
paramUsername.Value = txtUsername.Text
objCmd.Parameters.Add(paramUsername)
'Encrypt the password
Dim md5Hasher As New MD5CryptoServiceProvider()
Dim hashedBytes As Byte()
Dim encoder As New UTF8Encoding()
hashedBytes = md5Hasher.ComputeHash(encoder.GetBytes(txtPwd.Text))
Dim paramPwd As MySqlParameter
paramPwd = New MySqlParameter("?Password", SqlDbType.Binary, 16)
paramPwd.Value = hashedBytes
objCmd.Parameters.Add(paramPwd)
'Insert the records into the database
connection.Open()
objCmd.ExecuteReader()
connection.Close()
Catch ex As Exception
literror.Text = ex.Message
MsgBox(ex.Message)
End Try
Response.Redirect("userhome.aspx")
End Sub
|
|
|
|
|
The code seems seasonable to me, other than you might want to pick a stronger encryption (MD5 is known to be very weak!), and possibly check that the number of bytes comming from the hash will actually fit in the database field and the field is of the correct type to hold the data.
I don't use MySQL, so I don't know what it's going to support and what it's not, or what it's requirements for field types are going to be.
|
|
|
|
|
Dave Kreskowiak wrote: MD5 is known to be very weak!
Yep. Even my coffee is stronger :->
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hey NG
I am looking for a Video Player, which can play different types of Video Format.
For example: mpg, vob, divx, Flash, PowerPoint and so on.
Does anybody know, where I can get something like that, or how to make such a player?
I am using VB2005
Yours faithfully - THX
|
|
|
|
|
There is no player that can play all those formats. Most of the video formats require that codecs be installed, like vob and divx, in order for any player to play them. I don't know of any player that can play ShockWave/Flash AND PowerPoint AND any video stream.
Making a player like this yourself would require a enormous amount of work on your part and a complete understanding of each file format you want to support, like Flash or PowerPoint, and how to parse and render them.
|
|
|
|
|
Hey
Thank you, for reply. - This did not sound good....
Maybe out there someone had the idea to make such a player.
I will look further for informations.
Thank you!
|
|
|
|
|
|
I have a form with a DataGrid and a Listbox. My goal is to do a if statement looking for setting and depending on the outcome, show either the Data Grid OR the listbox by using the visible parameter. When I load the form it correctly shows the correct control by loading a saved file with the setting. I call a method in the same class and pass the value. The problem comes when I use a different form (Different class) and try to pass the setting in again. EX: I want to go to a properties windo and change the settings and have it update the baseform. I see the values going in the method but I don't see the form changing.
Code.
Private Sub frminYardTrucks_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
<br />
FileOpen(1, "C:\properties.txt", OpenMode.Input, OpenAccess.Read, OpenShare.LockRead)<br />
<br />
Dim savedProperties As Properties<br />
<br />
Input(1, savedProperties.software<br />
<br />
testSoftwareProperties(savedProperties.software)<br />
<br />
Public Sub testSoftwareProperties(ByVal choice As String)<br />
If choice.Equals("Transact") Then<br />
'MessageBox.Show("Show Grid")Test<br />
Me.lstbxTrucks.Visible = False<br />
Me.TestDataGrid.Visible = True<br />
<br />
Else<br />
'MessageBox.Show("Show Listbox")Test<br />
Me.TestDataGrid.Visible = False<br />
Me.lstbxTrucks.Visible = True<br />
End If<br />
End Sub<br />
<br />
Public Class frmProperties<br />
Inherits Windows.Forms.Form<br />
'Read in file and saved to cmbobxSoftware.Text <br />
Public Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click<br />
Dim test As New frminYardTrucks<br />
test.testSoftwareProperties(cmbobxSoftware.Text.ToString)
When I complete btnSave_Click the frm does not change.
Does it have to deal with Overriding.
|
|
|
|
|
You are missing an essential point (and if IIRC you did the same in some earlier post):
when you have a specialized form class (such as frminYardTrucks) you
dont have any object yet, and you dont see anything yet.
when you instantiate this class (with the New keyword), you have a form, that you dont
see yet, until you call Show (or ShowDialog) on it.
when you instantiate this class again, you get a second form, that you again dont see
until you Show it...
So creating a second form, not showing it and modifying it will never help you:
the original, unmodified form will be visible, the second modified form remains invisible.
What you must do is modify your EXISTING form instance, so dont do New frminYardTrucks
more than once, if you only want a single frminYardTrucks !!!
|
|
|
|
|
I want to change the vb.net datagridview control's color. the column headers are always displayed in Gray by default. does anyone know which property should i use to change this color. there are some properties which set the datagridview's cell's color. but i want a property which will change the column header color.
Thanks!
|
|
|
|
|
hi,
change datagridview property "EnableHeaderVisualStyles" to false & after that from "columnheaderdefaultcellstyle" property you can change the color of header
hope this helps
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
|
|
|
|
|
hi,
I want to know how i can Call form created in vb.net fom vb6.0 application.
Can someone send me some links or code to do this.
Thanks and Regards,
GIRISH
|
|
|
|
|
You can't interact with VB.NET from VB6, you can start a VB.NET program, just like any other.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have got something called as InterOp but i am not able to understand the logic correctly,it has demo also which shows that it it possible to call vb.net from from vb6.0 application.So,pls If u know the answer then give the answer and if u dont know the answer then dont give it atleast dont say that it is not possible.
|
|
|
|
|
|
I am a student, and we have a project about making a computerized system.
I am making the data entry module of the grades per class. How can view in the datagrid all of the students who enrolled in that class.
I hope you understand me...
please reply as soon as possible.
|
|
|
|
|
Rharzkie wrote: please help me...its about vb.net
Really ? Here in the VB.NET forum ? Seriously, try putting a meaningful subject line.
Rharzkie wrote: How can view in the datagrid all of the students who enrolled in that class.
By doing a SQL call to get that data, and putting it in a control like a gridview. What is your data store ?
Rharzkie wrote: please reply as soon as possible.
See, that's just rude.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
ok, sorry, its my first time here...
i just made database in access, the database is composed of different tables: file maintenance of the students, then the different subjects...
how to do an sql call to get the data???
in my module, the user will need to click the search button to search for the the different subjects. then, if you click it, all of the students who enrolled in that subjects will be view in the datagrid...
how can i do it?? i made a separate database for that. I think, i need to make a query for that, but i dont know how.
|
|
|
|
|
There are classes built into .NET for database access, there's tons of info on the web, google 'VB.NET Access database'. If you don't know how to write the SQL, then you need to buy a book and work through it, you're after the most simple SQL line there is.
Rharzkie wrote: I think, i need to make a query for that, but i dont know how.
Yes, you need to take the string and pass it to a query that searches for it. Again, you're asking very much beginner SQL questions, you need to buy a book and learn from it, so you have some understanding of what you're trying to do.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|