码迷,mamicode.com
首页 > 编程语言 > 详细

mfc dialog用法

时间:2014-12-29 21:17:37      阅读:250      评论:0      收藏:0      [点我收藏+]

标签:

CDialog
The CDialog class is the base class used for displaying dialog boxes on the screen. Dialog boxes are of two types: modal and modeless. A modal dialog box must be closed by the user before the application continues. A modeless dialog box allows the user to display the dialog box and return to another task without canceling or removing the dialog box.

CDialog::DoModal
virtual int DoModal( );
Remarks
Call this member function to invoke the modal dialog box and return the dialog-box result when done. This member function handles all interaction with the user while the dialog box is active. This is what makes the dialog box modal; that is, the user cannot interact with other windows until the dialog box is closed.

CDialog::Create
BOOL Create( LPCTSTR lpszTemplateName, CWnd* pParentWnd = NULL );
BOOL Create( UINT nIDTemplate, CWnd* pParentWnd = NULL );
Remarks
Call Create to create a modeless dialog box using a dialog-box template from a resource. You can put the call to Create inside the constructor or call it after the constructor is invoked.

CWnd::GetWindowText
int GetWindowText( LPTSTR lpszStringBuf, int nMaxCount ) const;
void GetWindowText( CString& rString ) const;

CWnd::GetDlgItem 
CWnd* GetDlgItem( int nID ) const;
void CWnd::GetDlgItem( int nID, HWND* phWnd ) const;

CWnd::GetDlgItemText 
int GetDlgItemText( int nID, LPTSTR lpStr, int nMaxCount ) const;
int GetDlgItemText( int nID, CString& rString ) const;

CWnd::SetDlgItemText
void SetDlgItemText( int nID, LPCTSTR lpszString );

CWnd::GetDlgItemInt 
UINT GetDlgItemInt( int nID, BOOL* lpTrans = NULL, BOOL bSigned = TRUE ) const;

CWnd::SetDlgItemInt
void SetDlgItemInt( int nID, UINT nValue, BOOL bSigned = TRUE );

CWnd::SendMessage
LRESULT SendMessage( UINT message, WPARAM wParam = 0, LPARAM lParam = 0 );

CWnd::SendDlgItemMessage
LRESULT SendDlgItemMessage( int nID, UINT message, WPARAM wParam = 0, LPARAM lParam = 0 );

EM_GETSEL
EM_SETSEL

对话框控件访问七种方式
1、GetDlgItem()->Get(Set)WindowText()
2、GetDlgItemText()/SetDlgItemText()
3、GetDlgItemInt()/SetDlgItemInt()
4、将控件和整型变量相关联
5、将控件和控件变量相关联
6、SendMessage()
7、SendDlgItemMessage()

CRect::IsRectEmpty
BOOL IsRectEmpty( ) const;

CRect::IsRectNull
BOOL IsRectNull( ) const;

CWnd::GetWindowRect
void GetWindowRect( LPRECT lpRect ) const;

Z-order
窗口的Z次序表明了重叠窗口堆中窗口的位置,这个窗口堆是按一个假想的轴定位的,这个轴就是从屏幕向外伸展的Z轴。Z次序最上面的窗口覆盖所有其它的窗口,Z次序最底层的窗口被所有其它的窗口覆盖。应用程序设置窗口在Z次序中的位置是通过把它放在一个给定窗口的后面,或是放在窗口堆的顶部或底部。

 Windows系统管理三个独立的Z次序——一个用于顶层窗口、一个用于兄弟窗口,还有一个是用于最顶层窗口。最顶层窗口覆盖所有其它非最顶层窗口,而不管它是不是活动窗口或是前台窗口。应用程序通过设置WS_EX_TOPMOST风格创建最顶层窗口。

一般情况下,Windows系统把刚刚创建的窗口放在Z次序的顶部,用户可通过激活另外一个窗口来改变Z次序;Windows系统总是把活动的窗口放在Z次序的顶部,应用程序可用函数BringWindowToTop把一个窗口放置到Z次序的顶部。函数SetWindowPos和DeferWindowPos用来重排Z次序。

