Monthly Archives: May 2013

Move JavaScript files to footer in WordPress

Loading excessive JavaScript files in the header will usually slow down your website. This happens because while JavaScript files are loading the browser stops all the other operations till those files have been processed.

An easily solution to remedy that is to move all the .js files in the footer so they will start to load after all the graphical elements of the website have been loaded. In order to do this, open your theme’s functions.php file an place the following code at the bottom.

Note: Keep in mind that in some cases some plugins might rely on specific JavaScript files to be loaded in the header, so make sure to check that everything is working properly (no errors in the java console) after moving all the files in the footer.

Send email using C#

Sending emails using C# is fairly easy. You require the host or the IP of an SMTP server that the email will be send through and a username/password if that server requires credentials.

For this example I will be providing a way to send emails using the Gmail SMTP server.

Move borderless form using mouse

Forms that have their FormBorderStyle set to None cannot be moved using the mouse by default. In order to achieve this functionally we can use the ReleaseCapture and SendMessage Windows functions.

Simply place the following code in your borderless form class.

Don’t forget to assign your form’s MouseDown event to the form1_MouseDown method !

Keep in mind that you could handle another control’s MouseDown event (a good example would be a MenuStrip control) instead of the form’s one, making your form moveable only when the user clicks and drags that specific control.

Minimize a form without border using the taskbar

By default borderless forms are not designed to be minimized, which means when the form’s FormBorderStyle property is set to None you will notice that clicking the application box in taskbar does not minimize the form.

This can be fixed by overriding CreateParams and adding the WS_MINIMIZEBOX style to the Window and CS_DBLCLKS to the Window class styles.

Simply place the following code inside your Form’s class which you want to enable the minimize functionality using the taskbar.

Enable Double Buffering for Controls to reduce flickering

Some controls do not have their DoubleBuffered property listed in the properties window. For this reason it requires an additional step to enable double buffering for specific controls such as a ListView control.

If you wish to enable the DoubleBuffed property of a control simply use the method provided below.

Example