c# interface - hover delay

Join Discord

Far

tsniffer
Staff member
Developer
May 19, 2003
20,180
30
2,783
540
iv made an interface for my app. currently using a picture box, it changes colour (using a different image) when i hover over it.

currently though it takes about a second to change the colour. when i also have an on_click function to change the picture, which changes instantly.

is there anyway to stop this delay, because it makes my app look abit crappy.
 

DeathWish

LOMCN VIP
VIP
Oct 29, 2003
1,269
1
185
what are you using at the mo for the function like on_click?

I was gna say if its a pic and u load it from file then ya cud load it when ya open the app at the start n just put it in a variable so its in the memory instead of on the hd tht wud speed it up but as ya usd on_click n it workd instant....
 

Far

tsniffer
Staff member
Developer
May 19, 2003
20,180
30
2,783
540
both mouse_down (on click as i described it earlier), and mouse_hover are done in the same way. which is why its puzzling me.
[delphi]
private void UpdateButton1_MouseHover(object sender, EventArgs e)
{
UpdateButton1.Image = new Bitmap("..\\..\\Resources\\SOnMouse.bmp");
}

private void UpdateButton1_MouseDown(object sender, MouseEventArgs e)
{
UpdateButton1.Image = new Bitmap("..\\..\\Resources\\SPressed.bmp");
}
[/delphi]

the only thing thats diff is mousedown is a mouseEvent, where as mousehover is just an event. as shown below in the designer form...
[delphi]
this.UpdateButton1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.UpdateButton1_MouseDown);
this.UpdateButton1.MouseHover += new System.EventHandler(this.UpdateButton1_MouseHover);
[/delphi]

but it wont let me change mousehover to run from windows.forms for some reason. i get this error when i try too...


Error 1 Cannot implicitly convert type 'System.Windows.Forms.MouseEventHandler' to 'System.EventHandler' E:\Project Work\Patcher\Form1.Designer.cs 68 46 Patcher
 
Last edited:

DeathWish

LOMCN VIP
VIP
Oct 29, 2003
1,269
1
185
Try loading the image at the beginning into a variable

n also try adding

Beep just after the updatebutton1.image = new bitmap blah blah


and when u hover ur mouse over it if u hear it beeping loads you know its loading it loads of times wher as mouse down is mouse down once unless u click loads if u kno wht i mean
 

Far

tsniffer
Staff member
Developer
May 19, 2003
20,180
30
2,783
540
i havnt done the variable thing yet (will try that in a sec) but when using a beep it plays the beep straight away, then loads the image as normal.

im using System.Console.Beep(250, 500); as the beep on a new line, only thing i could find coz its not that same as vb where u can just type beep.
 

DeathWish

LOMCN VIP
VIP
Oct 29, 2003
1,269
1
185
k well only thing i cn suggest then is tryingthe variable thing n seeing if tht works
 

Far

tsniffer
Staff member
Developer
May 19, 2003
20,180
30
2,783
540
nope just tried it as a variable...

string image = "..\\..\\Resources\\SPressed.bmp";

if thats how you mean. and it still has a delay :/
 

DeathWish

LOMCN VIP
VIP
Oct 29, 2003
1,269
1
185
btw tht means

bitmap image = new Bitmap("..\\..\\Resources\\SOnMouse.bmp");
 

Far

tsniffer
Staff member
Developer
May 19, 2003
20,180
30
2,783
540
nah using that i still have the annoying delay :(
 

Far

tsniffer
Staff member
Developer
May 19, 2003
20,180
30
2,783
540
lol. i just found mouseEnter and thats working fine. IM SO STUPID!!!
 

DeathWish

LOMCN VIP
VIP
Oct 29, 2003
1,269
1
185
haha at least its sortd! i broke my vs 2008 by uninstalling everything but the actually visual studio thinkin i didnt need all the otha **** n now i cnt debug lol


n i just realised that hovering is obviously gun ahav a delay or it wouldnt be hovering lol -_-
 

Far

tsniffer
Staff member
Developer
May 19, 2003
20,180
30
2,783
540
thats true lol. i neva saw mouseEnter. jus startin to properly learn c#, when iv been doing it at uni for the last 3 years :P
 

Far

tsniffer
Staff member
Developer
May 19, 2003
20,180
30
2,783
540
for my uni coursework im doing a client/server app, its a very simple premise, but im finding it fk hard to do.

this app is simply me messing about with an autopatcher and getting an interface working, since iv neva tried to do one before.
 

DeathWish

LOMCN VIP
VIP
Oct 29, 2003
1,269
1
185
lol oh right, auto patcher's are a pretty difficult thing do to tbh...

cuz u have to program 2 programs at least.

Cuz if u have an update for your program, it trys downloading the update and wen u download it you'll need to replace the process that is currently running so u need to close the process that is running replace it with the update somehow and then re-open it

but ye its abit messy :P
 

Far

tsniffer
Staff member
Developer
May 19, 2003
20,180
30
2,783
540
yeah the autopatcher wont get done. iv got sources for it in delphi, but trying to attempt it in c#.

hopefully the client/server (done in command prompt) wont be as hard as you explained :P
 

Far

tsniffer
Staff member
Developer
May 19, 2003
20,180
30
2,783
540
all its meant to do is ask the server where a person is (held in the servers db), and allow you to change the location. for example in comand prompt you'd type...


client.exe brian

get a responce.. "brain is in a lecture"

or change the location..

client.exe brian "is on the toilet"

get a responce "brian is on the toilet" next time you type client.exe brian

very simple idea, but its too complicated for me :(. all iv managed so far is the client side interacting with a server to tell you where a person is.