Diamonddrake 397 Master Poster

I would use a service from a web gateway company like websense that filters out questionable material. Or if I didnt want to pay big bucks I would write a proxy server app that blocks questionable websites and route all the computers in the cafe through it. with an optional override. displaying a message saying that the page has been blocked and if the user doesn't think that it should be have them tell the site url to the attendant and have him check it, if its clean they can use a 1 time password to access the site, or the attendant can optionally add it to the allow list on the proxy, or remove it from the deny list. or depending on how the proxy is written add it to the exceptions list.

and as for "the hardware owner is responsible for what their hardware is used for." if you had a lawyer write up a End user license agreement that displayed as the users first logged on and a click to accept button then you could have them digitally sign a contract saying that they alone are liable for their actions. Very similar to the "Skate at your own risk.!" Sign at skating rinks. under most circumstances if someone gets hurt at your business then you are liable, unless its posted that upon entering that one assumes responsibility for their own safety, then suddenly its not the business owner's problem. simply because there was a sign.

kvprajapati commented: helpful!! +7
Diamonddrake 397 Master Poster

SQL lite its a server technology that has to be installed on the system to use. MS access requires nothing to be additionally installed. that's what I like about it. Although, its not optimal for heavy usage for many simultaneous users, That's why most people speak poorly of it. But if the database only needs to be accessed by 1 computer/ user at a time. Its a pretty good system. I used it for a program that helps track my bills. 2GB worth of data now and still working strong. Even used it to store information for the guest book on my website.

The only problem with these new OSes such as Vista and 7 is your application cannot write to the Program Files directories. So remember once your application gets chugging along to save the Database in a document folder!

Diamonddrake 397 Master Poster

MSAccess requires nothing to be installed. SQLlite requires SQL lite server to be installed. But if you really want to make the switch just duplicate the tables in the new database and write a little loop that gets all the info from the first database table and creates objects in a list. then loop through the list and save the objects to the new database.

Should be pretty simple.

Diamonddrake 397 Master Poster

Using resources can be easily updated if you use an "languages" dll and have your app check for update versions from a webserver. but the XML approach isn't a bad one, just its important for speed that you don't access the file every time you need the information. Disk access is slow and so is parsing XML. if the form has a lot of text on it there could be a delay of opening a new form which can be annoying.

If you create an object in your application with all static members that match your language text, at application start you can check the language of the OS or Language setting and load all the information to the Language object then when new forms open you can use the Language object to get the necessary text.

But to each their own. I don't think there is a "best way" but there are many good ways. if you wanted to be far fetched you could use one of those google translation apis and have your application make web queries and just translate the English version on the fly using the web and instantly support any translation that api does. I wouldn't recommend it, but it could work. :)

Diamonddrake 397 Master Poster

Firstly, you are not specifying a path for your text file, just a file name, this is bad and can lead to an error. you should always specify a full path.

this write the data to a text file, then loads it back and uses its contents to fill the listview, if this code update the listview then you ARE saving it to the file.

You need to separate this, on form close loop through the listview items and write them to a file. on form load loop through the text file and load it to the listview.

but there is a more OOP way to go about it. Create an object that represents a contact, with 3 strings name, number, and address, as a property. Then create a list of those objects and use that as a source for your listview and serialize it to a XML file on save, deserialize it on open.

Diamonddrake 397 Master Poster

using the async load of the picturebox will work to an extent but eventually you will have loaded a ton of full size pictures into memory unnecessarily slowing down the system. alternatively you should consider creating a control from scratch that asynchronously reads the images from disk and creates a new image in the size you need and save it in a variable and on paint draw it to the surface of the control.

as for the threading the load, a thread pool would be the most efficient on a multiprocessor system, but otherwise a single worker thread should do fine. having the worker thread load the images, resize them, create the control, add the image to it and the pass that control object to the gui thread to be added to a container.

Diamonddrake 397 Master Poster

Icons for menu strips are 16px X 16px, and this is the default size for the Imagelist control.

Standard application icons contain 16x16, 32x32, 48x48 and in Vista and Win 7 they added 256x256.

Tool bar icons are also typically 16x16 But the developer has complete control over that decision. You can create Icons in any size you see fit and use them in your applications. 24x24 is a popular toolbar icon size based on that decision. But as monitors get larger, and screen resolutions get larger, icons will continue to get larger as well to compensate.

Diamonddrake 397 Master Poster

In vista and win 7 so long as User Account Control is turned on you will be prompted, a much better approach would be to check if the current app is running as an admin and if not request that it is, then restart it, then check again, that way the program won't get any further until they user accepts making it run as admin.

