Diamonddrake 397 Master Poster

on the usercontrol's cs file create an event delegate and event like so

public delegate void onMyEventHandler(object sender, EventArgs e);
        public event  onMyEventHandler OnMyEvent;

then when the usercontrol needs to tell the form its time to be removed. just call that event

OnMyEvent(this, new EventArgs(null));

on the main form you just create your event handlers as usual.

usercontrol myUserControl = new usercontrol();

myUserControl.OnMyEvent += new myUserControl.onMyEventHandler(catchevent);

void catchevent(object sender, EventArgs e)
{
     Panel2.Controls.remove(((control)sender));
     //or Panel2.Controls.Clear();
}

something simple that that should work. sorry its been a while since I have been on because I have been really busy.

Diamonddrake 397 Master Poster

If you need to customize all 3 of the buttons events, the standard practice is to create a your own title bar control such as seen on AIM and Y! instant messengers.

otherwise, DDoubleD has the right idea.

Diamonddrake 397 Master Poster

the system must have a equivalent or newer version of .net installed. not necessarily the same version.

and yes, as the previous person stated. the UAC in vista forces applications to automatically be ran as if the user does not have admin rights even if they do. there are ways around it. but the best practice is just to play it safe.

Diamonddrake 397 Master Poster

I have ran all of my apps on both XP and Vista, and the only issue I have had with 32/64 bit is on one of my apps I imported a few methods from user32.dll. on 64 bit vista 1 of the methods I imported didn't work. application still ran fine, just didn't perform that method. DdoubleD is right. Just compile for "any processor" its the default. and it should work fine, but its always a good idea to test the program on 64 bit before releasing it as 64 bit compatible.

Diamonddrake 397 Master Poster

you create an event handler from a button on the usercontrol in the main form then just do the removing there, Could be a lot of solutions.

Diamonddrake 397 Master Poster

since you always clear the controls on the panel first, seems like it will always be the only control on the panel, so panel2.controls. clear(); should work.

but you could also use panel2.Controls[0].Remove(); seems like there could be several ways to go about it.
you could even expose the panel2 as a public property of the form and modify its contents directly through the property.

Diamonddrake 397 Master Poster

If you write an application targeting the .net framework it will work across XP, vista, and windows 7 no problem. the 32/64 bit crossover might give you trouble if you use a lot of windows interlop. but other than that This is one of the things .net was made for, all .net languages work together perfectly, and all .net enabled versions of windows run the .net applications equally well.

happy coding.

Diamonddrake 397 Master Poster

Sorry, VPN is a safe way to transmit data, but I don't know much about it. and no you can't forward ports through code, but you don't have to worry about the ISP, just the router that is responsible for your LAN. if you check your internet connection on one of those PCs and get the "gateway IP" enter the gateway IP into a browser and you will be prompted for the password to the router, just go to PortForward.com. It will give you step by step instructions on forwarding ports on hundreds of routers.

Diamonddrake 397 Master Poster

...Sockets are basically how the internet works, and how you connect to a computer on a "local" network from the outside world is by configuring the router that controls the flow of information on the "local" network to forward a port to a particular device. That's pretty much the only way its done. So I'm not really understanding your problem.

lets say you are in a internet cafe. all the computers there are on a network to share the internet. now the Router that routes the information between them and the internet assigns all the computers there a "local" address, 192.168.1.100, 192.168.1.101, 192.168.1.103 This allow the router to know who's who. but no matter what computer on that network sends out a request, the internet sees it coming from the address that the router revcieved from the ISP's routing system. that's the external IP. now in order for your program to be connected to by the outside, the local router has to be configured to redirect all the data passed on a particular port to a local address. if your app is on 192.168.1.101 on the local network then the port you use on that program needs to be set to be forwarded by the router to 192.168.1.101

Now if you use a webserver that is directly connected to the internet, not on a local network. you can connect to that more easily, then use a program on …

Diamonddrake 397 Master Poster

once connected, the tcpClient object holds a reference to the client connection, so you use that object to send and receive data. you never worry about the IP or routing of the client.

Did your college programming instructors not do a very good job of explaining it?

Diamonddrake 397 Master Poster

the trick is that you have to set up a forwarded port on the router to the network that will be connected to.

