社区
界面
帖子详情
OnSize(UINT nType, int cx, int cy)
绿豆蛙2013
2008-09-02 08:15:27
这样得到的cx,cy是不是屏幕的宽度和高度?和GetSystemMetrics又有什么区别呢?我想设计一个任何像素的屏幕都能正常显示的界面,该用哪个函数?
...全文
807
3
打赏
收藏
OnSize(UINT nType, int cx, int cy)
这样得到的cx,cy是不是屏幕的宽度和高度?和GetSystemMetrics又有什么区别呢?我想设计一个任何像素的屏幕都能正常显示的界面,该用哪个函数?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
3 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
ykx_yeer
2008-09-02
打赏
举报
回复
OnSize(UINT nType, int cx, int cy) 是用来响应窗口大小变化
cx和cy是窗口变化后客户区的宽度和高度
绿豆蛙2013
2008-09-02
打赏
举报
回复
那OnSize(UINT nType, int cx, int cy) 的作用是什么呢?
datoucaicai
2008-09-02
打赏
举报
回复
cx,cy是不是屏幕的宽度和高度? //不是
用GetSystemMetrics
//这个你测试下就了解了
aaa.rar_OnDestroy_PreTranslateMessage_childview opengl_on
size
_vi
这是用MFC编写的使用openGL的视口代码。 CChildView::CChildView() 构造函数 CChildView::~CChildView() 析构函数 BEGIN_MESSAGE_MAP(CChildView,CWnd ) 消息映射 BOOL CChildView::PreCreateWindow(CREATESTRUCT& cs)创建窗口重新设置窗口参数 BOOL CChildView::PreTranslateMessage( MSG* pMsg ) 翻译消息
int
CChildView::OnCreate( LPCREATESTRUCT lpCreateStruct ) 窗口创建好后进入此函数 完成openGL的初始化 void CChildView::On
Size
( U
INT
nType
,
int
cx
,
int
cy
) 当窗口大小发生改变时重新设置OPenGL的视口参数。 void CChildView::OnDestroy() 销毁窗口
MFC控件大小随窗体大小而改变
一。大小和位置都改变 1.首先为窗体类添加CRect m_rect,该成员变量用来记录窗体的当前大小。 2.在类向导里面(Ctrl+W),为窗体添加消息WM_
SIZE
的响应函数On
Size
(); 注意if(
nType
==1) return;这一句必须添加,否则最小化恢复的时候会出错。 void CPaperManagementDlg::On
Size
(U
INT
nType
,
int
cx
,
int
cy
) { CDialog::On
Size
(
nType
,
cx
,
cy
); if(
nType
==1) return;//最小化则什么都不做 // TODO: Add your messa
Unity常用基础数据类型
sbyte、byte、short、ushort、
int
、u
int
、long、ulong8个是整数,他们之间的区别就是表示氛围不一样,而对于范围不一样的根本原因是类型在内存中的存储不同。
VC++ CTabCtrlBar 多标签
class CMainFrame : public CMDIFrameWnd { DECLARE_DYNAMIC(CMainFrame) public: CMainFrame(); // Attributes public: // Operations public: // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CMainFrame) virtual BOOL PreCreateWindow(CREATESTRUCT& cs); //}}AFX_VIRTUAL // Implementation public: virtual ~CMainFrame(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif protected: // control bar embedded members CStatusBar m_wndStatusBar; CToolBar m_wndToolBar; CDialogBar m_wndTabBar; public: CMyTab m_MyTab; CViewManager m_ViewManager; // Generated message map functions protected: //{{AFX_MSG(CMainFrame) afx_msg
int
OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void On
Size
(U
INT
nType
,
int
cx
,
int
cy
); //}}AFX_MSG DECLARE_MESSAGE_MAP()
界面技术-对话框的内容滚动显示.doc
Selecting the "Horizontal Scroll" and "Verticla Scroll" styles among the properties of your dialog box in the resource editor, you can add scroll bars to the dialog box. Remember also to select the 'resizing' border style. However for adding functionality to the scroll bars, you need to override the WM_VSCROLL and WM_HSCROLL message handlers. Also,override the WM_
SIZE
handler to set the scroll bar range if the
size
is reduced than the original. So you get the original
size
of the dialog in your OninitDialog(). The code would look something like this. Modify to your needs. 1. To OnInitDialog(),add the following line. GetWindowRect(m_rect); m_nScrollPos = 0; to get the original window
size
. Make m_rect a member variable of your dialog. Add another variable m_nScrollPos and initialize its value to zero. It stores the current vertical scroll position. 2. Here is the WM_
SIZE
handler for setting the scroll bar range.Set range 0 if
size
is increased more than original. void CCharlesDlg::On
Size
(U
INT
nType
,
int
cx
,
int
cy
) { CDialog::On
Size
(
nType
,
cx
,
cy
); // TODO: Add your message handler code here m_nCurHeight =
cy
;
int
nScrollMax; if (
cy
< m_rect.Height()) { nScrollMax = m_rect.Height() -
cy
; } else nScrollMax = 0; SCROLLINFO si; si.cb
Size
=
size
of(SCROLLINFO); si.fMask = SIF_ALL;// SIF_ALL = SIF_PAGE | SIF_RANGE | SIF_POS; si.nMin = 0; si.nMax = nScrollMax; si.nPage = si.nMax/10; si.nPos = 0; SetScrollInfo(SB_VERT, &si, TRUE); } You need m_nCurHeight to store the current height of the dialog and use it to handle the scrolling in OnVScroll. m_ncurHeight is also a member variable of the dialog. 3. Here is the handler for WM_VSCROLL. void CCharlesDlg::OnVScroll(U
INT
nSBCode,U
INT
nPos,CScrollBar* pScrollBar) { //TODO:Add your message handler code here and/or call default
int
nDelta;
int
nMaxPos = m_rect.Height() - m_nCurHeight; switch(nSBCode) { case SB_LINEDOWN: if (m_nScrollPos >= nMaxPos) return; nDelta = min(nMaxPos/100,nMaxPos-m_nScrollPos); break; case SB_LINEUP: if (m_nScrollPos <= 0) return; nDelta = -min(nMaxPos/100,m_nScrollPos); break; case SB_PAGEDOWN: if (m_nScrollPos >= nMaxPos) return; nDelta = min(nMaxPos/10,nMaxPos-m_nScrollPos); break; case SB_THUMBPOSITION: nDelta = (
int
)nPos - m_nScrollPos; break; case SB_PAGEUP: if (m_nScrollPos <= 0) return; nDelta = -min(nMaxPos/10,m_nScrollPos); break; default: return; } m_nScrollPos += nDelta; SetScrollPos(SB_VERT,m_nScrollPos,TRUE); ScrollWindow(0,-nDelta); CDialog::OnVScroll(nSBCode, nPos, pScrollBar); } The above code handles the vertical scrolling. For horizontal scrolling add the WM_HSCROLL similarly and add the necessary code to On
Size
and OnInitDialog. Information provided in this document and any software that may accompany this document is provided "as is" without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. The user assumes the entire risk as to the accura
cy
and the use of this information.
界面
15,979
社区成员
115,896
社区内容
发帖
与我相关
我的任务
界面
VC/MFC 界面
复制链接
扫一扫
分享
社区描述
VC/MFC 界面
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章