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

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

?? cbmpmenu.cpp

?? 最新visualC++編程200例書籍源碼包括對數據庫的操作
?? CPP
?? 第 1 頁 / 共 3 頁
字號:

//////////////////////////////////////////////////////////////
//類名:CBmpMenu
//功能:左側帶位圖或漸變色菜單效果的自繪式菜單顯示
//修改人:徐景周(jingzhou_xu@163.net)
//組織:未來工作室(Future Studio)
//日期:2000.10
///////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "CBmpMenu.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CBmpMenu
// constructor

CBmpMenu::CBmpMenu(int nBitmapW, BOOL bShowBmp4SubMenu, HBITMAP hBitmap, BOOL bStretchBmp)
{
	//check if hbitmap is a valid handle
	BITMAP bitmap;
	if(GetObject(hBitmap, sizeof(bitmap), &bitmap))
	{
		m_hBitmap   = hBitmap;
	}
	else
	{
		m_hBitmap	= NULL;
	}

	//initialize internal data
	m_bShowBmpAll	= bShowBmp4SubMenu;
	m_pOwnerWnd		= m_pToolbar = 0;
	m_bSubMenu		= FALSE;
	m_pSubMenuWnd	= 0;
	m_bStretchBmp	= bStretchBmp;
	m_nTBOffSet		= nBitmapW; //條狀位圖或漸變色寬度

}

CBmpMenu::~CBmpMenu()
{
}

IMPLEMENT_DYNAMIC( CBmpMenu, CWnd )

BEGIN_MESSAGE_MAP(CBmpMenu, CWnd)
	//{{AFX_MSG_MAP(CBmpMenu)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CBmpMenu message handlers

BOOL
CBmpMenu :: Attach( HMENU hMenu )
{
	return CMenu::Attach(hMenu);
}

HMENU
CBmpMenu :: Detach()
{
	return CMenu::Detach();
}


BOOL CBmpMenu::DestroyWindow() 
{
	//Send WM_EXITMENULOOP to the owner window
	m_pOwnerWnd->SendMessage(WM_EXITMENULOOP, FALSE);

	//destroy the current window and set focus to parent if parent is of the same class
	if(::IsWindow(GetParent()->GetSafeHwnd()) && 
		GetParent()->IsKindOf(RUNTIME_CLASS(CBmpMenu)))
	{
		GetParent()->SetFocus();
	}

	return CWnd::DestroyWindow();
}

