WinForms: Hide close button but show icon

Changing properties of the control box (so-called in Visual Studio) may have some undesireable side-effects:

  1. Setting the control box property to false hides all components in the title bar, expect the title itself. So there will be no icon in the title bar, only in the task bar.
  2. If you hide the maximize control (MaximizeBox), some problems regard resizing the application occur:
    • “aero snap” of your application isn’t visualized correctly (dragging it to the edge of your screen won’t resize the application).
    • Also double clicking the title bar to maximize the window won’t work.

The following shows some effort trying to hide the close button programatically. My conclusion on this AFAIK - it’s impossible.

virtual property System::Windows::Forms::CreateParams^ CreateParams
{
    System::Windows::Forms::CreateParams^ get() override
    {
        System::Windows::Forms::CreateParams^ overrideParams = Form::CreateParams;
        // Make your changes to overrideParams members here
        //overrideParams->ClassStyle = overrideParams->ClassStyle | 0×200; // only grayed it out
        overrideParams->Style &= ~0×80000; // like ControlBox set to false:
        return overrideParams;
    }
}

Only grayed it out:

using namespace System::Runtime::InteropServices;
[...]
#define SC_CLOSE 0xF060
#define MF_GRAYED 0×1
[...]
        // somewhere near initialization
        myform::EnableMenuItem(GetSystemMenu(this->Handle, false), SC_CLOSE, MF_GRAYED);
[...]
[DllImport("user32.dll")]
static IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);

[DllImport("user32.dll")]
static int EnableMenuItem(IntPtr hMenu, int wIDEnableItem, int wEnable);

VLC media player: set default audio language on the fly

The following describes how to make an alternative configuration file for VLC and a batch file to easily interchange settings.

 

  1. Copy C:\Users\JohnDoe\AppData\Roaming\vlc\vlcrc to C:\Users\JohnDoe\AppData\Roaming\vlc\vlcrc_alternative
  2. Edit vlrrc_alternative as desired (for example set #audio-track=-1 to #audio-track=1 to open the second audio track of a video as default)
  3. Create batch file (like SwitchAudioTrack.bat)
    @echo off
    taskkill /im vlc.exe /f
    ren vlcrc vlcrc_tmp
    ren vlcrc_alternative vlcrc
    ren vlcrc_tmp vlcrc_alternative

Et voilà.

TortoiseSVN: Disable/Enable context menu entries

You can temporarily disable the TortoiseSVN context menu with the following two registry files: Deposit them e.g. on your desktop and you can remove the entries by click.

DisableTortoiseSVN.reg

Windows Registry Editor Version 5.00
[-HKEY_CLASSES_ROOT\Folder\ShellEx\ContextMenuHandlers\TortoiseSVN]
[-HKEY_CLASSES_ROOT\Folder\ShellEx\DragDropHandlers\TortoiseSVN]
[-HKEY_CLASSES_ROOT\Drive\shellex\ContextMenuHandlers\TortoiseSVN]
[-HKEY_CLASSES_ROOT\Drive\shellex\PropertySheetHandlers\TortoiseSVN]
[-HKEY_CLASSES_ROOT\Directory\Background\shellex\ContextMenuHandlers\TortoiseSVN]
[-HKEY_CLASSES_ROOT\Directory\shellex\ContextMenuHandlers\TortoiseSVN]
[-HKEY_CLASSES_ROOT\Directory\shellex\CopyHookHandlers\TortoiseSVN]
[-HKEY_CLASSES_ROOT\Directory\shellex\DragDropHandlers\TortoiseSVN]
[-HKEY_CLASSES_ROOT\Directory\shellex\PropertySheetHandlers\TortoiseSVN]
[-HKEY_CLASSES_ROOT\*\shellex\PropertySheetHandlers\TortoiseSVN]
[-HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\TortoiseSVN]
[-HKEY_CLASSES_ROOT\lnkfile\shellex\ContextMenuHandlers\TortoiseSVN]
[-HKEY_CLASSES_ROOT\LibraryLocation\ShellEx\ContextMenuHandlers\TortoiseSVN]
[-HKEY_CLASSES_ROOT\LibraryFolder\background\shellex\ContextMenuHandlers\TortoiseSVN]

EnableTortoiseSVN.reg

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Folder\ShellEx\ContextMenuHandlers\TortoiseSVN]
@="{30351349-7B7D-4FCC-81B4-1E394CA267EB}"
[HKEY_CLASSES_ROOT\Folder\ShellEx\DragDropHandlers\TortoiseSVN]
@="{3035134A-7B7D-4FCC-81B4-1E394CA267EB}"
[HKEY_CLASSES_ROOT\Drive\shellex\ContextMenuHandlers\TortoiseSVN]
@="{30351349-7B7D-4FCC-81B4-1E394CA267EB}"
[HKEY_CLASSES_ROOT\Drive\shellex\PropertySheetHandlers\TortoiseSVN]
@="{30351349-7B7D-4FCC-81B4-1E394CA267EB}"
[HKEY_CLASSES_ROOT\Directory\Background\shellex\ContextMenuHandlers\TortoiseSVN]
@="{30351349-7B7D-4FCC-81B4-1E394CA267EB}"
[HKEY_CLASSES_ROOT\Directory\shellex\ContextMenuHandlers\TortoiseSVN]
@="{30351349-7B7D-4FCC-81B4-1E394CA267EB}"
[HKEY_CLASSES_ROOT\Directory\shellex\CopyHookHandlers\TortoiseSVN]
@="{30351349-7B7D-4FCC-81B4-1E394CA267EB}"
[HKEY_CLASSES_ROOT\Directory\shellex\DragDropHandlers\TortoiseSVN]
@="{3035134A-7B7D-4FCC-81B4-1E394CA267EB}"
[HKEY_CLASSES_ROOT\Directory\shellex\PropertySheetHandlers\TortoiseSVN]
@="{30351349-7B7D-4FCC-81B4-1E394CA267EB}"
[HKEY_CLASSES_ROOT\*\shellex\PropertySheetHandlers\TortoiseSVN]
@="{30351349-7B7D-4FCC-81B4-1E394CA267EB}"
[HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\TortoiseSVN]
@="{30351349-7B7D-4FCC-81B4-1E394CA267EB}"
[HKEY_CLASSES_ROOT\lnkfile\shellex\ContextMenuHandlers\TortoiseSVN]
@="{30351349-7B7D-4FCC-81B4-1E394CA267EB}"
[HKEY_CLASSES_ROOT\LibraryLocation\ShellEx\ContextMenuHandlers\TortoiseSVN]
@="{30351349-7B7D-4FCC-81B4-1E394CA267EB}"
[HKEY_CLASSES_ROOT\LibraryFolder\background\shellex\ContextMenuHandlers\TortoiseSVN]
@="{30351349-7B7D-4FCC-81B4-1E394CA267EB}"