Then just remember that any program started by a program with administrative privileges will have administrative privileges.

Here is the simplest way, the ultimate solution.

first add these namespaces

using Microsoft.Win32;
using System.Security.Principal;

then to the onload event of the first form add this

WindowsPrincipal pricipal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
            bool hasAdministrativeRight = pricipal.IsInRole(WindowsBuiltInRole.Administrator);

            if (hasAdministrativeRight)
            {

            }
            else
            {
                if (MessageBox.Show("This application requires admin privilages.\nClick Ok to elevate or Cancel to exit.", "Elevate?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    ProcessStartInfo processInfo = new ProcessStartInfo();
                    processInfo.Verb = "runas";
                    processInfo.FileName = Application.ExecutablePath;
                    try
                    {
                        Process.Start(processInfo);
                    }
                    catch (Win32Exception ex)
                    {
                        Application.Exit();
                    }

                    Application.Exit();

                }
                else
                {
                    Application.Exit();
                }
            }

The key here is the "runas" verb. this tells the system you want to run the current application as admin.

Now, assuming you just want to run a single child app as admin you just use a startinfo object using the verb "runas"

example as follows

ProcessStartInfo startInfo = new ProcessStartInfo()
            startInfo.FileName = @"pathgoeshere";
            startInfo.Verb = "runas";
            startInfo.Arguments = "anyargshere"; //feel free to lose this line

            Process p = new Process(); …
sknake commented: excellent +6
Diamonddrake 397 Master Poster

Interesting facts, If you have ever programed a console game, the entire idea is to create a game loop, that repeats until the game win conditions are met.

but i would say if you disable the buttons that affect your loop, doEvents shouldn't cause a problem. Microsofts documentations actually show how to use this method by using it in a load file loop. http://msdn.microsoft.com/en-us/library/system.windows.forms.application.doevents.aspx

Some Q and A from Microsoft:

Q: Why is DoEvents in the BCL namespace?

A: Glenn (Microsoft) Threading is difficult, and should be avoided if there's an easier way. If all you need to do is yield on your UI thread, DoEvents is perfect.

Q: DoEvents is evil?

A: Glenn (Microsoft) Yielding on the UI thread is a legitimate Windows programming practice. It always has been. DoEvents makes it easy, because the situations in which you need to use it are simple.

The biggest problem with doevents is it leaves the possibility to re-enable your current loop via the interface, but you can simply disable the button while the loop is in place.

Threading is hard, using a background worker can be simple. But its wrapping something so much more complicated and dangerous to you application.

Quote from codinghorror.com:

"You've never truly debugged an app until you've struggled with an obscure threading issue. Threading is a manly approach for tough guys, and it will put hair on your chest-- but you may not have …

ddanbe commented: Nice! +6
Diamonddrake 397 Master Poster

when you use taskmanager to "kill" the appliction, it doesn't fire any events, It simply stops the execution, This is how you close an application that has frozen. if you waited for it to handle any events, then it would still be frozen.

as for when you restart the computer or shutdown, the event will be called only if there is enough time, they system tells all applications it is shutting down and only gives them a short amount of time to handle business before it kills them. Windows 7 will show a dialog telling you which applications are still busy and ask you if you want to kill them and shutdown, or cancel. But as for XP, it just kills them after X amount of seconds.

Diamonddrake 397 Master Poster

if all you need is 1 key, then a simple hotkey would serve very nicely.

First Import the native methods you need.

//API Imports
        [DllImport("user32.dll", SetLastError = true)]
        public static extern bool RegisterHotKey(
            IntPtr hWnd, // handle to window    
            int id, // hot key identifier    
            KeyModifiers fsModifiers, // key-modifier options    
            Keys vk    // virtual-key code    
            );

        [DllImport("user32.dll", SetLastError = true)]
        public static extern bool UnregisterHotKey(
            IntPtr hWnd, // handle to window    
            int id      // hot key identifier    
            );

Create a enum to easily understand what key modifiers are used and a constant to hold the ID of the hotkey.

//const int HOTKEY_ID = 31197;    //any number to be used as an id within this app
        const int WM_HOTKEY = 0x0312;

        public enum KeyModifiers        //enum to call 3rd parameter of RegisterHotKey easily
        {
            None = 0,
            Alt = 1,
            Control = 2,
            Shift = 4,
            Windows = 8
        }

so we just create the hotkey bind on load, or whatever you need.

RegisterHotKey(this.Handle, HID, KeyModifiers.None, Keys.F11)

note, the hotkey ID is just just used to unregister the hot key

UnregisterHotKey(this.Handle, HID);

now we just check the WndProc to listen for our hotkey call!

const int WM_HOTKEY = 0x0312;//windows hotkey constant
        protected override void WndProc(ref Message message)
        {
           if (message.Msg == WM_HOTKEY)
            {
                   //there is your event, do whatever you like here.
            }
            base.WndProc(ref message);
        }

This is a simple hotkey, That's it, nothing else, nothing complicated. Now, you can make it complicated, if you wished. …

Diamonddrake 397 Master Poster

Shouldn't be anything more complicated than

Form1 F = new Form1();
            F.Show();
            F.SetDesktopLocation(Cursor.Position.X, Cursor.Position.Y);

if you use Control.MousePosition you will have to convert pointtoscreen.

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

public variables are not thread safe, the get and set properties make sure that a variable isn't in use by locking it temporarily an if is locked, causing a pause to occur until it is free. Its just the preferred way the framework handles variable access. with a simple bool value its easiest to do a Pubic Bool varname {get; set;} nothing complicated and it makes the system happy.

but if you want to use public variables that's up to you. Its obviously acceptable by the compiler, the code will run. in other languages every object is accessible from any other and there is no Public-Private mumbo jumbo.

Diamonddrake 397 Master Poster

Just add a trackbar with a min of 1 and a max of 4 then add a event handler for onchanged and update a label by dividing its max value by its current value you will get a percentage as a decimal, then multiply by 100 and add a % sign.

label1.Text = ((trackBar.Value / trackBar.Maximum) * 100) + "%";

if the slider was at 2, with a max of 4 then 2/4 = .5 and .5 X 100 = 50

Anyway, I am including a working project Example in VisualStudio 2008 Format.

Diamonddrake 397 Master Poster

1) When does Form1_Paint(..) called ?
Its called when the form needs to be repainted, see 2

