游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1431|回复: 1

请教,关于DDraw基础

[复制链接]

89

主题

207

帖子

221

积分

中级会员

Rank: 3Rank: 3

积分
221
发表于 2004-5-18 16:13:00 | 显示全部楼层 |阅读模式
各位请教一下,做一个基本的DDraw程序,main函数如下(省略了消息处理和ddraw初始化函数)
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,        
                   PSTR szCmdLine, int iCmdShow)        
{      
        static TCHAR szAppName[] = TEXT ("Game");      
        HWND   hwnd;                                        //窗口句柄      
        MSG    msg;
        WNDCLASS wndclass;
        
        wndclass.style                = NULL;      
        wndclass.lpfnWndProc        = WndProc;      
        wndclass.cbClsExtra        = 0;      
        wndclass.cbWndExtra        = 0;      
        wndclass.hInstance        = hInstance;        
        wndclass.hIcon                = NULL;        
        wndclass.hCursor        = NULL;        
        wndclass.hbrBackground        = NULL;        
        wndclass.lpszMenuName        = NULL;      
        wndclass.lpszClassName        = szAppName;
        

        if(!RegisterClass(&wndclass))      
        {        
            MessageBox (  NULL, "Failed registing window.",        
                                  szAppName, MB_ICONERROR);      
            return 0;        
        }

        hwnd = CreateWindow(szAppName,      // window class name      
                        TEXT("The Hello Program"),   // window caption      
                        WS_POPUP|WS_MAXIMIZE,  // window style        
                        CW_USEDEFAULT,// initial x position      
                        CW_USEDEFAULT,// initial y position        
                        GetSystemMetrics( SM_CXSCREEN ),// initial x size        
                        GetSystemMetrics( SM_CYSCREEN ),// initial y size        
                        NULL,                 // parent window handle        
                        NULL,            // window menu handle        
                        hInstance,   // program instance handle      
                        NULL);      // creation parameters
        
        ShowWindow(hwnd,iCmdShow);
        UpdateWindow(hwnd);
      
        while(1)
        {
                if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))        
                {      
                        TranslateMessage(&msg);      
                        DispatchMessage(&msg);                     
                }
        
        }
        return msg.wParam;      
}

程序编译一执行就出错,F10的结果是在createwindow函数结尾处出错:Unhandled exception in Game.exe:0xC0000005:Access Violation  

请问是为什么呢??

如果我去掉这个paint函数,就不会出现这个情况.但是这个paint函数是贴图和换页的函数,不能省略的

24

主题

229

帖子

229

积分

中级会员

Rank: 3Rank: 3

积分
229
发表于 2004-5-18 21:06:00 | 显示全部楼层

Re:请教,关于DDraw基础

你的窗口函数在哪?
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-7-1 01:43

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表