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

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

?? windowstrayiconmemoryleak.cpp

?? 用Java實現Windows系統托盤圖標源碼1
?? CPP
?? 第 1 頁 / 共 3 頁
字號:
}

// Handle icon mouse event (left/right button)
void HandleNotifyIcon(WPARAM id_num, LPARAM lParam) {
	switch (lParam)	{
		case WM_LBUTTONDOWN:
			// Callback Java class in new thread using "MousePressedCallback()"
			if (id_num >= 0) CallJavaVMSThread(MousePressedCallback,id_num,0);
			break;
		case WM_RBUTTONDOWN:
			if (id_num >= 0) {
				// If menu defined, then show it
				if (tray_icons[id_num].popup != NULL) {
					POINT pos;
					GetCursorPos(&pos);
					// Display and track the popup menu
					PopupMenu *menu = tray_icons[id_num].popup;
					menu->TrackPopupMenu(TPM_RIGHTALIGN | TPM_RIGHTBUTTON,&pos,my_hDlg);
				} else {
					// Callback Java class in new thread using "MousePressedCallback()"
					CallJavaVMSThread(MousePressedCallback,id_num,1);
				}
			}
			break;
	}
}

// Windows message proc for hidden window
// Receives mouse/menu events for the apps tray icons
LONG APIENTRY WndProc(HWND hWnd, UINT iMessage, UINT wParam, LONG lParam) {
	switch (iMessage) {
		case WM_DESTROY:
			// Exit message thread
			PostQuitMessage(0) ;
			break;
		case MYWM_NOTIFYICON:
			// Mouse event for icon (left/right button)
			HandleNotifyIcon(wParam, lParam);
			break;
		case MYWM_APPTALK:
			// ID used for sendWindowsMessage()
			// Callback Java class using "WindowsMessageCallback()"
			return CallJavaVMS(WindowsMessageCallback,0,(int)lParam);
		case WM_COMMAND:
			// Menu command for icon
			HandleMenuCommand(LOWORD(wParam));
			break;
		// Do nothing for other messages
		case WM_CREATE:
		case WM_GETMINMAXINFO:
		case WM_PAINT:
		case WM_MOUSEMOVE:
		case WM_RBUTTONDOWN:
		case WM_RBUTTONUP:
		case WM_MOVE:
		case WM_SIZE:
		case WM_LBUTTONDOWN:
		case WM_KEYDOWN:
			break;
		// Or use default handler
		default:
			return DefWindowProc (hWnd, iMessage, wParam, lParam) ;

	}
	return 0L ;
}

// Create the hidden window to receive the icon's mouse messages
HWND MakeHWND(HINSTANCE hInst) {
	HWND hWnd;
	// Create window class
	WNDCLASS wndclass;
	wndclass.style         = CS_HREDRAW | CS_VREDRAW;
	wndclass.lpfnWndProc   = (WNDPROC) WndProc;
	wndclass.cbClsExtra    = 0;
	wndclass.cbWndExtra    = 0;
	wndclass.hInstance     = hInst;
	wndclass.hIcon         = LoadIcon(hInst, IDI_APPLICATION);
	wndclass.hCursor       = LoadCursor(NULL, IDC_ARROW);
	wndclass.hbrBackground = GetStockObject(BLACK_BRUSH);
	wndclass.lpszMenuName  = NULL;
	wndclass.lpszClassName = szAppName;
	if (!RegisterClass(&wndclass)) return NULL;
	// Create window
	hWnd = CreateWindow(szAppName, szWndName, WS_OVERLAPPEDWINDOW,
                          0,0,100,100,
                          NULL, NULL, hInst, NULL);
	return hWnd;
}

// Remove the hidden window (on app closing)
void RemoveHWND() {
	// Close dial
	if (my_hDlg != NULL) {
		// Create wait event
		exit_event = CreateEvent(NULL,FALSE,FALSE,NULL);
		// Send destroy messages
		PostMessage(my_hDlg, WM_NCDESTROY, 0, 0);
		PostMessage(my_hDlg, WM_DESTROY, 0, 0);
		// Wait for window to destroy
		WaitForSingleObject(exit_event,10000);
		CloseHandle(exit_event);
		exit_event = NULL;
	}
	// Free handle
	if (wait_event != NULL) {
		CloseHandle(wait_event);
		wait_event = NULL;
	}
}

