|
Sometime when I use left/right/up/down key in Data Grid, the left/right key will affect the ComboBox field, cause ComboBox value changed , how could I solve this , thanks in advance .
|
|
|
|
|
Override the combo box and write a class which ignores teh keypress.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I've got a easier way from my friend to do this ! And thanks for your kindness reply !
In dataGrid1_CurrentCellChanged() Event , add statement "ComboBox.Enable=false" in beginning to avoid the interaction , and add statement "ComboBox.Enable=true" in ending to restore its attribute.
|
|
|
|
|
I have several "evaluation" functions. I first created a delegate for each and put them in an ArrayList. I traversed the list, invoking each function and stopping when a positive result was returned. I then found the "multicast" feature of delegates and simply added each delegate via myfunc += nextfunc.
I'm frustrated with this features because it appears there's no way to stop midstream. I've seen lots of talk about enumerating the collection but why do that?
Does anyone know how to invoke a (multicasted) delegate and then, when in the midst of one of the functions, stop and return a result?
Thanks in advance
|
|
|
|
|
I understand the multicast feature as a way to get all "listeners" being called,
without guaranteeing a specific order, and without expecting a return value (how
could you return one value from multiple methods ?).
So if your evaluation functions need to be called in a specific order until some
condition is met, I dont expect multicast to be the answer. I suggest you stick to an
ArrayList.
Luc Pattyn
|
|
|
|
|
I'd like to do something like this:
delegate void Evaluator();
some_func()
{
Evaluator Evaluate = new Evaluator();
Evaluate = new Evaluator(eval_1);
Evaluate += new Evaluator(eval_2);
Evaluate();
}
Evaluator eval_1()
{
// found something
if ( found_something )
{
Evaluate.EndInvoke();
}
}
Evaluator eval_2()
{
}
|
|
|
|
|
I forgot to mention, I've got it all working... I just let all of the delegates run and each function only modifies a ref var if the evaluation is meaningful. It's just frustrating that there's no way to stop the firing of delegates when they're multicast. It would be nice if I could do:
Evaluate.BeginInvoke();
and then in each evaluator function when it's time to stop in any particular function simply call
Evaluate.EndInvoke();
I've ready elsewhere that this causes an exception. Perhaps the best way out of this is just to:
try
{
Evaluate();
}
catch()
{
}
and then simply throw an exception of my own in each evaluator function when it's time to stop.
lol
|
|
|
|
|
Yes I understood from the beginning that such was your intention, but you are
assuming that all delegates are executed in a specific order, and AFAIK there
is no documentation that promises that.
For me the observation that something works is not good enough, if it implicitly
relies on undocumented behavior.
Of course, EndInvoke is intended to be used by the caller to obtain asynchronous
results, rather than for the callee(s) to terminate the sequence of calls.
Luc Pattyn
|
|
|
|
|
I'm writing a process that splits a multi-page tiff image into a bunch of single page tiffs. I'm using the MODI framework for this. I can not figure out how to create a new tif image. the MODI.Document.Create requires a filename of a file that exists.
THANKS!!!!
|
|
|
|
|
I am not familiar with MODI.
From the MODI documentation on Document.Create[^]
I understand it intends to create a document (not a TIFF file) and
it reads an existing TIFF file to use it inside the new document.
I'm not sure I understand how that fits your plans...
Anyway, the following C# code snippet would create a TIFF file with a dummy image:
int width=1;
int height=1;
Bitmap bm=new Bitmap(width, height);
bm.Save(fileSpec, ImageFormat.Tiff);
Does this help ?
Luc Pattyn
|
|
|
|
|
Hello everyone,
i'm trying to develop application that detect the caller id using tapi 3.1
i found alot of samples on codeproject and so many differant sites but they are all didnot work
and i have a softwear called audio caller id and it made using tapi and it's working fine and detected the caller id so could anyone help me urgently please ?
|
|
|
|
|
Please look at the code:
I am using three such timer and callback functions,but it seems timers are always running when I close application also.
timer = new System.Threading.Timer(new TimerCallback(OnNextMinute), null,
Timeout.Infinite, Timeout.Infinite);
timer.Start()
public void onNextMinute()
{
}
~Class
{
timer.dispose();
}
How to make sure that it stops running when my app is closed.
appreciate immediate help as it is urgent.
Thanks in advance,
|
|
|
|
|
Use the windows timer instead of the threading one. Have your window closed event call Stop on the timers. Either of those things should work. If your timer is still going, then your app is still running.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
There is no guarantee that the finalizer (~) will be run when the application ends. The finalizer is called after that the garbage collector has recognised that the object isn't used any more. An object with a finalizer is placed in a queue where a background thread will be calling the finalizer, but as your object is still used when the application ends, it will never make the queue.
As you have a resource that needs to be freed, you should implement the IDisposable interface so that you can call the Dispose method on the object to free the resources. Just as you are calling the Dispose method of the Timer object to make it free it's resources.
---
single minded; short sighted; long gone;
|
|
|
|
|
Thanks a lot for prompt replies,I will try to dispose the timer first to stop app from running..
|
|
|
|
|
I implemented IDisposable interface , but still not able to release resources.
I am trying to dispose the timer in Dispose Method and calling the Dispose Method in the Main Class event where I want to end the application.
But my app is crashed at the Dispose Method with StackOverflowException at
timer.Dispose().
Please help me...
|
|
|
|
|
A stack overflow usually means that you have "accomplished" an infinite recursive call.
What does your code look like?
---
single minded; short sighted; long gone;
|
|
|
|
|
I am just giving part of code ,main function of this class is when the user request a file to download, file is broken into chunks,the chunks are added to PendingChunks,the PendingChunks are updated in timer ,the callBack function gets the ChunkAddress of the requested pendingchunks from the server .
public Class:IDisposable
{
Class{
ArrayList PendingChunks=new ArrayList();
timer2 = new System.Threading.Timer(new TimerCallback(getAddressfromServer), null, Timeout.Infinite, Timeout.Infinite);
StartTimer();
}
public void getAddressfromServer(object state)
{
getChunkAddress(PendingChunks)
}
const long TIMER_INTERVAL = 10000L;
private void StartTimer()
{
timer.Change(0, TIMER_INTERVAL);
}
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (!disposed)
{
if (disposing)
{
timer.dispose(); }
disposed = true;
}
}
public void getChunkAddress(ArrayList chnkList)
{
ArrayList chnkAddrList=null;
Chunk c=null;
ChunkAddress chnkAdd;
chnkAddrList = HTTPClass.httpGetChunks(chnkList);
if (chnkAddrList != null)
{
for (int j = 0; j < chnkList.Count; j++)
{
c = (Chunk)chnkList[j];
for (int i = 0; i < chnkAddrList.Count; i++)
{
c.chnkAddress = (ChunkAddress)chnkAddrList[i];
}
}
}
|
|
|
|
|
The code that you show looks basically correct. I can't say anything about the actual code that you use, as you won't show it.
Where do you dispose the object?
---
single minded; short sighted; long gone;
|
|
|
|
|
I am disposing the timer in public void virtual Dispose Method
|
|
|
|
|
Sorry I have no idea how to dispose the object, can u please tell me?
|
|
|
|
|
aruna_koride wrote: Sorry I have no idea how to dispose the object, can u please tell me?
You just call the Dispose method.
This should usually be done by the object that contains the reference to the object to dispose. If you for instance have put the object in a form, that form would call Dispose on the object when the form is closing.
---
single minded; short sighted; long gone;
|
|
|
|
|
As you said I have a recursive loop because I am not stopping to get Chunk Address untill I cleared the PendingChunks ArrayList,may be that is Cause?
Yes I have Called Dispose method in an another class ,triggered by Application Shutdown event of Form,
like this:
using(Class1 c=new Class1)
{
c.Dispose();
}
Is it correct?
Do I need to use using method?or just call Dispose Method?
|
|
|
|
|
aruna_koride wrote: Yes I have Called Dispose method in an another class ,triggered by Application Shutdown event of Form,
like this:
using(Class1 c=new Class1)
{
c.Dispose();
}
Then you are creating a new object and dispose that, that doesn't dispose the object that you use in the rest of the code.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hello everyone,
Why on earth I am getting this message? Everything was working just fine till yesterday and all of the sudden nothing works and I get this Warning and nothing works!
Warning 1 'System.Runtime.InteropServices.UCOMIMoniker' is obsolete: 'Use System.Runtime.InteropServices.ComTypes.IMoniker instead. http://go.microsoft.com/fwlink/?linkid=14202' C:\Documents and Settings\miyaoo\Desktop\directshownet\DirectShow\DShowNET\DsDevice.cs
I have looked at the suggested web address and I get this regarding this error.
System.Runtime.InteropServices.UCOMITypeInfo (Type Obsoleted)
Message: Use System.Runtime.InteropServices.ComTypes.ITypeInfo instead.
I checked the line suggested in the warning and this is what I have.
private static string GetFriendlyName( UCOMIMoniker mon )
what am I suppose to change it to?!!!
Thanx in advance for your help or suggestion.
Khoramdin
|
|
|
|