just starting in windows programming

This is a discussion on just starting in windows programming within the Windows Programming forums, part of the Platform Specific Boards category; hey im trying to learn graphics/games and well DirectX seems to be the main graphics thing for windows and i ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    255

    just starting in windows programming

    hey im trying to learn graphics/games and well DirectX seems to be the main graphics thing for windows and i copy and pasted this code from the tutorial i was using and got an error and not sure why

    am using 2003 visual studio .net compiler and on the Dev Compiler cause i only have the .net one cause school gave it to me but on the Dev compiler i got similar errors as well so

    thanks


    Code:
    // Standard windows include
    #include <windows.h>
    
    // Message Loop CallBack Function prototype
    LRESULT CALLBACK fnMessageProcessor (HWND, UINT, WPARAM, LPARAM);
    // Function called automatically when the program starts
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine,int iCmdShow)
    {
       HWND         hWnd;
       MSG          msg;
       WNDCLASSEX   wndclass;
    
       // Set up window class
       wndclass.cbSize        = sizeof(WNDCLASSEX);
       wndclass.style         = CS_HREDRAW | CS_VREDRAW;
       wndclass.lpfnWndProc   = fnMessageProcessor;
       wndclass.cbClsExtra    = 0;
       wndclass.cbWndExtra    = 0;
       wndclass.hInstance     = hInstance;
       wndclass.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
       wndclass.hCursor       = LoadCursor(NULL, IDC_ARROW);
       wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
       wndclass.lpszMenuName  = NULL;
       wndclass.lpszClassName = "Window Class";
    // Class Name
       wndclass.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);
    
       // Register the window class
       if(RegisterClassEx(&wndclass) == 0)
       {
           // The program failed, exit
           exit(1);
       }
    
       // Create the window
       hWnd = CreateWindowEx(
          WS_EX_OVERLAPPEDWINDOW,
          "Window Class",            // Class name
          "Create Window Example",   // Title bar text
          WS_OVERLAPPEDWINDOW,
          0,
          0,
          320,
          200,
          NULL,
          NULL,
          hInstance,
          NULL);
    
       // Display the window
       ShowWindow(hWnd, iCmdShow);
    
       // Process messages until the program is terminated
       while(GetMessage (&msg, NULL, 0, 0))
       {
          TranslateMessage(&msg);
          DispatchMessage(&msg);
       }
    
       return (msg.wParam);
    }
    
    // Message loop callBack function (REQUIRED FOR ALL WINDOWS PROGRAMS)
    LRESULT CALLBACK fnMessageProcessor (HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
    {
       switch(iMsg)
       {
          // Called when window is first created
          case WM_CREATE:
             return(0);
          // Called when the window is refreshed
          case WM_PAINT:
             return(0);
          // Called when the user closes the window
          case WM_DESTROY:
             PostQuitMessage(0);
             return(0);
          default:
             return DefWindowProc(hWnd, iMsg, wParam, lParam);
       }
    }
    .NET ERRORS
    c:\source\game learn\game learn proj\createwindow.cpp(60): warning C4244: 'return' : conversion from 'WPARAM' to 'int', possible loss of data
    game learn proj error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup
    game learn proj fatal error LNK1120: 1 unresolved externals

    DEV ERRORS
    [Linker error] undefined reference to `GetStockObject@4'
    C:\source\Makefile.win [Build Error] [Project1.exe] Error 1
    hooch

  2. #2
    Even death may die... Dante Shamest's Avatar
    Join Date
    Apr 2003
    Location
    Malaysia
    Posts
    970
    Create a Win32 Project.
    Not a Win32 Console Project.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    255
    out of curiousity whats the difference between the two?
    hooch

  4. #4
    Registered User mrafcho001's Avatar
    Join Date
    Jan 2005
    Posts
    483
    One is for Win32 Console only, looks for main to begin the exectuion of the code, Win32 is for windows GUI programming, looks for WinMain to begin code execution.
    My Website
    010000110010101100101011
    Add Color To Your Code!

  5. #5
    Registered User
    Join Date
    Nov 2001
    Posts
    255
    so on the dev compiler for what my friends use then they should select windows application? instead of empty project? to fix the errors that i got on that compiler? or as i see it started with some premade code so i guess so lol

    but then adding more files is the same just add them to the project normally and rebuild it all?
    hooch

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 11-22-2007, 11:13 PM
  2. how to make a windows application
    By crvenkapa in forum C++ Programming
    Replies: 3
    Last Post: 03-26-2007, 09:59 AM
  3. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 06:05 PM
  4. IE 6 status bar
    By DavidP in forum Tech Board
    Replies: 15
    Last Post: 10-23-2002, 05:31 PM
  5. Manipulating the Windows Clipboard
    By Johno in forum Windows Programming
    Replies: 2
    Last Post: 10-01-2002, 09:37 AM

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