2) When does the Paint event of the form is raised ?
The paint of a control, or form is called when a portion of that object is invalidated or refreshed, which simply means that when windows thinks that part of the screen is no longer accurate, either by passing the WM_PAINT message to the form, or by code on the form itself requesting that it happen.

3) Why the Paint event is raised when I run the application ?
Because the paint event is responsible for drawing the graphics that appear on the control or form, since the application was just opened, its obviously not painted, so It calls Paint()

4) Why the circle is actually drawn on the form ? i.e. what is the relationship between the form class, the "PaintEventArgs e" argument, and the "e.Graphics" object ?

the reason the circle is drawn on the form is because you used the form's paint event. Which means that the PaintEventArgs class that is passed to the handler holds a graphics object that was created for that control (in this case form, forms inherit from control) so when you use the parm, "e" and get its Graphics object, that object is actually the Graphics object of the form, so when you call a drawing method from that object it will always relate to that form.

Diamonddrake 397 Master Poster

you could in theory take your image and load it in as a byte array, not as an image, sift through the bytes and find the start of the image data, then apply them there, but idk what the results would be. but other than that. there isn't sorry.

TotoTitus commented: Very relevant. +1
Diamonddrake 397 Master Poster

your extention was jpg but the image was NOT a jpeg. extensions mean nothing. Listen.

1. If you want to preserve your changes you cannot compress it, because compression codecs change those values.

2. Saving as a BMP is uncompressed, So it will work, but the file will be big.

3. if the file is big, then its uncompressed, and your data is preserved, if the file is small, then its compressed and you WILL LOOSE YOUR CHANGES

sorry that's how Imaging works.

Diamonddrake 397 Master Poster

sending information over a network is done using a stream. you write bytes to it. these bytes can be anything. Text, audio, pictures, whatever. Its simple, just find a way to compress your audio, but once compressed, instead of writing it to a file stream, write it to your network stream.

then on the receiving end, decompress you buffer and use it. If it is more important the audio be fast and not perfect then I suggest UDP over TCP but that's trivial. I don't have any free time to provide any code or further suggestions, but I hope this helps.

Diamonddrake 397 Master Poster

an Idea would be to draw the graph to a bitmap. Then display the bitmap, and just modify one of those 10,000 zooming picturebox controls floating around the net.

Diamonddrake 397 Master Poster

there is no fool proof way, but you could embed the videos into the application, when you needed to play them create a memory stream from the resource and play it from there, or copy it to temp, play it then delete it afterwards.

the only tactical way would be to create your own video codec that has custom drm, and only allow it to be played via a code your application has.

Even then, a crafty pc user could always find a way to copy it. There is a FREE utility out now that lets your copy blu-ray disk. Your asking a hard question.

kvprajapati commented: Very good suggestion. +6
Diamonddrake 397 Master Poster

