#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    13
    Rep Power
    0

    D3D programming in C++ using VisualC++6.0


    I need to figure out this problem..im trying to make a window skeleton....here is the code...

    #include <windows.h>
    LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
    char szWinName[] = "Crusher"; /* name of window class */
    int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst, LPSTR lpszArgs, int nWinMode)
    {
    HWND hwnd;
    MSG msg;
    /* Step 1: Define a window class. */
    WNDCLASS wcl;
    wcl.hInstance = hThisInst; /* handle to this instance */
    wcl.lpszClassName = szWinName; /* window class name */
    wcl.lpfnWndProc = WndProc; /* window function */
    wcl.style = 0; /* default style */
    wcl.hIcon = LoadIcon(NULL, MAKEINTRESOURCE( IDI_APPLICATION)); /* icon style */
    wcl.hCursor = LoadCursor(NULL, IDC_ARROW); /* cursor style */
    wcl.lpszMenuName = NULL; /* no menu */
    wcl.cbClsExtra = 0; /* no extra */
    wcl.cbWndExtra = 0; /* 0 information needed */
    wcl.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH) ; /* Make the window background white. */
    /* Step 2: Register the window class. */
    if(!RegisterClass (&wcl))
    return 0;
    /* Step 3: Now that a window class has been registered, a window can be created. */
    hwnd = CreateWindow(szWinName, /* name the window class */
    "FAKE 4", /* title */
    WS_OVERLAPPEDWINDOW, /* window style - normal */
    CW_USEDEFAULT, /* x coordinate - let Windows decide */
    CW_USEDEFAULT, /* y coordinate - let Windows decide */
    HWND_DESKTOP, /* no parent window */
    NULL, /* no menu */
    hThisInst, /* handle of this instance of the program */
    NULL /* no additional arguments */
    );
    /* Step 4: Display the window. */
    ShowWindow(hwnd, nWinMode);
    /* Step 5: Create the message loop. */
    while (GetMessage(&msg, NULL, 0, 0))
    {
    TranslateMessage(&msg); /* allow use of keyboard */
    DispatchMessage(&msg); /* return control to Windows */
    }
    return msg.wParam;
    }
    //__________________________________________________________
    // Name: WndProc
    // Desc: This function is called by Windows and is passed
    // messages from the message queue
    //__________________________________________________________
    LRESULT CALLBACK WndProc(HWND, UINT message,WPARAM wParam, LPARAM lParam)
    {
    switch (message)
    {
    case WM_DESTROY: /* terminate the program */
    PostQuitMessage(0);
    break;
    default: /* Let Windows process any messages not specified in the preceding switch statement. */
    return DefWindowProc(hwnd, message, wParam, lParam);
    }
    return 0;
    }
    int WINAPI WinMain(
    HINSTANCE hInstance, // handle to current instance
    HINSTANCE hPrevInstance,// handle to previous instance
    LPSTR lpCmdLine, // command line
    int nCmdShow // show state
    );

    here are my errors....I need help with the errors..here they are:

    Compiling...
    D3D.CPP
    c:\program files\microsoft visual studio\myprojects\d3d\d3d.cpp(33) : warning C4003: not enough actual parameters for macro 'CreateWindowA'
    c:\program files\microsoft visual studio\myprojects\d3d\d3d.cpp(33) : error C2059: syntax error : ','
    c:\program files\microsoft visual studio\myprojects\d3d\d3d.cpp(57) : error C2065: 'hwnd' : undeclared identifier
    Error executing cl.exe.

    D3D.OBJ - 2 error(s), 1 warning(s)
  2. #2
  3. No Profile Picture
    Offensive Member
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2002
    Location
    in the perfect world
    Posts
    622
    Rep Power
    28
    Please use code tags..........
    Line numbers are meaningless unless WE can see the line numbers. They do not match the lines on the post here.

    Point out the line giving the error.

    your problems could be solved by looking at the help files for the CreateWindow() function

    you have missed the width, height OR X-pos, Y_pos params in the call to create window.


    no variable name declared in function declaration.
    LRESULT CALLBACK WndProc(HWND, UINT message,WPARAM wParam, LPARAM lParam)
    The essence of Christianity is told us in the Garden of Eden history. The fruit that was forbidden was on the Tree of Knowledge. The subtext is, All the suffering you have is because you wanted to find out what was going on. You could be in the Garden of Eden if you had just kept your f***ing mouth shut and hadn't asked any questions.

    Frank Zappa
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    13
    Rep Power
    0
    ok thanks for the help...I got most of the errors fixed but one....here is the code and I will point where the error is sposed to be..its marked by>>:

    #include <windows.h>
    LRESULT CALLBACK WndProc(HWND, UINT message, WPARAM wParam, LPARAM lParam);
    char szWinName[] = "Crusher"; /* name of window class */
    int WINAPI WinMain(HINSTANCE hThisInst, HINSTANCE hPrevInst,
    LPSTR lpszArgs, int nWinMode)
    {
    HWND hwnd;
    MSG msg;
    /* Step 1: Define a window class. */
    WNDCLASS wcl;
    wcl.hInstance = hThisInst; /* handle to this instance */
    wcl.lpszClassName = szWinName; /* window class name */
    wcl.lpfnWndProc = WndProc; /* window function */
    wcl.style = 0; /* default style */
    wcl.hIcon = LoadIcon(NULL, MAKEINTRESOURCE( IDI_APPLICATION)); /* icon style */
    wcl.hCursor = LoadCursor(NULL, IDC_ARROW); /* cursor style */
    wcl.lpszMenuName = NULL; /* no menu */
    wcl.cbClsExtra = 0; /* no extra */
    wcl.cbWndExtra = 0; /* 0 information needed */
    wcl.hbrBackground =
    (HBRUSH) GetStockObject(WHITE_BRUSH) ; /* Make the window background white. */
    /* Step 2: Register the window class. */
    if(!RegisterClass (&wcl))
    return 0;
    /* Step 3: Now that a window class has been registered, a window can be created. */
    hwnd = CreateWindow(szWinName, /* name the window class */
    "FAKE 4", /* title */
    WS_OVERLAPPEDWINDOW, /* window style - normal */
    CW_USEDEFAULT, /* x coordinate - let Windows decide */
    CW_USEDEFAULT, /* y coordinate - let Windows decide */
    CW_USEDEFAULT, /* width - let windows decide */
    CW_USEDEFAULT, /* height - let windows decide */
    HWND_DESKTOP, /* no parent window */
    NULL, /* no menu */
    hThisInst, /* handle of this instance of the program */
    NULL /* no additional arguments */
    );
    /* Step 4: Display the window. */
    ShowWindow(hwnd, nWinMode);
    /* Step 5: Create the message loop. */
    while (GetMessage(&msg, NULL, 0, 0))
    {
    TranslateMessage(&msg); /* allow use of keyboard */
    DispatchMessage(&msg); /* return control to Windows */
    }
    return msg.wParam;
    }
    //__________________________________________________________
    // Name: WndProc
    // Desc: This function is called by Windows and is passed
    // messages from the message queue
    //__________________________________________________________
    LRESULT CALLBACK WndProc(HWND, UINT message,
    WPARAM wParam, LPARAM lParam)
    {
    switch (message)
    {
    case WM_DESTROY: /* terminate the program */
    PostQuitMessage(0);
    break;
    default: /* Let Windows process any messages not specified in the preceding switch statement. */
    >> return DefWindowProcA(hwnd, message, wParam, lParam);
    }
    return 0;
    }
    int WINAPI WinMain(
    HINSTANCE hInstance, // handle to current instance
    HINSTANCE hPrevInstance,// handle to previous instance
    LPSTR lpCmdLine, // command line
    int nCmdShow // show state
    );

    this is the error its marked by >> :
    error C2065: 'hwnd' : undeclared identifier
    Last edited by bes; July 1st, 2003 at 10:32 AM.
  6. #4
  7. No Profile Picture
    Offensive Member
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2002
    Location
    in the perfect world
    Posts
    622
    Rep Power
    28
    Again please use code tags. It makes it a lot easier to look at the code if it is indented properly. Most people will just ignore your post otherwise.

    As I am going to now.

    PS I believe I already fixed your second problem. You just failed to see the solution..............
    The essence of Christianity is told us in the Garden of Eden history. The fruit that was forbidden was on the Tree of Knowledge. The subtext is, All the suffering you have is because you wanted to find out what was going on. You could be in the Garden of Eden if you had just kept your f***ing mouth shut and hadn't asked any questions.

    Frank Zappa
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    10
    Rep Power
    0

    hwnd isn't identified


    your code says:
    LRESULT CALLBACK WndProc(HWND, UINT message,
    WPARAM wParam, LPARAM lParam)
    where it should be:
    LRESULT CALLBACK WndProc(HWND hwnd /* right before here is your problem */, UINT message,
    WPARAM wParam, LPARAM lParam)

    You forgot to put hwnd after HWND in the function declaration.
    That's what's wrong.
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Posts
    13
    Rep Power
    0
    thank you for your help..and not being an *** like the other guy:-)...the reason why i didnt put code tags is because I dont know WTF he is talking about....I showed him exactly where the problem was in the second one...ah well...thanx for the help
  12. #7
  13. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,253
    Rep Power
    2222
    Originally posted by bes
    thank you for your help..and not being an *** like the other guy:-)...the reason why i didnt put code tags is because I dont know WTF he is talking about....I showed him exactly where the problem was in the second one...ah well...thanx for the help
    This is what the other guy was talking about:
    Code tags tell the forum software that what lies between the tags is code and therefore needs to retain its indentation. Without code tags, that indentation gets stripped away and the resulting output becomes nearly unreadable.

    If you want free help from somebody, don't make it more difficult for them to help you. That means you should make your code as readable as possible. If you don't use code tags, then you are not only not doing your part, but you are also making it unnecessarily difficult for us. When confronted with a long listing of unreadable code that you could have very easily made readable but couldn't bother to, then our first reaction is that we can't bother to help you either.

    Now, "What is a code tag or any other kind of tag for that matter?", you may ask. It is analogous to HTML tags, only square brackets are used instead of "angle brackets". The open tag places the tag name inside square brackets and the close tag does the same except the name is preceded by a slash ('/'). For an example, reply to this message and look at the url tags under your edit box on the line starting with "Automatically parse URLs:" And if you quote my post when you reply, you will see quote tags around my message and you will see in this paragraph that I used bold tags, italics tags, and underline tags.

    You use code tags the same way; for example:
    Code:
    #include <stdlib.h>
    #include <stdio.h>
    
    int main(int argc, char *argv[])
    {
        long x;
        int i;
        float f;
        
        if (argc != 2)
        {
            fprintf(stderr,"Usage: f2hex <floating-point value>");
            exit(1);
        }
        
        x = atol(argv[1]);
        f = (float)x;
        printf("%g = ",f);
        
        for (i=3; i>= 0; i--)
            printf(" %02X",((unsigned char*)(&f))[ i ]);
        printf("\n"); 
        
        return 0;       
    }
    You will notice that my code retained its indentation and hence its readability. That is what code tags do for us. So please use them.

    BTW, this is covered in part in the sticky-note "New Users ... Read This First" post at the top of the forum section. So he was perhaps partially justified in copping the attitude that you should have known already what code tags are and that you need to use them.

    And if you didn't know, then instead of copping an attitude yourself, you needed to ask him what code tags are.
    Last edited by dwise1_aol; July 7th, 2003 at 02:58 PM.

IMN logo majestic logo threadwatch logo seochat tools logo