Comments

You could make arrays with the ID numbers and names and then run a loopto create the items, sort of like this:[code]int i, ret;UINT ids[]={1001,1002,1003,1004,0};TCHAR* names[]={L"&Import", L"&Export", L"&Backup", L"E&xit"};

[color=Blue]Catching depends on compiler options. As an example - there are few "exceptional" options in VS 2005 (I am not sure if your compiler has it). One of the options is to use SEH and one of the others is to use C++ exceptions. The SEH option will usually catch exceptions with the following code:[/color][code]try{}catch (...){}[/code][color=Blue]On the other hand - no need really to delete menu items if anything fails - just delete the whole menu with DestroyMenu().[/color]

//Attempt to add the backup now option if(!AppendMenu(this->hFileMenu, MF_ENABLED | MF_STRING, IDM_BACKUP, L"&Backup")) { DestroyMenu(this->hFileMenu); DestroyMenu(this->hMainMenu); return false; }[/code]This is a waste of space and there has GOT to be a better way to check for a single menu failing without a thousand "if" checks. This is actually only part of the code, and it's about double that for everything.-[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

[color=Blue]You need to use the error checking wisely. For example, if you logically think - you will see that AppendMenu() call will not involve any hardware interaction - it can fail only for TWO reasons: no memory and wrong HMENU passed to it.

I never seen a program fail due to memory limits (not recently, anyhow). Also, if you check the HMENU you passing once for all calls, then you are SURE - it will not fail.

If you still have a need to check each of these calls - there is a trick. The failing value for this function is FALSE. Which is ZERO! That means if you create a string of return values - its length (string length) will be EXACTLY equal to the number of times you call AppendMenu():[/color][code]char strCheck [32];

if (lstrlen (strCheck) != 8){ // Something failed in that "string" :-) of calls!}[/code][color=Blue]That works nicely for BOOL return values. Beware of handles. If returned handle is, say: 0x0FD7A300 - this will turn to zero once turned into char type, so the trick will fail miserably.[/color]

I like that idea. I'll implement it the next time I work on the backup utility. I am working on my windowing library right now, and enjoying some VERY nice new wallpapers I just grabbed in KDE. Yeah, I'm a Linux-lover, but I have to stay in Windows to play my games! >.<