亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? toolbars.shtml

?? mfc資源大全包含MFC編程各個方面的源碼
?? SHTML
字號:
<html>

<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<meta NAME="Author" CONTENT="Zafir Anjum">
<title>Toolbars and Statusbars on Dialogs</title>
</head>

<body background="../fancyhome/back.gif" bgcolor="#FFFFFF" link="#B50029" vlink="#8E2323"
alink="#FF0000">

<table WIDTH="100%">
  <tr WIDTH="100%">
    <td align="center"><!--#exec cgi="/cgi/ads.cgi"--></td>
    <td></td>
  </tr>
</table>

<h3 align="center"><font COLOR="#AOAO99">Toolbars and Statusbars on Dialogs </font></h3>

<hr align="center">

<p>This article was contributed by <a HREF="mailto:Cyril.C.Z.ZEKSER@TCC.thomson.fr">ZEKSER
Cyril</a>. </p>

<p>By default, MFC only allows you to add Toolbars and Statusbars on CFrameWnd subclassed
objects. This is great, but if you want to add toolbars on dialogs, you're like an idiot,
because you can't do this easily. </p>

<p>The first problem is that every handler function expect the parent to be a CFrameWnd
subclassed object, and another one is that you can only show tooltips or statusbar message
when the dialog is in IDLE state. In fact, for the control bars to function properly,
you'll have to catch some of the messages that the frame window uses. </p>

<p>I'll have to dig a lot in the documentation to find something that helps me doing that.
One issue was shown me by Mihai Filimon (see articles posted on Monday 16 march 1998),
which was fine, but not very &quot;clean&quot; since you have to make room for the bar
with an invisible static object. (I thanks a lot him for showing the light at the end of
the tunnel). </p>

<p>Let me expose you what to do if you want a toolbar (fixed, there is no other way
possible) and a menu which can talk with any StatusBar in the application (even in the
dialog but I think it will be the subject of another article). </p>

<p>I&#146;ll only expose you how to add a Toolbar on a dialog (the menu is obvious since
you only have to define one and add it on the resource editor). </p>

<p>First, you&#146;ll have to develop your dialog (with its object) without bothering the
place of the ToolBar, and subclass the CDialog class to use this dialog template (nothing
new here). </p>

<p>Then, add this code on the CDialog::OnInitDialog function (the m_wndToolBar variable is
of type CToolBarEx) : </p>

<pre><tt><font COLOR="#990000">
BOOL CMyDlg::OnInitDialog() 
{
	// TODO: Add extra initialization here
	CDialog::OnInitDialog();

	// Add the ToolBar.
	if (!m_wndToolBar.Create( this ) ||
		!m_wndToolBar.LoadToolBar(IDR_CORPS_EMIS) )
	{
		TRACE0(&quot;Failed to create toolbar\n&quot;);
		return -1;      // fail to create
	}

	// TODO: Remove this if you don't want tool tips or a resizeable toolbar
	m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
		CBRS_TOOLTIPS | CBRS_FLYBY  );

// We need to resize the dialog to make room for control bars.
	// First, figure out how big the control bars are.
	CRect rcClientStart;
	CRect rcClientNow;
	GetClientRect(rcClientStart);
	RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 
				   0, reposQuery, rcClientNow);
	
	// Now move all the controls so they are in the same relative
	// position within the remaining client area as they would be
	// with no control bars.
	CPoint ptOffset(rcClientNow.left - rcClientStart.left,
					rcClientNow.top - rcClientStart.top); 

	CRect  rcChild;					
	CWnd* pwndChild = GetWindow(GW_CHILD);
	while (pwndChild)
	{                               
		pwndChild-&gt;GetWindowRect(rcChild);
		ScreenToClient(rcChild);
		rcChild.OffsetRect(ptOffset);
		pwndChild-&gt;MoveWindow(rcChild, FALSE);
		pwndChild = pwndChild-&gt;GetNextWindow();
	}

	// Adjust the dialog window dimensions
	CRect rcWindow;
	GetWindowRect(rcWindow);
	rcWindow.right += rcClientStart.Width() - rcClientNow.Width();
	rcWindow.bottom += rcClientStart.Height() - rcClientNow.Height();
	MoveWindow(rcWindow, FALSE);
	
	// And position the control bars
	RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
</font></tt></pre>

<p>You can see that it is not obvious (I found it in a more complicated sample called
DLGCBR32, and I work a lot to find out the functions that are compulsory, and the others) </p>