Xamarin setup failed: Nothing happens

Window disappeared? No error message?
The log is just saying “Creating BA thread to run asynchronously.”?
The Windows Logs just saying something like:

Faulting application name: XamarinInstaller.exe, version: 3.5.0.0, time stamp: 0x50d8cc6f
Faulting module name: KERNELBASE.dll, version: 6.1.7601.18015, time stamp: 0x50b83c8a
Exception code: 0xe0434352
Fault offset: 0x0000c41f
Faulting process id: 0x534
Faulting application start time: 0x01ce3459d9ec83b2
Faulting application path: C:\Users\JohnDoe\Desktop\XamarinInstaller.exe
Faulting module path: C:\Windows\syswow64\KERNELBASE.dll
Report Id: 18a3a8b1-a04d-11e2-90ac-014543645654

Application: XamarinInstaller(1).exe Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception. 
Exception Info: 
System.TypeInitializationException Stack: 
at Xamarin.Wix.UI.XamarinBA.Run() 
at System.Threading.ThreadHelper.ThreadStart_Context(System.Object) 
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) 
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) 
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) 
at System.Threading.ThreadHelper.ThreadStart()

Deleted all data in C:\Users\JohnDoe\AppData\Local\Temp? Tried to run it as an administrator?
And still nothing happens?

Ensure you have .NET 4.5 installed!

Samsung Galaxy Ace 2: Use a 64GB Micro SD card

First of all let me just say: it worked. BUT there is some work to do to achieve this.

de_GT-I8160OKADBT_005_Front_black_thumbSandisk Micro SD card

The card is shipped preformatted with a file system called “exFAT” and that’s basically the problem. You will need to format the SD card to a “FAT32″ file system.

AFAIK this can only be done using a card reader so I bought this one “Hama SD-/MicroSD 8in1 USB 2.0″ (it might be working also by using Android’s USB storage).

  • Using the formatting tool included in Windows won’t work.
  • There is the tool “fat32formatter”, but it only nagged with some exception like “Partition collapsed! Initialize drive and try again.”
  • “HP USB Disk Storage Format Tool” seems to be limited to 32GB so if you try this, your Micro SD card will only have 32GB afterwards.

So it seems to be not possible, but it is. First use “HP USB Disk Storage Format Tool” to get your SD card formatted to 32GB, then use “fat32formatter” afterwards and you will get your full 64GB micro SD FAT32 formatted. Maybe you have to restart your phone, but it should be recognized (Android 2.36) correctly as 64GB storage.

VC++ – Load image from protected URL

private: System::Void loadImageFromUrl(System::Windows::Forms::PictureBox^ imageBox, String^ url)
{
	 try
	 {
		 WebRequest^ request = WebRequest::Create(url);
		 request->PreAuthenticate=true;

		 NetworkCredential^ networkCredential = gcnew NetworkCredential("John Doe", "Password123");   
		 request->Credentials = networkCredential;

		 WebResponse^ response = request->GetResponse();
		 System::IO::Stream^ responseStream = response->GetResponseStream();
		 Bitmap^ bitmap = gcnew Bitmap(responseStream);
		 imageBox->Image = bitmap;
	 }
	 catch (Exception^ e) 
	 {
		 Helper::getInstance()->log("There was an error opening the image file. Check the URL" + e->ToString());		 
	 }
 }