孙鑫老师VC++视频问题

来源:百度知道 编辑:UC知道 时间:2024/06/18 04:19:37
# include <windows.h>
# include <stdio.h>

LRESULT CALLBACK WinSunProc
(
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 szChar[10];
sprintf(szChar,"char is %d",wParam);
MessageBox(hwnd,szChar,"金",0);
break;
case WM_LBUTTONDOWN:
MessageBox(hwnd,"Mouse Clicked","金",0);
HDC hDC;
hDC=GetDC(hwnd);
TextOut(hDC,0,50,"I love you!",strlen("I love you!"));
ReleaseDC(hwnd,hDC);
break;
case WM_PAINT:
PAINTSTRUCT ps;
HDC Hdc;
Hdc=BeginPaint(hwnd,&ps);
TextOut(Hdc,0,0,"Fuck the world!",strlen("Fuck the world!"));
EndPaint(hwnd,&ps);
break;
case WM_CLOSE:
if(ID

window.h中包函了strlen
你的消息循环有问题。。。。
TranslteMessage();和DispatchMessage();反了或者改成如下:
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

下次写明第几课嘛~说第几课我大概就知道什么问题了嘛
没时间看源代码了,我记得有一课是说关闭窗口的响应的
说的就是当你点击关闭一个软件的时候,程序调用响应函数A关闭窗口,再调用函数B关闭进程,这些函数都要自己编辑的,如果你在函数A的位置放了一个函数关闭窗口,在B的位置放了一个空函数,那退出程序的时候窗口销毁了,但是进程中程序还运行着

1.# include <stdio.h>里面包含这个类。
2.你创建的窗口句柄仍然在进程中保留着。