<p>At that point, you have only a Toolbar in top of your dialog (you see that any toolbar
can fit the requirements to be shown in a dialog, since the preceding code is generic
enough). You can have many toolbars in your dialog, but you must manage the positions by
yourself. </p>

<p>Now, if you want tooltips on your Toolbar, you must handle the following messages
TTN_NEEDTEXTA and TTN_NEEDTEXTW (for both ANSI and Unicode characters sets), in the
following way : </p>

<h4>1. Add the message handlers declaration...</h4>

<pre><tt><font COLOR="#990000">
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
	...
	ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipText)
	ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipText)
END_MESSAGE_MAP()
</font></tt></pre>

<h4>2. Declare the function in your header file that way :</h4>

<pre><tt><font COLOR="#990000">
// Generated message map functions
//{{AFX_MSG(CMyDlg)
afx_msg BOOL OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult);
//}}AFX_MSG
</font></tt></pre>

<h4>3. And finally code your OnToolTipText function that way (comes from MFC Sample) :</h4>

<pre><tt><font COLOR="#990000">
BOOL CMyDlg::OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult)
{
	ASSERT(pNMHDR-&gt;code == TTN_NEEDTEXTA || pNMHDR-&gt;code == TTN_NEEDTEXTW);

	// allow top level routing frame to handle the message
	if (GetRoutingFrame() != NULL)
		return FALSE;

	// need to handle both ANSI and UNICODE versions of the message
	TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
	TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
	TCHAR szFullText[256];
	CString cstTipText;
	CString cstStatusText;

	UINT nID = pNMHDR-&gt;idFrom;
	if (pNMHDR-&gt;code == TTN_NEEDTEXTA &amp;&amp; (pTTTA-&gt;uFlags &amp; TTF_IDISHWND) ||
		pNMHDR-&gt;code == TTN_NEEDTEXTW &amp;&amp; (pTTTW-&gt;uFlags &amp; TTF_IDISHWND))
	{
		// idFrom is actually the HWND of the tool
		nID = ((UINT)(WORD)::GetDlgCtrlID((HWND)nID));
	}

	if (nID != 0) // will be zero on a separator
	{
		AfxLoadString(nID, szFullText);
			// this is the command id, not the button index
		AfxExtractSubString(cstTipText, szFullText, 1, '\n');
		AfxExtractSubString(cstStatusText, szFullText, 0, '\n');
	}

	// Non-UNICODE Strings only are shown in the tooltip window...
	if (pNMHDR-&gt;code == TTN_NEEDTEXTA)
		lstrcpyn(pTTTA-&gt;szText, cstTipText,
            (sizeof(pTTTA-&gt;szText)/sizeof(pTTTA-&gt;szText[0])));
	else
		_mbstowcsz(pTTTW-&gt;szText, cstTipText,
            (sizeof(pTTTW-&gt;szText)/sizeof(pTTTW-&gt;szText[0])));
	*pResult = 0;

	// bring the tooltip window above other popup windows
	::SetWindowPos(pNMHDR-&gt;hwndFrom, HWND_TOP, 0, 0, 0, 0,
		SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE);


	return TRUE;    // message was handled
}
</font></tt></pre>

<p>Now you have a toolbar with tooltips (the text shown in the tooltip box is defined the
classic way, with the resource editor). (pheeew ;-) ). </p>

<p>Now, if you want the mainframe's status bar to display the text that would normally be
prompted, the only line (right, the ONLY one) of code you have to add is in the above
function (it is useful for System modal dialog boxes since they are usually small), just
before the return statement (it also assume that m_wndStatusBar is public) : </p>

<pre><tt><font COLOR="#990000">
// Display the text in the mainframe's status bar (assumes the Help pane text
// is at the index zero.
	((CMainFrame*)GetParent())-&gt;m_wndStatusBar.SetPaneText(0, cstStatusText);
</font></tt></pre>

<p>That's all for today. </p>

<p>No, let me tell you just one more thing, if you want your dialog menu to display text
in the mainframe's status bar (on in any other status bar you have created) you can add
the following code to the handler of WM_MENUSELECT (window-type handler) : </p>

<pre><tt><font COLOR="#990000">
void CMyDlg::OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu) 
{
	CDialog::OnMenuSelect(nItemID, nFlags, hSysMenu);
	
	TCHAR szFullText[256];
	CString cstStatusText;
	// TODO: Add your message handler code here
	// Displays in the mainframe's status bar
	if (nItemID != 0) // will be zero on a separator
	{
		AfxLoadString(nItemID, szFullText);
			// this is the command id, not the button index
		AfxExtractSubString(cstStatusText, szFullText, 0, '\n');
		((CMainFrame*)GetParent())-&gt;m_wndStatusBar.SetPaneText(0,cstStatusText);
}
}
</font></tt></pre>

