以下是wndproc的源码,window style包含了WM_OWNDCLRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
char exam[100];
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
static RECT fr;
static POINT p;
switch (message)
{
case WM_SIZE:
p.x=LOWORD(lParam);
p.y=HIWORD(lParam);
hdc = BeginPaint(hWnd, &ps);
SetMapMode(hdc,MM_ISOTROPIC);
SetWindowExtEx(hdc,lcxmax,lcymax,0);
SetViewportExtEx(hdc,p.x,p.y,0);
fr.top=0;
fr.left=0;
DPtoLP(hdc,&p,1);
fr.bottom=p.y;
fr.right=p.x;
EndPaint(hWnd, &ps);
break;
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
hdc=GetDC(hWnd);
//Rectangle(hdc,fr.left,fr.top,fr.right,fr.bottom);
FrameRect(hdc,&fr,CreateSolidBrush(RGB(128,256,128)));
ReleaseDC(hWnd,hdc);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
有时有边框有时又没有,有时会出现杂纹,而且边框也不总是贴紧窗口边框的
{
char exam[100];
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
static RECT fr;
static POINT p;
switch (message)
{
case WM_SIZE:
p.x=LOWORD(lParam);
p.y=HIWORD(lParam);
hdc = BeginPaint(hWnd, &ps);
SetMapMode(hdc,MM_ISOTROPIC);
SetWindowExtEx(hdc,lcxmax,lcymax,0);
SetViewportExtEx(hdc,p.x,p.y,0);
fr.top=0;
fr.left=0;
DPtoLP(hdc,&p,1);
fr.bottom=p.y;
fr.right=p.x;
EndPaint(hWnd, &ps);
break;
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
hdc=GetDC(hWnd);
//Rectangle(hdc,fr.left,fr.top,fr.right,fr.bottom);
FrameRect(hdc,&fr,CreateSolidBrush(RGB(128,256,128)));
ReleaseDC(hWnd,hdc);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
有时有边框有时又没有,有时会出现杂纹,而且边框也不总是贴紧窗口边框的
解决方案 »
- 几个子对话框之间交换数据
- 我写了一个 重叠IO的 套接字程序,碰到一个难题
- 从directory.verisign.com请求联系人失败,了解活动目录服务器的please come in
- 窗口大小问题
- FormatMessage用法讲解
- TRACE窗口不断刷出 “Warning: skipping non-radio button in group.”,why?
- 困惑不解,求救
- 为什么我使用ADO方法来读数据库中的数据(使用sql server)长时间运行,就出问题
- 在VC中,如何不装载数据库环境(如MYSQL或SQLSERVER等)就能访问数据库?
- 找一个文件,100分,谢谢!
- VS2008下用unicode
- 详谈ADO,ODBC,ACCESS,SQL之间的联系与区别
另外画边框应该在WM_NCPAINT中实现。
hdc = BeginPaint(hWnd, &ps);
FrameRect(hdc,&fr,CreateSolidBrush(RGB(128,256,128)));
EndPaint(hWnd, &ps);