Re: A window with file and help meny items

From: Frank Hickman (fhickman_NOSP_at_M_noblesoft.com)
Date: 12/12/04


Date: Sun, 12 Dec 2004 08:26:36 -0500

You need to create a menu resource with the ID IDR_NYMENU then Windows will
attach it when the window is created.

-- 
============
Frank Hickman
NobleSoft, Inc.
============
Replace the _nosp@m_ with @ to reply.
"Tony Johansson" <johansson.andersson@telia.com> wrote in message 
news:vAWud.10879$d5.96061@newsb.telia.net...
> Hello Experts!
>
> I have a document about window system and here they show a window with two 
> menu items at the top of the screen to choose from. The Items are File and 
> Help.
>
> Now to my question I can't understand where in the code, statements are 
> used to be able to show the two menu items File and Help?
>
> Here is the program:
> The program is not complete because the callback procedure WndProc are not 
> include in the code but that doesn't affect the question.
>
> #include <windows.h>
> #include "resource.h"
>
> int WINAPI WinMain(HINSTANCE hInstance, hPrevInstance, LPSTR lpCmdLine,
> int nCmdShow)
> {
>    WNDCLASSEX     wc;
>    HWND    hwnd;
>    MSG    Msg;
>    wc.cbSize    = sizeof(WNDCLASSEX);
>    wc.style    = 0;
>    wc.lpfnWndProc    = WndProc;
>    wc.cbClsExtra     =     0;
>    wc.cbWndExtra    =    0;
>    wc.hInstance    =    hInstance;
>    wc.hIcon    =    LoadIcon(NULL, IDI_APPLICATION);
>    wc.hCursor    =    LoadCursor(NULL, IDC_ARROW);
>    wc.hbrBackground    =    (HBRUSH)(COLOR_WINDOW+1);
>    wc.lpszMenuName    =    MAKEINTRESOURCE(IDR_NYMENU);
>    wc.lpszClassName    =    g_szClassName;
>    wc.hIconSm    =    LoadIcon(NULL, IDI_APPLICATION);
>
>    if  (!RegisterClassEx(&wc))
>    {
>        MessageBox(NULL, "Window Registration failed!", "Error!",
>                            MB_ICONEXCLAMATION | MB_OK);
>        return 0;
>    }
>
>    hwnd    =    CreateWindowEx( WS_EX_CLIENTEDGE,
>                                                    g_szClassName,
>                                                    "The title of my 
> winow",
>                                                    WS_OVERLAPPEDWINDOW,
>                                                     CW_USEDEFAULT,
>                                                     CW_USEDEFAULT,
>                                                    240,
>                                                    120,
>                                                     NULL,
>                                                     NULL,
>                                                    hInstance,
>                                                    NULL);
>
> if (hwnd == NULL)
> {
>    MessageBox(NULL, "Window Creation Failed!", "Error!",
>                          MB_ICONEXCLAMATION | MBOK);
>    return 0;
> }
>
> ShowWindow(hwnd);
> UpdateWindow(hwnd);
>
> while(GetMessage(&Msg, NULL, 0 , 0)  >  0)
> {
>    TranslateMessage(&Msg);
>    DispatchMessage(&Msg);
> }
>    return Msg.wParam;
> } // End WinMain
>
> Many thanks in advance.
>
> //Tony
> 


Relevant Pages

  • Re: How add buton onto title bar of any external active window?
    ... I want to add buttons ontoany active window. ... int sm_CXSIZE; ... static int WindowsFeaturesWidth(HWND hwnd, DWORD style) ... LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM ...
    (microsoft.public.win32.programmer.gdi)
  • directX 9.0 help with textures and sprite hnadler
    ... initialised directX and decided to display a texture on screen. ... For some reason the program will run and window open, ... HRESULT InitD3D (HWND hWnd, HINSTANCE hInstance) ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: Serial data + DialogBox
    ... HWND global_handle; ... int WINAPI WinMain(HINSTANCE hInstance, ... // create and display the main program window. ...
    (microsoft.public.pocketpc.developer)
  • Re: Serial data + DialogBox
    ... HWND global_handle; ... int WINAPI WinMain(HINSTANCE hInstance, ... // create and display the main program window. ...
    (microsoft.public.windowsce.embedded)
  • Re: Serial data + DialogBox
    ... HWND global_handle; ... int WINAPI WinMain(HINSTANCE hInstance, ... // create and display the main program window. ...
    (microsoft.public.pocketpc)