BOOL
CBmpMenu :: TrackPopupMenu( UINT nFlags, int x, int y, CWnd* pParentWnd, CRect* pItemRect)
{
	//if this is a main menu, then parent window is same as owner window
	if(!m_bSubMenu)
	{
		m_pOwnerWnd = pParentWnd;
	}

	//Send menu messages to owner window
	if(m_pOwnerWnd && IsWindow(m_pOwnerWnd->m_hWnd))
		m_pOwnerWnd->SendMessage(m_bSubMenu?WM_INITMENUPOPUP:WM_INITMENU, (WPARAM)m_hMenu, 0);
	else
		return FALSE;

	//create the main window...child of this will be a toolbar which acts as a kind of menu
	if(!CreateEx(WS_EX_DLGMODALFRAME|WS_EX_PALETTEWINDOW|WS_EX_CONTROLPARENT
					, 0, 0, WS_POPUP|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_BORDER|WS_CHILD, 
					CRect(0,0,0,0), pParentWnd, 0))
		return FALSE;

	//set the data of parent popup menu
	if(m_bSubMenu)
	{
		((CBmpMenu*)GetParent())->m_pSubMenuWnd = this;
	}

	//create toolbar
	m_pToolbar = new MenuToolBar;

	//We add a custom draw toolbar which will act as a menu
	m_pToolbar->CreateEx(this, TBSTYLE_FLAT|TBSTYLE_LIST|TBSTYLE_CUSTOMERASE|TBSTYLE_WRAPABLE,
							WS_CLIPCHILDREN|CCS_NODIVIDER|CCS_NORESIZE|CCS_NOPARENTALIGN|CBRS_TOOLTIPS);

	//Initialize toolbar data and place the menu window on screen
	InitToolBarData(m_pToolbar, CPoint(x,y), pItemRect);

	//show the menu window without activating it....before that make the owner window as foreground window
	if(!m_bSubMenu)
	{
		m_pOwnerWnd->SetForegroundWindow();
	}
	
	ShowWindow(SW_SHOWNA);	

	//capture keyboard input
	SetFocus();

	//if this is a submenu and user had opened it by pressing right arrow key
	if(m_bSubMenu & MENU_SELECTFIRSTITEM)
	{
		m_pToolbar->SendMessage(TB_SETHOTITEM, 0, 0);
	}

	m_bSubMenu &= ~MENU_SELECTFIRSTITEM;

	//send a notification message to owner
	if(m_pOwnerWnd && IsWindow(m_pOwnerWnd->m_hWnd))
		m_pOwnerWnd->SendMessage(WM_ENTERMENULOOP, (WPARAM)m_hMenu, (LPARAM)m_hWnd);

	//run the modal loop so that the menu window acts as a kind of dialog
	RunModalLoop();

	//delete allocated memory and cleanup other stuff
	Cleanup();

	return TRUE;
}
//wp gives a point on which left mouse button was clicked for the parent menu
void CBmpMenu::PopupSubMenu(WPARAM wp, BOOL bSelectFirstItem)
{
	CPoint point(LOWORD(wp), HIWORD(wp));

	//Get the button on which left mouse button was clicked
	int nBtnIndex = (m_pToolbar->GetToolBarCtrl()).HitTest(&point);
	TBBUTTON tbb;
	(m_pToolbar->GetToolBarCtrl()).GetButton(nBtnIndex, &tbb);

/*  
  //得到漸變條顯示文字
	MENUITEMINFO *pMIData = (MENUITEMINFO *)tbb.dwData;
	char *pStr = pMIData->dwTypeData;
	CString strTitle;
	while (*pStr) {
		const char c = pStr[0];
		if (c != '&')
			strTitle  += c;
		pStr++;
	};
*/

	//Get window rectangle of this button
	CRect rect;
	(m_pToolbar->GetToolBarCtrl()).GetItemRect(nBtnIndex, &rect);
	(m_pToolbar->GetToolBarCtrl()).ClientToScreen(&rect);

	//Construct popup menu
	CBmpMenu oSubMenu(m_bShowBmpAll?m_nTBOffSet:0, m_bShowBmpAll, m_bShowBmpAll?m_hBitmap:0, m_bStretchBmp);
	
	//可在此設置漸變色條
//	oSubMenu.SetGradientColors(m_Color1, m_Color2, m_ColorText);
//	oSubMenu.SetTitle(strTitle);
	
	//intialize data of popup menu
	oSubMenu.m_pOwnerWnd = m_pOwnerWnd;

	//When user created an instance of CBmpMenu, automatically a handle was associated with root menu
	//when he called loadMenu or CreatePopupMenu. But we are not doing any of it for submenus..so just attach
	//the menu handle of the submenu to this submenu window

	oSubMenu.Attach(((MENUITEMINFO*)(tbb.dwData))->hSubMenu);

	//Set data to indicate whther first item should be set as a hot item
	oSubMenu.m_bSubMenu = TRUE | bSelectFirstItem;

	//Add the blank space with to get bounds rect of this button in root menu
	rect.left -= m_nTBOffSet;

	//Show the submenu window
	oSubMenu.TrackPopupMenu(0, 0, 0, this, &rect);

	//detach the menu handle
	oSubMenu.Detach();
}

