Re: Problem using windres

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Looks like I didn't embed that code properly.  I thought the Embed would do
the trick.  Hopefully this will be more readable:

The resource.txt file:

#include "resource.h"

IDR_MYMENU MENU DISCARDABLE
BEGIN
   POPUP "&File"
   BEGIN
	MENUITEM "E&xit", ID_FILE_EXIT
   END

   POPUP "&Stuff"
   BEGIN
	MENUITEM "&Go", ID_STUFF_GO
	MENUITEM "G&o somewhere else", 0, GRAYED
   END
END

IDI_MYICON  ICON  "menu_one.ico"


The prog7.c file:

#include <windows.h>
#include <resource.h>
#include <resource.rc>


/*	 From winprog.org tutorial 	*/

{	//  This extra bracket is necessary to insure that g_szClassName remains
defined at line 52

const char g_szClassName[] = "myWindowClass";

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg)
    {
        case WM_LBUTTONDOWN:
        {
            char szFileName[MAX_PATH];
            HINSTANCE hInstance = GetModuleHandle(NULL);

            GetModuleFileName(hInstance, szFileName, MAX_PATH);
            MessageBox(hwnd, szFileName, "This program is:", MB_OK |
MB_ICONINFORMATION);
        }
        break;
/* Mnu02.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
        case WM_CLOSE:
            DestroyWindow(hwnd);
        break;
        case WM_DESTROY:
            PostQuitMessage(0);
        break;
        default:
            return DefWindowProc(hwnd, msg, wParam, lParam);
    }
    return 0;
}

int WINAPI WinMain(HINSTANCE 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;
/* Mnu02.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
    wc.cbWndExtra    = 0;
    wc.hInstance     = hInstance;
    wc.hIcon         = LoadIcon(GetModuleHandle(NULL),
MAKEINTRESOURCE(IDI_MYICON));	// New
    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
    wc.lpszMenuName  = MAKEINTRESOURCE(IDR_MYMENU);	// New
    wc.lpszClassName = g_szClassName;
    wc.hIconSm       = (HICON)LoadImage(GetModuleHandle(NULL),
"menu_one.ico", IMAGE_ICON, 16,16,0);	// New

    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 window",
        WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, CW_USEDEFAULT, 240, 120,
        NULL, NULL, hInstance, NULL);

    if(hwnd == NULL)
    {
        MessageBox(NULL, "Window Creation Failed!", "Error!",
            MB_ICONEXCLAMATION | MB_OK);
        return 0;
    }

    ShowWindow(hwnd, nCmdShow);
    UpdateWindow(hwnd);

    while(GetMessage(&Msg, NULL, 0, 0) > 0)
    {
        TranslateMessage(&Msg);
        DispatchMessage(&Msg);
    }
    return Msg.wParam;
}
}






--
View this message in context: http://gcc.1065356.n5.nabble.com/Problem-using-windres-tp1009189p1009194.html
Sent from the gcc - Help mailing list archive at Nabble.com.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux