#include <Windows.h>
#include <stdio.h>LRESULT CALLBACK les1(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // pointer to command line
int nCmdShow // show state of window
)
{WNDCLASS wndclass
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wndclass.hCursor=Loadcursor(NULL,IDC_IBEAM);
wndclass.hIcon=LoadIcon(NULL,IDI_HAND);
wndclass.hInstance=hInstance;
wndclass.lpfnWndProc=Les1;
wndclass.lpszClassName=lesson1;
wndclass.style=CS_HREDRAW|CS_VREDRAW;
wndclass.lpszMenuName=NULL;
RegisterClass(&wndclass); HWND hwnd;
hwnd=HWND CreateWindow("lesson1","刘向培",WS_OVERLAPPEDWINDOW,
0,0,600,400,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);MSG msg;
While(GetMessage(&msg,NULL,0,0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
} LRESULT CALLBACK les1(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
Switch(uMsg)
{
case WM_CHAR:
char xp[20];
sprintf(xp,"xp Press %d",wParam);
MessageBox(hwnd,xp,"No 1",0);
break; default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
} return 0;
}
#include <stdio.h>LRESULT CALLBACK les1(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);
int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // pointer to command line
int nCmdShow // show state of window
)
{WNDCLASS wndclass
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wndclass.hCursor=Loadcursor(NULL,IDC_IBEAM);
wndclass.hIcon=LoadIcon(NULL,IDI_HAND);
wndclass.hInstance=hInstance;
wndclass.lpfnWndProc=Les1;
wndclass.lpszClassName=lesson1;
wndclass.style=CS_HREDRAW|CS_VREDRAW;
wndclass.lpszMenuName=NULL;
RegisterClass(&wndclass); HWND hwnd;
hwnd=HWND CreateWindow("lesson1","刘向培",WS_OVERLAPPEDWINDOW,
0,0,600,400,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd);MSG msg;
While(GetMessage(&msg,NULL,0,0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
} LRESULT CALLBACK les1(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
Switch(uMsg)
{
case WM_CHAR:
char xp[20];
sprintf(xp,"xp Press %d",wParam);
MessageBox(hwnd,xp,"No 1",0);
break; default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
} return 0;
}
解决方案 »
- 如何得到QQ炫舞那类窗体的句柄
- 如何设置浮动工具栏的大小
- VS2005中toolbar如何给按钮添加点击事件?
- 画图打印,在XP系统下可用,在WIN98下就不正常,有些显示,有些就不显示,都是同样的画图方法
- 如果编写带有工具条的 Activex ?
- 这样为什么会错呢?
- 冒泡排序的代码在控制台和exe向导生成程序中运行为何不一样?
- ????????????
- 求小鸡过河的算法,答对给100分。
- 汉诺塔的问题,为什么能想到用2个递归?内有解法的程序,请指点。
- VC6为什么找不到CView::OnSize或CWnd::OnSize的函数定义??????
- DirectShow中:播放WMV文件,内存泄漏很严重!
Loadcursor(NULL,IDC_IBEAM);--->>LoadCursor注意大小写
wndclass.lpfnWndProc=Les1;---->>les1注意大小写
wndclass.lpszClassName=lesson1;----->>"lesson1"添加双引号
hwnd=HWND CreateWindow("lesson1","刘向培",WS_OVERLAPPEDWINDOW,----->>去掉HWND
0,0,600,400,NULL,NULL,hInstance,NULL);
While(GetMessage(&msg,NULL,0,0)---->>while注意大小写
Switch(uMsg)---->>switch,注意大小写
写的时候也没注意大小写;
已经改过来了
#include <windows.h>
#include <stdio.h>LRESULT CALLBACK les1(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // pointer to command line
int nCmdShow // show state of window
)
{
WNDCLASS wndclass;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hbrBackground=(HBRUSH)GetStockObject(BLACK_BRUSH);
wndclass.hCursor=LoadCursor(NULL,IDC_IBEAM);
wndclass.hIcon=LoadIcon(NULL,IDI_HAND);
wndclass.hInstance=hInstance;
wndclass.lpfnWndProc=les1;
wndclass.lpszClassName = "lesson1";
wndclass.style=CS_HREDRAW|CS_VREDRAW;
wndclass.lpszMenuName=NULL;
RegisterClass(&wndclass); HWND hwnd;
hwnd = CreateWindow("lesson1","刘向培",WS_OVERLAPPEDWINDOW,
0,0,600,400,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,SW_SHOWNORMAL);
UpdateWindow(hwnd); MSG msg;
while (GetMessage(&msg,NULL,0,0)
{ TranslateMessage(&msg);
DispatchMessage(&msg); }
return 0;
} LRESULT CALLBACK les1(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
switch(uMsg)
{
case WM_CHAR:
char xp[20];
sprintf(xp,"xp Press %d",wParam);
MessageBox(hwnd,xp,"No 1",0);
break; default:
return DefWindowProc(hwnd,uMsg,wParam,lParam);
} return 0;
}
再次感谢各位
尤其是wxtsmart
MessageBox(hwnd,xp,"No 1",0);
这段代码显示出来的不是键入的字母
要显示键入的字母应该把%d改成%c吧