example, if network A has an external IP (the IP that the internet sees) of 168.100.159.172 and it supplies internal IPs (lan) incremented based on 192.168.1.100 Then that router needs to be configured to forward the port your application uses to the computer on the local network that is running the server application.

then the client is just told to connect to the external IP of the network the server is on in this example 168.100.159.172 at which ever port is forwarded for the app.

If you don't have access theses settings your only option is to use a 3rd system somewhere on the net as a server that will relay the information.

Diamonddrake 397 Master Poster

He guys, thanks.
Your replies are much appreciated!
But I still have a problem.
If I use DiamondDrake's code, it works but now I have flashing blue red rectangles one sec after the other.
This is of course caused by the last Refresh, can this be avoided?
If I leave it out I get a busy cursor and a form not responding message if I click on the form.

here is the thing. you are animating the effect from within the paint event, and that is typically not a good idea.

a better approach would be to create a bool value like idk, Bool red = false; local to the class, then in the paint event of the form, if its true paint it red and if its false paint it blue.

then use a timer to change the value after 1000ms and call refresh just after it change the bool and stop the timer. then you have a blue panel until the timer ticks, it will then after be red.

of course when you start the timer is up to you....
really. It would help if you told me your actual intended use. that way I could help you with a better solution.

Diamonddrake 397 Master Poster

Of course you shouldn't invalidate the entire form, you would get the object that is being repainted using the sender property and call invalidate on that.

I was sure this was just pseudo code, or else I might have gone into more details. But in the example danny posted there is a good chance if you just invalidated the rectangles that windows won't get around to updating them before that second is up, so it was yield the same result. or just flash blue then flush red. that's why i just used refresh()

And although its often considered best practice to use invalidate so windows can paint it when its good and ready, often when the effect you want is a blinking or fading effect based on a interval, using refresh on that area will topically yield a better visual result at the cost of some extra system resources. So I find that if i am focusing on an effect that I really want to look good, that I will put it in its own control, and refresh that entire control as necessary.

Also, a timer control would probably work just fine for an alternating color or fading type effect, creating a new thread would work too.

*off topic*
when I first learned flash actionscript I had a lot of trouble with events, as when you called an event from an object for example a movieclip used as a button, in its onRelease handler, the …

Diamonddrake 397 Master Poster

that my friend is because you are sleeping the thread before the paint event is finished, this means windows is never told by your program that it wants be be repainted, and since nothing you are doing outside of your program is encouraging windows to repaint your program, it just draws a blue rect, but windows never updates your control before it gets painted red.

here you could call This.Invalidate(true) here, but since you are sleeping the thread, a better approach would be calling this.Refresh();

using System.Drawing;
using System.Threading;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            Graphics G = e.Graphics;
            Rectangle R = new Rectangle(10, 10, 50, 50);
            G.FillRectangle(new SolidBrush(Color.Blue), R);
            This.Refresh(); //tells windows to repaint the form
            Thread.Sleep(1000);
            G.FillRectangle(new SolidBrush(Color.Red), R);
            This.Refresh(); //tells windows to repaint the form again,
             //ensuring that your one second wait period is not
            //extended by a busy system.
        }
    }
}
ddanbe commented: clarifing something about Sleep! +5
Diamonddrake 397 Master Poster

I actually never heard of Slashdot.org but I just checked it out, and it looks pretty cool, I look forward to seeing your app.

when it comes to UI stuff with GDI the possibilities are endless, its hard to just say hey you could do something like this!!! But if you want to get into some more powerful stuff try looking into the api call ExLayeredWindow or just layered windows in general, it allows for some better looking forms but requires a lot of work.

Diamonddrake 397 Master Poster

glad to hear it! might want to mark this thread as solved.

good luck with your application.

Diamonddrake 397 Master Poster

Yes that in menu merge system, its all the rage in forms applications. If you ever used a mac you will notice that all applications you ever open do this, and the file menu is always visible on the desk top.

the menu's for each bar will always merge with the parent container, there is a property that you can change that will influence this, but not stop if from happening. As far as I know you can't easily prevent it.

This question may go furthermore unanswered.

Diamonddrake 397 Master Poster

I'm glad I could be of help, I spend most of my time in C# trying to make things look the way I want them, so I can help with a lot of drawing related issues.

Best of luck with your app, I would love to see it when you are done!