<p><br>
Note that you can't use the ON_UPDATE_COMMAND_UI message on this toolbar, since it can
only be refresh when the dialog enters in idle state. To do so, you must subclass the
CToolBar (or CStatusBar) class - in CMyToolBar for instance -, add the message handler for
WM_IDLEUPDATECMDUI, and write the following code in this function : </p>

<pre><tt><font COLOR="#990000">
/////////////////////////////////////////////////////////////////////////////
// CMyToolBar::OnIdleUpdateCmdUI
//	OnIdleUpdateCmdUI handles the WM_IDLEUPDATECMDUI message, which is 
//	used to update the status of user-interface elements within the MFC 
//	framework.
//
// 	We have to get a little tricky here: CToolBar::OnUpdateCmdUI 
//	expects a CFrameWnd pointer as its first parameter.  However, it
//	doesn't do anything but pass the parameter on to another function
//	which only requires a CCmdTarget pointer.  We can get a CWnd pointer
//	to the parent window, which is a CCmdTarget, but may not be a 
//	CFrameWnd.  So, to make CToolBar::OnUpdateCmdUI happy, we will call
//	our CWnd pointer a CFrameWnd pointer temporarily.  	

LRESULT CMyToolBar::OnIdleUpdateCmdUI(WPARAM wParam, LPARAM) 
{
	if (IsWindowVisible()) 
	{
		CFrameWnd *pParent = (CFrameWnd *)GetParent();
		if (pParent)
			OnUpdateCmdUI(pParent, (BOOL)wParam);
	}
	return 0L;
}
</font></pre>
</tt>

<p><br>
In order to have the toolbar updated you MUST override the ContinueModal() function that
way: </p>

<pre><tt><font COLOR="#990000">
BOOL CMyDlg::ContinueModal()
{
    m_wndToolbar.SendMessage( WM_IDLEUPDATECMDUI, WPARAM(TRUE), 0);


    return CDialog::ContinueModal();
}
</font></pre>
</tt>

<p><br>
For AfxLoadString to compile you must Include the file &quot;Afxpriv.h&quot; at the
beginning of the CPP file. </p>

<hr>

