Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2341650
  • 博文数量: 816
  • 博客积分: 10000
  • 博客等级: 上将
  • 技术积分: 5010
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-17 17:57
文章分类

全部博文(816)

文章存档

2011年(1)

2008年(815)

分类:

2008-12-17 18:05:46

方法:传统SDK
环境:WINXP+SP2+.NET2003
功能描述:
在子窗口里加入EDIT控件以实现基本文字编辑功能
问题描述:
子窗口WM_SIZE消息不能正常工作,体现为2点,1:子窗口最大化时EDIT控件出错(实际可编辑区域不变);2:子窗口最大化后最大化最小化和还原大小按扭消失。
问题代码:(为子窗口窗口函数)
LRESULT CALLBACK HelloProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;

static HWND hWndFrame,hWndClient,hWndEdit;
static HMENU hMenuFrame,hMenuHello,hMenuFrameSub,hMenuHelloSub;
POINT xya,xyb,xy;
RECT wRect;

switch (message)
{
case WM_CREATE:
hWndClient=GetParent(hWnd);
hWndFrame=GetParent(hWndClient);
hMenuFrame=LoadMenu(hInst,(LPCSTR)IDC_MDI);
hMenuHello=LoadMenu(hInst,(LPCSTR)IDC_MDI_HELLO);
hMenuFrameSub=GetSubMenu(hMenuFrame,0);
hMenuHelloSub=GetSubMenu(hMenuHello,0);
/*
GetWindowRect(hWnd,&wRect);//返回屏幕坐标
xya.x=wRect.left;
xya.y=wRect.top;
xyb.x=wRect.right;
xyb.y=wRect.bottom;
ScreenToClient(hWnd,&xya);
ScreenToClient(hWnd,&xyb);
*/
/*
hWndEdit=CreateWindow(TEXT("edit"),NULL,WS_VISIBLE|WS_CHILD|ES_MULTILINE|ES_AUTOVSCROLL
|WS_VSCROLL,0,0,0,0,hWnd,NULL,hInst,NULL);
*/
break;
/*
//使用WM_SIZE不当会导致EDIT的右上按扭消失并滚动条在多子页面时出错
case WM_SIZE:
//MoveWindow(hWndEdit,0,0,LOWORD(lParam),HIWORD(lParam),TRUE);
break;
*/
case WM_RBUTTONUP:
xy.x=LOWORD(lParam);
xy.y=HIWORD(lParam);
ClientToScreen(hWnd,&xy);
TrackPopupMenu(hMenuHelloSub,TPM_RIGHTBUTTON,xy.x,xy.y,0,hWndFrame,NULL);
break;
case WM_MDIACTIVATE:
if(hWnd=(HWND)lParam)
{
            SendMessage(hWndClient,WM_MDISETMENU,(WPARAM)hMenuHello,(LPARAM)hMenuHelloSub);
}
else
{
SendMessage(hWndClient,WM_MDISETMENU,(WPARAM)hMenuFrame,(LPARAM)hMenuFrameSub);
}
DrawMenuBar(hWndFrame);
break;
case WM_COMMAND:
wmId    = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// 分析菜单选择:
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefMDIChildProc(hWnd, message, wParam, lParam);
}
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: 在此添加任意绘图代码...
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
break;
default:
return DefMDIChildProc(hWnd, message, wParam, lParam);
}
return 0;
}


--------------------next---------------------

阅读(1015) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~