来说说你们开发一个mfc程序的步骤
来说说你们开发一个mfc程序的步骤 本帖最后由 howzyao 于 2022-10-25 23:57 编辑WinMain里写:
set_cursor_title();
SetTimer(NULL, 10, 20, TimeProc);
while (GetMessage (&messages, NULL, 0, 0))
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
return messages.wParam;
回调里写:
EndBatchDraw();
callback_input();
switch (message) /* handle the messages */
{
case WM_CREATE:
break;
case WM_DESTROY:
KillTimer(NULL, 10);
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message, wParam, lParam);
}
KillTimer(NULL, 10);
return 0;
定时事件里写
void CALLBACK TimeProc(HWND hwnd, UINT message, UINT idTimer, DWORD dwTime)
{
cnt ++;
//FlushBatchDraw(); //每20毫秒画一次
//EndBatchDraw();
update();
EndBatchDraw();
}
顶上的写:
#if defined(UNICODE) && !defined(_UNICODE)
#define _UNICODE
#elif defined(_UNICODE) && !defined(UNICODE)
#define UNICODE
#endif
#include <tchar.h>
#include <graphics.h>
#include <mmsystem.h>
#include <Vfw.h>
#include <direct.h>
#include <math.h>
#include <time.h>
#include <stdio.h>
#include <conio.h>
UINT cnt = 0;
//定时器回调函数
void CALLBACK TimeProc(HWND hwnd, UINT message, UINT idTimer, DWORD dwTime);
//线程回调函数
DWORD CALLBACK WindowProcedure(PVOID pvoid);
/*Declare Windows procedure*/
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
/*Make the class name into a global variable*/
TCHAR szClassName[ ] = _T("e3 首个GUI32工程 需要按一下win键才能点击关闭 退出");
const int gw=1024;
const int gh=768;
/*Make the class name into a global variable*/
TCHAR szClassName[ ] = _T("e3 首个GUI32工程 需要按一下win键才能点击关闭 退出");
const int gw=1024;
const int gh=768;
MOUSEMSG msg;
MSG messages;
char name;
HWND mciwnd;
HWND hwnd;
RECT screen;
POINT screenlt,screenrb;
HCURSOR nullcursor;
void set_cursor_title();
int getmsg();
void up();
void down();
void left();
void right();
void pause();
void pause_title();
void play_sound(int);
void preparation();
void over();
IMAGE a, b, c, d;
IMAGE amask,bmask, cmask, dmask;
void loadimg()
{
loadimage(&amask,"./res/bg00.dat");
loadimage(&a,"./res/bg02.png");
loadimage(&bmask,"./res/ball00.dat");
loadimage(&b,"./res/ball01.dat");
loadimage(&cmask,"./res/block00.dat");
loadimage(&c,"./res/block01.dat");
loadimage(&dmask,"./res/paddle00.dat");
loadimage(&d,"./res/paddle01.dat");
}
class e
{
int len;
int *x,*y,*state,*mx,*my;
public:
e();
~e();
e(int);
void putpng(IMAGE&,IMAGE&);
void set_statu(int,int);
void set_xy(int,int,int);
intget_len();
intget_state();
void paddle_move(IMAGE&);
void block_stage(int);
};
e bg(1);
e ball(16);
e block(102);
e paddle(1);
void init_paddle();
void init_ball();
void init();
void update();
void the_millisecond_delay(int ms);
//加上几个e::中的方法不列举
外加说明:
GUI32工程学习
依旧要头库文件和设置链接器:
-leasyx //使用graphics.h时秘须要的参数
-lwinmm //使用mmsystem.h时必须要的参数
就跑起来了.
https://fishc.com.cn/thread-219940-1-1.html
这里有截图,和下载附件运行.
页:
[1]