Diamonddrake 397 Master Poster

sounds like your child forms don't have the MdiParent property set to the instance of the mdi form.

when you create your child forms you should set the MdiParent property on the form, and be sure that the mdi paretn form has the isMDIContainer property set to true.

Form2 thechildform = new Form2();

thechildform.MdiParent = this; //sounds like you are missing this.

thechildform.Show();
Diamonddrake 397 Master Poster

suspend and resume layout just stop the form from updating while making a lot of changes. since you are only making one change, it won't help you in your case.

you would use this.Refresh(); immediately after you change the opacity.

like...

void OpacityLowerTimer_Tick(object sender, EventArgs e)
		{
                       //not needed unless a lot of chaning occurs
			//this.SuspendLayout();
                        
			
			this.Opacity -= 0.01;
                        this.Refresh();
			


			//this.ResumeLayout();
		}

		void OpacityRaiseTimer_Tick(object sender, EventArgs e)
		{
                       //not needed unless a lot of chaning occurs
			//this.SuspendLayout();
			
			this.Opacity += 0.01;

                        this.Refresh();
			
			//this.ResumeLayout();
		}

That should do it. but it might flicker without double buffering.

another thing to note, you don't stop your timers in the timer tick, the method you attempt to stop it if you happen to be hovering over it at the right time, that's not the best idea. you should have it check in the tick events if you are at the high or low values example

double topopacity = 0.99;
double bottomopacity = 0.2;

void OpacityLowerTimer_Tick(object sender, EventArgs e)
		{
                       //not needed unless a lot of chaning occurs
			//this.SuspendLayout();
                        
			if(this.Opacity > bottomopacity)
                        {
			this.Opacity -= 0.01;
                        this.Refresh();
                        }
                     else
                       {
                         OpacityLowerTimer.Stop();
                       }

			//this.ResumeLayout();
		}

		void OpacityRaiseTimer_Tick(object sender, EventArgs e)
		{
                       //not needed unless a lot of chaning occurs
			//this.SuspendLayout();
			
                       if(this.Opacity < topopacity)
                       { 
			this.Opacity += 0.01;

                        this.Refresh();
                         }
                        else
                       {
                        OpacityRaiseTimer.Stop();
                       }
			
			//this.ResumeLayout();
		}

That will fix your know bug too.

Diamonddrake 397 Master Poster

you are asking your application to do a lot of changing, but you aren't telling i that it needs to repaint. after you change the opacity you should call either this.Invalidate(true); which will cause the form to repaint when but only as seen fit by the system. this is typically a good enough approach, but. since you are being aggressive about it, you will need to call this.Refresh(); which will cause an immediate repainting but will probably flicker if not doublebuffered.

a further note, you will want to stop your opacity at .99 not ever reaching 1. when you switch between partial opacity and opaque, where will be an unavoidable flicker. the easiest way around this is just going almost opaque, .99 opacity looks opaque, without the flicker.

good luck with you app.

Diamonddrake 397 Master Poster

I think sknake posted a good snippet on a different question here on this forum, when I get a chance I will find it for you. also. it depends what you are searching through. will it be a list of objects?

Diamonddrake 397 Master Poster

well I can tell you Google didn't write it. they based their entire empire on something they paid for with petty pocket change.

Its a great system, they have evolved the original algorithm a bit. It is unclear to me why you would post this question in the C# forum. if you were wanting to create your own web search system there is an asp.net daniweb forum. if you are interested in setting up a windows forms search system there is a keyword scoring system that can be used to do a pretty good search.

Diamonddrake 397 Master Poster

I am still not sure, your screenshot shows widows explorer while editing the name of a folder, if you wish to pass the name of a rightclicked folder to a program you don't need it when editing text.

you can modify the registry's HKEY_CLASSES_ROOT. it has a key named FOLDER you can add a command to that easily that will make rightclicking on a folder give you the ability to open your program passing to it that folder.

here is a codeproject example:

http://www.codeproject.com/KB/cs/appendmenu.aspx

otherwise it is unclear of your goals. I hope this helps.

Diamonddrake 397 Master Poster
Diamonddrake 397 Master Poster

well I am sorry to say, this isn't exactly beginner type programming. Its a goal to work toward, break it into small pieces, get each part of the concepts working, then bring them together.

