游戏开发论坛

 找回密码
 立即注册
搜索
查看: 1781|回复: 2

指定窗口消息处理函数的地址时发生错误~~~ 急救!

[复制链接]

1

主题

3

帖子

0

积分

新手上路

Rank: 1

积分
0
发表于 2007-1-16 11:45:00 | 显示全部楼层 |阅读模式
错误信息:
e:\gameworkspace\game2dmapedit\game2dmapedit\gamelib\windowform.cpp(26) : error C3867: “CWindowForm::WndProc”: 函数调用缺少参数列表;请使用“&CWindowForm::WndProc”创建指向成员的指针
e:\gameworkspace\game2dmapedit\game2dmapedit\gamelib\windowform.cpp(26) : error C2440: “=”: 无法从“LRESULT (__stdcall CWindowForm::* )(HWND,UINT,WPARAM,LPARAM)”转换为“WNDPROC”
        没有使该转换得以执行的上下文




源代码:
  #include "../stdafx.h"

class CWindowForm
{
protected:
        HWND hWnd;                                    //窗体句柄
        MSG msg;                                      //当前队列的消息
        WNDCLASSEX wcex;                           //窗体结构

public:
        CWindowForm(void);
        virtual ~CWindowForm(void);

public:
        void CreateForm();
        void ShowForm();
        void UpateForm();
        void CloseForm();

protected:

        LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);  //调用FormProc()
       
        virtual void FormProc() = 0;   //由子类实现,窗体各自定义自己的窗口消息处理
       
};


#include "WindowForm.h"

CWindowForm::CWindowForm(void)
{
}

CWindowForm::~CWindowForm(void)
{
}

LRESULT CALLBACK CWindowForm::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
        //各自窗体的消息处理
        //this->FormProc();

        return :efWindowProc(hWnd, message, wParam, lParam);
}

void CWindowForm::CreateForm()
{
        wcex.lpfnWndProc        = WndProc;
}


郁闷了好长时间了,
大家帮忙来看看啊!!  谢谢了 !


[em7] [em23]

8

主题

716

帖子

716

积分

高级会员

Rank: 4

积分
716
发表于 2007-1-16 14:53:00 | 显示全部楼层

Re:指定窗口消息处理函数的地址时发生错误~~~ 急救!

1. 推荐学习wxWidgets,而不要再在WIN32 API上纠缠了
2. windows在create时需要传一个消息处理的回调函数,而LZ传入的却是一个成员函数指针,当然是不行了,解:
   a. 加一个static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
    b. 再是一个virtual LRESULT CALLBACK OwnWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
    c. 用一个static CWindowForm s_thisptr;在CWindowForm的构造函数里指向this
    d. 注册WndProc,在里面调用s_thisptr->OwnWndProc
3. 以上是实现原理,在网上很多框架代码里有可以参考的,例如nehe.gamedev.net里

1

主题

3

帖子

0

积分

新手上路

Rank: 1

积分
0
 楼主| 发表于 2007-1-16 16:37:00 | 显示全部楼层

Re: 指定窗口消息处理函数的地址时发生错误~~~ 急救!




谢谢!  行了~~ [em13]
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-1-26 06:58

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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