|
Hi, I have a user thread and I need to tell it to run some code in the GUI thread. I was thinking that maybe I would use SendMessage and create a message handler for this but it sounds like more of a C/C++ way of doing it. Is there something in C# line this? Kind of like java has SwingUtilities.invokeLater()
-- Rocky Dean Pulley
|
|
|
|
|
Actually SendMessage is not directly implemented in the CLR.
You should use the BeginInvoke to call code in the UI thread from another thread.
Google for BeginInvoke and UI or read this article: http://www.codeproject.com/csharp/winformthreading.asp[^]
/cadi
24 hours is not enough
|
|
|
|
|
You can use BeginInvoke and Invoke on the System.Windows.Forms.Control class.
This[^] article explains the gory details.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hello,
I encountered a strange problem and I do not know what is causing it.
I created an empty form, added a tabs control to it and set the tab control
dock style to fill. Then I added three tabpages to it. To the first tab page
I added three buttons. The first button's click handler would set the tab
control's tab alignment to TabAlignment.Left and the second buttons click
handler would set it to Bottom.
I added mouse enter and mouse leave handlers to the third button. Whenever
the mouse would enter the button, I would change its background color to
yellow. When the mouse leaves the button, I would set the color back to its
original state.
Now, when I start the form, the mouse enter/leave events work great and
everything is fine. However, once I change the tabs alignment by hitting one
of the first two buttons, the third button no longer fires it's mouse leave
event and only fires the mouse enter event once. The mouse enters and mouse
enter fires correctly, but it seems that the mouse leave event has been
unregistered when the tab control's tab alignment changed.
Does anyone know what can be causing this behavior and how to fix/avoid it?
Thanks,
-Flack
|
|
|
|
|
I'm attempting to connect to a MySQL database from my ASP.NET application (c#). Here's my code:
string connString = "Database=games;Data Source=http://[my server's IP]/mysql;User ID=group; Password=" + strSystemPasswords[3];
conn = new MySqlConnection(connString);
conn.Open();
The database is contained in the mysql directory under the web server's root. (I added a space between group; and Password to prevent a smiley.)
When I run the code, I get the following error for conn.Open():
"The requested name is valid and was found in the database, but it does not have the correct associated data being resolved for "
I've researched the problem and have found the standard answer is that the address can't be resolved. However, I am assuming that this is not the problem in my case, as I can navigate to that exact address with my web browser. But I haven't found any alternate causes for this error.
Any suggestions?
Thanks for your help!
|
|
|
|
|
Your datasource is local to the server. ASP.NET is a server-side only technology that generates HTML for a client. Change your "Data Source" so your code is looking for it local to the server filesystem, not over an http connection.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Ok, I'm trying to capture text from a texbox inside of another program. In other words, I have a window handle of an exterior program. This program contains a textbox. I would like to capture that text. Is there a set of API commands that would enable me to do this? I've been looking on MSDN for a while and haven't found anything. Any help would be greatly appreciated. Until then, the searhc continues...
|
|
|
|
|
Try : <a href="http://www.pinvoke.net" rel="nofollow">http://www.pinvoke.net</a>[<a target=_blank title='New Window' rel='nofollow' href="http://www.pinvoke.net">^</a>]
|
|
|
|
|
Use the win api SendMessage twice first with WM_GETTEXTLENGTH then again with WM_GETTEXT. GO ahead and try it yourself with the example at pinvoke.net. If you still can't get it to work just let me know.
/\ |_ E X E GG
|
|
|
|
|
Hello,
It's easy to get a pointer to the window of all running applications. But i need to find out the position and the size of the minimize button outgoing from the pointer to this application window.
Anybody know if this is possible or knows how to do this?
Thanks for help.
FreeClimber
|
|
|
|
|
I have a class "Person"
Person has 2 propertys:
Name
Adress
Person p = new Person();
p.Name = "Mike";
p.Adress = "Anywhere";
Now I have a problem with adding it to the Combobox.
In the Combobox list, I only see [namespace].Person all the time, not "Mike".
There are possibilities through indexes, Hastables ... and so on..., but are these the only possibilities ?
Is there a way to add the object to combobox directly ?
|
|
|
|
|
You could override the ToString() method of you Person class.
public override string ToString()
{
return this.Name;
}
/cadi
|
|
|
|
|
The problem is still the same. with ToString, I only put the string in the combobox, not the object itself.
So the object should be added into the combobox and the Combobox Item description shouldn't be the objects name.
|
|
|
|
|
No, you do not!
You add the object and the Combobox uses the to String method of the items to display a text.
Try this:
<code>
private void Form1_Load(object sender, System.EventArgs e)
{
this.comboBox1.Items.Add(new Person());
foreach(object o in this.comboBox1.Items)
MessageBox.Show(String.Format("Item is of type {0} and is the persons name is {1}",o.GetType().FullName, (o is Person) ? ((Person)o).Name : "not a person") );
}
it works fine in my test.
/cadi
24 hours is not enough
|
|
|
|
|
cadi said it right. ComboBox actually calls ToString() method of it's Items . For your class default ToString() returns string representation of type. When you override ToString() , combobox will display Person.Name field, but e.g combobox.SelectedItem can still be instance of Person .
David
|
|
|
|
|
Thx, this works.
I added .ToString directly before.
|
|
|
|
|
I have a problem with UnitofWork.I have many objects in my UnitofWork but the problem is I dont have an update order in my hand.in an article it said....."the key to the puzzle is table-level topological sort".
What does this mean? thanks
|
|
|
|
|
Hi
{
I have to Generate an XML file from an existing XML.
The existing File is on HDD and and the Elements of the file are shown in a Tree view.
Now when the tree node is selected the child nodes are displayed in the checked List Box.
}Done
Now the selected chiled nodes along with its coressponging Paret node in tree view will be writen to another XML file.
Does any one have SAMPAL code for this task or can any one giude me.
Thanks.
Best Regards.
|
|
|
|
|
Is it possible to write code for selecting a folder and a file together from OpenFileDialog? The default operation appears only selection of a file.
|
|
|
|
|
Is it possible to change the name of the "Open" button in the OpenFileDialog class instance in C# application?
|
|
|
|
|
no because it is declared 'sealed' so you cannot inherit from it or modify it.
in the msdn library you can see this:
public sealed class OpenFileDialog : FileDialog
|
|
|
|
|
I did it once,:->
But that was because i created my own open file and open forlder dialog from the scratch.
|
|
|
|
|
It is possible but you have to use P/Invoke to create this dialog from scratch using the GetOpenFileName() call and the OPENFILENAME structure from the Win32 platform SDK on MSDN. In the OPENFILENAME structure specify a hook procedure for the lpfnHookProc data item. In this hook procedure capture the WM_INITDIALOG message, get the handle to the OK button, and call SetWindowText to change the name from "Open" to something else.
I hope this helps.
Human beings were not meant to sit in little cubicles staring at computer screens all day, filling out useless forms and listening to eight different bosses drone on about about mission statements. -- Peter Gibbons
|
|
|
|
|
Hi,
I want to update the value for a particular key in Hashtable.
How to update.
Usually in VB 6, i have used item property. But here i unable to use it
Thanks in Advance
Balamurugan
|
|
|
|
|