but I am sorry, I can't really help you much with it, as I'm not a great network programmer. Best of luck to you and your application.

Diamonddrake 397 Master Poster

This is not my area of expertise, but I think I can give you some ideas if anything.

A good start would be developing a client/server type application, the server would run on the computer you want controlled, or accessed from the outside, the client would be a standalone app you could use on any internet connected computer to access your server computer.

the server app should wait for a connection attempt and once successfully connected broadcast general information about the system to the client as requested. cursor position, active windows, directory information. there are windows apis you can import that will let you tell the system to click the mouse, release the mouse, ect.

of course the true MS remote desktop logs you in as the user, and lots the local user out, that type of concept I wouldn't know where to begin, but as for controlling the mouse and seeing the screen via a networked computer, it wouldn't bee to amazingly difficult.

Diamonddrake 397 Master Poster

thanks also diamonddrake for the quick reply but i prefer the solution antenka found because i do not need to draw a whole new arrow i just call base.drawarrow and presto fresh arrow

yeah. its a much simpler solution.

Diamonddrake 397 Master Poster

very simple solution, just use GDI+ to draw a new arrow :)

at the end just throw in

//e.Graphics.FillPolygon(Brushes.Black, new Point[]{new Point([I]x, y[/I]), new Point([I]x, y[/I]), new Point([I]x,y[/I])});

specify the points as needed. since you only pass 3 points you get a triangle, if two points have the same Y value, and the third point's x value is half way between the first 2 X values then you get a downward facing arrow, which I think is what you want.

now Im not sure what look you were going for so I didn't put in any values here, but I am sure if you are custom drawing your own controls you will be able to figure out the points yourself.

Best of luck. :)


Alternatively, the actual reason that the arrow isn't drawn is because you override the method that calls the method that draws it. called "drawarrow" from the base class, here is an excerpt from the code on the link that Antenka posted above me.

class MyRender : ToolStripRenderer
{
protected override void
OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs e)
{
base.OnRenderSplitButtonBackground(e);
ToolStripSplitButton item = e.Item as ToolStripSplitButton;
base.DrawArrow(new
ToolStripArrowRenderEventArgs(e.Graphics, item, item.DropDownButtonBounds,
SystemColors.ControlText, ArrowDirection.Down));
}
}
Diamonddrake 397 Master Poster

You aren't technically posting in the right place, that appears to be a asp.net question written in C#, there is an asp.net forum here at daniweb for that. you might get better help there.

the error states your code should have the <%runat="server"%> tag.

but it could also be that you didn't name your button with the "name" property, and also your click event code is incorrect. the correct syntax for adding a button click event in C# is button1.Click +=new EventHandler(button1_Click); but I cannot be sure, as I don't frequently use asp.net, my web server only supports classic asp. and I write C# forms applications.

best of luck.

Diamonddrake 397 Master Poster

setting any variables as public is considered no longer acceptable in 3.5. because in theory the variable could be attempted to be read from or written to at the same time crashing the app, now you can still do it, the get and set methods are built into .net that let the variable call check if its beeing accessed and wait if it is.

also, setting an objects reference to static is used so that if multiple usergamecontrol objects existed, that object would have the same values throughout all the instances. it should only be used if multiple objects of the same type are expected to always have the same value as the other instances... as far as I can tell, no a static reference isn't a good idea here. just set it to public should be enough, and a property to expose it would technically do the same thing, just be more modern object oriented programming.

glad you got it working!

Best of luck.

DdoubleD commented: good follow up +3
Diamonddrake 397 Master Poster

Sorry, I don't have much time to reply right now. but the reason that the "this" is throwing an error is because using "this" in the context I provided needs to be within a function and not directly in the class.

so you would have to create a variable to hold the instance directly in the class

MindMasterColourForm ColourForm;

then inside a method of some sort, for example the load event of the usergamecontrol create the instance and pass the "this" argument

ColourForm = new MindMasterColourForm(this);

sorry for the confusion. if you are still having trouble I will come back later and try to explain better and maybe post an example project to show you how it could work.

Diamonddrake 397 Master Poster

Apparently up on terms of properties, constructors, and passing references...

you almost got it. the first code chuck i presented was an example of how to set a private control accesible by a public property, you would need to substitute in the type and private control you wanted to expose, in the example I used type of panel, and a non existant panel called mypanel.