// The thread proc that creates the hidden window an listens for messages
void DialogThread(void *dummy) {
	MSG msg;
	// Create window
	my_hDlg = MakeHWND(g_hinst);
	// Signal wait event
	if (wait_event != NULL) SetEvent(wait_event);
	// Hide window
	ShowWindow(my_hDlg, SW_HIDE);
	UpdateWindow(my_hDlg);
	// Process messages
	while (GetMessage(&msg, NULL, 0, 0)){
		TranslateMessage(&msg) ;
		DispatchMessage(&msg) ;
	}
	// Unregister window class
	UnregisterClass(szAppName, g_hinst);
	// Signal exit event (so app knows hidden window is destroyed)
	if (exit_event != NULL) SetEvent(exit_event);
}

// New icon resource with no bitmap and zero size
IconData::IconData() {
	wd = hi = 0;
	hBitmapAND = hBitmapXOR = NULL;
}

// Destroy icon resources (and and xor bitmap)
IconData::~IconData() {
	if (hBitmapAND != NULL) DeleteObject(hBitmapAND);
	if (hBitmapXOR != NULL) DeleteObject(hBitmapXOR);
}

// Make icon using and and xor bitmaps (returns handle to new icon)
HICON IconData::makeIcon(HINSTANCE hInst) {
        ICONINFO ii;
        ii.fIcon    = TRUE;
        ii.xHotspot = 0;
        ii.yHotspot = 0;
        ii.hbmMask  = hBitmapAND;
        ii.hbmColor = hBitmapXOR;
        return CreateIconIndirect(&ii);
}

// Set icon's image data (pixel array, width, height)
int IconData::setData(unsigned long *data, int wd, int hi) {
	// Set size
	this->wd = wd;
	this->hi = hi;
	// Clean up if setData was called before
	if (hBitmapAND != NULL) DeleteObject(hBitmapAND);
	if (hBitmapXOR != NULL) DeleteObject(hBitmapXOR);
	// To protect against java sending a dud image
	if (wd > 0 && hi > 0) {
		// Set up the header for creating our 24 bit colour bitmap
	    	BITMAPINFOHEADER bih;
		bih.biSize          = sizeof(BITMAPINFOHEADER);
	    	bih.biWidth         = wd;
		bih.biHeight        = hi;
		bih.biPlanes        = 1;
	    	bih.biBitCount      = 24;
	    	bih.biCompression   = BI_RGB;
	    	bih.biSizeImage     = 0;
	    	bih.biXPelsPerMeter = 0;
	    	bih.biYPelsPerMeter = 0;
	    	bih.biClrUsed       = 0;
	    	bih.biClrImportant  = 0;
	    	// Create memory DC
	    	HDC hdc = CreateCompatibleDC(NULL);
	    	// Make the 24-bit DIB
	    	hBitmapXOR = CreateDIBSection(hdc, (LPBITMAPINFO)&bih, DIB_RGB_COLORS, (LPVOID *)NULL, NULL, 0);
	    	// Select it into the DC so we can draw onto it
	    	SelectObject(hdc, hBitmapXOR);
	    	// Calloc memory to be used to create a monochrome bitmask
		long size = (wd*hi/8)+1;
	    	unsigned char *andMask = new unsigned char[size];
		if (andMask != NULL) {
			for (int i = 0; i < size; i++) andMask[i] = 0;
        		// Loop through the given pixels and draw onto the colour and mono bitmaps
		    	unsigned long pixel;
		    	unsigned char red, green, blue, alpha;
		    	for (int row = 0; row < hi; row++) {
				for (int col = 0; col < wd; col++) {
	        			pixel = data[(row*wd)+col];
		        		alpha = (unsigned char)((pixel >> 24) & 0x000000ff);
		        		red   = (unsigned char)((pixel >> 16) & 0x000000ff);
	                		green = (unsigned char)((pixel >>  8) & 0x000000ff);
	                		blue  = (unsigned char)( pixel        & 0x000000ff);
	        		    	if (alpha == 0xFF) {
						// Pixel is not transparent - update xor bitmap
						SetPixel(hdc, col, row, RGB(red, green, blue));
					} else {
						// Pixel is transparent - update and mask
		        			int p = (row*wd) + col;
				        	andMask[p/8] |= 1 << (7-(p%8));
					}
				}
			}
			// Create the monochrome bitmask with transparency info
			hBitmapAND = CreateBitmap(wd, hi, 1, 1, andMask);
			// Free memory
			delete andMask;
			// Release the memory DC
			ReleaseDC(NULL, hdc);
			return 0;
		}
		// Release the memory DC
		ReleaseDC(NULL, hdc);
	}
	// Error on zero size icons
	return -1;
}

