|
|
Thanks Alomgir
I don't want add usercontrol in a windows form , i want add usercontrol in a class library
|
|
|
|
|
This applies to classs library as well.
|
|
|
|
|
I have a Windows Form that creates an instance of a class of my own, and within that object I need to call a function that is part of the Windows Form. The problem is I don't know how to give my class a reference to my Windows Form. If this was C++ I'd just pass a pointer through the constructor... but this isn't C++... Anyone know the proper way to get a reference to a parent object so its methods can be called?
Bungo!
|
|
|
|
|
You can always pass the reference to the parent object and call methods of it. The reference is just like pointers in c++.
Live Life King Size
Alomgir Miah
|
|
|
|
|
You could just pass the form to the class during instantiation using 'this' keyword. For example, assume your form is called MyForm and has a function called MyFormFunction that you want to call from MyClass:
during instantiation in MyForm:
MyClass newClass = new MyClass(this);
in MyClass:
private MyForm _externalForm; //declare as class level private variable
//ctor
public MyClass(MyForm passedFormReference)
{
_externalForm = passedFormReference;
}
public MyFormFunction()
{
_externalForm.MyFormFunction();
}
Hope this helps,
Regards,
-----
Josh Lindenmuth
jlindenmuth at paycepayroll dot com
Payce Payroll - Smart for Business
|
|
|
|
|
I am designing a function that requires an asynchronous call to be made to a remote device and the reception of some data from that device. Once the data is acquired the function can return its result.
Currently the function initiates the call and terminates, waiting for a communications event to signal that the data has been received.
How do I make the function wait until the event returns the value (or times out at which time I return an error) before it terminates and returns its value?
Thanks
Chris
|
|
|
|
|
if i understood you correctly you want the caller of the function wait untile its recive the signal or timeout
if this is correct So
The IAsyncResult interface returned from BeginInvoke ( ) has the AsyncWaitHandle property which have some overloaded WaitOne method
One of the take Timespan parameter you can use it to pass
Timeout value
IAsyncResult asyncResult = yourDelegate.BeginInvoke(param1,param2,null,null);
asyncResult.AsyncWaitHandle.WaitOne(timeoutValue,false);
int result;
result = yourDelegate.EndInvoke(asyncResult);
WaitHandle.WaitOne Method[^]
MCAD
-- modified at 19:36 Monday 29th August, 2005
|
|
|
|
|
Thanks for your response....Just so that you understand this fully:
My function has a method that just opens the comms port and dials out the number of the remote device. At that point exeution of the method terminates. At the same time in the function's class constructor I subscribe to the OnComm event (which fires whenever communications events happen, such as when receiving data). When I receive data, I parse it in the event handler of the OnComm event and if valid I fire an event with the data as its argument.
What I am looking to do is have the original method initiating the call wait until this valid data event is fired, or a timeout occurs. Once either of these happens I would like the function to return the data or an error code accordingly.
Thanks
Chris
|
|
|
|
|
Just adding to the previous response
//Client Code
AsyncCallback callback = new AsyncCallback(MyCallback);
MyBeginMethod(param1, param2,..., callback, null);
private void MyCallback(IAsyncResult result)
{
MyRetType obj = EndMyMethod(result);
//Some stuff
}
//Server Code
public MyRetType MyMethod(string param1, string param2, ... )
{
//your logic
}
public IAsyncResult BeginMyMethod(string param1, string param2, ..., AsyncCallback ac, Object state)
{
MyDelegate d = new MyDelegateMyMethod);
IAsyncResult result = d.BeginInvoke(string param1, string param2, ..., ac, null);
return result;
}
public static MyRetType EndMyMethod(IAsyncResult result)
{
MyDelegate d = (MyDelegate)((AsyncResult)result).AsyncDelegate;
return d.EndInvoke(result);
}
Live Life King Size
Alomgir Miah
|
|
|
|
|
I am working on the extraction of the frames from the AVI Movie.As i want to grab each and every frame from the AVI movie and perform some processing on them.I have done it in Visual C++ using AVI Library there.But i can't find the same library there.So i want to know how it can be done.Moreover the library(if any) in C# which will be used to handle AVI can be used to handle MP3 format.
|
|
|
|
|
|
Hello
You can try to interop Video for Windows for this task. Look at my "Motion detection algorithms" for sample. Or you can try to work with DirectShow (which is able to play MP3s too). A small sample for the second approach you can find in that article too or other article here on CP.
With best regards,
Andrew
|
|
|
|
|
I am currently working on a number plate recognition project.My sotware is finding the plates from the images.Now in next task i want to grab the number plate and increase its size if its width and height is less then the certain threshold for better pixel information.In Visual C++ there is a function StretchBlt which serves the purpose but in CSharp i cannot find the way to Stretch(Increase Size)image.I have resized the image and displayed it on the screen.But i want to save to resize it and store it into Bitmap object at the backend.
|
|
|
|
|
<br />
using System.Drawing;<br />
using System.Drawing.Imaging;<br />
using System.Drawing.Drawing2D;<br />
<br />
<br />
void ResizeBitmap(Bitmap org, string filename, int width, int height)<br />
{<br />
Bitmap newBmp = new Bitmap(width, height);<br />
using (Graphics g = Graphics.FromImage(newBmp))<br />
{<br />
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.DrawImage(org, 0, 0, width, height);<br />
}<br />
<br />
newBmp.Save(filename, ImageFormat.Bmp);<br />
newBmp.Dispose();<br />
<br />
}<br />
|
|
|
|
|
Hello,
I have a situation that I have not been able to solve, maybe one of you can point me in a direction to pursue.
I have a Windows Form application that utilizies a RichTextBox to view the contents of a file. Some of the file have very lnog lines in them that initially need to be displayed for various reasons. For example, the first line may be 9,000 characters before its crlf is encountered.
The behavoir I'm getting in the RichTextBox is that it chops this line up on the display, so maybe at character 3,00o it wraps the line, then again at 2,800, then finally displays the remaining chunck of characters. So, I get the line displayed on 3 lines, although the line count is 1. If I open the file up in say Visual Studio or TextPad, it displays the contents all in 1 line, like I need it to.
I have set WordWrap to false.
Any ideas would be appreciated.
Thanks in advance.
|
|
|
|
|
Using the code from the DirectX.Capture project, I would like to read the mouse clicks and movements in the video preview panel. However, since the panel in the main form is overlayed with a new panel whenever Preview is active, the mouse movements on the original panel are unavailable. Is there a way to fetch the mouse movements in the "new" panel?
Thanks.
|
|
|
|
|
I would like to know how
to creat CDX index file for DBF Table.
thx
|
|
|
|
|
I have two forms (login and main). And as suggested on this forum, I load the login from my main form. So I have a modal login form infront of my main form. That is the way I want it but another problem emerged with the use of loginForm.ShowDialog(). If user clicks 'ok' and something is not right, I call a messageBox with an appropriate messsage; however, when I click 'ok' (on the message box) instead of bringing me back to the login form so I can retry loging in, application exits. It dosn't occure when I call loginForm.Show(), but this is not what I need. Please let me know where I'm going wrong.
Thank you
-- modified at 13:02 Monday 29th August, 2005
|
|
|
|
|
Build a loop (e.g. do-while-loop) that calls loginForm.ShowDialog and evaluates the DialogResult. If user clicks 'ok' and something is not right, show the message box and ensure that the loop is executed one more time (e.g. with a bool variable).
www.troschuetz.de
|
|
|
|
|
I was wondering why does the closing of the message box trigger the closing of the actual login form?
Thanx
|
|
|
|
|
Hmm, I guess I misunderstood your first posting a bit. Thought you check whether something is not right and call a messageBox after the ShowDialog method returned. Am I right that you do this inside of an event handler of the OK button?
Anyway, I think your login form automatically closes cause you set the DialogResult property of your OK button. If the value of this property is set to anything other than DialogResult.None , and if the form was displayed through the ShowDialog method, clicking the button closes the form without your having to hook up any events.
www.troschuetz.de
|
|
|
|
|
The code I'm working with was initially witten by someone else that is why I wasn't aware that DialogResult of the OK button was set to something. Your suggestion hit the spot. Thanks a lot.
|
|
|
|
|
|
hi all,
I have developed a application using C# and generate exe.(test.exe).But the problem is when I used a decompiller ,I can easily obtain the code again.Even though I convert this exe to class Library, It is also can decompile to get source code.
So How am I avoid this situation.How can I stop decompilling the .NET Application exe?
any answers greatly appreciated.
thanks in advance.
|
|
|
|