That's really up to the programmer. If you work for a company that expects this, then its up to them, but if you are just writing software by your self it doesn't really matter.

The big selling point of putting logic in classes is portability. once you have written it once, you can easily use it in other applications. another thing is it keeps your code organized, so in a large application its easier to find and edit your code.

but writing a class for 10 lines of code that could easily be condensed into 5, that's just silly.

Diamonddrake 397 Master Poster

Don't you love those people who obviously just joined the forum for the single purpose of asking a complicated question in a manner that makes it seem just a simple as "which way is the bathroom?"

Reminds me of when I first started programming. Once you get into the mindset. You look a problems completely different. And the questions you ask are much more refined. But sometimes its the difference between "Do you know were I could get some lumber and a hammer?" and "I would like one(1) free house please."
lol.


as for the OP. Glad024 try you some of this http://www.devhood.com/tutorials/tutorial_details.aspx?tutorial_id=576

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

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 decided to goahead and write that article for code project. Its still pending moderator approval but the link is :
http://www.codeproject.com/KB/cs/DDFormsFader.aspx

I wrote a user32 wrapper class that handles all the fading directly without messing with the .net wrapper at all. It works unbelievably well, and its incredibly easy to use. You might want to archive this for future use, and if you get a second check it out. I wrote more comments then code, so it should be really easy to follow and its very clean code.

still looking forward to seeing that app :)

Geekitygeek commented: very nice! Nothing worse than the dreaded flicker :p +1
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

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

that's really neat danny. Idk when i might ever need it. But I'll add it to my private code snippet library just in case. right next to that numbers only with 1 decimal point only textbox class.

Diamonddrake 397 Master Poster

Im not sure why you are using 2 executable for this. why not write a control that does its own scrolling text? not very difficult.

but you can easily create an event that when the background image of the panel changes just save it do disk and read it with the other application.

panel1.BackgroundImage.Save("C:\\myimage.bmp");

but why do you need 2 apps for this?

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

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
Button B = this.Controls[buttonname];

That should work for what you are looking for.
or you could add each control to a list and access it that way, I can think of a lot of ways, but this is the simplest.

ddanbe commented: As Einstein said: "Keep it simple, but not simpler" +13
sknake commented: most reliable way to go about it +15
Diamonddrake 397 Master Poster

I have been working on a custom Hue Slider, when you drag the knob the color of it changes to its hue value. (ex 0 is red). I added a little gloss to the knob, I feel its not done, I Just don't have any Ideas as to how to give it finishing touches...

any ideas people?
I would like it to look a little more professional.

image attached:

serkan sendur commented: good question +9
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

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

That's interesting sknake, I never would have thought of catching the close method like that.

But as far as all these answers go, the Simple response is the X button does only call the form to close. and however you catch that close call, either by wndproc or by a simple form closing event, the trick is to set a flag, just a simple Boolean variable, if its true, cancel the closing and handle your business, if its false, do nothing and allow the form to close.

when you need to call this.Close(); first change your variable. else you can create a public method for your form called DoClose() or something and change the flag there and call close, its up to you.

ddanbe commented: Simple things are often the best! +12
sknake commented: Thats what I would do +14
Diamonddrake 397 Master Poster

I would also like to point out that the code sknake posted is a "per machine" list of installed programs, some programs are installed on a "user" level and would not appear in this list.

also most MSI installed applications won't appear in this list either. I am not sure where they are all stored. But this method is no longer considered a solution.

serkan sendur commented: nice attendum +8
sknake commented: good addition +14
Diamonddrake 397 Master Poster

idk about authentication, but I have done much heavy scripting in flash, as far as I know, if a flash application is not scripted to accept external modifications of its variables. then you won't be able to.

but I could be wrong. if the variables are on the root of the flash movie, then its possible to use query strings or params to change them, but in that case your C# application would need to be showing the flash animation in a webcontrol, and not as a com object.

MOST important, there are sometimes 3 problems with what you are trying to do.

1. a well written flash game will be comprised of many different swf files, and need to be ran from the same directory.

2. a well secured flash game will check its domain for consistancy, and choose not to run unless its in its home.

3. some games use shared resources, in which multiple swfs must be loaded on screen simultaneously.( I one time saw a flash game that used the site logo from the site's header flash, and if they weren't on the same page the game would fail to load.)

best of luck.

ddanbe commented: Good explanation. +12
Diamonddrake 397 Master Poster

depends on what you consider a reference, a temporary one using reflection is the one only way without using a reference at design time.

here's an example
http://mahiways.spaces.live.com/Blog/cns!6A1F270FEA8CDD8C!338.entry

serkan sendur commented: nice idea +7
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

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

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
Diamonddrake 397 Master Poster

