|
You have to click the Button on the same thread as it was created, otherwise you'll get this exception.
For normal applications that means that all UI components are created on the main (UI) thread and all calls to the UI coming from background threads have to be marshaled back to the UI thread, either by using Control.Invoke or a SynchronizationContext.
In your szenario, either run the 3rd party software on the UI thread and your tasks on a background thread, then you can use Invoke or a SynchronizationContext, or really be sure that everything you call to the 3rd party app is on the same worker thread.
Regards
Urs
-^-^-^-^-^-^-^-
no risk no funk
|
|
|
|
|
chieldHwnd= FindWindowEx(parentHwnd, chieldHwnd, "obj_EDIT", null);
int length = SendMessage(chieldHwnd, WM_GETTEXTLENGTH, (IntPtr)0, (IntPtr)0);
if (length > 0)
{
StringBuilder sb = new StringBuilder(length);
int numChars = SendMessage(chieldHwnd, WM_GETTEXT, (IntPtr)(length + 1), sb);
listBox1.Items.Add("in Textbox : " + sb);
}
this code takes a text in textbox but form has 2 textboxes and it takes last textbox's text how can i get the specified text.
username -------------
password -------------
both of them empty
and it takes allways password's text of textbox
thanks for everything i have...
|
|
|
|
|
You need to call FindWindowEx in a loop passing previous values as hwndChildAfter. The loop should end when FindWindowEx returns NULL.
By the way, winapi questions should be asked here: Visual C++ / MFC[^]
|
|
|
|
|
thx and i am sorry that i send wrong place (
thanks for everything i have...
|
|
|
|
|
private int GetChildHandle(int parent, string className)
{
int child = FindWindowEx(parent, IntPtr.Zero, className, null);
return child;
}
public void DoExternalWrite(string text)
{
int parent = FindWindow("obj_Form", "Adobe Creative Suite 2 by cvs/SSG");
int child = GetChildHandle(parent, "obj_BUTTON");// is a group box
//in this groupbox there are two text box
int child2 = GetChildHandle(child, "obj_EDIT");
SendMessage(child, WM_SETTEXT, IntPtr.Zero, text);
}
1 ---------
2 --------- it types mytext to this textbox why ??
thanks for everything i have...
|
|
|
|
|
|
private int GetChildHandle(int parent, string className)
{
int childafter=0;
while (childafter != null )
{
childafter = FindWindowEx(parent, childafter, className, null);
}
return childafter;
}
????????????
thanks for everything i have...
|
|
|
|
|
|
private int GetChildHandle(int parent, string className)
{
int childafter = FindWindowEx(parent, 0, className, null);
while (childafter != 0 )
{
childafter = FindWindowEx(parent, childafter, className, null);
listBox1.Items.Add(childafter);
}
return childafter;
}
parent takes the hwnd with findwindow()
classname i gave
when i use that functions, it gives the same . It add to listbox only second textbox hwnd, i am going to crayz ???
thanks for everything i have...
|
|
|
|
|
Why are you adding hwnds to the listbox? I thought you wanted to get text from them.
|
|
|
|
|
yes you are right just i wanna see which hwnd i can take just because of this. and always it takes last one hwnd so always takes last one's text
thanks for everything i have...
|
|
|
|
|
You are returning only the last one. Find text for all the hwnds you get by the loop.
|
|
|
|
|
could you help on this? how can i do that?
thanks for everything i have...
|
|
|
|
|
Well, you get text by sending messages to the control identified by the hwnd, don't you? So send those messages to all the childhwnds you get.
|
|
|
|
|
Just throwing my 2 cents in... There is one little problem with using WM_GETTEXT to get the string out of textboxes - reliability.
There is nothing that says that the control has to respond to that message. There are subclassed textbox classes being used that ignore the WM_GETTEXT message, and hence, return nothing. A password textbox sounds like a good candidate for a customized version of a textbox control that ignores the message, doesn't it?
|
|
|
|
|
Hi folks,
Is there any way to display an owned without graying out the title bar of the owner?
|
|
|
|
|
You would have to manipulate aspects of the window with Windows API commands. I do not believe their is an easy way to accomplish this in .NET alone.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
Thnx 4 da rply. But do u hav any idea of which APIs to call?
modified on Wednesday, October 8, 2008 4:28 AM
|
|
|
|
|
Google[^]
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
Hi!
I'm looking for a free Html Editor control to use in a WinForm application. Anybody can suggest me one?
Therefore, I'm unable to find a free good Grid Control with the same features like Excel.
Thanks in advance for your information.
Mathieu.
|
|
|
|
|
|
Hi there!
I have a rich text box and in the formatting toolbar (that sticks to its upper border) I have a ComboBox that displays the standard Font sizes. Just like it is in MS Word or Excel.
The user after selecting text will click a size. How do I achieve this?
I know how to handle this when the selected text is written in a single font. I put the following code in the SelectedIndexChanged event of the combobox.
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
Font font=new Font(richTextBox1.SelectionFont.FontFamily.ToString(),Convert.ToInt16 (comboBox1.Text),richTextBox1.SelectionFont.Style);
richTextBox1.SelectionFont = font;
}
This works fine when the Selected text consists of only one "rtb.SelectionFont.FontFamily". However, when the user selects a piece of text that consists of more than two font types the rtb.SelectionFont is returning null. And the catch block is catching an ugly NullReferenceException everytime.
I cannot use a font dialogue box or anything that would force me change the UI.
Any suggestion would help.
Best Regards,
Sid
|
|
|
|
|
babai28 wrote: Any suggestion would help.
Suggestions about what? You already seem to know everything there is to know about your situation. Very good job of describing it by the way.
led mike
|
|
|
|
|
"This works fine when the Selected text consists of only one "rtb.SelectionFont.FontFamily". However, when the user selects a piece of text that consists of more than two font types the rtb.SelectionFont is returning null. And the catch block is catching an ugly NullReferenceException everytime.
I cannot use a font dialogue box or anything that would force me change the UI.
Any suggestion would help. "
Hey, I wrote it..Come on Led!!
Best Regards,
Sid
|
|
|
|
|
Hi all,
i found some code retrieve form's caption but i need to get text from a textbox or label on a windows form which i want. how can i do this ? i am really new on api.
thanks...
thanks for everything i have...
|
|
|
|