首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

求解:为何在win32 SDK的框架下GetClientRect()总是返回0

2013-10-14 
求解:为什么在win32 SDK的框架下GetClientRect()总是返回0LRESULT CALLBACK WndProc (HWND hwnd, UINT mes

求解:为什么在win32 SDK的框架下GetClientRect()总是返回0
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static int  cxClient, cyClient ;
HDC         hdc ;
PAINTSTRUCT ps ;
LPRECT      lpRect=0;
long        length,width;
FILE        *in=fopen("f:\\in.txt","r"),*out=fopen("f:\\out.txt","w");
int         x0,y0,xend,yend;

switch (message)
{
case WM_SIZE:
cxClient = LOWORD (lParam) ;
cyClient = HIWORD (lParam) ;
return 0 ;

case WM_PAINT:
hdc = BeginPaint (hwnd, &ps) ;
/*获取文件*/

/*计算现有窗口的边界值*/
if(GetClientRect(hwnd,lpRect)){
length=lpRect->right-lpRect->left;
length/=2;
width=lpRect->bottom-lpRect->top;
width/=2;
}
else{ 
exit(1);
}

fscanf(in,"%d%d%d%d",&x0,&y0,&xend,&yend);
这是部分代码,包含了这个函数。
为什么会出现这种情况呢?小弟刚学win32,很多都不明白。
[解决办法]
LPRECT      lpRect=0;
==> RECT rect;
GetClientRect(hwnd,lpRect)
===>
GetClientRect(hwnd,&rect)

热点排行