Do you have Microsoft office installed on your computer?

ddanbe commented: Indeed, not everyone has! +8
Diamonddrake 397 Master Poster

of course, set the formborderstyle to siziabletoolwidow. then simply change the controlbox property to false, then you get a titlebarless window. still the border, but I believe you can clip the display region by the client rectangle to get rid of the border. but as for the code involved, I'm not quite sure.

Diamonddrake 397 Master Poster

what is this webin object that is used to load the html? It seems to be already created before the function that calls the print. you could try creating it loading, printing, then disposing that object. Its likely that its still treating the file like its still in use even though you call its own method that seems to navigate away.

Just a though, if you haven't tried that yet.

Diamonddrake 397 Master Poster

The code ramy posted was sound. It had a little left to chance, but I don't see how anyone could have a problem with it.

I have included an example project, just compile it and click the button, then go back and read the code.

all credit to this code goes to ramy, I just copy and pasted it in, then modified it slightly to be more obvious in what was what.

Ramy Mahrous commented: Thanks :) +7
Diamonddrake 397 Master Poster

It is possible just to create a public method in the form and call it from the panel. though it makes the panel easier to reuse in other forms when you use an event. i'm not sure exactly how he was passing his data between the form and the panel, but another benefit to using an event is you can create a custom event args class, and pass any information you need to your event handler. This would prevent you from needing to create a large amount of properties to send information back to the form.

but in this case, either one would seem to work equally well.

ddanbe commented: Think your solution is better : custom event args... +6
Diamonddrake 397 Master Poster

you need to call the close() method from inside the login form's code...

just add the line to this section

//Open Main CRM Form
                    CRMMain crmMainForm = new CRMMain();
                    crmMainForm.employee = employee;
                    crmMainForm.Show();
                   [B]this.Close();[/B]//this will cause the login form
                   //close  after the main form is opened

otherwise you would need to pass the instance of the login form to the main form in order to reference it to close it. your code actually creates a new form, never shows it, but then closes it.

what is unnecessary, but you could do in that way would be make these changes...

//Open Main CRM Form
                    CRMMain crmMainForm = new CRMMain([B]this[/B]);
                    crmMainForm.employee = employee;
                    crmMainForm.Show();

then in the main form constructor reference that for a close like...

public CRMMain([B]Form lgfrm[/B])
        {
            InitializeComponent();
           [B]lfgrm.Close();[/B] 
        }

best of luck :)

Sailor_Jerry commented: Helped correct my code +4
Diamonddrake 397 Master Poster

This is actually a bit more tricky then its given credit. The problem is, when you run your first form, that is, in the program.cs file, you call Application.Run(new Form1); //or whatever the log in form is called.

It then becomes responsible for the thread, if you close it. Then the application exits. so if you want to Close the login form when you are done with it. your application will exit. To keep this from happening you have multiple viable solutions. you could run the main form (the one that will accept the login information) then hide it, and have it call and create the login form. then simply pass the data into the main from when the login is closed.

or, you could create the login form manually in the Main() method, then call Application.Run() with no args, and when you close any forms or all the forms, the program still runs, and then just create an event handler for you main form for onclosed and call Application.exit();

Now for something a little more advanced, you could created an applicationContext class, that would create all your forms for you, and run them in the pattern of your choosing, then pass that class to your Application.Run(ApplicationContext); method.

These are just some ways to handle it, there are more, but when it comes down to it. Its which ever best suits your application. But either way, its very important to remember, just because visual …

ddanbe commented: Closing the main form can be tricky, you explained why,thanks! +6
Diamonddrake 397 Master Poster

I have posted an example of what I was talking about, I just used that codeproject alphablendform and created a form that inherits from it, used a mousemove to set its position. But inorder to pass the click from one form to another, I had to use a mouse_event interlop to tell windows to release, then click again, without you actually have to do so. I added a picture box, set an image to it, then used some basic stuff to set the positon of the new form over the old text box, told it to create a thumbnail form the image, just incase its a zoomed picture, set the size of the new form to the size of the text box, set the dpp of the image to match requirements, and used bitmap.maketransparent to ensure it has a transparent region require for such a thing, this could all be done a better way, and is not error proof, its all just poped in for sake the demonstration.

the VS2008 project I included has the "debug" prebuilt in the bin folder, give it a try, just click and drag the image I included of a cupcake, it will pop out, be lightly transparent, I used 200 out of 255. and it will follow the mouse til you let go, in which case it just closes the new form. but you can do whatever you want, have it call a function in the main form passing where the mouse was …

ddanbe commented: Thanks for the effoet you put in! +6