resizing dialog
来源:互联网 发布:武汉淘宝拍摄 编辑:程序博客网 时间:2024/05/20 08:43
When will I use resizing dialog
我不推荐大家使用可改变尺寸的对话框。一般情况下,某些控件的尺寸不能随便调整,如
- Static
- Single Line edit
- etc
有些控件的尺寸是比较适合调整的,如
- multiple Line edit
- ListBox
- ListControl etc
一般情况下,我在以下条件下使用resizing dlg,
- 控件很少
- 只有一个控件需要调整尺寸,其他控件不变。而可调整的控件需要充满剩余窗口
- 如果是Edit控件且该控件右侧没有控件时可以调整它的宽度
implementation
这里我将说一个带有一个可调整尺寸的list ctrl的对话框的实现
准备资源
- 创建一个对话框资源
- 选中最大化框、最小化框和resizing风格
- 把除了list ctrl之外的控件集中在对话框上方,并加一个group control 来括住他们,注意这个控件不能使用ID_STATIC做ID,给一个IDC_FRAME。为了方便计算,这个控件的左右两侧应该靠近对话框边缘
- 把list ctrl放在group control 之外(IDC_LIST1)
创建对话框类,并给IDC_LIST1和IDC_FRAME关联一个控件变量m_frame,m_list
给对话框增加WM_SIZE的处理,代码如下
void CMyDialog::OnSize(UINT nType,int cx,int cy){ CDialog::OnSize(nType,cx,cy); if(m_list.GetSafeHwnd() == NULL)return; CRect rc; //获得组控件的尺寸 m_frame.GetWindowRect(rc); //转换坐标系 ScreenToClient(rc); //改变list的尺寸 m_list.MoveWindow(7, rc.bottom + 5, cx - 14, cy - rc.bottom - 10);}
Notify icon处理函数
void CMyDialog::ShowIcon(BOOL bShow){ NOTIFYICONDATA nid; nid.cbSize =sizeof(nid); nid.hWnd =GetSafeHwnd(); nid.uID =1; nid.uFlags =NIF_MESSAGE|NIF_TIP|NIF_ICON; nid.uCallbackMessage=WM_USER+500; nid.hIcon =m_hIcon;//如果对话框没有icon,需要你在构建对话框时创建一个 GetWindowText(nid.szTip,sizeof(nid.szTip)/sizeof(TCHAR)); if(bShow) { Shell_NotifyIcon(NIM_ADD,&nid); ShowWindow(SW_HIDE); } else { Shell_NotifyIcon(NIM_DELETE,&nid); ShowWindow(SW_RESTORE); }}下面处理WM_USER+500消息,在MessageMapping中增加 ON_MESSAGE(WM_USER+500,OnNotifyIcon)在对话框类中增加Protected函数LRESULT CMyDialog::OnNotifyIcon(WPARAM wParam,LPARAM lParam){ if(lParam == WM_LBUTTONDBLCLK) ShowIcon(TRUE); return 0;}
处理WM_DESTROY消息和WM_SYSCOMMAND+SC_MINIMIZE消息
void CMyDialog::OnDestroy(){ ShowIcon(FALSE); CDialog::OnDestroy();}void CMyDialog::OnSysCommand(UINT nID, LPARAM lParam){ if ((nID & 0xFFF0) == IDM_ABOUTBOX) { CAboutDlg dlgAbout; dlgAbout.DoModal(); } else if (nID == SC_MINIMIZE) { ShowIcon(FALSE);} else { CDialog::OnSysCommand(nID, lParam); }}
- resizing dialog
- EasySize - Dialog resizing in no time!
- EasySize-Dialog-resizing-in-no-time
- EasySize - Dialog resizing in no time!
- EasySize - Dialog resizing in no time!
- EasySize - Dialog resizing in no time!
- EasySize - Dialog resizing in no time!
- CodeProject: EasySize - Dialog resizing in no time!. Free source code and programming help
- CodeProject: EasySize - Dialog resizing in no time!. Free source code and programming help
- MFC对话框Border类型(None、Thin、Resizing、Dialog Frame)对应的部分属性
- MFC对话框Border类型(None、Thin、Resizing、Dialog Frame)对应的部分属性
- MFC对话框Border类型(None、Thin、Resizing、Dialog Frame)对应的部分属性
- MFC对话框自动调整(Automatic Dialog Resizing) -- 翻译 Dmitry Kochin
- Window Resizing
- Nullsoft Winamp Plug-in With Bitmapped UI, Docking and Restrictive Resizing - The Code Project - Dialog and Windows
- Resizing Controls at Runtime
- SoftICE Window Resizing Commands
- resizing applet in browser
- JBoss学习文档
- Linux下C语言的socket函数解析
- DropDownList 实现分页不包含选择值
- 人生的又一个起点
- 用java poi编写代码来设置Excel单元格是否锁定功能?
- resizing dialog
- Ruby
- poi框架如何生成加密的EXCEL
- 用tar打包时忽略文件的目录结构,不保存目录结构
- Error occured during creation of oracle snapshot
- java实现数据库连接池
- 英语中与数字有关的表达方式
- 使用poi灵活生成和读取报表
- 项目计划书--家庭理财系统