Help converting simple VB6 project to .NET

DanMcNewbie

Newcomer
Joined
Mar 10, 2003
Messages
4
Location
UK
Hi,
I'm really stuck trying to get the attached project to work in dotNET.

I come from a graphic design background and I'm not very good at VB yet (7 days experience) and just as I started to get the hang of Version 6 I've been told my project has to be done in VB.NET.
If anyone can help me convert this to a working VB.NET project I will be eternally greatfull.

The main problem seems to revolve around a rollover control I downloaded from one of the links on the forum. It works great in my VB6 program but I can't get it to work after I convet the project to VB.NET.

I've seached far and wide for a similar control that works nativly in VB.NET to no avail.

Thanks for taking the time to read.
 

Attachments

You didn't include some necessary files. It's worth noting, though, that .net controls have both a MouseEnter and MouseLeave event, thus greatly simplifying your task.
 
Hi Divil

What file(s) did I forget to attach?

I didn't realise that there's now a MouseLeave event!

I guess the major issue for me is my lack of expereince.

I can see how to make a control react to the events but it gets messy real quick unless you know how to impliment these events into a single user control with a click property.

E.g one control that lets me specify two bitmaps in its properties, normal and mouse over. I don't want to have to worry about checking the button state bitmap in the main 'click' event code.

I'm sure I'll get there in the end, I just need to press on with my reading. The more I use dotNET the more I like.
 
If you make yourself a new control, and give it two image properties, it should be a fairly simple matter of drawing whichever one you need to. If you get stuck with a specific problem doing this, post it here.
 
mouseenter and mouseleave i presume are mousedown and mouseup, if so you may recognise the names for them better now. yes those two functions are very important :)
1 thing i learnt from this very board quite some time ago now is that it's much better to code your project using .NET to start with rather than upgrading a vb6 project using a wizard, not only does this help you to understand .Net better but also it looks a lot less messy code wise.
 
I wasn't referring to MouseDown and MouseUp, there are actually MouseEnter and MouseLeave events for every control.
 
divil said:
If you make yourself a new control, and give it two image properties, it should be a fairly simple matter of drawing whichever one you need to. If you get stuck with a specific problem doing this, post it here.

To be honest Divil I'm still a little out of my depth here. I'd dont understand how to make my own control and give it two image properties. The MSDN built in help just seems to complicate things rather than help :confused:

I've managed to get it working my setting up handlers for each event, like this :

----------------------
rem Set correct image for MouseEnter
Private Sub PictureBoxBE_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBoxBE.MouseEnter
PictureBoxBE.Image = System.Drawing.Image.FromFile("d:\image\btn_be_down.gif")
End Sub

rem Set correct image for MouseLeave
Private Sub PictureBoxBE_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBoxBE.MouseLeave
PictureBoxBE.Image = System.Drawing.Image.FromFile("d:\image\btn_be_up.gif")
End Sub

rem Click has occured
Private Sub PictureBoxBE_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBoxBE.Click
MsgBox("Click")
End Sub
----------------------

Its works but I know its not the way I should be doing things. Image these three routines for each of the 5 rollover images I'm using, the code looks total mess.

On a secondary note, this also requires that I have the images external to the main EXE rather than built in. The only way I know (so far) of getting over this is to have the images all loaded as picture controls in a seperate form and referece them from there....ugly :-(
 
The first step is going to the project menu and adding a new User Control. Once that's code, you should be able to add two properties to it and respond to the MouseEnter and MouseLeave events (NOT Enter and Leave events) in the control to give the control the right images.

This will also make the control designable, you'll be able to drop it on to your form from the toolbar and choose the images in the propertygrid like you would in, say, a picturebox.
 
divil said:
The first step is going to the project menu and adding a new User Control. Once that's code, you should be able to add two properties to it and respond to the MouseEnter and MouseLeave events (NOT Enter and Leave events) in the control to give the control the right images.

This will also make the control designable, you'll be able to drop it on to your form from the toolbar and choose the images in the propertygrid like you would in, say, a picturebox.

I can see this is the way to go, once the user control is made you just add the control to your form and hey presto.

Well I added a user control but I just don't have the ability to code it. Is there any chance you can offer me a more detailed guide to get me through this?
 
Back
Top