Win32的代码,无语法错误,但是不出现窗口

yingzijuntuan 2014-06-16 11:05:27
代码如下:
#include <Windows.h>
#include <iostream>
using namespace std ;
LRESULT CALLBACK ZhqProc(
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, // command line
int nCmdShow // show state
)
{
WNDCLASS wndclass ;
wndclass.style= CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc=ZhqProc;
wndclass.cbClsExtra=0;
wndclass.cbWndExtra=0;
wndclass.hInstance=hInstance ;
wndclass.hIcon=LoadIcon(NULL,IDI_HAND);
wndclass.hCursor=LoadCursor(NULL,IDC_ARROW);
wndclass.hbrBackground=(HBRUSH)COLOR_BACKGROUND;
wndclass.lpszMenuName=NULL;
wndclass.lpszClassName="Zhq";

RegisterClass(&wndclass);

HWND hwnd ;
hwnd=CreateWindow("Zhq","hehe",WS_OVERLAPPEDWINDOW,100,100,400,400,NULL,NULL,hInstance,NULL);

ShowWindow(hwnd,SW_SHOWNORMAL);
MSG msg ;
while(GetMessage(&msg,hwnd,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}

}

LRESULT CALLBACK ZhqProc(
HWND hwnd, // handle to window
UINT uMsg, // message identifier
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
switch(uMsg)
{
case WM_LBUTTONDOWN:
// double xPos = GET_X_LPARAM(lParam);
// double yPos = GET_Y_LPARAM(lParam);

POINTS points;
points=MAKEPOINTS(lParam);
cout<<points.x<<endl;
cout<<points.y<<endl;
break;
default:

DefWindowProc(
hwnd, // handle to window
uMsg, // message identifier
wParam, // first message parameter
lParam // second message parameter
);
break;

}
return 0;
}

还有一个问题,CreateWindow函数里面有一个参数是dwStyle,ShowWindow里面的nCmdShow,假如我把前面的弄成最小化,后面的最大化,那最后窗口会怎么显示?
...全文
111 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
lovecjj19910205 2014-06-19
  • 打赏
  • 举报
回复
改成 return DefWindowProc( hwnd, // handle to window uMsg, // message identifier wParam, // first message parameter lParam // second message parameter );
movsd 2014-06-16
  • 打赏
  • 举报
回复

default:
         return DefWindowProc(
                     hwnd,      // handle to window
                      uMsg,       // message identifier
                      wParam,  // first message parameter
                      lParam   // second message parameter
                    );
        break;

64,646

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