// Find free menu id for submenu item (given icon id = owner)
// Each tray icon with a submenu has a number of menu ids, one for each menu item
long getFreeMenuId(int id_num) {
	long size = arrUsedMenuIds->getSize();
	long id = 0;
	BOOL done = FALSE;
	// Find for free id in array that maps menu ids to icon ids
	for (id = 0; id < size && !done; id++)
		if (arrUsedMenuIds->getElementAt(id) == -1) done = TRUE;
	// Found none, create new id
	if (!done) {
		id = size;
		arrUsedMenuIds->addElement(-1);
	}
	// Mark id in array as belonging to icon with id id_num
	arrUsedMenuIds->setElementAt(id, id_num);
	// Return id for new submenu item
	return id;
}

// Free all menu ids for a given icon
void setFreeMenuId(int id_num) {
	long size = arrUsedMenuIds->getSize();
	// Find ids for given icon and free them
	for (long ps = 0; ps < size; ps++) {
		if (arrUsedMenuIds->getElementAt(ps) == id_num)
			arrUsedMenuIds->setElementAt(ps, -1);
	}
	// Shrink array if there are trailing empty places
	long delofs = arrUsedMenuIds->getSize();
	while (delofs > 0 && arrUsedMenuIds->getElementAt(delofs-1) == -1) {
		delofs--;
		arrUsedMenuIds->removeElementAt(delofs);
	}
}

// Map menu id to icon id
int getMenuItemIdNum(int id) {
	long size = arrUsedMenuIds->getSize();
	if (id < size) return arrUsedMenuIds->getElementAt(id);
	else return -1;
}

// Make new popup menu
PopupSubMenu::PopupSubMenu() {
	hMenu = CreatePopupMenu();
	bSub = FALSE;
}

// Make new popup menu (reset all class members)
void PopupSubMenu::reNewMenu() {
	if (!isSub()) DestroyMenu(hMenu);
	hMenu = CreatePopupMenu();
	bSub = FALSE;
}

// Destroy popupmenu
PopupSubMenu::~PopupSubMenu() {
	if (!isSub()) DestroyMenu(hMenu); // Only needed when parent menu, not for submenus
}

// Is this a submenu or a parent popup menu
BOOL PopupSubMenu::isSub() {
	return bSub;
}

// Mark this popup menu as being a submenu
void PopupSubMenu::makeSub() {
	bSub = TRUE;
}

// Get the windows menu handle, used for AppendMenu,..
HMENU PopupSubMenu::getMenu() {
	return hMenu;
}

// Display the popupmenu at given position (in neighbourhood of tray icon)
void PopupSubMenu::TrackPopupMenu(UINT flags, POINT* pos, HWND hWnd) {
	// SetForegroundWindow/PostMessage are hacks because TrackPopupMenu contains bug/feature
	// Otherwise it's not hidden properly when the user clicks on desktop
	SetForegroundWindow(hWnd);
	::TrackPopupMenu(hMenu, flags, (*pos).x, (*pos).y, 0, hWnd, NULL);
	PostMessage(hWnd, WM_NULL, 0, 0);
}

// Make new popup main menu with maximum submenu depth
PopupMenu::PopupMenu(int levels) {
	nbLevels = levels;
	popup = new PtrPopupSubMenu[levels];
	for (int ctr = 0; ctr < levels; ctr++) popup[ctr] = NULL;
}

// Destroy main popup menu
PopupMenu::~PopupMenu() {
	// Destroy all submenu levels
	for (int ctr = 0; ctr < nbLevels; ctr++)
		if (popup[ctr] != NULL) delete popup[ctr];
	delete popup;
}

// Init menu at given level (make new or call reNewMenu())
void PopupMenu::initMenu(int level) {
	if (level >= nbLevels) return;
	if (popup[level] != NULL) popup[level]->reNewMenu();
	else popup[level] = new PopupSubMenu();
}

// Return windows menu handle for given level (should be 0 for main menu)
HMENU PopupMenu::getMenu(int level) {
	PopupSubMenu *menu = getSubMenu(level);
	if (menu == NULL) return NULL;
	else return menu->getMenu();
}

// Return sub menu @ given level (used in getMenu()/TrackPopupMenu())
PopupSubMenu* PopupMenu::getSubMenu(int level) {
	if (level >= nbLevels) return NULL;
	return popup[level];
}