<table BORDER="0" WIDTH="100%">
  <tr>
    <td WIDTH="33%"><font SIZE="-1"><a HREF="http://www.codeguru.com">Goto HomePage</a></font></td>
    <td WIDTH="33%"><p align="center"><font SIZE="-2">

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产激情视频一区二区在线观看| 日韩av在线免费观看不卡| 久久国产精品第一页| 欧美日韩一区二区三区视频 | 国产乱淫av一区二区三区| 欧美大尺度电影在线| 国产麻豆成人精品| 中文成人av在线| 日本高清不卡视频| 丝袜美腿亚洲色图| 日韩欧美国产精品| 国产一区欧美一区| 亚洲欧美日韩中文播放| 欧美精品视频www在线观看| 美国毛片一区二区| 国产精品国产三级国产三级人妇| 免费在线观看一区| 国产欧美日韩久久| 91在线免费播放| 丝袜诱惑亚洲看片| 久久久久九九视频| 欧美性欧美巨大黑白大战| 久久综合久久综合久久| 极品少妇xxxx精品少妇| 国产精品你懂的在线| 欧美丝袜丝交足nylons图片| 精品制服美女丁香| 亚洲人成7777| 精品国产麻豆免费人成网站| 97se亚洲国产综合自在线| 日韩综合一区二区| 日韩一区中文字幕| 26uuu国产电影一区二区| 91视频xxxx| 国产裸体歌舞团一区二区| 亚洲愉拍自拍另类高清精品| 精品国产乱码久久久久久久 | 日韩一区二区中文字幕| 国产成人在线视频网站| 亚洲国产另类av| 国产精品免费丝袜| 欧美成人精品高清在线播放| 91国产福利在线| 国产成人综合视频| 免费在线观看精品| 亚洲福利视频一区| 最好看的中文字幕久久| 国产色综合一区| 欧美一区二区三区在线看| 日本高清视频一区二区| 成人激情开心网| 激情综合网激情| 奇米一区二区三区| 亚洲国产毛片aaaaa无费看| 亚洲天堂精品在线观看| 久久精品视频一区二区| 精品国产99国产精品| 欧美一区二区啪啪| 欧美日韩国产一级| 日本福利一区二区| 色综合中文字幕国产 | 欧美xingq一区二区| 欧美视频中文一区二区三区在线观看| 日韩美女视频19| 精品美女在线观看| 欧美一二三在线| 69久久夜色精品国产69蝌蚪网| 日韩成人免费电影| 亚洲一级二级在线| 夜夜嗨av一区二区三区中文字幕| 欧美亚洲高清一区二区三区不卡| 日本亚洲三级在线| 日韩极品在线观看| 日本欧美大码aⅴ在线播放| 一区二区三区在线观看视频| 亚洲欧美一区二区三区国产精品| 欧美肥妇free| 欧美一级生活片| 欧美成人免费网站| 久久久夜色精品亚洲| 久久久91精品国产一区二区精品| 色综合久久久久网| 99视频精品在线| 91国产福利在线| 欧美无人高清视频在线观看| 欧美老肥妇做.爰bbww视频| 欧美一区二区三区视频在线观看| 成人免费三级在线| 色欲综合视频天天天| 在线观看国产91| 欧美久久一二三四区| 日韩欧美www| 欧美国产日本韩| 亚洲一区欧美一区| 麻豆91精品视频| 懂色av中文一区二区三区| 99久久综合狠狠综合久久| 欧美性感一类影片在线播放| 欧美日韩国产高清一区二区三区| 成人在线视频一区二区| 成人av电影在线播放| 欧美体内she精视频| 精品成a人在线观看| 国产欧美视频一区二区| 亚洲精品午夜久久久| 日韩电影一区二区三区四区| 国产一区二区福利| 色综合色综合色综合色综合色综合 | 欧美午夜一区二区| 精品美女在线观看| 亚洲视频中文字幕| 日韩av一区二区在线影视| 精品无码三级在线观看视频| 成人一区二区三区在线观看| 在线观看国产91| 国产亚洲一区二区三区四区| 亚洲另类春色国产| 久久不见久久见免费视频1| 不卡的av网站| 欧美成人精品高清在线播放| 亚洲人成精品久久久久久| 精品一区二区三区欧美| 91免费看`日韩一区二区| 日韩三级在线观看| 亚洲精品国产a| 国产九九视频一区二区三区| 欧美视频一区在线| 国产精品三级视频| 日本成人在线看| 成人精品免费网站| 日韩三区在线观看| 亚洲国产精品久久不卡毛片 | 国产精品乱码久久久久久| 日本伊人午夜精品| 91麻豆123| 久久久九九九九| 另类调教123区| 欧美日韩精品一区二区三区四区 | 在线精品国精品国产尤物884a| 91视频你懂的| 久久久久成人黄色影片| 人人精品人人爱| 欧美日韩亚洲不卡| 亚洲欧美中日韩| 韩国毛片一区二区三区| 欧美肥大bbwbbw高潮| 亚洲午夜影视影院在线观看| 成人污污视频在线观看| 精品国产网站在线观看| 日韩福利视频网| 欧美电影在线免费观看| 亚洲第一狼人社区| 色94色欧美sute亚洲13| 亚洲私人影院在线观看| 99精品热视频| 亚洲欧美另类综合偷拍| 99精品欧美一区二区蜜桃免费 | 欧美一区午夜视频在线观看| 一区二区三区精品视频在线| a在线播放不卡| 中文字幕欧美一| 成人高清免费观看| 中文字幕 久热精品 视频在线 | 欧美mv和日韩mv的网站| 首页国产欧美久久| 欧美午夜影院一区| 亚洲成国产人片在线观看| 欧美影视一区在线| 亚洲午夜一区二区| 91麻豆精品国产无毒不卡在线观看| 欧美极品xxx| 不卡欧美aaaaa| 一区二区三区在线观看欧美| 在线观看欧美黄色| 亚洲18色成人| 8x福利精品第一导航| 蜜臀久久99精品久久久久宅男 | 国产中文字幕一区| 欧美成人三级在线| 国产成人在线视频免费播放| 国产精品萝li| 欧美在线视频日韩| 奇米综合一区二区三区精品视频| 94色蜜桃网一区二区三区| 亚洲男人的天堂一区二区| 欧美在线观看视频一区二区| 日韩电影一二三区| 久久久精品tv| 色妹子一区二区| 日韩国产欧美一区二区三区| 精品福利视频一区二区三区| 东方aⅴ免费观看久久av| 亚洲欧美日韩在线不卡| 欧美精品第一页| 国产高清不卡二三区| 一区二区三区四区不卡在线| 777奇米成人网| zzijzzij亚洲日本少妇熟睡| 亚洲第四色夜色| 国产日产欧产精品推荐色|