the 2nd 2 were actually cut and paste working code.
since in your usergameControl you created the colorform, you tell it which instance of the usergamecontrol you want to access.

in the last codebit I created a variable of type usergamecontorl to hold the reference of the instance to the control. and the public MindMasterColourForm(UserControlGame ucgParam) part is where you capture that "(this)" reference and then its set to that variable we created.

now ugc is a variable that refers to that usergamecontrol instance in all of your color form, so you can access all the public properties using ugc.Proptertynamehere and you set the controls you need availabe using the first code block I posted about creating public properties...

sorry I can't explain better I am actually in a big hurry... best luck and happy coding.

Diamonddrake 397 Master Poster

ok, first thing you need to do is set all the controls you need access to from the outside as properties.

example

public Panel thepanel
{
get
{
return mypanel;
}
set
{
mypanel = value;
}
}

this will let objects see your controls and access them easily.

then all you have to do is pass a reference to the usercontrol to the constructor of the color form like so

MindMasterColourForm ColourForm = new MindMasterColourForm(this);

then catch that in the constructor of the mindmastercolourform

UserControlGame ucg;
        public MindMasterColourForm(UserControlGame ucgParam)
        {
            InitializeComponent();

           ucg = ucgParam;
        }

then when you need a control from the colourform you can access it via its property like so

ucg.thepanel.Location.X;
//or whatever you want to do with it.
Diamonddrake 397 Master Poster

Sorry papanyquiL, apparently I should reload my tabs more often, I had this tab open an hour before I got around to answering, lol, I guess I am over multitasking...

Below is the almost identical answer as above lol, and daniweb doesn't have a delete button, just an edit.

You have a while loop going, its looking for qty to be -1. since your loop never changes the value of qty. it is allays whatever it was set to during read-line, which happens before the loop is created.

since qty is never set to -1 its just going to loop forever.

obviously you just want to check first if qty is -1. so you are better off just using an if statement.

static void Main(string[] args)
{
int qty, prodNum;
double totalRetail;

Console.WriteLine("Enter product number 1, 2, or 3. ");
prodNum = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Enter in quantity sold of this product or enter -1 to quit: ");
qty = Convert.ToInt32(Console.ReadLine());
totalRetail = 0;
if(qty == -1)
{
Console.WriteLine("Exiting app...");
return;
}

switch (prodNum)
{
case 1 :
totalRetail = 2.98 * qty;
break;
case 2:
totalRetail = 4.50 * qty;
break;
case 3:
totalRetail = 9.98 * qty;
break;

Console.WriteLine("Total Sales: {0:C}", totalRetail);
}

}
}
}

try this instead.

Diamonddrake 397 Master Poster

Ok, the simple solution is to have your program save the embedded resource swf movie to disk if it doesn't' already exist. then pass the path to your load movie function.

more importantly, instead of using the loadMovie function, the appropriate way to load a flash movie is using the axShockwaveFlash.Movie property.

now using that there is a more complicated way to go about it, if you set embedmove to true, when the program is ran, it will embed the movie into the control itself. so the movie is playing from memory not disk. unfortunately, this happens at run time and not compile time. although I heard that some people have found ways to make it work.

for now, stick with answer 1.

sknake commented: well said +15
Diamonddrake 397 Master Poster

the image returned will be the same size as the rectangle it was cropped from, not the original image, as for any other problem. you might want to look at how the cropping rectangle is created.

The code you have posted looks sound, there is no reason why it shouldn't work, aside from the croppedAreaRectangle. that's probably where the problem is.

Diamonddrake 397 Master Poster

Oh yes! I forgot to answer the "official" question about diagonal lines! lol

ok here's the dig, pixels don't have to be square! they can be rectangular!
but as far as images in .net 3.5 are concerned, there are only square pixles. (even if you have a funny screen resolution and the pixels are stretched, they are still offically square in a .net Image)

to test this just check the horizontalResolution and VerticalResolution of the image, you of course will get 96 for both, showing you that the pixels are square. This means, using our rule, that a line 300 px long drawn on a new bitmap will always be 3.125 in long on paper, REGARDLESS of what direction it goes, be it vertical, horizontal, diagonal, 10 degrees or 70 degrees!

Best of luck!