void CBmpMenu::InitToolBarData(CToolBar *pToolBar, CPoint pt, CRect* pItemRect)
{
	//enable tooltips
	pToolBar->EnableToolTips(TRUE);

	//set toolbar buutons bitmap size first. This should be equal to checkmark dimensions
	//button size will be automatically calculated by toolbar
	pToolBar->SendMessage(TB_SETBITMAPSIZE, 0, MAKELPARAM(GetSystemMetrics(SM_CXMENUCHECK), GetSystemMetrics(SM_CYMENUCHECK)));

	//for each menu item...add corrsponding buttons to the toolbar
	for(int i=0; i<(int)GetMenuItemCount(); i++)
	{
		MENUITEMINFO	menuInfo, *pMenuInfo;
		TBBUTTON		buttonInfo;
		char			*pszBuffer;

		//initialize
		menuInfo.cbSize = sizeof(menuInfo);
		menuInfo.fMask = MIIM_CHECKMARKS|MIIM_DATA|MIIM_ID|MIIM_STATE|MIIM_SUBMENU|MIIM_TYPE;
		pszBuffer = new char[MAX_PATH];		//buffer for button text
		menuInfo.cch = MAX_PATH;
		menuInfo.dwTypeData = pszBuffer;
		ZeroMemory(&buttonInfo, sizeof(buttonInfo));

		GetMenuItemInfo(i, &menuInfo, TRUE);
		
		if(menuInfo.dwTypeData == 0)
			delete pszBuffer;

		//store the app defined data pointer
		pMenuInfo = new MENUITEMINFO;
		*pMenuInfo = menuInfo;
		buttonInfo.dwData = (ULONG)pMenuInfo;

		//set button info from menuInfo...default state is enabled
		buttonInfo.fsState = TBSTATE_ENABLED|TBSTATE_WRAP;

		//check if its a separator
		if(menuInfo.fType & MFT_SEPARATOR)
		{
			buttonInfo.fsStyle = TBSTYLE_SEP;
		}

		//check if the menu item is disabled or grayed
		if((menuInfo.fState & MF_GRAYED) || (MF_DISABLED & menuInfo.fState))
			buttonInfo.fsState = 0;

		//set button command id
		buttonInfo.idCommand = menuInfo.wID;

		//add the button
		(pToolBar->GetToolBarCtrl()).AddButtons(1, &buttonInfo);

		//Set button text
		if(menuInfo.dwTypeData)
		{
			pToolBar->SetButtonText(i, pszBuffer);
		}
	}

	//Get the button width and add width of arrow mark to be drawn for popup menus
	int nWidth = LOWORD(pToolBar->GetToolBarCtrl().GetButtonSize());
	nWidth += GetSystemMetrics(SM_CXMENUCHECK);
	//add width for showing arrows for submenus
	pToolBar->GetToolBarCtrl().SetButtonWidth(nWidth, nWidth);

	//set the toolbar button size
	CRect rect1, rect2;

	(pToolBar->GetToolBarCtrl()).GetItemRect(0, &rect1);
	//if all the buttons have dropdown arrow...the toolbar returns extra height equal to one row
	(pToolBar->GetToolBarCtrl()).GetItemRect(GetMenuItemCount()-1, &rect2);

	//set the total toolbar size
	//offset of 3 pixels to either side of the toolbar
	//If another control(bitmap or slider) is to be placed by the side of toolbar then we have to take 
	//into account the width of that control=m_nTBOffSet
	//Also we need to check that this window rect lies in the screen rect
	PositionMenuWindow(pt, pItemRect, CRect(0, 0, rect1.Width()+6+m_nTBOffSet, rect2.bottom-rect1.top+6));

	//place the toolbar window in the menu window
	pToolBar->MoveWindow(m_nTBOffSet, 0, rect1.Width()+6, rect2.bottom-rect1.top+6);

	//Show the toolbar window without activating it
	pToolBar->ShowWindow(SW_SHOWNOACTIVATE);
}