// Display the popupmenu at given position (in neighbourhood of tray icon)
void PopupMenu::TrackPopupMenu(UINT flags, POINT* pos, HWND hWnd) {
	PopupSubMenu *menu = getSubMenu(0);
	if (menu != NULL) menu->TrackPopupMenu(flags, pos, hWnd);
}

// Create new growable integer array
QSIntArray::QSIntArray() {
	m_Array = new int[5];
	m_ArrSize = 5;
	m_Size = 0;
	m_Grow = 10;
}

// Create new growable integer array with initial size and grow term
QSIntArray::QSIntArray(long size, long grow) {
	m_Array = new int[size];
	m_ArrSize = size;
	m_Size = 0;
	m_Grow = grow;
}

// Delete growable integer array
QSIntArray::~QSIntArray() {
	delete m_Array;
}

// Get size
long QSIntArray::getSize() {
	return m_Size;
}

// Get integer @ given position
int QSIntArray::getElementAt(long idx) {
	return m_Array[idx];
}

// Add integer at end of array
void QSIntArray::addElement(int element) {
	m_Size++;
	grow();
	m_Array[m_Size-1] = element;
}

// Set integer @ given position (may be >= getSize() - array grows)
void QSIntArray::setElementAt(long idx, int element) {
	m_Size = max(m_Size, idx+1);
	grow();
	m_Array[idx] = element;
}

// Remove integer at given position
void QSIntArray::removeElementAt(long idx) {
	m_Size--;
	for (long pos = idx; pos < m_Size; pos++)
		m_Array[pos] = m_Array[pos+1];
	shrink();
}

// Empty array
void QSIntArray::removeAll() {
	m_Size = 0;
	shrink();
}

// Shrink array to convenient size
void QSIntArray::shrink() {
	if (m_Size < m_ArrSize - m_Grow) {
		long nSize = m_Size + m_Grow;
		int* nArray = new int[nSize];
		for (long idx = 0; idx < m_Size; idx++)
			nArray[idx] = m_Array[idx];
		delete m_Array;
		m_Array = nArray;
		m_ArrSize = nSize;
	}
}

// Grow array to convenient size
void QSIntArray::grow() {
	if (m_Size > m_ArrSize) {
		long nSize = m_Size + m_Grow;
		int* nArray = new int[nSize];
		for (long idx = 0; idx < m_ArrSize; idx++)
			nArray[idx] = m_Array[idx];
		delete m_Array;
		m_Array = nArray;
		m_ArrSize = nSize;
	}
}







