Thread: why wont this compile?!? :confused:

  1. #1
    Registered User
    Join Date
    May 2004
    Posts
    12

    why wont this compile?!? :confused:

    I cant figure out why this wont compile.

    Main:
    Code:
    #include <windows.h>
    #define IDI_MYICON 101
    
    /*  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 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 (NULL, IDI_APPLICATION);
        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 (&wincl))
            return 0;
    
        /* The class is registered, let's create the program*/
        hwnd = CreateWindowEx (
               0,                   /* Extended possibilites for variation */
               szClassName,         /* Classname */
               "Windows App",       /* 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 (&messages, NULL, 0, 0))
        {
            /* Translate virtual-key messages into character messages */
            TranslateMessage(&messages);
            /* Send message to WindowProcedure */
            DispatchMessage(&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;
    }
    Resource:
    Code:
    #include <resource1.h>
    
    IDI_MYICON ICON "C:\Dev-Cpp\Icons\Console.ico"
    It says "cannot create makefile". Im using dev-c++

  2. #2
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    Probably because your doing something wrong. Why don't you start off by learing win32 programming first. espcially since your using devc++.
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

  3. #3
    Registered User
    Join Date
    Jun 2003
    Posts
    361
    It compiled for me and ran just fine in DevC++

    All I did was copy/paste that code into a "Windows Application" (you sure you didn't try a "Console Application"?)

    Incidentaly, DevC++ starts you off with that code (or a very close variation).

    What's the resource all about?


    caroundw5h: Having as many posts as you do, you should know the difference between a helpful and a non-helpful reply.
    Last edited by Epo; 11-24-2004 at 08:43 PM.

  4. #4
    Hello,

    For good coding practice, when including local files always quote the filename. For example:
    Code:
    #include "resource1.h"
    Instead of:
    Code:
    #include <resource1.h>
    If the filename is quoted, searching for the file typically begins where the source program was found; if it is not found there, or if the name is enclosed in < and >, searching follows an implementation-defined rule to find the file.

    And if there is a specific error, can you post it.


    - Stack Overflow
    Segmentation Fault: I am an error in which a running program attempts to access memory not allocated to it and core dumps with a segmentation violation error. This is often caused by improper usage of pointers, attempts to access a non-existent or read-only physical memory address, re-use of memory if freed within the same scope, de-referencing a null pointer, or (in C) inadvertently using a non-pointer variable as a pointer.

  5. #5
    Registered User caroundw5h's Avatar
    Join Date
    Oct 2003
    Posts
    751
    Quote Originally Posted by Epo
    It compiled for me and ran just fine in DevC++

    All I did was copy/paste that code into a "Windows Application" (you sure you didn't try a "Console Application"?)

    Incidentaly, DevC++ starts you off with that code (or a very close variation).

    What's the resource all about?


    caroundw5h: Having as many posts as you do, you should know the difference between a helpful and a non-helpful reply.
    are you serious?? did you even read my post, did you read your post? and did you read stackoverflow's post? If the op doesn't know how to compile A basic win32 app on his compiler - i showed him how.
    Warning: Opinions subject to change without notice

    The C Library Reference Guide
    Understand the fundamentals
    Then have some more fun

  6. #6
    #junkie
    Join Date
    Oct 2004
    Posts
    240
    Quote Originally Posted by caroundw5h
    are you serious?? did you even read my post, did you read your post? and did you read stackoverflow's post? If the op doesn't know how to compile A basic win32 app on his compiler - i showed him how.
    hey caround, show me some code where somethins wrong. then see how useful simply stating "prob cuz you did somethin wrong, heres a link, figure it out." is lol.

    The Win32 API Link was alright, but still. I totally 2nd Epo, his post was still more helpful than yours. And lacking the better-than-thou elitist quest you were on (ok, taking far overboard, but i made my point lol.)
    01110111011000010110110001100100011011110010000001 11000101110101011010010111010000100000011011000110 10010110011001100101001000000111100101101111011101 0100100000011011100111010101100010

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. open scene graph compile issues
    By ichijoji in forum Game Programming
    Replies: 1
    Last Post: 08-04-2005, 12:31 PM
  2. compile program?
    By Goosie in forum C++ Programming
    Replies: 9
    Last Post: 06-22-2005, 02:26 PM
  3. dvv-cpp not able to compile?
    By Rune Hunter in forum C++ Programming
    Replies: 12
    Last Post: 10-23-2004, 06:36 PM
  4. Replies: 3
    Last Post: 03-27-2004, 12:15 PM
  5. compile once, compile twice ...error
    By Benzakhar in forum Windows Programming
    Replies: 6
    Last Post: 12-28-2003, 06:00 AM