|
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!
|
|
|
|
|
Tom, could you please clarify which method goes on the main form and which goes in the Control?
Thanks!
|
|
|
|
|
Hmmmm.... first, you need a plan. Here's the situation as I see it:
--- OPTION 1 ---
1. You have a UserControl that sits on your form.
2. You want to be notified when something changes on your UserControl.
3. You want to be able to read a property on the user control that tells you the slider bar position.
So, first you declare the event on the UserControl, like this:
public event EventHandler SomethingChanged;
Then you write the standard private method for raising the event like this:
private void OnSomethingChanged()
{
if( SomethingChanged != null ) SomethingChanged(this, EventArgs.Empty);
}
Then you call OnSomethingChanged() when something changes, like this:
private void tbVol_Changed(object sender, System.EventArgs e)
{
OnSomethingChanged();
}
You also want to expose the current value of the tbVol control as a property, so you probably do something like this:
public int TrackValue { get { return tbVol.Value; } }
---------
Now, in your form, you want to respond to this event on your user control. So you want to create an event handler for the SomethingChangedEvent. If you're using the IDE, you can go the the properties window, events tab, and double click in the value area for SomethingChanged. That will generate the event handler which you can use to set the value of your SecBuff object.
private void ctlVolume_SomethingChanged(object sender, System.EventArgs e)
{
SecBuff.Volume = ctlVolume.TrackValue;
}
----------------------------------------------------
---- OPTION 2 -----
If that doesn't work for you, you could add the following code to your ctlVolume control:
private SecondaryBuffer m_buff = null;
public void SetSecondaryBuffer(SecondaryBuffer buff)
{
m_buff = buff;
}
You could call this right after:
SecBuff = new SecondaryBuffer(FileName, ApplicationDevice);
like this:
ctlVolumme.SetSecondaryBuffer(SecBuff);
Then you could write the event handler for tbVol Changed event like this:
private void tbVol_Changed(object sender, System.EventArgs e)
{
if( m_buff != null )
m_buff.Volume = tbVol.Value;
}
I hope this gets you started. Truthfully, it's pretty much beginner stuff.
Tom Clement
Apptero, Inc.
www.apptero.com
articles[^]
|
|
|
|
|
This is a newbie question, but I would be grateful if someone could clear this concept for me.
Suppose I have:
1. A class cMainForm that has a DirectSound object, SecBuffer
2. A control for this class, cControl , that has a trackbar which controls the volume of the DirectSound buffer.
How do I get the code in the cControl class to verify and recognize that the object <secbuffer> has been created, and how do I use it?
My app requires that the code be written in separate classes, because different controls will all access the same SecBuffer object.
Thanks for your help.
|
|
|
|
|
Are cControl also on cMainForm. If so you only have to write the code to bind them together. If not, you will have to make public properties, methods and events on cMainForm that expose the features that you would like. If the cControl class only wants to detect if the object SecBuffer is created you can use a read-only property.
|
|
|
|
|
I am trying to retrieve the password age from Active Directory using the classes in System.DirectoryServices. how ever when I get that property it is returning a COM object. What do I need to do with that to get the password age out?
Cheers,
Andy.
|
|
|
|
|
"COM object" is not specific. Please tell us what type the debugger reports. You should also set a breakpoint after getting the property and examine the data in the object to determine what is exposed. You may have to declare COM interfaces to extract the data, but without knowing more it's difficult to help you.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|