?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
极品少妇一区二区| 久久久无码精品亚洲日韩按摩| 亚洲精品v日韩精品| 99精品视频一区二区三区| 综合久久久久久| 欧美系列在线观看| 日韩成人一区二区三区在线观看| 欧美性生交片4| 日韩av一级电影| 欧美精品一区二区高清在线观看| 国产老妇另类xxxxx| 国产精品久久久久久久裸模| 色综合激情久久| 亚洲成年人网站在线观看| 欧美成人一区二区三区片免费| 黑人巨大精品欧美黑白配亚洲| 国产日本欧美一区二区| 欧美在线免费播放| 日韩成人一级片| 国产精品色噜噜| 欧美视频一区二区| 狠狠色丁香久久婷婷综| 中文一区一区三区高中清不卡| 97精品久久久午夜一区二区三区| 亚洲成人自拍偷拍| 久久影院午夜论| 欧美最新大片在线看| 精品亚洲porn| 亚洲主播在线观看| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 国产成人午夜99999| 亚洲欧美日韩成人高清在线一区| 欧美乱妇15p| jizz一区二区| 久久国产尿小便嘘嘘尿| 一区二区三区在线视频播放| 日韩欧美国产wwwww| 色婷婷亚洲一区二区三区| 久久99国内精品| 美女被吸乳得到大胸91| 国产欧美日本一区二区三区| 777久久久精品| 91在线视频免费91| 国产美女精品人人做人人爽| 亚洲国产日韩a在线播放| 国产精品色在线| 日韩一区二区三| 在线观看亚洲成人| 不卡免费追剧大全电视剧网站| 欧美a级理论片| 国产盗摄视频一区二区三区| 欧美无人高清视频在线观看| 亚洲欧美日韩国产成人精品影院| 91理论电影在线观看| 中文字幕不卡在线| 国产成人日日夜夜| 中文字幕综合网| 在线免费观看成人短视频| 亚洲综合视频在线观看| 欧美伊人久久久久久午夜久久久久| 亚洲人被黑人高潮完整版| 欧美群妇大交群的观看方式| 男人的j进女人的j一区| 日韩一级精品视频在线观看| 国产99精品在线观看| 国产精品传媒视频| 久久久国产精品不卡| 国产麻豆精品一区二区| 亚洲国产中文字幕在线视频综合| 国产精品久久久久久久久动漫| 国产91在线观看| 一区二区三区资源| 欧美人xxxx| 亚洲国产人成综合网站| 制服.丝袜.亚洲.中文.综合| www.成人网.com| 91在线无精精品入口| 91精品在线观看入口| 亚洲欧美激情小说另类| 亚洲成人免费视| 成人免费在线观看入口| 国产欧美视频一区二区| 亚洲国产高清在线观看视频| 国产精品美日韩| **欧美大码日韩| 亚洲视频一区二区在线观看| 亚洲免费高清视频在线| 亚洲国产aⅴ成人精品无吗| 亚洲国产三级在线| 日本午夜一区二区| 三级一区在线视频先锋| 免费在线一区观看| 国产精品主播直播| 暴力调教一区二区三区| 91激情五月电影| 91精品国产综合久久国产大片| 色视频欧美一区二区三区| 国产在线精品一区二区三区不卡| 日日摸夜夜添夜夜添亚洲女人| 亚洲精品一二三| 亚洲成人动漫精品| 男女男精品视频| 首页国产丝袜综合| 老司机免费视频一区二区| 老司机午夜精品| 成人精品视频一区二区三区尤物| 国产一区二区不卡在线| av一区二区三区四区| 色婷婷精品大在线视频 | 亚洲高清一区二区三区| 亚洲大片在线观看| 老色鬼精品视频在线观看播放| 日韩高清一区在线| 日本国产一区二区| 国产日韩欧美a| 麻豆国产欧美一区二区三区| 青青草国产精品97视觉盛宴| 99国内精品久久| 91网站在线观看视频| 成人av午夜影院| 国产大片一区二区| 国产成人免费在线| 在线成人免费视频| 亚洲成a人片在线观看中文| 精品噜噜噜噜久久久久久久久试看| 麻豆91在线观看| 一区二区三区色| 国产一区999| 欧美精品在线一区二区三区| 国产精品久久久一区麻豆最新章节| 亚洲18女电影在线观看| 粉嫩av一区二区三区粉嫩| 欧美日韩中文一区| 欧美激情综合在线| 毛片基地黄久久久久久天堂| 色综合久久久久网| 久久久精品免费网站| 亚洲国产欧美日韩另类综合| 成人性视频免费网站| 欧美大片拔萝卜| 性久久久久久久| 成人黄色小视频| 久久综合九色欧美综合狠狠| 日韩国产欧美在线视频| 国产精品一区久久久久| 国产精品三级在线观看| 秋霞电影网一区二区| 欧美日韩午夜影院| 亚洲一区二区精品久久av| 欧美亚洲一区三区| 日产国产欧美视频一区精品| 欧美精品欧美精品系列| 亚洲午夜激情av| 91精选在线观看| 久久 天天综合| 国产欧美日韩在线| 99精品久久99久久久久| 一区二区三区在线视频观看58| 欧美日韩一卡二卡三卡| 1024成人网| 欧美一区二区在线视频| 久国产精品韩国三级视频| 日韩无一区二区| 激情偷乱视频一区二区三区| 日韩美女视频19| 777xxx欧美| 国产精品一区二区免费不卡| 亚洲国产高清在线观看视频| 欧美影院一区二区三区| 久草精品在线观看| 亚洲国产高清不卡| 亚洲综合成人网| 日韩欧美一区二区久久婷婷| 国产一区二区毛片| 亚洲黄色av一区| 视频一区在线视频| 色综合久久天天| 国产精品网曝门| 本田岬高潮一区二区三区| 中国av一区二区三区| 春色校园综合激情亚洲| 国产精品福利一区| 97se亚洲国产综合自在线观| 亚洲综合免费观看高清完整版在线 | 美女视频黄 久久| 欧美xxxxxxxxx| 国产乱色国产精品免费视频| 中文字幕精品一区二区三区精品| 成人精品视频一区二区三区| 亚洲图片激情小说| 欧美日韩一区二区在线观看视频 | 在线视频国产一区| 国产一区二区精品久久91| 蜜臀99久久精品久久久久久软件| ...av二区三区久久精品| 欧美电影免费观看高清完整版在线 | 视频一区在线播放| 亚洲色图欧洲色图婷婷| 自拍偷拍亚洲欧美日韩| 中文字幕在线一区二区三区|