|
Go to http://www.gotdotnet.com/team/csharp, choose tools and utilities on the right. There are a couple of better programs there.
|
|
|
|
|
thanks eric - by the way what are your favourite tools? I see you have created a regular expression workbench - a tool I wish was in Visual Studio from the beginning.
My particular favourite is XML spy - damn useful for creating xpath queries and such.
Stupidity dies.
The end of future offspring.
Evolution wins.
- A Darwin Awards Haiku
|
|
|
|
|
Please help me solve this problem
I created an application that saves its settings to a file. This file has to be globally accessible. Here is the problem: If the administrator is the first to use the program, then the file will be created by the administrator. When a user with less rights logs-in, the application tries to modify the file. But, the they dont have enough rights.
How do I create a file that everyone has rights to? Or, How do I change the permissions to allow everyone to read, write to the file? (note: this file doesn't contain anything important, so its safe to allow unlimited access)
If someone could do me a favor and post an answer, I would be very glad. Thanks!
|
|
|
|
|
AK wrote:
Here is the problem: If the administrator is the first to use the program, then the file will be created by the administrator. When a user with less rights logs-in, the application tries to modify the file. But, the they dont have enough rights.
AK,
What you are describing sounds like a network rights issue. When the app is first installed the Admin needs to set the rights to the file for use by everyone.
With that said, are you sure that you want to be using a file for multi-user read-write? You will run into all kinds of issues related to concurrency. A database (even an Access MDB) would serve you better. (If you were using the file for read-only you could get away w/o any problems but read/write will give you headaches in a multi-user environ.)
|
|
|
|
|
Actually this is pretty similar to a network issue. But, in my case the problem resides in the NT file system. When an admin account creats a file the users with less rights (ie. normal users) cannot access the file that was created. Another thing, if a person with low rights creats this file it is accessible to the admins and people that have more power.
I just dont know how to change the permissions, to allow everyone to have full control.
|
|
|
|
|
AK,
Yeah, thats what I'm talking about. The Admin needs to change the rights.
|
|
|
|
|
I have a library at http://www.codeproject.com/useritems/NTSecurityNET.asp that allows one to manipulate NTFS access control lists. This may help you change the permissions of the file so that the appropriate users have access.
|
|
|
|
|
I sincerly thank you for point out the article. Its a wonderful peice of work. In fact, it solved my problem in only 3 lines of code!
Thanks again.
|
|
|
|
|
I'm trying to draw directly on the screen. Whatever is drawn needs to be "above" the controls on the form. And, of course, I need to erase whatever is drawn to restore the way things looked before I did my drawing.
I looked at the "Reversible" drawing functions on the ControlPaint object but these don't give me the control over the color that I need. (I really only need Black, White, and a dotted grid of Gray.)
What should I be looking at now to get GDI+ to work with me on this?
-----
I'm essentially trying allow users to select controls. If one control overlaps another I still want the selection cues to appear atop the covering control.
|
|
|
|
|
With DirectDraw you are able to draw directly on the screen!
|
|
|
|
|
Really all I'm trying to do is recreate Visual Studio's form desinger. I think adding DirectDraw would be overkill.
|
|
|
|
|
You got me interested!
What do you mean recreate VisualStudio's form designer?
I think there is a way you can just import the functionality from a the original libary. I think its located in C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\Microsoft.VSDesigner.dll.
If you want to do it another way, it can get very messy very fast. Ie. if you draw directly on the screen you then have to do hooks to handle the mouse events...
Good luck to you. By the way, ASP WebMatrix did an ASP think like this. They have a VisualStudio like UI, with with the ASP webforms designer surface.
|
|
|
|
|
To answer your question directly, this is how you can draw on the screen:
System.Drawing.Graphics g = System.Drawing.Graphics.FromHwnd(System.IntPtr.Zero);
-or, something like this-
IntPtr handle = System.IntPtr.Zero;
System.Drawing.Graphics g = System.Drawing.Graphics.FromHdc(handle);
--
Basicly you need to tell it you use null as the handle. This creates a graphics object that draw on top of everything. But, it can be very messy.
|
|
|
|
|
AK,
I tried both suggestions. The second throws an exception and the first doesnt crash but it doesn't do anything. Can you give me a link to a web page about using the null pointer to gain access to the screen?
Thanks.
|
|
|
|
|
Hi,
I read AK's article and experimented with his second solution. It did throw an exception. And I modify it as follow and now it works:
IntPtr hdc = GetDC(IntPtr.Zero); // get hdc for the screen
Graphics g = Graphics.FromHdc(hdc);
g.DrawLine(new Pen(Color.Blue), 0,0,500,500); // draw a line for testing.
g.Dispose(); // <- I don't know if I should use g.Dispose or g.ReleaseHdc here...
ReleaseDC(IntPtr.Zero,hdc);
GetDC & ReleaseDC are Win32 API in user32.dll
Hope this could help you
|
|
|
|
|
Sorry, I forgot to tell you to use GetDC.
I knew I missed something.
|
|
|
|
|
I've never tried this, so it may or may not work but here goes
Create a control the same size as the Form (a panel would do), now when you want to draw your grid or whatever above the Form you do several things....
form will be the Form you are trying to draw on top of
parent will be the panel or whatever that the Form is sitting on top of
<br />
Graphics g = parent.CreateGraphics();<br />
PaintEventArgs e = new PaintEventArgs(e, form.Bounds);<br />
<br />
InvokePaint(form, e); <br />
<br />
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
James,
Hmm, I've been trying a similar approach but I like yours better because there is only a single surface to draw on. My only question is will I need to make your panel Transparent? I ask because I’ve been trying to create a user control with the graphics drawn on it around the edges. Then I was going to make the background color transparent and place this usercontrol over the other control (lets say it is a button) already on the form. In this way the button would show threw and my usercontrol's graphics would indicate that the button has been selected; even though the user control completely covers the button.
The only problem is that I can't make the usercontrol transparent!!! Will I have to make your panel transparent too. Because this just isn't working for me.
|
|
|
|
|
Here you go, a quick demo showing how its done
It doesn't paint the non-client area but I think you can send some messages to windows to get it to do that (just need to call GetHdc/ReleaseHdc when passing it to windows).
InvokePaintTest.zip (8.1 Kb)
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
Wow, thanks James
I tried out your sample just now and its pretty cool. I'm probably not going to use it though because I want to keep the controls on the same form BUT if the screen painting turns out to be a hassle I’ll definitely come back to your solution.
|
|
|
|
|
Hi all,
I was wondering if there is an attribute that can be applied to a class/struct that tells the compiler not to compile it?
Thanx
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
Am I missing something? Could you explain your situation a bit more?
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|
I mean it must have some functionality e.g. lets call it an IncompleteAttribute (maybe NotImplementedAttribute) that one would be able to apply to a class/struct (what about maethods and properties) , so when one compile the project that those classes/structs doesnot get compiled.
This would be neat especcially working on a library of classes when certian classes might not be working as it should or the structure has just been put in place. Hey, even class status for example, like WorkingButWithErrors, etc.
I hope you understand a better.
PS: If there is not such an Attribute, would it be difficult to do?
MYrc : A .NET IRC client with C# Plugin Capabilities. See
http://sourceforge.net/projects/myrc for more info.
|
|
|
|
|
There aren't any attributes to stop code from getting compiled, because attributes don't play a part until code execution (except for attributes that the compiler looks for, but this is after the code has been compiled but before the assembly is created).
So you are left with commenting out or #if/#endif
James
"And we are all men; apart from the females." - Colin Davies
|
|
|
|
|