sknake commented: excellent answer +14
Diamonddrake 397 Master Poster

Welcome my friend to the most complicated question you may have ever asked. but I am here to show you the way!

First off, all drawing in GDI+ is done based on pixels... now that means nothing to a printer, because of a little concept called pixel density! better known as dots per inch, or! DPI!!!

now DPI varies from display to display. and according to printer settings! so in theory, if your printer was set up to directly print whatever you sent to it... and you drew a 300 px line, and printed it at a 300 DPI you would then have a 1 inch long line!

but wait!!! that means every picture you printed off the web would look like a postage stamp! YUK!!!

that's because we forgot about resolution... now the resolution of an image is how many Pixels there are in any given unit of measurement.
standard web resolution is 72 pixels per inch. so if your line is 300 px wide, and the printer is set to a DPI of 300 the actual print size on paper would be approximately 4.2 inches!

now to keep things looking consistent printer drivers scale images based on their resolution and DPI, so images of the same pixel size always come out the same size on paper, they just look better with more dots. so ignore the target printer DPI settings in your battle to create print graphics.

you need to focus …

Diamonddrake 397 Master Poster

Glad i could help, and as for the padding, just place the control the distance from the anchored sides that you want it to stay, and then the anchor property handles it for you , it will stay the same distance from the anchored edges at all times.

Diamonddrake 397 Master Poster

ok lets jump off this dock.

the X and Y properties of a location type cannot be set directly. so no you can't set them that way.

the "anchor" property should do what you want, but only if the position of your controls is set prior to the setting of the anchor property. ( in code execution order)
that looks something like this. Control.Anchor = AnchorStyles.Top | AnchorStyles.Right the control.Right property is "get" only. that means it tells you the distance in pixels from the right edge of the control to the right edge of the parent control, you can't set it because its actually just a calculation, it doesn't point toward an actual variable. it looks something like this...

Public Int string Right()
{ 
get
{
     return (this.Location.X + this.Width) - this.Parent.Width;
}
}

So setting it will fail.


you can also manually stick a control to the top right corner using the forms on resize event, but the anchor property does just fine.

ddanbe commented: Good explanation! +13
Diamonddrake 397 Master Poster

I just wanted to mention, if you still were having troubles with this you could look into the class drawreversibleframe, is what is used to draw selection rectangles, so long as you are only drawing rectangles it will draw on top of controls. although you don't get definite choice of color...

Diamonddrake 397 Master Poster

Its not in a class, the method has to be interloped from shell32.dll

here's an example on codeproject http://www.codeproject.com/KB/cs/iconhandler.aspx

Please try and search google for answers before posting questions in our forums. they tend to get crowded with links to codeproject or dream in code.

Diamonddrake 397 Master Poster

not even that complicated. if your control inherits from Control, or UserControl just throw this code in the constructor of your controls.

this.SetStyle(ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | 
    ControlStyles.AllPaintingInWmPaint | ControlStyles.SupportsTransparentBackColor,
    true);

feel free to remove any of those flags you want, the OptimizedDoubleBuffer is the one that does the magic, of course all the others help make things look nice too. but the transparentbackcolor you might not need in this instance.

.net then handles all the double buffering for you, of course you could do it manually, but why bother when .net does it for you.

Diamonddrake 397 Master Poster

Scott he's not using the form's graphics object because he needs to draw in front of them so he's drawing to the screen.

back to the OP.
I messed with you example the object not set to an instance of an object error is something trivial happened when moving the code probably, wouldn't worry about that.

I couldn't seem to force an out of memory exception though. just didn't' happen. and I messed with it a lot.

as for all your flicker, you will need to user draw all the user controls that are being refreshed and double buffer them. but that's not your problem at hand.

1 thing you have the using block and still call G.Dispose, not necessary but shouldn't cause a problem.

another when you call refresh in the mouse move it is actually refreshing the entire control and all the child controls it contains. it could be any of the child controls causing the problem when they are painted. as many of these controls appear to be custom drawn you might want to go back and check all of their paint events to see if the leak is there.

I hope this helps. seems you are doing a great job so far.

Diamonddrake 397 Master Poster

you could try a Using statement on the graphics object. but Its clearly disposed in the example I posted. are you sure you didn't omit the g.dispose(); call?

