Results 1 to 3 of 3

Thread: Where am i wrong?

  1. #1

    Thread Starter
    Hyperactive Member abhid's Avatar
    Join Date
    Nov 2001
    Location
    3rd rock from the sun
    Posts
    467

    Where am i wrong?

    hi all
    i am attaching a C program for windows 2000. I am trying to run
    this in VC++. I get no errors or warnings but the windows
    doesn't shows up!
    What is wrong?Please tell me..
    Thanks in advance
    Attached Files Attached Files

  2. #2
    Member
    Join Date
    Feb 2001
    Posts
    57
    I don't know why your code does not work, but if you change RegisterClassEx to RegisterClass then it works for some reason. Perhaps someone else knows exactly why.


    PHP Code:

    #include <windows.h>
    LRESULT CALLBACK WindowFunc(HWND,UINT,WPARAM,LPARAM);
    char szWinName[] = "MyWin";
    int WINAPI WinMain(HINSTANCE hThisInstance,HINSTANCE hPrevInst,LPSTR
                       lpszArgs
    int nWinMode)
    {
        
    HWND hWnd;
        
    MSG msg;
        
    WNDCLASS wcl;

        
        
    wcl.hInstance hThisInstance;
        
    wcl.lpszClassName szWinName;
        
    wcl.lpfnWndProc WindowFunc;
        
    wcl.style CS_HREDRAW CS_VREDRAW;

        
    wcl.hIcon LoadIcon(NULL,IDI_APPLICATION);
        
    wcl.hCursor LoadCursor(NULL,IDC_ARROW);

        
    wcl.lpszMenuName NULL;
        
    wcl.cbClsExtra 0;
        
    wcl.cbWndExtra 0;
         
        
    wcl.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
        if(!
    RegisterClass(&wcl)) return 0;

        
    hWnd CreateWindow(
            
    szWinName,
            
    "My First Window",
            
    WS_OVERLAPPEDWINDOW,
            
    CW_USEDEFAULT,
            
    CW_USEDEFAULT,
            
    CW_USEDEFAULT,
            
    CW_USEDEFAULT,
            
    NULL,
            
    NULL,
            
    hThisInstance,
            
    NULL
        
    );

        
    ShowWindow(hWnd,nWinMode);
        
    UpdateWindow(hWnd);

        while(
    GetMessage(&msg,NULL,0,0))
        {
            
    TranslateMessage(&msg);
            
    DispatchMessage(&msg);
        }
        return 
    msg.wParam;
    }
    LRESULT CALLBACK WindowFunc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam)
    {
        switch(
    message) {
            case 
    WM_DESTROY:
                
    PostQuitMessage(0);
                break;
            default:
                return 
    DefWindowProc(hWnd,message,wParam,lParam);
        }
        return 
    0;


  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    You must set the hIconSm member of WNDCLASSEX
    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.

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