Thursday, September 20, 2012

Resource file does not support multiplication and division operators

Microsoft Visual Studio 2008 - Resource Scripts support only addition '+' and subtraction '-' operators for the Numerical fields. Multiplication '*' and Division '\' operators and Parentheses '( )' are not supported.

e.g. 
Main.rc

# define WINDOW_X 0
# define WINDOW_Y 0
# define WINDOW_WIDTH 300
# define WINDOW_HEIGHT 120

# define BORDER_SIZE 2

IDD_MAINDIALOG  DIALOG  WINDOW_X, WINDOW_Y, WINDOW_WIDTH-2*BORDER_SIZE, WINDOW_HEIGHT

// Here WINDOW_WIDTH-2*BORDER_SIZE will evaluate to only: WINDOW_WIDTH

// Thus instead use:

WINDOW_WIDTH-BORDER_SIZE-BORDER_SIZE

Friday, September 07, 2012

Multiple Partitions or One?

I recommend that you have only a single drive instead of dividing your disk into multiple partitions.

It is a general belief that multiple partitions help you organize your data and protects your data - in-case you happen to have to format your disk.

Well both of these reasons are wrong.
  1. Folders themselves are the best way to separate and organize your files.
    Having to go all the way upto the list of drives then navigating to your file is very inconvenient - as it likely that you will have to do that many times in a day.

    More over you will have to remember more - first: which drive is it in.
  2. There is no reason to format only one drive - it is not required when you upgrade or re-install your operating system. Also only formatting one drive and leaving the rest offers you no advantage in eradicating a virus infection.
Dividing your drive into multiple partitions is like dividing your hall into small 'rooms' with card-board. This only constricts the available space and regularly gives you the headache of low disk space - when in-fact you are likely to have that space.

I would even recommend that if you have existing additional partitions on the same disk - you should merge it into one single drive.

Only exception that comes to my mind is when you have to have multiple operating systems. But again in many, if not most, cases you would be better off with Virtual machines and virtual hard-disks that are dynamically sized, for secondary operating systems.

Also usually laptops come with recovery partitions - If you are pro user I think its best to have that recovery transferred to an another media like a DVD and to reclaim that precious non used disk space.

Wednesday, September 05, 2012

Get Clipboard Size : Windows

The windows clipboard has a group of parallel versions of the same data.

To get clipboard data you use the function GetClipboardData with the format-ID parameter.
This gives you the handle to the Global Memory block that contains this particular version of the clipboard data.
In-order to get the size of this block in bytes use: GlobalSize on the handle got by GetClipboardData.

HGLOBAL hMem;
hMem = GetClipboardData(uformat_id);
cbSize = GlobalSize(hMem); // got the size in cbSize
pData = GlobalLock(hMem);