Results 1 to 21 of 21

Thread: Man This Stinks

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Whaaaaat...........
    Posts
    44

    Man This Stinks

    Could ne one help me here? im now gettin into windows API, and I tried to manually debug it, but I cannot snatch the error. help ne one?

    Here it is:

    #include <windows.h>

    LRESULT CALLBACK WndProc (HWND hWindow, UNIT iMessage, WPARAM wParam, LPARAM lParam);

    int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nShowCmd)
    {
    WNDCLASS kWndClass;

    kWndClass.hCursor = LoadCursor (NULL, IDC_ARROW);
    kWndClass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    kWndClass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);

    kWndClass.hInstance = hInstance;
    kWndClass.lpfnWndProc = WndProc;
    kWndClass.lpszClassName = "Alex's Window";

    kWndClass.lpszMenuName = NULL;

    kWndClass.cbClsExtra = NULL;
    kWndClass.cbWndExtra = NULL;
    kWndClass.style = NULL;

    if (!RegisterClass (&kWndClass))
    {
    return -1;
    }

    HWND hWindow;

    hWindow = CreateWindow ("Alex's Window", "A Blank Window", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);

    MSG kMessage;
    while (GetMessage (&kMessage, hWindow, 0, 0))
    {
    TranslateMessage (&kMessage);
    DispatchMessage (&kMessage)
    }

    return 0;
    }

    LRESULT CALLBACK WndProc (HWND hWindow, UNIT iMessage, WPARAM wParam, LPARAm lParam)
    {
    switch (iMessage)
    {
    case WM_CLOSE;
    POSTQUITMESSAGE (0);
    break;

    default:
    return DefWindowProc (hWindow, iMessage, wParam, lParam);
    }
    return 0;
    }

    I'd Appreciate any help! thanks ohh and here are the errors....

    --------------------Configuration: Window - Win32 Debug--------------------
    Compiling...
    Window S.cpp
    C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(3) : error C2061: syntax error : identifier 'UNIT'
    C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(14) : error C2440: '=' : cannot convert from 'long (__stdcall *)(struct HWND__ *)' to 'long (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
    This conversion requires a reinterpret_cast, a C-style cast or function-style cast
    C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(37) : error C2143: syntax error : missing ';' before '}'
    C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(42) : error C2061: syntax error : identifier 'UNIT'
    C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(44) : error C2065: 'iMessage' : undeclared identifier
    C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(46) : error C2143: syntax error : missing ':' before ';'
    C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(47) : error C2065: 'POSTQUITMESSAGE' : undeclared identifier
    C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(51) : error C2065: 'wParam' : undeclared identifier
    C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(51) : error C2065: 'lParam' : undeclared identifier
    Error executing cl.exe.

    Window.exe - 9 error(s), 0 warning(s)
    A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.

  2. #2
    Lively Member
    Join Date
    May 2002
    Location
    Oregon
    Posts
    64
    instead of UNIT try UINT where you declare the WndProc procedure...

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    I could solve every error for you, but that would be of little use to you.

    First I recommend you walk through your app and search for missing ; or places where you confused : and ;
    I see two errors coming from that.

    Then you should correct the error Arawn pointed out. UINT is an abbreviation for unsigned integer.

    Next check case. C++ is case sensitive and names of the windows API follow a simple case scheme: types and constants are all capitals (1 error) and functions start with a capital and each word in them also starts with a capital (1 error).

    The remaining errors (2) are follow-ups.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Whaaaaat...........
    Posts
    44
    Alright, thaks guys, I appreciate it
    A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.

  5. #5
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    And please always place your code here between code tags:

    [code] Your code here [/code]

    It makes it easier to read since the code is posted exactely (formatting) as you wrote it, and it makes it easier to see in a glance what's code and what not.
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  6. #6

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Whaaaaat...........
    Posts
    44
    Ok thanks guys, im down to 1 error, and im guessing its the function begining not begining with a capital, but where?????

    Code:
    C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(43) : error C2447: missing function header (old-style formal list?)
    A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.

  7. #7
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    What are the lines around line 43? And 43 itself too of course.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  8. #8
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Could it be that you added a ; here?
    Code:
    }
    
    LRESULT CALLBACK WndProc (HWND hWindow, UNIT iMessage, WPARAM wParam, LPARAm lParam) <--
    {
    switch (iMessage)
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  9. #9

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Whaaaaat...........
    Posts
    44
    I erased it and still has one error of the header ****ing old style
    A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.

  10. #10
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Show me your new code.
    And mark the line where the error occurs.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  11. #11

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Whaaaaat...........
    Posts
    44
    alright here:
    Code:
    #include <windows.h>
    
    LRESULT CALLBACK WndProc (HWND hWindow, UINT iMessage, WPARAM wParam, LPARAM lParam);
    
    int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nShowCmd)
    {
    	WNDCLASS kWndClass;
    
    	kWndClass.hCursor   = LoadCursor (NULL, IDC_ARROW);
    	kWndClass.hIcon    = LoadIcon (NULL, IDI_APPLICATION);
    	kWndClass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
    
    	kWndClass.hInstance   = hInstance;
    	kWndClass.lpfnWndProc   = WndProc;
    	kWndClass.lpszClassName   = "Alex's Window";
    
    	kWndClass.lpszMenuName   = NULL;
    
    	kWndClass.cbClsExtra   = NULL;
    	kWndClass.cbWndExtra   = NULL;
    	kWndClass.style   = NULL;
    
    	if (!RegisterClass (&kWndClass))
    	{
    		return -1;
    	}
    
    	HWND hWindow;
    
    	hWindow = CreateWindow ("Alex's Window", "A Blank Window", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
    	
    	MSG kMessage;
    	while (GetMessage (&kMessage, hWindow, 0, 0))
    	{
    		TranslateMessage (&kMessage);
    		DispatchMessage (&kMessage);
    	}
    
    	return 0;
    }
    
    LRESULT CALLBACK WndProc (HWND hWindow, UINT iMessage, WPARAM wParam, LPARAM lParam);
    {
    	switch (iMessage)
    	{
    		case WM_CLOSE;
    			POSTQUITMESSAGE (0);
    			break;
    
    	default:
    		return DefWindowProc (hWindow, iMessage, wParam, lParam)
    	}
    	return 0;
    }
    It dose not really tell me where but once I saw a bue arrow right here:
    Code:
    LRESULT CALLBACK WndProc (HWND hWindow, UINT iMessage, WPARAM wParam, LPARAM lParam);
    {
    The bracket under the function.

    So I dont know if this helped you help me....
    Thanks ne way.
    A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.

  12. #12
    Hyperactive Member
    Join Date
    Sep 2001
    Posts
    396
    Code:
    LRESULT CALLBACK WndProc (HWND hWindow, UINT iMessage, WPARAM wParam, LPARAM lParam);
    {
    Remove the ; like CornedBee has told you.
    Code:
    LRESULT CALLBACK WndProc (HWND hWindow, UINT iMessage, WPARAM wParam, LPARAM lParam)
    {

  13. #13

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Whaaaaat...........
    Posts
    44
    that generates 5 more errors and like 1 warning:


    C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(45) : warning C4060: switch statement contains no 'case' or 'default' labels
    C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(47) : error C2143: syntax error : missing ':' before ';'
    C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(47) : error C2046: illegal case
    C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(48) : error C2065: 'POSTQUITMESSAGE' : undeclared identifier
    C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(49) : error C2143: syntax error : missing ';' before 'break'
    C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(49) : error C2043: illegal break
    C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(51) : error C2047: illegal default
    C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(53) : error C2143: syntax error : missing ';' before '}'
    Error executing cl.exe.

    The Code:

    #include <windows.h>

    LRESULT CALLBACK WndProc (HWND hWindow, UINT iMessage, WPARAM wParam, LPARAM lParam);

    int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nShowCmd)
    {
    WNDCLASS kWndClass;

    kWndClass.hCursor = LoadCursor (NULL, IDC_ARROW);
    kWndClass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    kWndClass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);

    kWndClass.hInstance = hInstance;
    kWndClass.lpfnWndProc = WndProc;
    kWndClass.lpszClassName = "Alex's Window";

    kWndClass.lpszMenuName = NULL;

    kWndClass.cbClsExtra = NULL;
    kWndClass.cbWndExtra = NULL;
    kWndClass.style = NULL;

    if (!RegisterClass (&kWndClass))
    {
    return -1;
    }

    HWND hWindow;

    hWindow = CreateWindow ("Alex's Window", "A Blank Window", WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);

    MSG kMessage;

    while (GetMessage (&kMessage, hWindow, 0, 0))
    {
    TranslateMessage (&kMessage);
    DispatchMessage (&kMessage);
    }

    return 0;
    }

    LRESULT CALLBACK WndProc (HWND hWindow, UINT iMessage, WPARAM wParam, LPARAM lParam)
    {
    switch (iMessage);
    {
    case WM_CLOSE;
    POSTQUITMESSAGE (0)
    break;

    default:
    return DefWindowProc (hWindow, iMessage, wParam, lParam)
    }
    return 0;
    }

    I cannot make ne thing of it lol
    A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.

  14. #14

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Whaaaaat...........
    Posts
    44
    ok never mind, only creates 2 more errors, the other ones were my fault, here are the 2 more:
    C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(47) : error C2143: syntax error : missing ':' before ';'
    C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(48) : error C2065: 'POSTQUITMESSAGE' : undeclared identifier
    C:\Program Files\Microsoft Visual Studio\MyProjects\Window\Window S.cpp(53) : error C2143: syntax error : missing ';' before '}'
    Error executing cl.exe.
    A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.

  15. #15
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Look at the switch in WndProc.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  16. #16

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Whaaaaat...........
    Posts
    44
    ok thanks guys
    A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.

  17. #17

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Whaaaaat...........
    Posts
    44
    ok this is really starting to piss me off..... Ok there are 0 errors in building it, but two errors in compieling it! *** god, I hate this compieler.................. and it hates me.. ok here they are:


    --------------------Configuration: Window S - Win32 Debug--------------------
    Linking...
    LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
    Debug/Window S.exe : fatal error LNK1120: 1 unresolved externals
    Error executing link.exe.

    Window S.exe - 2 error(s), 0 warning(s)

    Ok? some one help? dont tell me you need the code because I posted it only like 6 times above, please help! I need this crap to work!!!!!
    A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.

  18. #18

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Whaaaaat...........
    Posts
    44
    people? please? help?
    A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.

  19. #19
    Frenzied Member Zaei's Avatar
    Join Date
    Jul 2002
    Location
    My own little world...
    Posts
    1,710
    Create a new project that is NOT a Win32 Console Application, but a Win32 Application. Console applications use main as the entry point, Win32 applications use WinMain.

    Z.

  20. #20

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Whaaaaat...........
    Posts
    44
    Zaei, it is a win32 app. , not a console, thanks 4 trying tho
    A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.

  21. #21

    Thread Starter
    Member
    Join Date
    Nov 2002
    Location
    Whaaaaat...........
    Posts
    44
    wait... hold on.... it works!!!!!!!!! YEAH THANKS FINALLY FOR THE SAKE OF GOD!!!!!!!! I thought I made sure it was a win 32 app.
    damn....
    A way to find answers, is to ask questions, for a question that has been asked may seem stupid for 5 minutes, but a question never asked will remain unknown forever.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width