Changing the start up location of a WPF window

Just set WindowStartupLocation, Height, Width, Left, and Top in xaml: <Window x:Class=”WpfApplication1.Window1″ xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” Title=”Window1″ Height=”500″ Width=”500″ WindowStartupLocation=”Manual” Left=”0″ Top=”0″> </Window>

Combine onload and onresize (jQuery)

You can bind to the resize event alone, and trigger this event automatically upon load: // Bind to the resize event of the window object $(window).on(“resize”, function () { // Set .right’s width to the window width minus 480 pixels $(“.content .right”).width( $(this).width() – 480 ); // Invoke the resize event immediately }).resize(); The last … Read more

WPF Icon for all app windows

A good reference on the subject is here MSDN. States that you have an Icon for the Application (Desktop Icon), and one for each Window. A WPF window always displays an icon. When one is not provided by setting Icon, WPF chooses an icon to display based on the following rules: Use the assembly icon, … Read more

.NET / Windows Forms: remember windows size and location

If you add this code to your FormClosing event handler: if (WindowState == FormWindowState.Maximized) { Properties.Settings.Default.Location = RestoreBounds.Location; Properties.Settings.Default.Size = RestoreBounds.Size; Properties.Settings.Default.Maximised = true; Properties.Settings.Default.Minimised = false; } else if (WindowState == FormWindowState.Normal) { Properties.Settings.Default.Location = Location; Properties.Settings.Default.Size = Size; Properties.Settings.Default.Maximised = false; Properties.Settings.Default.Minimised = false; } else { Properties.Settings.Default.Location = RestoreBounds.Location; Properties.Settings.Default.Size = RestoreBounds.Size; … Read more

JavaScript – Get Browser Height

You’ll want something like this, taken from http://www.howtocreate.co.uk/tutorials/javascript/browserwindow function alertSize() { var myWidth = 0, myHeight = 0; if( typeof( window.innerWidth ) == ‘number’ ) { //Non-IE myWidth = window.innerWidth; myHeight = window.innerHeight; } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { //IE 6+ in ‘standards compliant mode’ myWidth = document.documentElement.clientWidth; myHeight … Read more

Foreground Vs Active window

The active window (the result of GetActiveWindow()) is the window attached to the calling thread that gets input. The foreground window (the result of of GetForegroundWindow()) is the window that’s currently getting input regardless of its relationship to the calling thread. The active window is essentially localized to your application; the foreground window is global … Read more

Loading a WPF Window without showing it

If you are targeting .NET 4.0 you can make use of the new EnsureHandle method available on the WindowInteropHelper: public void InitHwnd() { var helper = new WindowInteropHelper(this); helper.EnsureHandle(); } (thanks to Thomas Levesque for pointing this out.) If you are targeting an older version of the .NET Framework, the easiest way is to show … Read more

JavaScript, browsers, window close – send an AJAX request or run a script on window closing

Updated 2021 TL;DR Beacon API is the solution to this issue (on almost every browser). A beacon request is supposed to complete even if the user exits the page. When should you trigger your Beacon request ? This will depend on your usecase. If you are looking to catch any user exit, visibilitychange (not unload) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)