|
Hi,
How can I determin If I run on a 9x or a NT-based box?
I need to query some ugly registry keys that differe between the two...
Italian is a beautiful language. amare means to love, and amara bitter.
sighist | Agile Programming | doxygen
|
|
|
|
|
System.Environment.OSVersion.PlatformID != System.PlatformID.Win32NT
(use .NET SDK WinCV.exe to browse the CLR features by keyword (the resultset is often better and richer than the MSDN7's index)).
|
|
|
|
|
Thanks! Someday I'll find my own way around the CLR...
(winCV seems a cute tool, but wouldn't have helped me here...)
Italian is a beautiful language. amare means to love, and amara bitter.
sighist | Agile Programming | doxygen
|
|
|
|
|
I have treeview in my application.How can I delete a node when I have its FullPath ?
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
Given the actual implementation of the FullPath property :
private void GetFullPath(StringBuilder path, string pathSeparator) {
if (this.parent != null) {
this.parent.GetFullPath(path, pathSeparator);
if (this.parent.parent != null)
path.Append(pathSeparator);
path.Append(this.text);
}
}
the only way to Remove a TreeNode based on its FullPath is to parse it and browse the parent/children hierarchy with a recursive routine, seeking the actual TreeNode.
|
|
|
|
|
I got the point.Thank you very much.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
Does anyone know how to send keystrokes/mouse clicks remotely? (aka pcAnywhere)? For example, i have a client connecting to the remote host, can view the remote desktop and run a program (let's say defrag) and want to send a mouse click / keystroke across (using co-ordinates i suppose) to allow the end user to "control" the remote pc. Is there a sample code for this or is it even possible in C#?
|
|
|
|
|
you would need to have some service executing on the remote pc to proxy the commands for you.
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Hey folks - hope you can help me!
OK - in VB I can do this:
Dim x as Object = CreateObject("Word.Application") Is there a similar thing in C#? (without creating version dependencies - I want to link to either Word 2000 or XP?
Thanks!
--
Andrew.
|
|
|
|
|
At least two ways :
1- integrate interoped assemblies by just right-clicking on the References item, then add a reference to the Word type-library. (msoxxx.dll). MS distributes reference Office assemblies known as PIAs.
2- explicitely ask the CLR to create wrappers for the COM type-library :
- Type t = Type.GetTypeFromProgID("Word.Application");
- WordObject obj = Activator.CreateInstance(t);
Unfortunately, with the obj running, you have no object model to play with. You need to create a wrapper : look Marshal.CreateWrapperOfType(...).
|
|
|
|
|
Thanks - the second method was just what I was looking for! I've not done much C# yet (only just got hold of the final release of VS.NET) but have got a small project that I thought would benefit nicely from .NET.
--
Andrew.
|
|
|
|
|
is this correct regarding delegates (?) :
if you have a usercontrol , and make it listen to the parent containers mousemove events (say it hooks itself to the parent in the "parentchanged" event)
will the mouse event handlers create a strong ref from the parent to the usercontrol?
(i beleve it does)
the problem if so , is if you remove the usercontrol from its parent , and loose all references to it. (the only valid ref still alive is the delegate target in the parents mouse event)
now , will this usercontrol be garbage collected?
(i beleve it doesnt , since ive profiled this with a mem profiler)
is all the above correct?? , and if not , how come are the usercontrol still alive and kicking when profiling ,even if i have called gc.collect() after loosing all refs.
do i really HAVE TO call .Dispose() on my usercontrol before dropping all refs to it?
and if so , is that really good/standard windows forms coding practice?
according to msdn you should NEVER call .dispose() unless the target holds valuable resources such as gdi objects , file pointers etc , and never ever do it if you are simply dealing with managed code..
//Roger
ps.
if you add a Console.Writeline("blah") to the destructor and dispose you can clearly see that they does NOT fire when the usercontrol have attached itself to some parent container events ,
while if you remove the eventhandlers , finalize and dispose fire just fine...
|
|
|
|
|
I think the solution is that if your usercontrol hooks itself to the parent's events it should also unhook itself. If you remove the control from its parent the control will get a ParentChanged event and the Parent will now be null. For example, the following code within the user control seems to work:
private Control parent = null;
private MouseEventHandler meh = null;
private void UserControl1_ParentChanged(object sender, System.EventArgs e) {
// Unhook from previous parent (if any)
if (parent != null) {
parent.MouseMove -= meh;
}
// Remember new parent
parent = Parent;
// Hook new parent (if any)
if (parent != null) {
if (meh == null) meh = new MouseEventHandler(parent_MouseMove);
parent.MouseMove += meh;
}
}
Chris Jobson
|
|
|
|
|
Hi.
I have an app that populates a ListView when files are selected via a file dialog. Selecting one or more items in the ListView and 'editing' them activates another Form that then (should) populate its ListView from the selected items in the main form that called this form. I run into an error when doing so (at run time) because the Collection of ListViewItems can't be added into a second ListView. I would like to avoid removing the items from the first listview, adding them to the second listview (which I tried and it works), and then run into the hassle of adding the 'edited' items back to first listview when the second form is no longer needed, and therefore closed.
I tried reading through many posts to find a solution to this little problem I am having, and have inferred that binding a data source to 2 ListBoxes also presents this problem, however I didn't attempt implementing any solution with listboxes.
Any direction would be appreciated. Thanks for reading this.
|
|
|
|
|
hi!
I try to create an new anchor Element with this line...
> mshtml.HTMLAnchorElement YYY = new mshtml.HTMLAnchorElementClass();
(I added mshtml,...)
and the following error occurs...
"An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in xcwrapper.dll
Additional information: COM object with CLSID {3050F248-98B5-11CF-BB82-00AA00BDCE0B} is either not valid or not registered."
what is wrong here?
anyone any idea? (I stuck here since a week
|
|
|
|
|
HTMLAnchorElement is a read-only class, ie it's used to reflect the properties of an EXISTING anchor in the current document.
To add a new anchor, the easiest way is to use either document.write() (which means you don't necessarily control where the anchor is inserted), or better, use the children/parent element hierarchy and then, use HTMLElement.insertAdjacentHTML("<a ....").
|
|
|
|
|
Hi, I finished my project and want to make a setup project for this. I made my configurations and want to build and i come across an error which is "dotNETFXRedist_x86_enu.msm must not be used to redistribute the .NET Framework. Please exclude this merge module." When i exclude this module everything is ok but on the client machine the setup project asks for a NET Framework download. How can i make this setup project in a way that don't want the framework download on a client machine???
Thanx for reading...
|
|
|
|
|
Hi All,
I am a student new to C# and was hoping someone can help please...
I am trying to create a program where the users can dynamically add controls like, textboxes, comboboxes, labels, buttons etc. to a tabcontrol.
The number of tabpages created is also controlled by the user.
The problem that I am having is trying to control all these controls etc. I was thinking that I would have a Collection (control array) for the tabpages and then another Collection for every tab page for all the controls on that tabpage. Is this the best way to do it?? or is there a better way to do it...
Any help will be seriously welcome this is more than stressing
Thank You.
|
|
|
|
|
Since you asked nicely, and admitted that you are a student, I will help you. Pay no attention to anybody who flames you because you asked about a homework question. They're losers.
For the tab pages, you are obviously going to have to have a tab control to hold them. Well, what you need to do to add a tabpage to a tab control is:
myTabControl.TabPages.Add(new TabPage("Title goes here"));
The TabControl already has a built in collection for you to use, you can iterate over it or get one particular index to a tab page, etc.
As for the second part, the controls within a tabpage, that gets a little more complicated. The TabPage does have a Controls property which is it's own ControlCollection. So you could actually do:
TabPage myTabPage = myTabControl.TabPages[0];
Control myControl = new Control();
myControl.Width = 200;
myControl.Height = 500;
myControl.Top = 30;
myControl.Left = 30;
myTabPage.Controls.Add(myControl);
Now, what you are going to have to do to get that to work is to change the type of myControl to an actual control like TextBox, DropDownList, etc. and set any properties that are specific to that type of control.
Hope that helps.
any idiot
can write haiku you just stop
at seventeenth syl
-ThinkGeek Fortunes
|
|
|
|
|
David Stone wrote:
Pay no attention to anybody who flames you because you asked about a homework question. They're losers.
Hey David, I don't get the point here. There's nothing wrong about homework posts, as long as the original poster really shows attempt to solve the problem. The fact is, statistically, most homework posters are just posting in Cp as well as a few other devsites, and return the next day to pick the answers. As long as someone doesn't show a real attempt to understand and solve a problem - which is what programming is all about - it's not useful to answer.
That said, anyone is free to post. And anyone is free to waste time offering comprehensive answers - read: backed by a will to show how things work - to ducks that are only expecting a copy/paste code answer and don't give a sh*t about anything else, actually.
|
|
|
|
|
.S.Rod. wrote:
Hey David, I don't get the point here. There's nothing wrong about homework posts, as long as the original poster really shows attempt to solve the problem. The fact is, statistically, most homework posters are just posting in Cp as well as a few other devsites, and return the next day to pick the answers. As long as someone doesn't show a real attempt to understand and solve a problem - which is what programming is all about - it's not useful to answer.
True, that is how it usually goes. However, even when someone does show initiative, like this guy did, and admits that he's stumped on his homework, they usually wind up getting flamed to death anyway.
.S.Rod. wrote:
And anyone is free to waste time offering comprehensive answers
Like yours? Actually, what do you think about my answer? Was I too explanative, or not enough? I didn't think I gave him enough code to just copy and paste into a solution, do you?
any idiot
can write haiku you just stop
at seventeenth syl
-ThinkGeek Fortunes
|
|
|
|
|
David, thank you for your help
and I would also just like to clarify something.. I was not hoping for someone to put up some code, that I could simply cut and paste into my application. All I wanted was to make sure they way that I was going about trying to solve my problem was an efficient way, I thought that if I asked then maybe someone could point me in the right direction.
This was not a homework question. I have not been taught C# at uni, I have learnt what I do know from books, MSDN and tutorials, in my spare time, its a shame that people do post messages just to save time and hassle of learning themselves, it gives the rest of us students bad images
thanks.
|
|
|
|
|
No problem...and I'm glad that you're taking time to learn C# by yourself rather than just stick with what your uni's trying to teach you. The college I'm transfering to only "officially" teaches Java. However, I've spoken with one of the professors in the compsci dept, and he said that most of the profs are fine with students using C# because it's so much like Java in it's OOP-ness. So that made me very happy.
But yeah...you're welcome for the answer. I hope it helped.
any idiot
can write haiku you just stop
at seventeenth syl
-ThinkGeek Fortunes
|
|
|
|
|
David Stone wrote:
Actually, what do you think about my answer?
It's ok. If there were a built-in code-snippet feature in the Cp navigation bar, then I would add the code, and would point to it on posts related to this issue in the future.
|
|
|
|
|
Hi,
I finally figured how to parse my string as singles but I am looking for a way to prevent the user from entering non numeric values in the textBox, could a maskEdit do this or is there a way to do it directly with the textBox. Thanks
Jean S. Paquet
// JS Paquet
cout << "Thank you all" << endl;
|
|
|
|