Going over the Windows Programming Code...

Pages: 123
Hi, I am a beginner C++ programmer. I know only as much in C++ than any beginner would -- not very much. I am trying to learn more to create my own program so, using the given Windows Application template from Microsoft Visual Studio 2010 C++, I was going over the code. The first line of code is HINSTANCE hInst // current instance -- what does HINSTANCE hInst do? How does it help/work in the program?

Thanks --
Most if not all the variables used in Windows programming that are prefixed with an 'h' symbol are 'HANDLES'. These are essentially virtual memory pointers (sometimes called opaque pointers) that are needed many times for use as arguements to Windows Api functions. I haven't looked at your example, but the hInstance variable of which you are speaking is likely used in WinMain() to initialize the WNDCLASSEX::hInstance member of the WNDCLASSEX struct. The number will be meaningless to you, but highly meaningful to the operating system itself in identifying the location in virtual memory of the running instance. It is also needed in CreateWindowEx() calls. Also, it can be obtained in a number of ways in addition to retrieval from the WinMain() parameter list, for example, GetModuleHandle().

You are entering a strange new world, and at least for awhile, are going to have to accept some of these things 'in good faith'.
Last edited on
I used to be a web developer working in some of the languages such as HTML, CSS and a little bit of Javascript before devoting some of my time to C++, so I think I've entered that 'strange new world' a little while ago ") ... Anywho, those languages were easy compared to C++ programming. It just takes a lot of learning and practice, but I know I'll get there.

I would like to know how to manipulate the Windows Application, like adding my own icon, adding/taking away the close, minimize and restore button -- just learn everything about the window; I'm not really concerned about adding content at this moment. I'm not sure where to find the code or what the code called in the already written for this in the program...
Any help will be helpful... ")
Thanks for the reply --
If you look at a couple of the theads currently active you'll see references to Charles Petzold's "Programming Windows" books. These books cover the exact sort of material you are looking for, i.e., what all those strange variables are such as hInstance, hWnd, hIcon, etc. While its likely possible to get up to speed without Petzold's books by just spending a lot of time doing internet searches, your time will be much better spent by just getting the standard text book on this subject.

I think its important to realize that doing Win32 coding is getting as close to bare metal as you can get with Windows. Its the lowest level possible. All the technologies you just listed above are several layers of abstraction above where you are at with Win32.
I'll try the book you mentioned, thanks.

I'm trying to start somewhere, and if I can learn how to make my own interface with a file menu or similar to that, I can then begin to add content and soon have my own program. I'll mess with the code and try different things and learn that way I guess.

I appreciate your help --
Here's about the simplest (except for my message cracker scheme) "Hello, World!" type Win32 GUI program that will put up a 'File' menu ...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//Main.cpp
#include <windows.h>
#include <tchar.h>
#include "Mnu01.h"


long fnWndProc_OnCreate(WndEventArgs& Wea)
{
 Wea.hIns=((LPCREATESTRUCT)Wea.lParam)->hInstance;
 return 0;
}


long fnWndProc_OnDestroy(WndEventArgs& Wea)
{
 PostQuitMessage(0);
 return 0;
}


LRESULT CALLBACK fnWndProc(HWND hwnd, unsigned int msg, WPARAM wParam, LPARAM lParam)
{
 WndEventArgs Wea;

 for(unsigned int i=0; i<dim(EventHandler); i++)
 {
     if(EventHandler[i].iMsg==msg)
     {
        Wea.hWnd=hwnd, Wea.lParam=lParam, Wea.wParam=wParam;
        return (*EventHandler[i].fnPtr)(Wea);
     }
 }

 return (DefWindowProc(hwnd, msg, wParam, lParam));
}