LRESULT CBmpMenu::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
{
	// TODO: Add your specialized code here and/or call the base class
	CWnd*	pWnd = 0;
	BOOL	bFlag = FALSE;

	switch(message)
	{
	case WM_ACTIVATE:
		{
			//Close all menu windows, if another window is being activated because of a mouse click outside menu window
			CWnd oWnd;
			if(lParam && IsWindow(HWND(lParam)) && (LOWORD(wParam) == WA_INACTIVE))
				if(!oWnd.FromHandle(HWND(lParam))->IsKindOf(RUNTIME_CLASS(CBmpMenu)))
					DestroyRootMenu();

			if(!lParam)
				DestroyRootMenu();

			return 0L;
		}
		break;

	case WM_SYSKEYDOWN:
		//destroy root menu when alt or any syskey is pressed
		DestroyRootMenu();
		break;

	case WM_KEYDOWN:
		//pass the keydown event to toolbar
		//If a submenu is being shown for this menu, then key down should be handled by submenu window
		//else pass it to toolbar
		if(m_pSubMenuWnd)
			m_pSubMenuWnd->SendMessage(WM_KEYDOWN, wParam, lParam);
		else
			m_pToolbar->SendMessage(WM_KEYDOWN, wParam, lParam);
		return 0L;

	case WM_RESETDATA:
		//User defined message to be sent to toolbar to reinitialize internal data
		m_pToolbar->SendMessage(WM_RESETDATA, 0, 0);
		return 0L;

	case WM_COMMAND:
		//pass on control specific messages(if any) to owner window
		m_pOwnerWnd->PostMessage(WM_COMMAND, wParam, lParam);
		return 0L;

	case WM_POPUPSUBMENU:
		//popup the submenu
		PopupSubMenu(wParam, lParam);
		return 0L;
	}

	return CWnd::DefWindowProc(message, wParam, lParam);
}

//destroys all menu window
void CBmpMenu::DestroyRootMenu()
{
	if(m_hWnd && IsWindow(m_hWnd))
	{
		CWnd *pParent = GetParent();

		if(pParent && IsWindow(pParent->m_hWnd))
		{
			if(pParent->IsKindOf(RUNTIME_CLASS(CBmpMenu)))
				((CBmpMenu*)pParent)->DestroyRootMenu();	
		}

		if(m_hWnd && IsWindow(m_hWnd))
		{
			DestroySubMenus();

			//end the modal loop started using RunModalLoop in TrackPopupMenu function
			EndModalLoop(0);

			m_pSubMenuWnd = 0;
		}
	}
}

//destroy all the submenu window associated with this menu
void CBmpMenu::DestroySubMenus()
{
	if(m_pSubMenuWnd)
	{
		m_pSubMenuWnd->DestroySubMenus();

		//end the modal loop started using RunModalLoop in TrackPopupMenu function
		m_pSubMenuWnd->EndModalLoop(0);

		m_pSubMenuWnd = 0;
	}
}

void CBmpMenu::Cleanup()
{
	//remove all allocated memory
	if(m_pToolbar && IsWindow(m_pToolbar->m_hWnd))
	{
		for(int i = 0; i<(m_pToolbar->GetToolBarCtrl()).GetButtonCount(); i++)
		{
			TBBUTTON tbb;
			(m_pToolbar->GetToolBarCtrl()).GetButton(i, &tbb);
			if(tbb.dwData)
			{
				if(((MENUITEMINFO*)(tbb.dwData))->dwTypeData)
					delete (char*)(((MENUITEMINFO*)(tbb.dwData))->dwTypeData);
				delete (MENUITEMINFO*)(tbb.dwData);
				tbb.dwData = 0;
			}
		}

		//destroy our windows
		m_pToolbar->DestroyWindow();
		delete m_pToolbar;
		m_pToolbar = 0;
	}

	if(IsWindow(m_hWnd))
		DestroyWindow();
}

BOOL CBmpMenu::PreCreateWindow(CREATESTRUCT& cs) 
{
	// TODO: Add your specialized code here and/or call the base class

	BOOL bRet = CWnd::PreCreateWindow(cs);

	WNDCLASS wc; 

	::GetClassInfo(AfxGetInstanceHandle(), cs.lpszClass, &wc);

	//register new class with same info but different class
	wc.lpszClassName = cs.lpszClass = "BitmapMenu";

	AfxRegisterClass(&wc);

	return bRet;
}


