invalidate, events and audio?

A

Andre Buck

Hi,

first at all, I'm new here. So if there are some questions which had been
posted a few times: sorry. Btw, if you got some good links about faqs or
something similar, don't hesitate to post them.

1)
I've got a for-loop, which should move a pictureBox. (See code below) The
pictureBox is moving but the old positions are still painted on the form
until it stops and the "animation" is finished. Why does the invalidate() do
not take effect until the for-loop is finished?

for (int i=0; i<50; i++)
{
this.picBox2.Left += 1;
this.picBox2.Update(); // works
this.Invalidate(); // ignored here?
}

2)
I read in this newsgroup, that drag&drop is not possible with the compact
framework. In the "normal" framework, I got a lot of events for a pictureBox
to do that. What kind of possibilities do I got in the compact framework to
pick up a bitmap (in a pictureBox) and move it with the stylus to another
position?

3)
I found an audio and player class in the openNETCF. Is that the only way to
play some *.wav files (e.g. when pushing a button)

Thanks in advance.
:: Andre
 
C

Chris Tacke, eMVP

1. Because you've not given it a chance to update. Paint is a low-priority
action. Add a DoEvents after the invalidate and it will probably work
(though you might get some bad flickering if you're going far).

2. Trap the mousedown, mousemove and mouseup and do the work internally.

3. Pretty much. You can P/Invoke directly as well - just look at the
OpenNETCF source to see how it's done.
 
A

Andre Buck

1. [...] (though you might get some bad flickering if you're
going far).

Thx, I think I can fix that with a kind of doublebuffer!?
2. [...] and do the work internally.

What do you mean? Should I ask every time a MouseDown event is
released, whether my "mouse" is within the box and if it's true to
change the position with the MouseMove ... I think I didn't get it, did
I?

Thanks so far ...

Andre
 
C

Chris Tacke, eMVP

1. [...] (though you might get some bad flickering if you're
Thx, I think I can fix that with a kind of doublebuffer!?

Yep, that's the route I'd go.
2. [...] and do the work internally.

What do you mean? Should I ask every time a MouseDown event is
released, whether my "mouse" is within the box and if it's true to
change the position with the MouseMove ... I think I didn't get it, did
I?

No, you got it.

OnMouseDown
{
if(OnMyObject) drag = true
}

OnMouseUp
{
drag = false
}

OnMouseMove
{
if(drag)
{
ReactToNewMousePosition()
}
}
 
A

André Buck

Andre said:
What do you mean? Should I ask every time a MouseDown event is
released, whether my "mouse" is within the box and if it's true to
change the position with the MouseMove ...

I solved the Problem with a manually generated event handler:

this.picBox.MouseMove += new
System.Windows.Forms.MouseEventHandler(this.PicBox_MouseMove);
[...]
public void PicBox_MouseMove(objects sender, MouseEventArgs e)
{
....
}

greets ab
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top