Thread: Converting from MSVC++ 6 to .NET 2003

  1. #1
    Climber spoon_'s Avatar
    Join Date
    Jun 2002
    Location
    ATL
    Posts
    182

    Converting from MSVC++ 6 to .NET 2003

    So, I'm having this REALLY weird problem with a switch statement. I'm manually converting code from a MSVC++ 6 application to a .NET 2003 application.

    The following code compiles:

    Code:
    LRESULT CALLBACK DialogProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    	switch(message)
    	{
    	case WM_INITDIALOG:
    		{
    			break;
    		}
    	case WM_COMMAND:
    		{
    			break;
    		}
    	case WM_DESTROY:
    		{
    			PostQuitMessage(0);
    			break;
    		}
    	case WM_CLOSE:
    		{
    			DestroyWindow(hWnd);
    			break;
    		}
    	default:
    		{
    			return FALSE;
    		}
    	}
    	return TRUE;
    }
    But when I add another case to the switch, like WM_WTF:

    (WM_WTF is defined as #define WM_WTF (WM_USER + 20))

    Code:
    LRESULT CALLBACK DialogProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    	switch(message)
    	{
    	case WM_WTF:
    		{
    			break;
    		}
    	case WM_INITDIALOG:
    		{
    			break;
    		}
    	case WM_COMMAND:
    		{
    			break;
    		}
    	case WM_DESTROY:
    		{
    			PostQuitMessage(0);
    			break;
    		}
    	case WM_CLOSE:
    		{
    			DestroyWindow(hWnd);
    			break;
    		}
    	default:
    		{
    			return FALSE;
    		}
    	}
    	return TRUE;
    }
    It breaks everything and gives me the following errors:

    error C2143: syntax error : missing ':' before ';'
    error C2143: syntax error : missing ';' before ':'
    error C2046: illegal case
    error C2043: illegal break
    ...etc

    So, wtf is going on?
    Last edited by spoon_; 03-11-2005 at 05:15 PM.
    {RTFM, KISS}

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    Probably WM_WTF is not declared.
    Woop?

  3. #3
    Climber spoon_'s Avatar
    Join Date
    Jun 2002
    Location
    ATL
    Posts
    182
    It is, I just edited my post to show how it is defined.
    {RTFM, KISS}

  4. #4
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    Where is your WM_WTF defined and are you sure your switch can get to it?
    Woop?

  5. #5
    Climber spoon_'s Avatar
    Join Date
    Jun 2002
    Location
    ATL
    Posts
    182
    It's defined in the same .c file that the switch is in.

    It's defined at the top before anything else...
    Last edited by spoon_; 03-11-2005 at 05:42 PM.
    {RTFM, KISS}

  6. #6
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    Well then my usefullness has run out, maybe post the real code if the above you posted was not it or post more code
    Woop?

  7. #7
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    >>It's defined at the top before anything else...

    Sometimes that does not give it scope through the whole file.

    Try define'ing it in an included header or at the top of the callback (and see if the problem persists)

    or

    do you have a conflict with a system defined WM_USER msg?

    MSDN on WM_USER

    "These values cannot be used to define messages that are meaningful throughout an application, because some predefined window classes already define values in this range. For example, predefined control classes such as BUTTON, EDIT, LISTBOX, and COMBOBOX may use these values. "
    "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

  8. #8
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    #define WM_WTF (WM_USER + 20))

    You have an extra )

    -edit-
    unless......oh...it's in parenthesis, ahhahahahahahhaha

    OMG IMM STUPID CUZ I DIDNT SE TAHT1111111 OMG LOL

  9. #9
    Climber spoon_'s Avatar
    Join Date
    Jun 2002
    Location
    ATL
    Posts
    182
    I moved the #define WTF WM_USER + 20 to a header file and everything worked out.

    Thanks all.
    {RTFM, KISS}

  10. #10
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    Code:
    #define WM_WTF (WM_USER + 20)
    Yet another reason why defines are to be avoided. This error would never have happened with a normal constant:
    Code:
    CONST DWORD WM_WTF = (WM_USER + 20);
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. VC++ 6.0 vs .NET 2003
    By Frantic- in forum C++ Programming
    Replies: 4
    Last Post: 06-26-2005, 08:41 AM
  2. Visual C++ .NET 2003 and XP Style
    By kuphryn in forum Windows Programming
    Replies: 1
    Last Post: 10-07-2003, 11:08 AM
  3. FILES in WinAPI
    By Garfield in forum Windows Programming
    Replies: 46
    Last Post: 10-02-2003, 06:51 PM
  4. VC++ .net 2003.....
    By iwod in forum Windows Programming
    Replies: 32
    Last Post: 07-13-2003, 11:44 AM
  5. Visual J#
    By mfc2themax in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 10-08-2001, 02:41 PM