void CBmpMenu::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	CRect rect;
	GetClientRect(&rect);

/*
    //可在在此處畫漸變條
	CRect rect2 = rect;
	rect2.right = m_nTBOffSet;
	PaintGradiantRect(&dc, rect2, m_Color1, m_Color2, false, true);

	// Initialize fonts:
	LOGFONT lf;
	memset (&lf, 0, sizeof (LOGFONT));
	
	
	// Text will be rotated counter-clockwise 90 degrees.
	lf.lfOrientation = lf.lfEscapement = 900;
	
	// We need a TrueType font to get rotated text.  MS Sans //Serif won't cut it!
	lstrcpy ( lf.lfFaceName, _T("Arial") );
	
	lf.lfHeight = 14;
	lf.lfWeight = FW_DEMIBOLD;
	lf.lfItalic = TRUE;
	
	// Create a font with the tweaked attributes.
	CFont font;
	font.CreateFontIndirect ( &lf );
	
	CFont * OldFont = dc.SelectObject ( &font );
	

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
韩国三级中文字幕hd久久精品| 日韩美女视频一区| 久久精品免费观看| 精品久久免费看| 国产成人精品亚洲日本在线桃色| 国产亚洲成年网址在线观看| www.亚洲色图.com| 亚洲女同ⅹxx女同tv| 欧美裸体bbwbbwbbw| 日韩av电影免费观看高清完整版 | www欧美成人18+| 国产乱码精品一区二区三区av| 亚洲国产电影在线观看| 色播五月激情综合网| 日本三级亚洲精品| 欧美国产日韩a欧美在线观看| 色吧成人激情小说| 蜜桃视频一区二区三区| 国产精品久久毛片a| 欧美视频三区在线播放| 精品中文字幕一区二区| 日韩一区有码在线| 欧美成人午夜电影| 色综合天天综合给合国产| 琪琪久久久久日韩精品| 136国产福利精品导航| 91精品久久久久久久91蜜桃| 福利一区福利二区| 日韩精品五月天| 国产精品高潮呻吟| 欧美成人a视频| 在线观看欧美日本| 国产在线不卡一区| 午夜婷婷国产麻豆精品| 中文字幕免费不卡在线| 91精品国产综合久久国产大片| 国产精品一区二区三区四区| 亚洲第一激情av| 中文字幕一区二区三区四区| 91麻豆精品国产91久久久久| 99久久99久久精品免费看蜜桃| 美女mm1313爽爽久久久蜜臀| 一区二区三区精品视频在线| 久久久不卡影院| 日韩一区二区高清| 91福利精品视频| 成人精品免费网站| 国产在线精品一区二区夜色| 亚洲午夜精品一区二区三区他趣| 中文字幕成人在线观看| 精品国产一区二区在线观看| 欧美日高清视频| 色综合婷婷久久| 成人av在线电影| 精品一区二区久久| 日本成人在线电影网| 亚洲一区二区三区不卡国产欧美| 国产精品女主播在线观看| 欧美精品一区二区三区蜜臀 | 欧美一级片免费看| 91福利在线导航| 成人久久久精品乱码一区二区三区| 看国产成人h片视频| 日韩精品一级中文字幕精品视频免费观看 | 日av在线不卡| 天天影视涩香欲综合网| 亚洲一区在线观看免费 | 欧美日韩夫妻久久| 欧美在线观看一二区| 日本黄色一区二区| 色激情天天射综合网| 一本大道久久精品懂色aⅴ| 91老师国产黑色丝袜在线| 99久精品国产| 一本久久精品一区二区| 色88888久久久久久影院野外| 色婷婷综合五月| 色88888久久久久久影院按摩| 色老汉一区二区三区| 欧美色国产精品| 91精品国产一区二区人妖| 日韩一区二区三区观看| 精品粉嫩aⅴ一区二区三区四区| 日韩美女视频在线| 久久久久久久久久看片| 国产精品久久久99| 亚洲综合激情另类小说区| 亚洲国产一二三| 美女国产一区二区三区| 国产一区二区免费视频| 成人免费视频视频在线观看免费 | 成人免费观看av| 不卡的av在线播放| 在线精品视频免费播放| 777午夜精品免费视频| 精品久久久网站| 中文字幕av一区二区三区| 一区二区免费在线播放| 午夜精品一区二区三区三上悠亚| 麻豆精品在线看| 成人免费av资源| 欧美色视频一区| 精品国产乱码久久久久久久久| 久久久精品tv| 亚洲综合在线观看视频| 日本vs亚洲vs韩国一区三区二区| 国产在线一区观看| 色天天综合色天天久久| 日韩女优电影在线观看| 国产精品视频看| 日韩精品一区第一页| 成人免费观看视频| 91麻豆精品国产91久久久| 国产欧美中文在线| 婷婷久久综合九色综合伊人色| 韩国女主播成人在线观看| 一本色道a无线码一区v| 精品国产一区二区三区四区四 | 亚洲日本中文字幕区| 免费一级片91| 色综合久久久久久久| 欧美成人一区二区三区| 亚洲伦理在线免费看| 激情五月婷婷综合网| 在线观看视频欧美| 国产日韩欧美精品在线| 免费欧美高清视频| 色呦呦国产精品| 国产日韩欧美a| 蜜桃精品视频在线| 欧美一a一片一级一片| 国产精品视频线看| 经典三级一区二区| 欧美精品v国产精品v日韩精品 | 免费xxxx性欧美18vr| 91小视频免费观看| 欧美激情在线一区二区三区| 免费国产亚洲视频| 精品视频在线视频| 成人欧美一区二区三区1314| 国产原创一区二区| 日韩欧美精品三级| 日日摸夜夜添夜夜添亚洲女人| 日本乱人伦一区| 亚洲特级片在线| 成人理论电影网| 国产偷国产偷精品高清尤物 | 亚洲六月丁香色婷婷综合久久 | 国产人妖乱国产精品人妖| 日本欧美肥老太交大片| 欧美日韩精品一二三区| 亚洲综合成人在线| 色偷偷成人一区二区三区91| 国产精品电影院| 成人a免费在线看| 国产精品视频yy9299一区| 国产高清在线观看免费不卡| 欧美成人bangbros| 精品亚洲aⅴ乱码一区二区三区| 精品视频一区二区三区免费| 亚洲激情图片小说视频| 91蜜桃在线观看| 亚洲同性gay激情无套| va亚洲va日韩不卡在线观看| 国产精品嫩草99a| 丁香激情综合五月| 国产精品成人免费在线| jlzzjlzz亚洲日本少妇| 国产精品美女久久久久久| av在线不卡免费看| 亚洲精品videosex极品| 欧美性生活久久| 视频一区视频二区中文| 欧美一级生活片| 激情都市一区二区| 国产色综合久久| 成人app在线观看| 成人免费一区二区三区在线观看| 91香蕉视频在线| 亚洲福利电影网| 日韩欧美在线影院| 国内国产精品久久| 国产精品麻豆99久久久久久| 色视频欧美一区二区三区| 亚洲国产日韩a在线播放性色| 欧美日韩一区二区三区在线 | 国产精品欧美一区喷水| 欧美体内she精视频| 强制捆绑调教一区二区| 欧美激情在线一区二区三区| 一本大道综合伊人精品热热 | 成+人+亚洲+综合天堂| 一区二区久久久| 日韩亚洲欧美在线观看| 国产不卡视频在线观看| 亚洲一区二区精品视频| 日韩欧美黄色影院| 97成人超碰视| 日韩成人免费电影| 国产精品入口麻豆九色|