Menu

Interesting Problem

2008-03-24
2012-09-26
  • William Wheeler

    William Wheeler - 2008-03-24

    I am trying to create a base program, or "Hello World" Program if you will, and I created an Icon, made resource.rc, resource.h files, and then went to compile it, and I got the following error Status:

    Compiler: Default compiler
    Building Makefile: "C:\Documents and Settings\Skipper\My Documents\C++ Files\Test\Makefile.win"
    Executing make...
    make.exe -f "C:\Documents and Settings\Skipper\My Documents\C++ Files\Test\Makefile.win" all
    g++.exe -c main.cpp -o main.o -I"C:/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Dev-Cpp/include/c++/3.4.2" -I"C:/Dev-Cpp/include"

    main.cpp: In function int WinMain(HINSTANCE__*, HINSTANCE__*, HINSTANCE__*, CHAR*, int)': main.cpp:29: error:IDI_MYICON' undeclared (first use this function)
    main.cpp:29: error: (Each undeclared identifier is reported only once for each function it appears in.)

    make.exe: *** [main.o] Error 1

    Execution terminated

    The Resource.h file contains the Following Line:

    define IDC_MYICON 101

    The Resource.rc File contains the Following:

    include "resource.h"

    IDI_MYICON ICON "raindrop.ico"

    And the WinMain:

    include <windows.h>

    include "resource.h"

    / Declare Windows procedure /
    LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

    / Make the class name into a global variable /
    char szClassName[ ] = "WindowsApp";

    int WINAPI WinMain (HINSTANCE hInstance,
    HINSTANCE hThisInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpszArgument,
    int nFunsterStil)

    {
    HWND hwnd; / This is the handle for our window /
    MSG messages; / Here messages to the application are saved /
    WNDCLASSEX wincl; / Data structure for the windowclass /

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);
    
    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_MYICON));
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default color as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
    
    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&amp;wincl))
        return 0;
    
    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           &quot;Windows App&quot;,       /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           544,                 /* The programs width */
           375,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );
    
    /* Make the window visible on the screen */
    ShowWindow (hwnd, nFunsterStil);
    
    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&amp;messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&amp;messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&amp;messages);
    }
    
    /* The program return-value is 0 - The value that PostQuitMessage() gave */
    return messages.wParam;
    

    }

    / This function is called by the Windows function DispatchMessage() /

    LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    switch (message) / handle the messages /
    {
    case WM_DESTROY:
    PostQuitMessage (0); / send a WM_QUIT to the message queue /
    break;
    default: / for messages that we don't deal with /
    return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
    

    }

    Any Clues as to what I have done? I only have one thought. Does the .rc file not automagically compile, is there some way that I have to include it other that add to project?

     
    • cpns

      cpns - 2008-03-24

      The thread title was a real let down. That was completely uninteresting.

      You are however asking for trouble with "C:\Documents and Settings\Skipper\My Documents\C++ Files"!

       
      • cpns

        cpns - 2008-03-24

        ... actually I mentioned that in the last thread you posted, and you never got back on that, although you obviously got past the problem despite ignoring the advice.

        As service to the community, you are asked to provide closure on any threads you start. This one for instance; it might be useful to know what the problem was.

         
    • William Wheeler

      William Wheeler - 2008-03-29

      Sorry About the Title.

      The Problem was simple, in my Resource.h, I declared IDC_MYICON, and then in WinMain(), I called upon IDI_MYICON.

      It was a stupid mistype.

       
    • William Wheeler

      William Wheeler - 2008-03-24

      Also Forgot To Mention:

      Using DEV C++ Ver. 4.9.9.2

       
    • William Wheeler

      William Wheeler - 2008-03-24

      Okay Figured This one Out. Sorry for the stupidity, but Found the problem.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.