|
well just want to say hiya to start with.
i need a bit of healp on C# GUI programming.
the problem i have is this.
i need to vreate a C# forms appliction that access data from the registry.say the CPU speed for example.
then it need to display it on the forums.how do i do this.
thanks guys!
Ashley
|
|
|
|
|
If you're wanting the CPU speed, you should be looking at WMI since the CPU speed is not kept in the registry. Look in your help files for "Registry Class". The examples there are quite good for basic information. If you have questions beyound that information, by all means please ask.
Phil
|
|
|
|
|
hi phil thanks for replying.
all i need to do is access the reg or WMI and display the info on a GUI win app project.
i dont suppose you have any example code at all do you.
thanks!
|
|
|
|
|
There are many examples of that on this web site. Do a search for "Registry" or WMI and you will get a number of hits. Be sure to limit your search to C# and you will get mostly C# articles. You should download the examples and go through them.
Phil
|
|
|
|
|
do you have a link to just one of them.
the only ones i can find are console and does not help me at all.
i cant seem to find anything on forms programming.
thanks!
x
|
|
|
|
|
Ok, now I understand the problem you are having. I believe it is this:
You have a control on your form such as a text box in which you want to place a value. The value might be the current CPU usage or other value. But you can't seem to display it on the form.
Try doing the following:
Add a button to your form
Add a textbox to your form
Double click on the button which will generate the _Click(...) stub. In this stub do the following:
Pseudo code
int myValue = 110; // Replace this line with a query to WMI or the Registry
TextBox.Text = myValue.ToString();
End Pseudo code
The second line in the pseudo code block I believe is the information you seem to be missing.
Phil
|
|
|
|
|
hi,
I originally wrote an object as a struct, and now I am changing it to a class.
In one of my member methods I want to pass "this" by reference to a method in another class and I get teh below error when I try to build? Is this common? Anyone know why it works with a struct and not a class?
Cannot pass '<this>' as a ref or out argument because it is read-only
thanks
cb
|
|
|
|
|
Hi,
for structs, ints and other simple data types, "this" is the value itself
(hence the name "value types"); you may add the "ref" keyword to obtain a
reference to it (similar to a pointer in C/C++).
for class instances, "this" is a reference (hence "reference types"),
so it behaves as a pointer would in C/C++; hence you should drop the "ref"
all together when switching from struct to class.
|
|
|
|
|
Hi,
as Luc already suggested, you can just drop the 'ref' from your method's parameter and everything should work. I will just add some explanation why you must not pass 'this' as a ref parameter.
If you have a value object (a struct) and you pass it by value (no 'ref' parameter) to the method, the method gets its own copy and the original will not be affected by any changes made in the method. If the value object is passed by reference, all changes do affect the original.
If you have a reference object (a class) and you pass it by value, the reference itself is copied. Thus you have two references to the same object. If the method changes the referenced object, the changes will affect the original. However, if the method changes the reference itself (e.g. set it to 'null'), this will not affect the original reference. If you pass the reference object as a reference parameter, you are able not only to manipulate the referenced object but also the reference itself. Sometimes this is the desired behaviour, but you definitely don't want enable any method to set your 'this' reference to 'null'. Therefore 'this' is read-only and must not be passed by reference.
Hope this helps.
Regards,
Tim
|
|
|
|
|
Hi,
I need help in reading an edit box from one application (java) to a C# application.
Currently (using Spy++ / Winspector as reference) I have been able to locate the parent handle of the java application using FindWindow like so:
IntPtr hWndParent = FindWindow(null, "Application Name");
I then find the correct child handle by looping through all the child handles until I get to the actual edit box on the java application using FindWindowEx like so:
IntPtr hWndChild = FindWindowEx(hWndParent, IntPtr.Zero, null, null);
Now that I have the address of the edit box, I am wanting to pull the actual data stored in the edit box and save it into the C# application.
jn
|
|
|
|
|
You need to use p/invoke to call GetWindowText on that text box via it's handle.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I have read that GetWindowText will not work if I am reading any control outside of the application that is outside of the calling application.
|
|
|
|
|
True! You can also send the WM_GETTEXT message to the window handle without running into that restriction.
But, of course, it gets worse! There nothing that say that the target edit box has to respond to either request! You could go through all this junk and find out that the edit box doesn't care about that message and won't respond to it.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
I have a database application that uses a DataGridView to display all records and textboxes, comboboxes, checkboxes, etc., to display each individual record. The user edits the individual record controls to update (or add) records. The comboboxes text field is bound to the appropriate data item in the datatable. Unfortunately, though I can select a new item from the combobox, that item does not get updated to the datasource when I save any updates. The textboxes and such do get updated. Can anyone explain to me why this is the case? Thanks.
|
|
|
|
|
Hello! Sorry for my million annoying questions, but i have another one.
So:
I have i RichTextBox, and i click in the center of some word.
How can i get a full word ?
(is there some methods, or i have to move left and right to spaces?)
Thanks!
One nation - underground
|
|
|
|
|
With the System.Windows.Forms.RichTextBox, yes, you have to do your own code to figure out the word given a location.
If you use the Windows Presentation Foundation (WPF) RichTextBox, there's some built-in things to help you get the run/word/paragraph at a particular point, IIRC.
|
|
|
|
|
Hi guys, I am not sure why everyone is moving on C# besides it microsoft technlogy, provide drag and drop functionality and easy to do programming and coloured syntax. If C++ is powerfull why there wasn't any work get done on it. Infact Windows is also written in C/C++. How come there wasn't any VS2005 kind of editor for C/C++ programmers that could have the "." style object lists . Wouldn't it better if we could have more developement in C++ Apis,syntaxs, memory managements, plug and play controls and component based control progrmaming so we can get more control over what we want to achieve rather than calling C/C++ API functions in C# programming.
Thanks
|
|
|
|
|
netJP12L wrote: How come there wasn't any VS2005 kind of editor for C/C++ programmers that could have the "." style object lists .
VS2005 does C++, and does it pretty well.
C# is easier to use, and easier to write most types of Windows apps. I write some pretty complex and non standard code in C#, it works just fine. If Microsoft were to go under, C# is subject to an external standard, but, either way, I'd lose my platform as well. I know C++, I have been a C++ MVP, as it happens ( I am now a C# MVP, should change my sig ). But, C# is a better tool for a lot of jobs, in my experience. Why would a client pay me double to have the same functionality, have it take twice as long, so they can say it's written in C++ ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I agree with Christian and his points. I still feel that I should point out though, that there are very specific cases when C/C++ is a better choice. A case that comes to mind is when outright speed is essential, an example would be a driver. However, C# allows much more rapid user interface development with a lot less coding.
Phil
|
|
|
|
|
I agree, there are times when you need C++. Writing the .NET framework is an obvious example :P
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks for your response, I do agree what you said but why microsoft or some other regulatory body didn't take the initiative to redesign the C/C++ codeing style and made it what C# offers to programmers rather than coming up with a new language. I mean, lets say in the future someone else come up with new easy language syntax and bit something different everyone gonna be moving towards that then. Why don't we focus entire on Parent language rather than producing child languages.
|
|
|
|
|
There are too many problems with that approach. If you think of this from a business perspective, a business makes more money by selling separate compilers than by selling upgrades that are not necessarily backwards compatible. Then there is the problem of forcing companies to re-write software so that the latest compiler will work with it. Customers don't like to change something that is working just because someone has a better idea or wants to implement things in a different way. There are many more technical problems, that are not business related that have to be overcome. Another perspective is from the customer point of view. As a customer, do you really want to keep re-writing working software for the latest version of the compiler? That is very costly.
If you want an example of this, just look at the year 2000 issue with time and how many banks were worried that their 30 year old COBOL code would break.
Phil
|
|
|
|
|
Hi All,
I have created web service using C#, VS2005. I can browse the web service and check whether the web methods are working fine or not (on my develoment server); so far so good.
I want to deploy this web service on other host, so I created web setup project from VS2005 and created installables. I ran these installables on other host and they got added too (I checked it through IIS manager).
Now when I browse the web service I get the following error message.
"The page cannot be found.
The page you are looking for might have been removed, had its name changed, or is temporarily unavailable. "
Could someone let me know what exactly am I missing here.
I am new to both C# and web services, so any kind of help would be much appreciated.
Thanks in advance,
JD.
PS: I have posted the same question in .Net section too as its regarding a Web Service.
|
|
|
|
|
dancelicious wrote: I want to deploy this web service on other host, so I created web setup project from VS2005 and created installables. I ran these installables on other host and they got added too (I checked it through IIS manager).
Why are you intalling the webservice on the other system. Try and set it up manually.
Mubashir
Software Architect
Storan Technologies Inc, USA
Every job is a self portrait of the person who did it.
|
|
|
|
|
I am totally new to web services, so I have no idea how to set it up manually.
In fact even the idea of making an installable was from MSDN.
Could you please tell me how to do it.
Sorry for the dumb question
Thanks,
JD.
|
|
|
|