Thread: About the code

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    3

    About the code

    This code I have here should work but it will not compile on my machine. I have been trying to do this for about 2 hours now. My girlfriend is getting ........ed off at me because she wants to play and I won't get off intill I figure this out. When I build the code I get this error
    :\My Documents\Source.cpp(10) : error C2065: 'MainDialog_OnCommand' : undeclared identifier
    C:\My Documents\Source.cpp(19) : error C2373: 'MainDialog_OnCommand' : redefinition; different type modifiers
    Error executing cl.exe.
    What should I write or do with this code. I am getting fustratied I know for a fact this crap is not that hard to figure out for most of you people but I am having a hard time with this simple and easy task. sorry for bothering everyone.


    #include <windows.h>
    #include <tchar.h>
    #include "resource.h"

    BOOL MainDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    {
    switch (uMsg)
    {
    case WM_COMMAND:
    return MainDialog_OnCommand(hWnd, LOWORD(wParam), HIWORD(wParam), (HWND)lParam);
    case WM_CLOSE:
    EndDialog(hWnd, 0);
    return TRUE;
    }
    return FALSE;
    }

    BOOL MainDialog_OnCommand(HWND hWnd, WORD wCommand, WORD wNotify, HWND hControl)
    {
    switch (wCommand)
    {
    case IDOK:
    MessageBox(hWnd, _T("Bye-bye world!"), _T("Sample Application"), MB_OK);

    case IDCANCEL:
    EndDialog(hWnd, wCommand);
    break;
    }
    return TRUE;
    }

    int _tmain(void)
    {
    DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)MainDialogProc, 0);

    return 0;
    }

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    You have no prototype for the function declared before you try to use it.

    Put

    BOOL MainDialog_OnCommand(HWND hWnd, WORD wCommand, WORD wNotify, HWND hControl);

    at the top of the file
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extended ASCII Characters in an RTF Control
    By JustMax in forum C Programming
    Replies: 18
    Last Post: 04-03-2009, 08:20 PM
  2. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 06:05 PM