|
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
|
|
|
|
|
|
Hi,
I am a beginner level programmer and I would be happy
if somebody can clarify me this small doubt.
I want to know,if using 'this' to refer to the local variables inside a class is a good practice. using 'this' would be a bit costly or it would infact aid performance ?
Please clarify this , would be more thankful if you can give me some links for improving code performance.
Thanks a ton.
|
|
|
|
|
It doesn't make any difference. Whether you explicitly use "this" or not, the compiler generated code will have to use it to refer to member variables and methods.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
As far as I know, it doesn't hurt or boost the performance. It's rather a question of taste. Do you like the style of using 'this' for calling private variables ?
In my opinion it doesn't matter if you use 'this', but I prefer only using it when there's no other way. An example:
private int var;<br />
<br />
public SomeClass(int var) {<br />
this.var = var;<br />
}
WM.
What about weapons of mass-construction?
|
|
|
|
|
A local variable is one which is within the scope of the method or property, not the class. I think what you mean is member variable (aka field in .NET)
Using the this keyword is just making explicit what the compiler will do implicitly anyway. There is no perfomance advantage to using it or not as the resulting code will be compiled to be the same anyway.
The only time where it does make a difference is where you have a local variable and a member variable with the same name. You must use the this keyword to refer to the member variable in that instance otherwise the compiler will assume you are referring to the local variable.
Does this help?
My: Blog | Photos
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and More
|
|
|
|
|
There is no difference in the created IL code wether you use this or not.
(try Lutz Röders excelent Reflector tool to check this).
(field accesses will always resolve to a ldfld opcode and method calls to call or callvirt )
I personally changed my way of using the this keyword.
I started by not using it at all beeing happy not to have to use it as in the old c++ days...
Then i switched to use it on fields and properties. Simpy for readability.
Now i went as far as using it for method calls too.
Even though it seems a little overdone i think the code readability gains a lot.
Especially for everyone who has not written the code but is reading it.
By using the this keyword it is immediatly clear that you refere to a member of the current class.
Currrently i am not as far as using the base keyword for any derieved method.
As long as a method, field or property is not ambigious it is completely up to you and your personal style whether you use the this keyword or not.
/cadi
|
|
|
|
|
Also, using 'this' will give you intellisense to speed your typing, or just to let you browse for the item you are looking for.
|
|
|
|
|
I'm using a System.Timers.Timer to send some data to a serial port every so often. Problem is, if the main thread gets tied up, with internal processing, or hitting a breakpoint for example. A long queue of events gets queued up, then once the app is back in business, all of the messages get handled almost simultaniously. I've tried to come up with a work around, but I'm stumped, any suggestions.
Thanks,
sam
|
|
|
|