you could try making sure it goes out of scope by using a "using" block example:

[DllImport("User32.dll")]

        public static extern IntPtr GetDC(IntPtr hwnd);

        [DllImport("User32.dll")]

        public static extern void ReleaseDC(IntPtr dc);

        protected override void OnPaint(PaintEventArgs e)
        {


            IntPtr desktopDC = GetDC(IntPtr.Zero);

            Using(Graphics g = Graphics.FromHdc(desktopDC))
{
            SolidBrush b = new SolidBrush(Color.Blue);
            g.FillEllipse(b, 0, 0, 800, 600);

            
}
            ReleaseDC(desktopDC);

        }

that might help, also Im not sure where you are refreshing but I recomend control.Invalidate(true); because it allows windows to decide if its a good time to redraw instead of demanding that it is done now. although refresh might get you a more consistent look. you might try it to see if it increases performance.

best of luck with you Control. tell me how it goes. I always say I am going to do stuff like this but Im lazy, as soon as I figure out how its done, I get bored and do something else.

Diamonddrake 397 Master Poster

To answer the OP's question, Keyloggers could be written in any language, although it will require some simple calls to the windows API. If you have any experience in programming I don't see how you could have any problem with such a simple thing. any of the guys here could produce a key logger application in 20 minutes complete with silent install.

But I agree completely. It's not a good idea, and we don't want to help you spy on your girlfriend. Knowing what some one types out of context isn't a good basis of anything anyway.

you want to keep people's kids safe, write an application that kills browser processes as soon as they are started, then runs a new instance of a 2nd program that is a "safe" browser specially written to only allow access to safe domains.

Do anything besides write a privacy destroying application. and yeah, its a password stealing concept, just thing of the log...
Log:
www.bankaccount.comuser@yahoo.com TAB password
that's what will happen about a thousand times a day, a NOONE deserves to know your passwords to ANYTHING.

Diamonddrake 397 Master Poster

sorry that line is unnecessary. but scratch that code. its works great just you will never see its effect because the desktop invalidates all the other windows and its just immediately erases it.

[DllImport("User32.dll")]

        public static extern IntPtr GetDC(IntPtr hwnd);

        [DllImport("User32.dll")]

        public static extern void ReleaseDC(IntPtr dc);

        protected override void OnPaint(PaintEventArgs e)
        {

            SolidBrush b = new SolidBrush(Color.Blue);


            IntPtr desktopDC = GetDC(IntPtr.Zero);

            Graphics g = Graphics.FromHdc(desktopDC);

            g.FillEllipse(b, 0, 0, 800, 600);

            g.Dispose();

            ReleaseDC(desktopDC);

        }

just paste this into a new form. add
using System.Drawing.Drawing2D;
using System.Runtime.InteropServices;
to the top of the cs file.

you will see its effect. this will get you started down the long and complicated road. Have fun. sorry for the problematic code I posted before.

Diamonddrake 397 Master Poster

you don't use hotkeys for mouse events... for that you will have to use a low level "hook" not too hard.

here is an article that should get you on your way

http://www.codeproject.com/KB/cs/globalhook.aspx

Diamonddrake 397 Master Poster

That is a pretty good article adatapost, but keep in mind. The problem with "registering" a hot key using those functions, is that there is only 1 windows message for a hotkey that is passed to your application. that is to say if you register 10 different hotkeys, they will all fire the same function. so you must them get event data to determine the pressed key, and handle it accordingly. so its a bit more complicated that that article intails. it also doesn't go into detail about catching the messages. a simple solution would be just to override WndProc and check for the hotkey message, then if so get the key pressed with

Keys key = (Keys)(((int)message.LParam >> 16) & 0xFFFF);
                    KeyModifiers modifier = (KeyModifiers)((int)message.LParam & 0xFFFF);
//where keymodifiers is an enum of modifier keys

then compare it to keys you have set most likely in a custom collection.

A good practice if you wish to put all the code in a separate class would be to create a class that inherits from NativeWindow, it accepts a property of the form handle that it should regulate, then you can override the wndproc method there, cleanly and out of the way. you can also create a custom event args class that contains values for keys and modifiers, and create a custom event called hotkeypressed or something like that, and have it accepts your custom event args. have a class that registers your hotkeys, and creates your native window …

serkan sendur commented: chic +7