Getting Errors

i need help because i am getting errors and i don't know why

Page 1 of 1

4 Replies - 554 Views - Last Post: 30 March 2010 - 01:35 PM Rate Topic: -----

#1 cplusplus2392  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 30-March 10

Getting Errors

Posted 30 March 2010 - 09:32 AM

I am having some problems with this code. The code i have i got from my teacher and its is exactly as he has it. Yet i am still getting errors. It is an online class so i am unable to ask him for help or i would.

The instructions given:
So, let's create 70 lines of code for a real window that does nothing.

Here is what i have so far:
#include <windows.h>

const char g_szClassName[] = "myWindowClass";

LRESULT CALLBACK WndProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
        switch (msg)
        {
               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;
    wc.cbWndExtra             = 0;
    wc.hInstance              = hInstance;
    wc.hIcon                  = LoadIcon (NULL, IDI_APPLICATION);
    wc.hCursor                = LoadCursor (NULL, IDC_ARROW);
    wc.hbrBackground          = (HBRUSH) (COLOR_WINDOW+1);
    wc.lpszMenuName           = NULL;
    wc.lpszClassName          = g_szClassName;
    wc.hIconSm                = LoadIcon (NULL, IDI_APPLICATION);
    
    if (!RegisterClassEx (&wc))
    {
       MessageBox (NULL, "Window Registration Failed!", "Error!", MB_ICONEXLAMATION | MB_OK);
       return 0;
    }
    
    hwnd = CreateWindowEx (
         ws_EX_CLIENTEDGE,
         g_szClassName,
         "My window... Get Your Own. :P/>",
         WS_OVERLAPPEDWINDOW,
         CW_USEDEFAULT, CW_USEDEFAULT, 400, 120,
         NULL, NULL, hInstance, NULL);
         
    if (hwnd == NULL)
    {
         MessageBox (NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
         return 0;
    }
    
    ShopWindow (hwnd, nCmdShow);
    UpdateWindow (hwnd);
    
    while (GetMessage (&Msg, NULL, 0, 0) > 0)
    {
          TranslateMessage (&Msg);
          DispatchMessage (&Msg);
    }
    return Msg.wPram;
}



Here are the errors i am getting:
Line | Error
In function `int WinMain(HINSTANCE__*, HINSTANCE__*, CHAR*, int)':
43 `MB_ICONEXLAMATION' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)
48 `ws_EX_CLIENTEDGE' undeclared (first use this function)
61 `ShopWindow' undeclared (first use this function)
64 `Msg' undeclared (first use this function)

Any and all help is welcomed and needed.
Please and thank you in advance.

Is This A Good Question/Topic? 0
  • +

Replies To: Getting Errors

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6078
  • View blog
  • Posts: 23,550
  • Joined: 23-August 08

Re: Getting Errors

Posted 30 March 2010 - 09:33 AM

HINT: Spelling and case COUNT! Programming is an exact science.
Was This Post Helpful? 0
  • +
  • -

#3 KYA  Icon User is online

  • g++ jameson.cpp -o beverage
  • member icon

Reputation: 3106
  • View blog
  • Posts: 19,145
  • Joined: 14-September 07

Re: Getting Errors

Posted 30 March 2010 - 09:33 AM

 while (GetMessage (&Msg, NULL, 0, 0) > 0)




is a typo

msg is not equivalent to Msg
Was This Post Helpful? 0
  • +
  • -

#4 sarmanu  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 966
  • View blog
  • Posts: 2,362
  • Joined: 04-December 09

Re: Getting Errors

Posted 30 March 2010 - 09:35 AM

You have some syntax errors:
MB_ICONEXLAMATION should be MB_ICONEXCLAMATION
ws_EX_CLIENTEDGE should be WS_EX_CLIENTEDGE
MSG should be msg
ShopWindow should be ShowWindow

This post has been edited by sarmanu: 30 March 2010 - 09:36 AM

Was This Post Helpful? 1
  • +
  • -

#5 cplusplus2392  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 14
  • Joined: 30-March 10

Re: Getting Errors

Posted 30 March 2010 - 01:35 PM

ok thank you all for your help.
i can't believe i made all those spelling errors and couldn't even pick up on them.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1