|
Thanks Kev,
I'm new to programming and thought that margin would be added automatically to the control coordinate already given. I'll try something like this:
ControlPaint.DrawButton(g, t.Left + e.MarginBounds.Left, t.Top + e.MarginBounds.Top, t.Width, t.Height, ButtonState.Pushed );
Ron
|
|
|
|
|
Printing allows you to print in the page margins because Headers and Footers go into the margins.
Anyway, good luck with your printing.
Kev Pearman MCP
|
|
|
|
|
How to read a value from an address in memory using C#
|
|
|
|
|
I am developing a component that compiles code into a dynamic in-memory assembly (using CodeDOM). This in-memory assembly needs to run under restricted permissions, including limited access to the filesystem, but it also needs to have access to certain paths.
Now, I expect that the way to go about doing this is to make a code group, and a custom permission set to assign to that code group. However, I have some questions:
- How do I make the assembly run under the code group I've defined? I can't use a URL, as the dynamic code can come from numerous places. Nor can I use a hash (for obvious reasons). So I guess a strong name would be the best option.
- I'm wanting to allow the code to have read-only access to a certain directory. Since the directory path is determined at install time, how would I go about defining the FileIOPermission in the permission set XML file?
- How do I best go about ensuring that the code group is installed before the component executes the restricted code? (If the code group is not in place, the code may recieve more permissions than it ought to.)
Sorry if some of my questions sound stupid; I haven't dealt with more than just basic CAS before (although I've read all the MSDN docs I've found on the subject).
TIA
|
|
|
|
|
This is not my article, however, I would just like to draw the attention of the forum to the following article of an implementation of SPAM identification with a C# libary.
http://www.generation5.org/content/2004/KillSpam.asp
I hope that the code behind it does not in fact generate even more spam in some secretive way, however, what is said in the article makes a lot of sense.
|
|
|
|
|
I can connect to a remote registry using microsoft.win32 package.. but it only works if i have authentication.. and the only way i know how to get it is try to access the computer over the network and fill in the details:P how do i gain permission using c# code?
|
|
|
|
|
By default, the CurrentPrincipal on the thread is GenericPrincipal. If you set the CurrentPrincipal to WindowsPrincipal it should be the same as doing a RunAs. You can access the property off of the current thread (System.Threading.Thread.CurrentPrincipal). You can also set this at the AppDomain level, but you can only do this once during the entire life of the application domain. By doing it at the domain level, you inherit the WindowsPrincipal througout all threads within that application domain.
|
|
|
|
|
ok im not too familiar with CurrentPrincipal.. so could i plz have a code example to show me how to pass credentials to a remote computer to access their registry thanks
|
|
|
|
|
Getting credentials to see if a user is in a particular role is easy.
Passing credentials from one system to another to access registry information is not. If it was easy, we'd have one more security patch to be applied to Windows because it would be such an easy hack.
If there were a real business justification for doing something like this, then about the only way I could think of was to have the user install an agent and access the agent via remoting.
This signature left intentionally blank
|
|
|
|
|
Hi,
I am using two model dialog boxes named "StartUp" and "AddNewItem" from the main Form named "Form1" with the following code
frmStartUp = new StartUp();
frmStartUp.ShowDialog();
if (frmStartUp.DialogResult == DialogResult.OK)
{
// Doing Something
frmStartUp.Dispose();
}
else if(frmStartUp.DialogResult == DialogResult.Cancel)
{
frmStartUp.Dispose();
}
same is the code for the second dialog box (AddNewItem).
When i click on the Cancal button of the second dialog box it gives the following excpetion
An unhandled exception of type 'System.Runtime.InteropServices.SEHException' occurred in system.windows.forms.dll
Additional information: External component has thrown an exception.
whereas clicking the cancal button of the first dialog box (StartUp) does not give any exception.
what the problem with it.
Thanks in Advance
Omar Rehman
|
|
|
|
|
try this:
frmStartUp = new StartUp();
if (frmStartUp.ShowDialog == DialogResult.OK)
{
// Doing Something
frmStartUp.Dispose();
}
else
{
frmStartUp.Dispose();
}
|
|
|
|
|
Hello. I require some assistance in measuring an image. Currently I am able to measure a stadard line (horizontal, diagonal and vertical). Now, I would want to measure a non standard form. What I would want to do is to click from one point to another continuously and each clicked point will be assigned to a standard incremental node name (ex: A, B,..Z). Then, the software will record the coordinate of each nodes into a table. I really need sonebody;s help in this since I am rather new with this software. Thank you.
M
|
|
|
|
|
Well, it sounds to me like you have a bunch of small lines and you want to add their lengths, am I right ? That sounds fairly straighforward to me, or have I missed something ? If you store the co-ordinates in an arraylist, you can make that a data source for a data grid.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi Christian
Thanks for the answer but since I am rather new with this C# programming I would relly much appreciate it if you could assist me on the programming codes. I honestly have no idea how to do this.
M
|
|
|
|
|
at the top:
using System.Collections
in your class:
ArrayList points = new ArrayList();
when someone does a click
points.Add(ptMousePos ( however you get the point in the event ));
Then you can go through the array, and work out your lengths from each point pair, and create a form with a datagrid, and just have something like
theGrid.DataSource = points;
theGrid.DataBind();
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I really appreicate you fast reply. It sounded so easy for you. Like counting 1,2,3. Won't be easy for me since I'm a first time user. Anyway, thanks for the reply. I appreciate it very- very- very much. I'll try and give it a go.
M
|
|
|
|
|
Dear Christian
I am really- really sorry to be bothering you again but I ave tried to program the codes but am unable to get anywhere near what I wanted (due to the fact that I'm a first time user). Do you have a running application so as I can study the code rather then having to develop the code. Thank you again and I honestly am really- really sorry for bothering you.
I apologize again.
M
|
|
|
|
|
No need to apolgise, that's what this forum is for. Why don't you post some code, so I can have a look at it. What's it doing, and what do you want it to do differently ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Hi Chritian
I'll be very honest with you. I am a control and Electrical person who has no prior ecperience in high level language. NONE what so ever. Currently, what I'm doing is trying (really hard) to undertand people's programming codes (that's how I study this language) in addition to study the basic concept of C#. Since I am really- really new,I am unable to develop any codes cause it's hard enough for me to understnd the coding itself he!he!. Now I only manage to open and save file. I am still finding a way (whihc I doubt) to program the application stated before. Anyway, Christian I appreciate your fast responses an d you ever find codes that;s relevant to my rewuirements, please email them to me okay. Thank you again.
M
|
|
|
|
|
Hello
I want to make a preferences/settings dialog where you can click on a node in a treeview and then the controls to the right where you can change the settings change. How do I make this? Do I have alot of panal controls, fill them with what I want and then make one visible and the rest invisible or are there a better way?
Tips and ideas are very appreciated!
Thanks in advance!
~~~~~~~~~~~~~~
Martin Lundberg
Student, Sweden
I have to thank every member of the Code Project for making it such a great place for a beginner to learn!
|
|
|
|
|
Implement every settings page as a separate UserControl.
When clicking on a tree node destroy the control currently visible and create
a new one corresponding to your entry.
You might want to consider having a settings class that will subscribe to events inside the controls on your UserControls to store the values of your preferences. However if the amount of settings groups/subgroups is not that great, I would recommend using the traditional tabbed dialog design instead.
|
|
|
|
|
i draw some rectangle into my form and when i minize the rectangles disappeared how to slove this problem ?
|
|
|
|
|
Are you using the OnPaint event, and drawing it every time the form repaints?
|
|
|
|
|
1.Overide OnPaint Event and write all the painting algorithm inside this.
2. Use graphics object obtained from PaintEventArgs's Graphics property. This will ensure non-flickering during painting.
protected override void OnPaint ( System.Windows.Forms.PaintEventArgs e )
{
Graphics g = e.Graphics;
}
Do revert back whether it could solve your problem or not?
Regards,
Jay.
|
|
|
|
|
Hi everybody.
I got a WinSock related question. This is mainly about C#. I find C# to be very strage in this problem... maybe because I'm a begginer in C#. I'm using the GetData method to retrieve some data a socket received. Here is the data about this method:
Void axWinsock.GetData (ref object data, object type, object maxLen)
In Visual Basic .Net the last two parameters are optional. But in C# you MUST provide them, otherwise the function will not work. I tried this... (in Socket_DataArrival)
object oRData;
oRData = "";
Socket.GetData(ref oRData, (object) null, (object) null);
After casting nulls to objects it worked, but I`m not sure if this is how I can avoid using those parameters. I`m not sure if the function will work.
But the big question is... HOW DO I GET THAT DATA OUT OF my object variable, oRData. Pfff... I tried casting it to a string but that doesn't work. In fact,
object oRData;
oRData = "";
IRC.GetData(ref oRData, (object) null, (object) null);
MessageBox.Show ("Test");
When using a breakpoint... the GetData method gets executed, but surprise surprise... the Message Box is never displayed. It's just like the GetData method crashes the entire DataArrival event.
I`m totally puzzled ... anybody know anything?
Thank you in advance, have a nice day/night
The Greater Mind Balance
|
|
|
|