|
i would like to know if its possible to open 2 or more similar form without changing the opened form parameter as example existing form opened int value is 123, after opening another similar form, int is set to 456 but i do not want it changed in the previos opened form. hope u get what i mean.
|
|
|
|
|
Hi,
this is quite simple. Normally if you open a second instance of the form, the content of the first form is not modified. If it is, you are accessing a static object or some other shared resource. Here is some code that opens two instances of the same form (Form2) when clicking a button.
private void button1_Click(object sender, EventArgs e)
{
Form2 frm2_1 = new Form2();
frm2_1.Show();
Form2 frm2_2 = new Form2();
frm2_2.Show();
}
|
|
|
|
|
Overload the form constructor to pass in the count value e.g.
public frm(int count)
{
InitializeComponent();
}
This way, every form instance will be responsible for handling the count value on its own.
|
|
|
|
|
Forms are just classes; you can instantiate them as often as you like; and no fields get shared between instances unless they are marked static.
|
|
|
|
|
I am currently writing code for a WINDOWS UTILITY program that enables users to priview, install and uninstall fonts. But am facing quite some problem displaying the file names only in the list box without having to display the font path.
And also I noticed I cannot access the default folder without adding code for the Access Control.
Please help!! The source code is available here https://sourceforge.net/projects/ezwinkedfb/[^]
|
|
|
|
|
|
I don't think anyone is likely to download your code in order to debug it for you. Please describe your problem clearly and show the portions of your code that do not work correctly; don't forget to enclose them within <pre> tags so they show up correctly, like this:
public class Application
{
static void Main(string[] args)
{
Console.WriteLine("Hello, world");
}
}
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
|
Hello,
I'm developing a VAD in C# and I'm using a sample program, it is called Ozeki VoIP SIP SDK. It's quite useful as it provides documentations and source code. But I'm not sure about its flexibilty. Do you know if it is compatible with other system or not?
You can find the sample program here: http://www.voip-sip-sdk.com/p_238-voice-activation-detection-voip.html[^]
Thanks,
Will
|
|
|
|
|
Wouldn't it be better to ask the people who publish this program?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
hi guys ..
i need ur help
my Graduation Project remote control pc via mobile
i can't write code in windows phone7 control mouse and
keyboard
begin i'm writing code in c# i have code (remote client and remote server ) but i can't convert it to windows phone7
help me plz
|
|
|
|
|
Try some of these articles[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
thnx so much
|
|
|
|
|
I am attempting to create a Windows Form application that will select a window based on it handle. No problem here doing that.
Afterwards, the I used Thread.Sleep() to buy some time, then use SendKeys.Send(). Of course, without doing the work here on another Thread, my UI will hang on my application while the Thread sleeps.
Therefore, I wanted to create another Thread, which I did, and encapsulate the above work (Thread.Sleep and SendKeys.Send) to a method and send it to the Thread. Unfortunately, the SendKeys doesn't end up sending any text as a result.
Am I missing something rather remedial here? Does the SendKeys() have to come from the primary thread? I am also selecting another window, not my application, for the SendKeys() to target.
Thread oThread = new Thread(new ThreadStart(sendTheKeys());
public static void sendTheKeys()
{
Thread.Sleep(5000);
SendKeys.Send("Simple Text Message here!");
}
|
|
|
|
|
Do you have any proof the thread got executed? I don't see any oThread.Start() ...
BTW1: if that is all you need, you could as well use a System.Windows.Forms.Timer, have it tick once (after 5 sec), and stop it inside its Tick handler (which runs on the main thread).
BTW2: if the process you want to send data to is one your app has launched, you might be better off using Process.WaitForInputIdle() rather than delaying for a fixed amount of time.
|
|
|
|
|
It did, I started the thread using the exact code immediately after.
For further thought, I also tried using Task.Factory.StartNew();
I inserted some test code and the thread seems to execute just no SendKeys output.
For simplicity I will probably just set a timer for my couple of tasks, however at this point I'm just wondering if I'm doing something wrong or if it must run on the primary thread.
|
|
|
|
|
I performed a little experiment and indeed SendKeys seems to fail when called by anything but the main thread; I don't recall having read about such requirement though.
|
|
|
|
|
Do you happen to know of a function / method I could use that will run off of a secondary thread?
Thank you for the help.
|
|
|
|
|
I have no idea what you mean here.
This was my test code:
public class CPTest_SendKeys : CPTest {
public override void Test(int arg) {
if (arg==1) {
runner();
} else {
BackgroundWorker bgw=new BackgroundWorker();
bgw.DoWork+=new DoWorkEventHandler(bgw_DoWork);
bgw.RunWorkerAsync();
}
}
void bgw_DoWork(object sender, DoWorkEventArgs e) {
runner();
}
private void runner() {
Process p=Process.Start("notepad.exe");
p.WaitForInputIdle();
SendKeys.Send("abcd");
log("sent");
}
}
|
|
|
|
|
Oh. All I'm asking is, absent of SendKeys, is there any other class or WinAPI that offers sending keystrokes to another application? Whether it be that the application has to be the foreground application or not?
|
|
|
|
|
I see.
I know of: SendKeys, SendInput (in user32.dll), and SendMessage (also in user32.dll).
The latter takes a hWnd (and needs a message such as WM_KEYDOWN), the other two implicitly address the active window. I tend to use SendKeys for simulated keyboard input, SendInput only for mouse operations.
|
|
|
|
|
class foo<T>{
T myT;
foo(T t){myT=new T(t);}
}
of course the above fails because i havn't restricted T to have new.
I don't want to copy by reference the T passed in.
Is it possible to have 1 class which constructs correctly where possible, but also accepts basic types, which don't contain a copy constructor?
class foo<T> where T:new(){
T myT;
foo(T t){myT=new T(t);}
}
class foo<T> where T: NOT new(){
T myT;
foo(T t){myT=t;}
}
so that foo<int>, foo<otherClass> both work.
|
|
|
|
|
Test to see if type isClass[^]
"You get that on the big jobs."
|
|
|
|
|
Hi
I'm working on new winform project using EF and i'm looking for best approach to pass an entity between forms as parameter.
In main form i have a grid populated with i.e. customers from dbcontext like:
var db = new context();
grid.datasource = db.Customers.toList();
db.dispose();
Then i want to edit grid selected row(presents a customer record) in a new form(Detail form).
I get selected customer by this:
Customer editCustomer = (Customer)grid.selectedRows[0].dataBoundItem;
and then pass the 'editCustomer' to a new instance of Detail form constructor.
Now my problem is how to save editCustomer changes made in Detail form? (with consideration of in Detail form the editCustomer have Detached state). this really confusing me
Please help me.
Thanks.
|
|
|
|
|
The easy way is to just pass the customer ID, create a new context and retrieve the customer record using the id and manage from there.
I nicer solution would be to implement MVVM and data binding. There'd be a learning curve if you're not already familiar with the concepts.
"You get that on the big jobs."
|
|
|
|