|
in your OnMouseUp event of your control, add the following code:
MessageBox.Show("X: " + Cursor.Position.X + ", Y: " + Cursor.Position.Y);
You can use the Cursor.Position property to find the current location of your mouse cursor on the screen.
Jon G
www.Gizmocoder.com
|
|
|
|
|
After retrieval of the mouse position as described by the preceding posting use the PointToClient method of your Panel to convert the mouse position from screen coordinates into client coordinates of your Panel.
www.troschuetz.de
|
|
|
|
|
Hi~
using CEMAPI
The function
HRESULT IMAPIable::QueryRows(LONG lRowCount, ULong ulFlags, LPSRowSet *lppRows);
The maximum number of return of row is 10 and cannot get the retral rows.
How to get the next 10 rows?
Thanks
|
|
|
|
|
Hi guys i got the question keep asking but haven't got the right answer yet.
The question is how can make the progress bar working with long run process using threading. I have 1 form, a long run process method e.g
public void LongRunProcess(), and a progress bar. i would like to make the progress bar run based on the time of the LongRunProcess(), ie. when the process the progress bar show 100% complete and the UI won't freeze. Anyone help me to do so. Thank you
Popoxinhxan
|
|
|
|
|
You have haven't said what the problem is, other that a general "UI freezes", all we can do if refer you to examples of other Progress Bar controls. Check out Building a Progress Bar that Doesn't Progress[^] for a threaded Progress Bar. The code is in VB.NET, but can easily be translated to C#.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You wrote :
Hi guys i got the question keep asking but haven't got the right answer yet.
This is simply a trick.If are getting good suggection i recommand you to go ahead with that.
I can suggest you one thing. Create a custom event which will increase the value of the progress bar. I mean you need to fill the progress bar without any user interaction or something. Call this event in different stages of your thread execution.
For eg: You have a thred which will execute 100 lines of code. You can call your custom event in alternate 10 lines. You can step the status bar value by 10 in your event handler.
Sreejith Nair
[ My Articles ]
|
|
|
|
|
Here is my code but i don't know how to make this work
private void btnUpdate_Click(object sender, System.EventArgs e)
{
timer1.Start();
Thread t = new Thread(new ThreadStart(GetWebServices));
t.Start();
}
//Update the progressBarFormAction this will be put in tick event of timer1
private void UpdateProgressBar()
{
if(prgBar.Value!=prgBar.Maximum)
prgBar.PerformStep();
}
//Long run method
public void GetWebServices()
{
//int noWs =0;
com.strikeiron.www.StrikeIronDirectoryService service = new com.strikeiron.www.StrikeIronDirectoryService();
com.strikeiron.www.LicStatus lic = new com.strikeiron.www.LicStatus();
com.strikeiron.www.RespStatus res = new com.strikeiron.www.RespStatus();
com.strikeiron.www.WebServiceInfo [] list =null;
try
{
list = service.GetAllPublicServices(this.siLicense,out res,out lic);
}
catch (System.Net.WebException)
{
MessageBox.Show(this,"Internet connection error");
}
System.Threading.Thread.Sleep(100000);
}
Popoxinhxan
|
|
|
|
|
You can't monitor the progress of the call to .GetAllPublicServices . Also, by putting the progress increment in a timer, you're not showing the actual progress of the call, but of the timer itself. You best bet to to use a progress bar class that shows something is going on, but not actault progress towards a "100% goal". The link I gave you is a perfect example of this.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Still you are into same issue ?. What about my last post. Did you tried ?
Sreejith Nair
[ My Articles ]
|
|
|
|
|
Hi!Dear,
How to conjoin C# code with vc++6.0 code?
where can I get tips about this?
Thanks lot!
|
|
|
|
|
You should start by reading the .NET Framework SDK, such as the section entitled Interoperating with Unmanaged Code[^]. This explains interop'ing with COM servers, clients, and unmanaged functions exported from native DLLs.
There's also a lot of other articles on this site discussing .NET Interop.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi!Heath Stewart,
Thank you very much! I am a new hand with .NET Framework and C# programming,but I found myself fall my love into them.What's more,this website always offers much help,so many warmhearted people there. I am a Chinese programmer,I love this website and I love you all!
Thanks again!
Momer
|
|
|
|
|
hey guys,
if anyone has idea about how to stream a video via asp.net application using flash player or windows media palayer pls post me related site,tutorial or code sample as soon as possible.
best regards from mohan
|
|
|
|
|
You should ask this in the ASP.NET forum.
Honestly, ASP.NET shouldn't stream the video. There's already servers that do that, such as Windows Media Server on Windows 2000 Server and Windows Server 2003.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
i've a private void drawGraph(PaintEventArgs pe) function and i triggle it only after i click the button. However, after i click the button,if i minimise my form or drag it away from view, the drawing disappear. why is it like this?
|
|
|
|
|
You need to override OnPaint and perform your painting operations using the PaintEventArgs.Graphics object passed to the method. Also, don't forget to call base.OnPaint before starting your painting (typically).
If you don't do this, when the form gets invalidated (such as minimizing it) then it will not get repainted.
There are many articles about custom drawing on this web site and you should try searching for some using the search box below the logo at the top of every page.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
hi,thanks for the reply.
(1)However, now i'm using a function to draw my graph.i did not use "PaintEventArgs e" but i did this way
private void drawGraph()
{
MessageBox.Show(""+ getValue);
Graphics myGraphics = CreateGraphics(); //instead of e.Graphics;
Pen myPen = new Pen(Color.Black,1);
............
} because i need to call this function when button1 is click. So how should i go about doing the override OnPaint and base.OnPaint ?
(2)After button1 is click, how do i display the graph onto a PictureBox instead of display it onto the form?
|
|
|
|
|
Firs tof all, MessageBox.Show is the worst way to debug an application. Set a breakpoint on the line you want and in Visual Studio hit F5 while doing a debug build. That's real debugging and can yield far more valuable data than MessageBox.Show .
Define drawGraph like so (and please following .NET naming guideilnes when developing, which is documented in the .NET Framework SDK):
static readonly Pen BlackPen = new Pen(Color.Black, 1);
private void DrawGraph(Graphics g)
{
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (graphEnabled) DrawGraph(e.Graphics);
}
private void button1_Click(object sender, EventArgs e)
{
graphEnabled = true;
Refresh();
} I'm assuming here that button1 works as an enabler. When you call Refresh the client area is invalidated and redrawn immediately, meaning that OnPaint gets called. As long as graphEnabled is true in this example, any invalidated of your control (i.e., when a portion is hidden) will be redrawn with the graph.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
hi, sorry for the late reply. i took quite some time to draw my graph
1)i used your method and i managed to get what i want. however, i'm still not able to draw it into the picture box. my drawing is still drawn onto the form
2)how do i remove flickering? should i do it in drawgraph(Graphics g) or in protected override void OnPaint(PaintEventArgs e)
i've tried this but didn't work out:
this.SetStyle( <br />
<br />
ControlStyles.AllPaintingInWmPaint | <br />
<br />
ControlStyles.UserPaint | <br />
<br />
ControlStyles.DoubleBuffer,true);
Thanks.
Chris
|
|
|
|
|
Double-buffering won't solve all your problems. You need to honor the PaintEventArgs.ClipRectangle and draw only what needs to be drawn. You can also improve performance if you cache pens, brushes, and other static and semi-statis data (i.e., data that doesn't change each time you draw). If you're doing a lot of calculations and creating a lot of objects while painting, you will notice flicker.
I would suggest that - in situations like this - you take a look at the OnPaint override for the PictureBox to determine how it's currently working in order to override it the way you want. You can use ildasm.exe (from the .NET Framework SDK) to disassemble the assembly (if you know IL), or something like .NET Reflector to decompile (i.e., to source form) the source. Overriding the painting routines should work, but you must override painting for the PictureBox (not the containing control like a Form ) and you must first call base.OnPaint so that the PictureBox 's painting code doesn't paint over your drawing (last "write" wins).
You should also consider just dropping the PictureBox and painting an image yourself. The Graphics objects makes this easy. Just override OnPaint in a derivative Control class, paint the image, then paint over it all from within OnPaint (or methods it may call similar to what you're doing now).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I'm trying to reword the question I asked below in more general terms.
From a class classSecond how do you check if an object Obj_classFirst of classFirst has been created?
Also, how do you access and modify its value?
|
|
|
|
|
NietzscheDisciple wrote:
From a class classSecond how do you check if an object Obj_classFirst of classFirst has been created?
I guess if it has not been created, it will hold it's default value, which should be set to null. The real problem with this question is that it cannot be answered without knowing the relationship between the two classes.
NietzscheDisciple wrote:
Also, how do you access and modify its value?
If there is no interface so that one is a member of the other, or some other mechanism is provided through methods that both can see, the answer is that they can't.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Christian, thanks for the reply.
In my main form's class, I have an object of the DirectSound SecondaryBuffer class. It is declared as follows:
public SecondaryBuffer SecBuff = null;
and is initialized later in the code as follows:
SecBuff = new SecondaryBuffer(FileName, ApplicationDevice);
The above code belongs in the class "MainForm" that is declared as
public class MainForm : System.Windows.Forms.Form
Now, I have a separate Control,
public class ctlVolume: System.Windows.Forms.UserControl
All I have in this Control is a trackbar, tbVol. I want the volume of SecBuff to change when the trackbar value changes. This is accomplished by calling the Volume method on this object.
How do I access the object SecBuff which is in the class MainForm? How do I use interfaces to do it?
Thanks!
|
|
|
|
|
Maybe I'm missing something here, but it seems that you're trying to obtain an event from your user control that contains the trackbar. I don't really know why you need the separate UserControl, since you could just place the trackbar on the form, but if you have to do that, you'll need to declare a public event on the UserControl, then create an event handler in your form. In the user control, you would handle the value changed event (whatever that is) from the track bar, and raise the event.
The .NET documentation indicates a pretty straightforward design pattern for this. Assuming your event is ValueChanged you typically declare a method:
private void OnValueChanged()
{
if( ValueChanged != null ) ValueChanged(this, EventArgs.Empty);
}
In the event handler for the trackbar event, call this method.
You'll also need to expose a public property that tells you where the progress bar is, so that in your form, when you respond to the event you can read the value and pass it to your SecBuff.
All that said, really, it would be much easier just to site the track bar on the form and respond to its value changed event by passing the current track bar position into the SecBuff.
Another approach you could take would be to pass the SecBuff object into your user control as a property, then respond to the value changed event on the track bar by setting the corresponding value on the SecBuff object.
Tom Clement
Apptero, Inc.
www.apptero.com
articles[^]
|
|
|
|
|
Tom, thanks for the advice.
The volume control is just an example. I actually need to perform some DSP functions on the audio data. I have five controls for five DSP functions.
I'm trying to first establish communication between these two classes.
I'll try what you suggested and see if I can get it to work.
Thanks!
|
|
|
|