c的windows_api中的wm_char消息的有关问题
c的windows_api中的wm_char消息的问题
程序功能:打字练习游戏
程序随机输出字符,当键盘输入的字符与界面中的字符吻合时,消除该字符,否则等待下一个输入的字符;
问题描述:当输入字符在链表中有吻合项时程序没问题,但当输入的字符在链表中无吻合项时,出现无响应现象;求高手告知问题所在;
注:感觉是链表结尾有问题,访问了非法内存,但查看链表的几个函数有找不到问题所在,请各位不吝赐教;
程序功能:打字练习游戏
程序随机输出字符,当键盘输入的字符与界面中的字符吻合时,消除该字符,否则等待下一个输入的字符;
问题描述:当输入字符在链表中有吻合项时程序没问题,但当输入的字符在链表中无吻合项时,出现无响应现象;求高手告知问题所在;
注:感觉是链表结尾有问题,访问了非法内存,但查看链表的几个函数有找不到问题所在,请各位不吝赐教;
#include <windows.h>
#include <stdlib.h>
#include <time.h>
typedef struct node
{
POINT cCoord;
char ch;
struct node *pNext;
}NODE;
typedef NODE *NODELIST;
bool AddNode(NODELIST *pHead); //添加节点
void FreeNodeList(NODELIST *pHead); //释放链表
void DeleteNode(NODELIST *pHead,NODELIST pNode); //删除节点
NODELIST ScanListCh(NODELIST*pHead,char ch); //遍历链表查找字符
void UpdateList(NODELIST *ppHead,int iLimit,int,int); //更新节点数据
void OutputNodeData(HDC,NODELIST,COLORREF); //用指定颜色在指定位置输出字符
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
/* Make the class name into a global variable */
char szClassName[ ] = "CodeBlocksWindowsApp";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nCmdShow)
{
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default colour as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */