Is program missing some necessary #include(s)

This is a discussion on Is program missing some necessary #include(s) within the C Programming forums, part of the General Programming Boards category; Greetings, Win7x64, dev-c++ for C. I found a FirstWindow program A First Windows Application - Cprogramming.com that I am trying ...

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    31

    Is program missing some necessary #include(s)

    Greetings,
    Win7x64, dev-c++ for C.
    I found a FirstWindow program
    A First Windows Application - Cprogramming.com
    that I am trying to compile/run.
    But it gives this error msg:
    C:\Program Files (x86)\Dev-Cpp\Examples.c\FirstWindowProgram\Makefile.win [Error] [FirstWindow.exe] Error 1 (if this is the only error: please check your library includes)

    I think that means that it is missing some necessary #include(s).
    Can someone tell me what program is missing?


    Code:
    /*   Trim fat from windows*/
    #define WIN32_LEAN_AND_MEAN   
    #pragma comment(linker, "/subsystem:windows")
    /*   Pre-processor directives*/
    #include "stdafx.h"
    #include <windows.h>
    /*   Windows Procedure Event Handler*/
    LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
       PAINTSTRUCT paintStruct;
       /*   Device Context*/
       HDC hDC; 
       /*   Text for display*/
       char string[] = "Hello, World!"; 
       /*   Switch message, condition that is met will execute*/
       switch(message)
       {
          /*   Window is being created*/
          case WM_CREATE: 
             return 0;
             break;
          /*   Window is closing*/
          case WM_CLOSE: 
             PostQuitMessage(0);
             return 0;
             break;
          /*   Window needs update*/
          case WM_PAINT: 
             hDC = BeginPaint(hwnd,&paintStruct);
             /*   Set txt color to blue*/
             SetTextColor(hDC, COLORREF(0x00FF0000));
             /*   Display text in middle of window*/
             TextOut(hDC,150,150,string,sizeof(string)-1);
             EndPaint(hwnd, &paintStruct);
             return 0;
             break;
          default:
             break;
       }
       return (DefWindowProc(hwnd,message,wParam,lParam));
    }
    /*   Main function*/
    int APIENTRY WinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPSTR     lpCmdLine,
                         int       nCmdShow)
    {
       WNDCLASSEX  windowClass;      //window class
       HWND      hwnd;            //window handle
       MSG         msg;            //message
       bool      done;            //flag saying when app is complete
       /*   Fill out the window class structure*/
       windowClass.cbSize = sizeof(WNDCLASSEX);
       windowClass.style = CS_HREDRAW | CS_VREDRAW;
       windowClass.lpfnWndProc = WndProc;
       windowClass.cbClsExtra = 0;
       windowClass.cbWndExtra = 0;
       windowClass.hInstance = hInstance;
       windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
       windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
       windowClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
       windowClass.lpszMenuName = NULL;
       windowClass.lpszClassName = "MyClass";
       windowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
       /*   Register window class*/
       if (!RegisterClassEx(&windowClass))
       {
          return 0;
       }
       /*   Class registerd, so now create window*/
       hwnd = CreateWindowEx(NULL,      //extended style
          "MyClass",         //class name
          "A Real Win App",      //app name
          WS_OVERLAPPEDWINDOW |      //window style
          WS_VISIBLE |
          WS_SYSMENU,
          100,100,         //x/y coords
          400,400,         //width,height
          NULL,            //handle to parent
          NULL,            //handle to menu
          hInstance,         //application instance
          NULL);            //no extra parameter's
       /*   Check if window creation failed*/
       if (!hwnd)
          return 0;
       done = false; //initialize loop condition variable
       /*   main message loop*/
       while(!done)
       {
          PeekMessage(&msg,NULL,NULL,NULL,PM_REMOVE);
          if (msg.message == WM_QUIT) //check for a quit message
          {
             done = true; //if found, quit app
          }
          else
          {
             /*   Translate and dispatch to event queue*/
             TranslateMessage(&msg); 
             DispatchMessage(&msg);
          }
       }
       return msg.wParam;
    }

    Or if there is a better example, please aim me at it.

    Thanks...vmars316

  2. #2
    - - - - - - - - oogabooga's Avatar
    Join Date
    Jan 2008
    Posts
    2,808
    Open dev-c++.
    Create a new project.
    Make it a "windows application" (not a console app).
    The starter code that comes up is a decent example in itself.

    Telling dev-c++ (or whatever ide) that it's a "windows" app will automatically link with the commonly needed libraries. And you don't need the "stdafx.h" file in dev-c++.

  3. #3
    Registered User
    Join Date
    Jan 2010
    Posts
    31
    Quote Originally Posted by oogabooga View Post
    Open dev-c++.
    Create a new project.
    Make it a "windows application" (not a console app).
    The starter code that comes up is a decent example in itself.
    Thank you very much!...vm

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. My program is still missing something...
    By Johne Johnson in forum C++ Programming
    Replies: 1
    Last Post: 01-28-2012, 04:47 PM
  2. #include causes missing symbol definitions
    By mjl3434 in forum C Programming
    Replies: 4
    Last Post: 02-17-2011, 01:43 PM
  3. Compiler missing stdafx.h include file
    By jamort in forum C++ Programming
    Replies: 3
    Last Post: 02-10-2010, 04:03 AM
  4. what am I missing? (Program won't compile)
    By steals10304 in forum C Programming
    Replies: 3
    Last Post: 08-25-2009, 04:01 PM
  5. Missing something in dayofweek program
    By s_ny33 in forum C Programming
    Replies: 2
    Last Post: 11-15-2005, 10:34 AM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21