窗口
兄弟窗口
         共享同一个父窗口的多个子窗口叫兄弟窗口。

活动窗口
         活动窗口是应用程序的顶层窗口,也就是当前使用的窗口。只有一个顶层窗口可以是活动窗口,如果用户使用的是一个子窗口,Windows系统就激活与这个子窗口相应的顶层窗口。
         何时候系统中只能有一个顶层窗口是活动的。用户通过单击窗口(或其中的一个子窗口)、使用ALT+TAB或ALT+ESC组合键来激活一个顶层窗口,应用程序则调用函数SetActiveWindow来激活一个顶层窗口。


前台窗口和后台窗口
        在Windows系统中,每一个进程可运行多个线程,每个线程都能创建窗口。创建正在使用窗口的线程称之为前台线程,这个窗口就称之为前台窗口。所有其它的线程都是后台线程,由后台线程所创建的窗口叫后台窗口。
        用户通过单击一个窗口、使用ALT+TAB或ALT+ESC组合键来设置前台窗口,应用程序则用函数SetForegroundWindow设置前台窗口。如果新的前台窗口是一个顶层窗口,那么Windows系统就激活它,换句话说,Windows系统激活相应的顶层窗口。

CWnd::SetWindowPos
BOOL SetWindowPos( const CWnd* pWndInsertAfter, int x, int y, int cx, int cy, UINT nFlags );

SetWindowLong
The SetWindowLong function changes an attribute of the specified window. The function also sets a 32-bit (long) value at the specified offset into the extra window memory of a window. 

LONG SetWindowLong(
  HWND hWnd,       // handle of window
  int nIndex,      // offset of value to set
  LONG dwNewLong   // new value
); 

WM_INITDIALOG
The WM_INITDIALOG message is sent to the dialog box procedure immediately before a dialog box is displayed. Dialog box procedures typically use this message to initialize controls and carry out any other initialization tasks that affect the appearance of the dialog box.

WM_INITDIALOG
hwndFocus = (HWND) wParam; // handle of control to receive focus
lInitParam = lParam;       // initialization parameter
 
SetFocus
The SetFocus function sets the keyboard focus to the specified window. The window must be associated with the calling thread‘s message queue. 
HWND SetFocus(
  HWND hWnd   // handle to window to receive focus
);
 
GetNextWindow
The GetNextWindow function retrieves a handle to the next or previous window in the Z order. The next window is below the specified window; the previous window is above. If the specified window is a topmost window, the function retrieves a handle to the next (or previous) topmost window. If the specified window is a top-level window, the function retrieves a handle to the next (or previous) top-level window. If the specified window is a child window, the function searches for a handle to the next (or previous) child window.

HWND GetNextWindow(
  HWND hWnd,  // handle to current window
  UINT wCmd   // direction flag
);

GetWindow
The GetWindow function retrieves a handle to a window that has the specified relationship (Z order or owner) to the specified window.

HWND GetWindow(
  HWND hWnd,  // handle to original window
  UINT uCmd   // relationship flag
);

GetNextDlgTabItem
The GetNextDlgTabItem function retrieves the handle of the first control that has the WS_TABSTOP style that precedes (or follows) the specified control. 
HWND GetNextDlgTabItem(
  HWND hDlg,       // handle of dialog box
  HWND hCtl,       // handle of known control
  BOOL bPrevious   // direction flag
);

CWnd::GetNextWindow 
CWnd* GetNextWindow( UINT nFlag = GW_HWNDNEXT ) const;

CWnd::GetWindow
CWnd* GetWindow( UINT nCmd ) const;

CWnd::GetNextDlgTabItem 
CWnd* GetNextDlgTabItem( CWnd* pWndCtl, BOOL bPrevious = FALSE ) const;

CWnd::SetFocus
CWnd* SetFocus( );

mfc dialog用法

标签:

原文地址:http://www.cnblogs.com/yang95/p/4192338.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!