|
|
hi,
TehMedic Wrote :
Form.Controls not contain the sqlDataAccess like objects
You mean controls are not object of their base ?
**************************
S r e e j i t h N a i r
**************************
|
|
|
|
|
I think he means all the visual components he dragged onto the form in the VS Designer.
The Designer creates instance variables for the components, and displays a little box for each one. No matter if you drag a control or another icon onto the form, the Designer always creates an instance variable und writes code to create and initialize the object.
The controls can be found later on in the form's Controls collection, just like any other control. But there's no collection for the non-controls, they are nothing but instance fields that are initialized in InitializeComponent.
|
|
|
|
|
Hello All
I'm working in a LAN monitoring software one of it's feature is to shut down it's clients. Can anybody guide me which classes to explore to shut down a remote pc form ur C# Applcation. I'll be thankfuk for ur guidance.
God bless
Riz
|
|
|
|
|
Hello jinn_baba,
I do not know if there are any native .NET class library functions that you can use to perform remote machine shutdowns. However, you certainly can use the native Win32 APIs to do the job.
The main API is InitiateSystemShutdown(). You would also need to adjust your pvivileges to have the SE_REMOTE_SHUTDOWN_NAME privilege. For this would would need the following APIs :
OpenProcessToken()
LookupPrivilegeValue()
AdjustTokenPrivileges().
Regards,
Bio.
|
|
|
|
|
It needs to be done using the method spelled out by Bio. There is no .NET native class or method to do this.
You would have to have Administrator rights to the target machine or at least the Shutdown priv as directed by Bio.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanx to both of U. what do u think to use WMI (Ihave listend). and how to use it in C#
Regards Gosh
|
|
|
|
|
Does anyone out there know if it is possible to have the graphics object preserve what is drawn to it. If you consider programs such as AutoCAD, where the user would perform a variety of operations resulting in a drawing displayed on screen. Now if the user minimises AutoCAD and restores it again there is no noticeable time spent repainting the drawing window. This can also be seen when you drag a smaller window around over the drawing area where the invalidated regions of the drawing area take no noticeable time to repaint. Now if you consider a basic .NET windows form, which has, its background property (Image) set to an existing bitmap and you minimise and restore the form and drag a smaller window around over the form you will see a noticeable lag repainting the invalidated regions that resulted from the smaller window being dragged around over it.
Is there a way to have windows preserve what is draw to it so that the OnPaint()
method need only be called when there are changes to make to what is displayed?
|
|
|
|
|
When you get a message to minimise the window, you could first do a screenshot, and use that to render the screen state when maximised ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Well, to address your last questions, yes, OnPaint should already have a an update rectangle (knowledge derived from WM_PAINT, don't know the equivalent .NET property, my help is at work). Then you only need to refresh that rectangle.
In more general terms, as already stated, storing a bitmap of your area is a common technique. Then all you have to do for a OnPaint is blit the bitmap to the screen. Of course, you still need to generate this bitmap when ever the user does something.
Another idea is use Windows Metafiles. (Again, since I don't have my docs, I'm speaking about win32). Creating a metafile will give you a HDC, which you then paint on top of. Then you can "replay" then metafile to any other HDC (screen, printer, bitmap, whatever).
Since my company develops utilities for AutoCAD, I can say that it uses MUCH more complex mathematical routines. In general tho, it caches the geometry that is visible on the screen for quick updates. Perhaps it even has more then one cache.
Somewhere in CodeProject (I think, maybe somewhere else) someone wrote a "persistent" canvas that remembered what was drawn to it (TCL/TK has it built in). If you need, I could dig it up.
--
Joel Lucsy
|
|
|
|
|
Thanks for the response and for the suggestions.
I had already tried drawing to an off screen bitmap, but it still results in some lag when repainting (Well in my books anyway). If you could dig up the "Persistent" Canvas example I would really appreciate it.
|
|
|
|
|
|
Thanks Joel
I have not had a chance to have a in depth look at it but at a glance it seems to be just what I have been looking for.
To give you more detail, I have been working on a GPS mapping system for about 2 years now and already have a working system, but there is still much work to be done and I find myself spending much time trying to find better ways to do things.
Jonathan
|
|
|
|
|
Hi,
I have 5 CheckedListBox controls on a winForm. I am appending the selected items in a stringBuilder on a buttonClick Event. my question is,
say,
I have checkedListBox named as A, B, C, D and E. after selecting the items from each CheckedListBox, it first shows me the selected values from E,D,C,B and A. why does it shows the selection in reverse, when i am adding the selected values immediately to the StringBuilder. my code is given below.
Thanks, for ur help. I am actually using the selected items to form a dynamic query.
StringBuffer sb=new StringBuffer();
CheckedListBox clb = null;
foreach(Control c in groupBox1.Controls)
{
if(c is CheckedListBox)
{
clb = c as CheckedListBox;
if(clb.CheckedItems.Count !=0)
{
for(int i=0; i<=clb.CheckedItems.Count -1; i++)
{
sb.Append(clb.CheckedItems[i].ToString());
sb.Append(", ");
}
}
}
MessageBox.Show(sb.ToString());
abhi
|
|
|
|
|
Hi Abhi,
Take a look in your form's InitializeComponent() method. Somewhere in there, the VS designer wrote you some code like:
groupBox1.Controls.Add(this.CheckedListBoxE);
groupBox1.Controls.Add(this.CheckedListBoxD);
...
The items appear in the Controls collection in the order in which they were added (AFAIK). So either: edit the InitializeComponent() code to reverse the order in which they are added, or just reverse your loop and work for the end of the collection forward. I'd do the former, but I don't think there's a compelling argument either way.
Hope this helps,
Bill
|
|
|
|
|
Because .NET have added them to group in that order.
Look into InitializeComponent method
You would see something like
//
// groupBox1
//
this.groupBox1.Controls.Add(this.checkedListBox4);
this.groupBox1.Controls.Add(this.checkedListBox3);
this.groupBox1.Controls.Add(this.checkedListBox2);
this.groupBox1.Controls.Add(this.checkedListBox1);
Sanjay Sansanwal
www.sansanwal.com
|
|
|
|
|
I'm normally a C++ .NET programmer but have been working on a C# .NET DirectX project. Everything works fine for me, but when I try to give the executable and needed data files to friends, they all end up with errors that won't let the program load (all have the latest version of DirectX and .NET framework).
At least one error I have seen is "Failed to delay load library mscorlib.dll (win32 error:998)"
Am I missing something with how I compile my project? Any suggestions would be appreciated.
Thanks
Cyric
cyric74@hotmail.com
|
|
|
|
|
I believe I was reading some DX documentatin which said this was a possible problem with DirectX. I could be wrong. Do you set the project to make a local copy of anything you import ? I always do that, and then anything I use goes with the distribution.
Did you use DX to play audio and video ? If so, how did you find it ? I'm preparing an article on all the problems I had with it, so I wondered if anyone else has found it the same.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
How do I set the project to make a local copy of the imports? I guess there is a difference with C++ .NET and C# .NET because I've never run into a problem like this with C++. It always packaged everything it needed without my messing around with it.
I have not yet used DX for audio/video. It is only being used graphically in this project at the moment.
|
|
|
|
|
Click on the reference in question and in the properties box is 'Copy Local'. Set this to true.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I've just about finished my project, and I'm trying to set up the icon. As you can imagine, a google for
'icon' is next to useless. I've edited the icon in VS, and it appears in 32x32, but I can't see how to set the 16x16 icon ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
With the icon open, click Image -> Current Icon Image Types and select the size you want. Under the Image menu is additional actions.
Note, I do recommend you use a decent icon creation package. I personally like Icon Workshop, but I'm not recommending anything.
Also, with .NET applications make sure that your main form's Icon property is set as well as the project's icon in the project properties.
Personally, to save room, I embed the icon you'll use for Form.Icon and define a static property to return that Icon . In your form's constructor, set this.Icon to the Icon returned from said property, and you can reuse it as well. If you use the PropertyGrid, the icon is base64-encoded and serialized to a ResX file specific to the Form . Using that in additional forms or controls will do the same for a different ResX file.
Note that the project setting actually embeds the icon as a Win32 resource. The command-line switch that's equivalent is /win32icon:<file>.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Thanks for the help. This was more info than I'd managed to work out on my own.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
All sorted.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Prohibiting multiple instances is not the problem neither is restoring the app if it is just minimized on the task bar but when its in the system tray and hidden i'm really pulling my hair out as to how to restore it.
Thanks in advance for any thoughts
|
|
|
|