int WINAPI WinMain(HINSTANCE hIns, HINSTANCE hPrevIns, LPSTR lpszArgument, int iShow)
{
 TCHAR szClassName[]=_T("Mnu01");
 WNDCLASS wc;
 MSG messages;
 HWND hWnd;

 wc.style         = 0;
 wc.lpfnWndProc   = fnWndProc;
 wc.lpszClassName = szClassName;
 wc.cbClsExtra    = 0;
 wc.cbWndExtra    = 0;
 wc.hInstance     = hIns,
 wc.hIcon         = NULL;
 wc.hCursor       = LoadCursor(NULL,IDC_ARROW);
 wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW;
 wc.lpszMenuName  = MAKEINTRESOURCE(IDR_MAIN_MENU);
 RegisterClass(&wc);
 hWnd=CreateWindow(szClassName,szClassName,WS_OVERLAPPEDWINDOW,75,75,320,200,HWND_DESKTOP,0,hIns,0);
 ShowWindow(hWnd,iShow);
 while(GetMessage(&messages,NULL,0,0))
 {
    TranslateMessage(&messages);
    DispatchMessage(&messages);
 }

 return messages.wParam;
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//Mnu01.h
#ifndef Mnu01_h
#define Mnu01_h

#define dim(x) (sizeof(x) / sizeof(x[0]))

struct WndEventArgs
{
 HWND                         hWnd;
 WPARAM                       wParam;
 LPARAM                       lParam;
 HINSTANCE                    hIns;
};

long fnWndProc_OnCreate       (WndEventArgs&);
long fnWndProc_OnDestroy      (WndEventArgs&);

struct                        EVENTHANDLER
{
 unsigned int                 iMsg;
 long                         (*fnPtr)(WndEventArgs&);
};

const EVENTHANDLER EventHandler[]=
{
 {WM_CREATE,                  fnWndProc_OnCreate},
 {WM_DESTROY,                 fnWndProc_OnDestroy}
};

#define IDR_MAIN_MENU         2000

#define IDM_FILE_OPEN         2100
#define IDM_FILE_EXIT         2105

#endif 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* Mnu01.rc  */
#define IDR_MAIN_MENU                        2000

#define IDM_FILE_OPEN                        2100
#define IDM_FILE_EXIT                        2105

IDR_MAIN_MENU MENU DISCARDABLE
BEGIN
    POPUP "&File"
    BEGIN
        MENUITEM "&Open...",      IDM_FILE_OPEN
        MENUITEM "E&xit",         IDM_FILE_EXIT
    END
END


You'll need to know how to create a project in your IDE and add the resource file (*.rc) and header file.

Last edited on
Wow, thanks! What language is that -- c++? Because I'm trying to follow a tutorial online on C++ icon changing and so on, and he's typing his code (By the way, he's making a WIndows app) in DevC++ but when I type it in visual studio, it doesn't work...

I'll copy & paste your code and test it. Very much appreciated!
Actually, I can't test your code because your I don't have your files that you used in your headers... I'll just have to surf through there and find the 'file' code...
Yes, that's C++.

My code should work. There are only three files, e.g., Main.cpp (the top one), Mnu01.h (middle one), and Mnu01.rc (bottom one). You can name your Visual Studio Project whatever you want, but you should copy the code as is and name it as described above. Put the three files in the same directory Visual Studio makes for the project, and use the 'Add Files' right click option to include the three files in the project.

The only thing anyway near non-standard in any of the above code is my message cracker scheme I use. The purpose of that is to create seperate message handling functions in place of a large Window Procedure with a massive switch statement. I can easily reverse that for you if you want.
Just tested with VC9 (Visual Studio 2008 Pro). No errors or warnings. Tomorrow I'll post a simplified version without the message crackers. It'll be easier to follow. I would have done that at first, but the above was the way I had it.
Here's an altered version with no file dependencies. In other words, you don't need Mnu01.h or Mnu01.rc. All you need is this file - Main.cpp.

What I did was replace the complicated message cracking scheme with a simple WndProc and switch construct, and I created the menu from code directly inside the WM_CREATE case instead of relying on the resource script ...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//Main.cpp
#include <windows.h>
#include <tchar.h>
#define IDR_MAIN_MENU  2000
#define IDM_FILE_OPEN  2100
#define IDM_FILE_EXIT  2105


LRESULT CALLBACK fnWndProc(HWND hwnd, unsigned int msg, WPARAM wParam, LPARAM lParam)
{
 switch(msg)
 {
    case WM_CREATE:
     {
         HMENU hMenu, hSubMenu;
         hMenu = CreateMenu();
         hSubMenu = CreatePopupMenu();
         AppendMenu(hSubMenu,  MF_STRING,            IDM_FILE_OPEN,       "&Open");
         AppendMenu(hSubMenu,  MF_STRING,            IDM_FILE_EXIT,       "E&xit");
         AppendMenu(hMenu,     MF_STRING | MF_POPUP, (UINT)hSubMenu,      "&File");
         SetMenu(hwnd, hMenu);
         return 0;
     }
    case WM_DESTROY:
     {
         PostQuitMessage(0);
         return 0;
     }
 }

 return (DefWindowProc(hwnd, msg, wParam, lParam));
}


int WINAPI WinMain(HINSTANCE hIns, HINSTANCE hPrevIns, LPSTR lpszArgument, int iShow)
{
 TCHAR szClassName[]=_T("Mnu05");
 WNDCLASS wc;
 MSG messages;
 HWND hWnd;

 wc.style         = 0,                         wc.lpfnWndProc   = fnWndProc;
 wc.lpszClassName = szClassName,               wc.cbClsExtra    = 0;
 wc.cbWndExtra    = 0,                         wc.hInstance     = hIns,
 wc.hIcon         = NULL,                      wc.hCursor       = LoadCursor(NULL,IDC_ARROW);
 wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW,   wc.lpszMenuName  = NULL;
 RegisterClass(&wc);
 hWnd=CreateWindow(szClassName,szClassName,WS_OVERLAPPEDWINDOW,75,75,320,200,HWND_DESKTOP,0,hIns,0);
 ShowWindow(hWnd,iShow);
 while(GetMessage(&messages,NULL,0,0))
 {
    TranslateMessage(&messages);
    DispatchMessage(&messages);
 }

 return messages.wParam;
}
Last edited on
I'm getting red lines under IDM_FILE_OPEN, "&Open");
IDM_FILE_EXIT, "E&xit");
"&File");
This happened before but I typed AppendMenu(hMenu.... under
switch (message) and I got the same result -- red lines.
My output box says there's an undeclared identifier.

As I look back at the code, I see you had switch (msg), same thing I had.



switch (message)	
case WM_CREATE:{
		HMENU hMenubar = CreateMenu();
		HMENU hFile = CreateMenu();
		HMENU hOptions = CreateMenu();

		AppendMenu(hMenubar);
				   }



But I added
WM_CREATE: {
                    HMENU hMenubar = CreateMenu();
                    HMENU hMenubar = hFile();
                    HMENU hMenubar = hOptions();
} 
I didn't test that last program in Visual Studio (rather in Code::Blocks), and low and behold, I forgot the TCHAR macros on the strings. CodeBlocks wouldn't have hollered on that. So this might help ...

1
2
3
4
5
6
7
8
9
10
case WM_CREATE:
  {
     HMENU hMenu = CreateMenu();
     HMENU hSubMenu = CreatePopupMenu();
     AppendMenu(hSubMenu,  MF_STRING,            IDM_FILE_OPEN,       _T("&Open"));
     AppendMenu(hSubMenu,  MF_STRING,            IDM_FILE_EXIT,       _T("E&xit"));
     AppendMenu(hMenu,     MF_STRING | MF_POPUP, (UINT)hSubMenu,      _T("&File"));
     SetMenu(hwnd, hMenu);
     return 0;
  }


Other than that, I don't know what the problem is. Afterall IDM_FILE_OPEN and IDM_FILE_EXIT are defined???
Yes! It worked. I believe that was the problem -- you forgot the TCHAR because it was telling me that the header TCHAR wasn't defined I think. So I deleted it and added #include "stdafx.h" but it still didn't work. The code you posted worked -- it looks great, but it's small; that should be an easy fix...
How would I create another file popup next to 'file', like MUSIC? I tried coping and pasting the following:


case WM_CREATE:
  {
     HMENU hMenu = CreateMenu();
     HMENU hSubMenu = CreatePopupMenu();
     AppendMenu(hSubMenu,  MF_STRING,            IDM_FILE_OPEN,       _T("&Open"));
     AppendMenu(hSubMenu,  MF_STRING,            IDM_FILE_EXIT,       _T("E&xit"));
     AppendMenu(hMenu,     MF_STRING | MF_POPUP, (UINT)hSubMenu,      _T("&File"));
     SetMenu(hwnd, hMenu);
     return 0;
  }


and replacing IDM_FILE_OPEN to IDM_MUSIC_OPEN, ... but got those red lines again...

... but got those red lines again...


Them red lines are a bugger, ain't they?

Try this ...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//Main.cpp
#include <windows.h>
#include <tchar.h>
#define IDR_MAIN_MENU       2000
#define IDM_FILE_OPEN       2100
#define IDM_FILE_EXIT       2105

#define IDM_MUSIC_BLUEGRASS 2200
#define IDM_MUSIC_ROCK      2205
#define IDM_MUSIC_COUNTRY   2210

#define IDM_HELP_HELP       2300
#define IDM_HELP_ABOUT      2305


LRESULT CALLBACK fnWndProc(HWND hwnd, unsigned int msg, WPARAM wParam, LPARAM lParam)
{
 switch(msg)
 {
    case WM_CREATE:
     {
         HMENU hMenu    = CreateMenu();
         HMENU hSubMenu = CreatePopupMenu();

         AppendMenu(hSubMenu,  MF_STRING,            IDM_FILE_OPEN,       _T("&Open"));
         AppendMenu(hSubMenu,  MF_STRING,            IDM_FILE_EXIT,       _T("E&xit"));
         AppendMenu(hMenu,     MF_STRING | MF_POPUP, (UINT)hSubMenu,      _T("&File"));

         hSubMenu = CreatePopupMenu();
         AppendMenu(hSubMenu,  MF_STRING,            IDM_MUSIC_BLUEGRASS, _T("&Bluegrass Music"));
         AppendMenu(hSubMenu,  MF_STRING,            IDM_MUSIC_ROCK,      _T("&Rock Music"));
         AppendMenu(hSubMenu,  MF_STRING,            IDM_MUSIC_COUNTRY,   _T("&Country Music"));
         AppendMenu(hMenu,     MF_STRING | MF_POPUP, (UINT)hSubMenu,      _T("&Music"));

         hSubMenu = CreatePopupMenu();
         AppendMenu(hSubMenu,  MF_STRING,            IDM_HELP_HELP,       _T("&Help"));
         AppendMenu(hSubMenu,  MF_STRING,            IDM_HELP_ABOUT,      _T("&About"));
         AppendMenu(hMenu,     MF_STRING | MF_POPUP, (UINT)hSubMenu,      _T("&Help"));

         SetMenu(hwnd, hMenu);
         return 0;
     }
    case WM_DESTROY:
     {
         PostQuitMessage(0);
         return 0;
     }
 }

 return (DefWindowProc(hwnd, msg, wParam, lParam));
}


int WINAPI WinMain(HINSTANCE hIns, HINSTANCE hPrevIns, LPSTR lpszArgument, int iShow)
{
 TCHAR szClassName[]=_T("Mnu05");
 WNDCLASS wc;
 MSG messages;
 HWND hWnd;

 wc.style         = 0,                         wc.lpfnWndProc   = fnWndProc;
 wc.lpszClassName = szClassName,               wc.cbClsExtra    = 0;
 wc.cbWndExtra    = 0,                         wc.hInstance     = hIns,
 wc.hIcon         = NULL,                      wc.hCursor       = LoadCursor(NULL,IDC_ARROW);
 wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW,   wc.lpszMenuName  = NULL;
 RegisterClass(&wc);
 hWnd=CreateWindow(szClassName,szClassName,WS_OVERLAPPEDWINDOW,75,75,320,200,HWND_DESKTOP,0,hIns,0);
 ShowWindow(hWnd,iShow);
 while(GetMessage(&messages,NULL,0,0))
 {
    TranslateMessage(&messages);
    DispatchMessage(&messages);
 }

 return messages.wParam;
}
Last edited on
It worked -- what did you add to it? I noticed this line on the top:

#define IDR_MAIN_MENU       2000
#define IDM_FILE_OPEN       2100
#define IDM_FILE_EXIT       2105

#define IDM_MUSIC_BLUEGRASS 2200
#define IDM_MUSIC_ROCK      2205
#define IDM_MUSIC_COUNTRY   2210

#define IDM_HELP_HELP       2300
#define IDM_HELP_ABOUT      2305


Why are those number next to them? How do they help the program work?
You might want to grab the code again as I fixed a couple small glitches.

Those numbers are termed equates. They simply associate an id number with a text string that is more readable and understandable than a number in isolation, i.e., a mystery number which doesn't mean anything to you.

Their significance will become somewhat clearer to you when you ask your next question, which is, ...

"OK, that works. But when I click on a menu selection, nothing happens?"

I believe you said in your first post that you were only starting at programming, so I don't know how far along you are. But this type of coding is somewhat advanced. Most folks who start it get a copy of Charles Petzold's book, "Programming Windows", I believe 4th or 5th edition. There are a whole lot of architectural issues that need to be expolained, and they are not really C++ issues as you would find in C++ oriented books. They are rather issues relating to how Windows was put together and its Api. There are a lot of tutorials out there too if the Petzold books are too expensive for you. One of them is the Forger's Win32 Api Tutorial. Do a search on that. Another is one I wrote, which is here ...

http://www.jose.it-berater.org/smfforum/index.php?topic=3389.0
Yes, I was going to ask how to make the file menu work.
I know others put NULL in their codes and I'm assuming that is what makes your file menu not link.

I will check out the link provided, it seems to have good programming help on there...
One question: you had "e&xit"?
The '&' symbol is what is termed (I think) a 'keyboard accelerator'. Run the program below and hold down the [ALT] key and then touch the 'F' key while keeping the [ALT] key held down. That should open up the 'File' menu. Then, still holding the [ALT] key down, touch the 'x' key. That will trigger the ...

File >> Exit

command, once you've built and run the below program ....

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//Main.cpp
#include <windows.h>
#include <tchar.h>
#define IDR_MAIN_MENU       2000
#define IDM_FILE_OPEN       2100
#define IDM_FILE_EXIT       2105

#define IDM_MUSIC_BLUEGRASS 2200
#define IDM_MUSIC_ROCK      2205
#define IDM_MUSIC_COUNTRY   2210

#define IDM_HELP_HELP       2300
#define IDM_HELP_ABOUT      2305


LRESULT CALLBACK fnWndProc(HWND hwnd, unsigned int msg, WPARAM wParam, LPARAM lParam)
{
 switch(msg)
 {
    case WM_CREATE:
     {
         HMENU hMenu    = CreateMenu();
         HMENU hSubMenu = CreatePopupMenu();

         AppendMenu(hSubMenu,  MF_STRING,            IDM_FILE_OPEN,       _T("&Open"));
         AppendMenu(hSubMenu,  MF_STRING,            IDM_FILE_EXIT,       _T("E&xit"));
         AppendMenu(hMenu,     MF_STRING | MF_POPUP, (UINT)hSubMenu,      _T("&File"));

         hSubMenu = CreatePopupMenu();
         AppendMenu(hSubMenu,  MF_STRING,            IDM_MUSIC_BLUEGRASS, _T("&Bluegrass Music"));
         AppendMenu(hSubMenu,  MF_STRING,            IDM_MUSIC_ROCK,      _T("&Rock Music"));
         AppendMenu(hSubMenu,  MF_STRING,            IDM_MUSIC_COUNTRY,   _T("&Country Music"));
         AppendMenu(hMenu,     MF_STRING | MF_POPUP, (UINT)hSubMenu,      _T("&Music"));

         hSubMenu = CreatePopupMenu();
         AppendMenu(hSubMenu,  MF_STRING,            IDM_HELP_HELP,       _T("&Help"));
         AppendMenu(hSubMenu,  MF_STRING,            IDM_HELP_ABOUT,      _T("&About"));
         AppendMenu(hMenu,     MF_STRING | MF_POPUP, (UINT)hSubMenu,      _T("&Help"));

         SetMenu(hwnd, hMenu);
         return 0;
     }
    case WM_COMMAND:
     {
         switch(LOWORD(wParam))
         {
            case IDM_FILE_OPEN:
              MessageBox(hwnd,_T("You Chose File >>> Open ..."),_T("Picked Up WM_COMMAND"),MB_OK);
              break;
            case IDM_FILE_EXIT:
              MessageBox(hwnd,_T("You Chose File >>> Exit ..."),_T("Picked Up WM_COMMAND"),MB_OK);
              SendMessage(hwnd,WM_CLOSE,0,0);
              break;
            case IDM_MUSIC_BLUEGRASS:
              MessageBox(hwnd,_T("You Chose Music >>> Bluegrass ..."),_T("Picked Up WM_COMMAND"),MB_OK);
              break;
            case IDM_MUSIC_ROCK:
              MessageBox(hwnd,_T("You Chose Music >>> Rock ..."),_T("Picked Up WM_COMMAND"),MB_OK);
              break;
            case IDM_MUSIC_COUNTRY:
              MessageBox(hwnd,_T("You Chose Music >>> Country ..."),_T("Picked Up WM_COMMAND"),MB_OK);
              break;
            case IDM_HELP_HELP:
              MessageBox(hwnd,_T("You Chose Help >>> Help ..."),_T("Picked Up WM_COMMAND"),MB_OK);
              break;
            case IDM_HELP_ABOUT:
              MessageBox(hwnd,_T("You Chose Help >>> About ..."),_T("Picked Up WM_COMMAND"),MB_OK);
              break;
         }
         return 0;
     }
    case WM_DESTROY:
     {
         PostQuitMessage(0);
         return 0;
     }
 }

 return (DefWindowProc(hwnd, msg, wParam, lParam));
}


int WINAPI WinMain(HINSTANCE hIns, HINSTANCE hPrevIns, LPSTR lpszArgument, int iShow)
{
 TCHAR szClassName[]=_T("Mnu05");
 WNDCLASS wc;
 MSG messages;
 HWND hWnd;

 wc.style         = 0,                         wc.lpfnWndProc   = fnWndProc;
 wc.lpszClassName = szClassName,               wc.cbClsExtra    = 0;
 wc.cbWndExtra    = 0,                         wc.hInstance     = hIns,
 wc.hIcon         = NULL,                      wc.hCursor       = LoadCursor(NULL,IDC_ARROW);
 wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW,   wc.lpszMenuName  = NULL;
 RegisterClass(&wc);
 hWnd=CreateWindow(szClassName,szClassName,WS_OVERLAPPEDWINDOW,75,75,320,200,HWND_DESKTOP,0,hIns,0);
 ShowWindow(hWnd,iShow);
 while(GetMessage(&messages,NULL,0,0))
 {
    TranslateMessage(&messages);
    DispatchMessage(&messages);
 }

 return messages.wParam;
}


Note how every addition to the program has resulted in WinMain() staying exactly the same; everything added went into fnWndProc(), i.e., the Window Procedure. That's how it works. If you continued and made a real program out of this that really did something, you would end up with a program with a WinMain() exactly the same, and several thousands of horrid lines of code in a rambling WndProc(). Mark my words. That's why the original program I posted didn't look like this. It was designed to be extensible and completely modular. But its a lot harder for a beginner to grasp.
Does it make a difference that in the code there's ("&OPEN") and then ("E&xit")? Does it matter that the keyboard accelerator is between the 'e' and 'x'?

I see you added

case IDM_FILE_OPEN:
              MessageBox(hwnd,_T("You Chose File >>> Open ..."),_T("Picked Up WM_COMMAND"),MB_OK);
              break;

Nice...
Pages: 123