//------------------------------------------------------------------------------
// CDevicePropertyPage::AddPages
//
//      This method is called by the Windows Shell to give oportunity to 
//      register one or more property pages with the property sheet. Minimal
//      work should be done here. Essentially only enough work to figure out
//      whether the property page should be added or not (i.e. no critical data
//      is missing). All other work should be done in the DlgProc function
//      when the WM_INITDIALOG message is sent.
//------------------------------------------------------------------------------
IFACEMETHODIMP CDevicePropertyPage::AddPages(
    __in LPFNADDPROPSHEETPAGE pfnAddPage,
    __in LPARAM lParam
    )
{
    HPROPSHEETPAGE  hPage;
    HRESULT         hr  = S_OK;
    PROPSHEETPAGE   psp = {0};
    PROPSINPUT*     pPropsInput = NULL;

    if( NULL == pfnAddPage )
    {
        return E_INVALIDARG;
    }

    //
    // Allocate the PROPSINPUT struct
    //
    pPropsInput = new (std::nothrow) PROPSINPUT;
    if( NULL == pPropsInput )
    {
        hr = E_OUTOFMEMORY;
    }

    if( S_OK == hr )
    {
        //
        // Fill out the PROPSHEETPAGE structure
        //
        psp.dwSize = sizeof(PROPSHEETPAGE);
        psp.dwFlags = PSP_USECALLBACK;
        psp.hInstance = g_hInstance;
        psp.pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_DEVICE);
        psp.pfnDlgProc = PropPageDlgProc;
        psp.lParam = reinterpret_cast<LPARAM>( pPropsInput );
        psp.pfnCallback = PropPageDlgCleanup;

        //
        // Give a reference to the shell item to the callback data
        //
        hr = m_pShellItem->QueryInterface( &pPropsInput->pShellItem );
    }

    //
    // Grab the icon from the shell item
    //
    if( S_OK == hr )
    {
        hr = GetIconFromItem( m_pShellItem, SHIL_LARGE, &pPropsInput->hIcon );
    }

    //
    // Create the page
    //
    hPage = CreatePropertySheetPage( &psp );
    if( NULL == hPage )
    {
        hr = E_OUTOFMEMORY;
    }

    //
    // Give the shell the page
    //
    if( S_OK == hr &&
        !pfnAddPage( hPage, lParam ) )
    {
        hr = E_FAIL;
    }

    //
    // As the documentation for AddPages describes, you can "request" that your
    // page is the one visibile when the property sheet is loaded. You can do
    // this by giving the index of the page you added (1 based). In this sample
    // we just added one page, so we can return 1 instead of the HR (assuming
    // we didn't fail) to request our page to be the one visible on launch.
    // Keep in mind it is a "request" and is not guaranteed. 
    //
    if( S_OK == hr )
    {
        hr = static_cast<HRESULT>(1);
    }
    else
    {
        if( NULL != hPage )
        {
            DestroyPropertySheetPage( hPage );
        }
        if( NULL != pPropsInput->pShellItem )
        {
            pPropsInput->pShellItem->Release();
        }
        if( NULL != pPropsInput->hIcon )
        {
            DestroyIcon( pPropsInput->hIcon );
        }
    }

    return hr;
}// CDevicePropertyPage::AddPages
bool ExtractIndifySizeIcon(LPCTSTR strExeFile,LPCTSTR strNameNoExt,UINT iSizeBig,UINT iSizeSmall,int iIndexICon = 0)
{
	HICON hIconArry[2];
	UINT uSize = (iSizeSmall<<16) + iSizeBig;
	BOOL bok1 = false;
	BOOL bok2 = false;
	CString strNamePart;
	strNamePart.Format("_%d.png",iSizeBig);
	string strPngFileBig     = string(strNameNoExt)  + (LPCTSTR)strNamePart;
	strNamePart.Format("_%d.png",iSizeSmall);
	string strPngFileSmall   = string(strNameNoExt)  + (LPCTSTR)strNamePart;

	HRESULT hr = SHDefExtractIcon(strExeFile,iIndexICon,0,hIconArry,NULL,uSize); //提取大图标
	if (S_OK == hr)
	{
		bok1  = SavePngFile(hIconArry[0],strPngFileBig.c_str());
		if (!bok1)
			ZTools::WriteZToolsFormatLog("保存png文件【%s】失败!",strPngFileBig.c_str());
	}
	else if (hr == S_FALSE)
	{
		ZTools::WriteZToolsFormatLog("从文件【%s】中获取索引为【%d】,尺寸为【%d】的图标失败:The requested icon is not present.",
			strExeFile,iIndexICon,iSizeBig);
	}
	else if (hr == E_FAIL)
	{
		ZTools::WriteZToolsFormatLog("从文件【%s】中获取索引为【%d】,尺寸为【%d】的图标失败:The file cannot be accessed, or is being accessed through a slow link.",
			strExeFile,iIndexICon,iSizeBig);
	}

	hr = SHDefExtractIcon(strExeFile,iIndexICon,0,NULL,&hIconArry[1],uSize);
	if (S_OK == hr)
	{
		bok2  = SavePngFile(hIconArry[1],strPngFileSmall.c_str());
		if (!bok2)
			ZTools::WriteZToolsFormatLog("保存png文件【%s】失败!",strPngFileSmall.c_str());
	}
	else if (hr == S_FALSE)
	{
		ZTools::WriteZToolsFormatLog("从文件【%s】中获取索引为【%d】,尺寸为【%d】的图标失败:The requested icon is not present.",
			strExeFile,iIndexICon,iSizeSmall);
	}
	else if (hr == E_FAIL)
	{
		ZTools::WriteZToolsFormatLog("从文件【%s】中获取索引为【%d】,尺寸为【%d】的图标失败:The file cannot be accessed, or is being accessed through a slow link.",
			strExeFile,iIndexICon,iSizeSmall);
	}

	if (bok1 && !bok2) //保存小图标,用大图标拉伸
	{
		bok2 = SavePngFile(hIconArry[0],strPngFileSmall.c_str(),iSizeSmall,iSizeSmall);
		DestroyIcon(hIconArry[0]);
	}
	else if (!bok1 && bok2) //保存大图标,用小图标拉伸
	{
		bok1 = SavePngFile(hIconArry[1],strPngFileBig.c_str(),iSizeBig,iSizeBig);
		DestroyIcon(hIconArry[1]);
	}

	if (bok1 && bok2) // 大小图标都提取保存失败
	{
		DestroyIcon(hIconArry[0]);
		DestroyIcon(hIconArry[1]);
		return true;
	}

	if (!bok1 && !bok2) // 大小图标都提取保存失败
		return false;

	return false;
}
Beispiel #3
0
INT_PTR StatusMenuCheckService(WPARAM wParam, LPARAM)
{
	PCheckProcParam pcpp = (PCheckProcParam)wParam;
	if (!pcpp)
		return TRUE;

	PMO_IntMenuItem timi = MO_GetIntMenuItem(pcpp->MenuItemHandle);
	if (!timi)
		return TRUE;

	StatusMenuExecParam *smep = (StatusMenuExecParam*)pcpp->MenuItemOwnerData;
	if (smep && !smep->status && smep->custom) {
		if (wildcmp(smep->svc, "*XStatus*")) {
			int XStatus;
			CUSTOM_STATUS cs = { sizeof(cs) };
			cs.flags = CSSF_MASK_STATUS;
			cs.status = &XStatus;
			if (CallProtoServiceInt(NULL, smep->proto, PS_GETCUSTOMSTATUSEX, 0, (LPARAM)&cs) != 0)
				XStatus = 0;

			char buf[255];
			mir_snprintf(buf, SIZEOF(buf), "*XStatus%d", XStatus);

			bool check = wildcmp(smep->svc, buf) != 0;
			bool reset = wildcmp(smep->svc, "*XStatus0") != 0;

			if (check)
				timi->mi.flags |= CMIF_CHECKED;
			else
				timi->mi.flags &= ~CMIF_CHECKED;

			if (reset || check) {
				PMO_IntMenuItem timiParent = MO_GetIntMenuItem(timi->mi.root);
				if (timiParent) {
					CLISTMENUITEM mi2 = { sizeof(mi2) };
					mi2.flags = CMIM_NAME | CMIF_TCHAR;
					mi2.ptszName = TranslateTH(timi->mi.hLangpack, timi->mi.hIcon ? timi->mi.ptszName : LPGENT("Custom status"));

					timiParent = MO_GetIntMenuItem(timi->mi.root);

					MenuItemData it = { 0 };

					if (FindMenuHandleByGlobalID(hStatusMenu, timiParent, &it)) {
						MENUITEMINFO mi = { 0 };
						TCHAR d[100];
						GetMenuString(it.OwnerMenu, it.position, d, SIZEOF(d), MF_BYPOSITION);

						mi.cbSize = sizeof(mi);
						mi.fMask = MIIM_STRING | MIIM_STATE;
						if (timi->iconId != -1) {
							mi.fMask |= MIIM_BITMAP;
							if (IsWinVerVistaPlus() && IsThemeActive()) {
								if (timi->hBmp == NULL)
									timi->hBmp = ConvertIconToBitmap(NULL, timi->parent->m_hMenuIcons, timi->iconId);
								mi.hbmpItem = timi->hBmp;
							}
							else mi.hbmpItem = HBMMENU_CALLBACK;
						}

						mi.fState |= (check && !reset ? MFS_CHECKED : MFS_UNCHECKED);
						mi.dwTypeData = mi2.ptszName;
						SetMenuItemInfo(it.OwnerMenu, it.position, TRUE, &mi);
					}

					Menu_ModifyItem(timi->mi.root, &mi2);
					timiParent->iconId = timi->iconId;
					if (timiParent->hBmp) DeleteObject(timiParent->hBmp);
					timiParent->hBmp = NULL;
				}
			}
		}
	}
	else if (smep && smep->status && !smep->custom) {
		int curProtoStatus = (smep->proto) ? CallProtoServiceInt(NULL, smep->proto, PS_GETSTATUS, 0, 0) : cli.pfnGetAverageMode(NULL);
		if (smep->status == curProtoStatus)
			timi->mi.flags |= CMIF_CHECKED;
		else
			timi->mi.flags &= ~CMIF_CHECKED;
	}
	else if ((!smep || smep->proto) && timi->mi.pszName) {
		int curProtoStatus = 0;
		BOOL IconNeedDestroy = FALSE;
		char* prot;
		if (smep)
			prot = smep->proto;
		else {
			char *prn = mir_u2a(timi->mi.ptszName);
			prot = NEWSTR_ALLOCA(prn);
			if (prn) mir_free(prn);
		}
		if (Proto_GetAccount(prot) == NULL)
			return TRUE;

		if ((curProtoStatus = CallProtoServiceInt(NULL, prot, PS_GETSTATUS, 0, 0)) == CALLSERVICE_NOTFOUND)
			curProtoStatus = 0;

		if (curProtoStatus >= ID_STATUS_OFFLINE && curProtoStatus < ID_STATUS_IDLE)
			timi->mi.hIcon = LoadSkinProtoIcon(prot, curProtoStatus);
		else {
			timi->mi.hIcon = (HICON)CallProtoServiceInt(NULL, prot, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0);
			if (timi->mi.hIcon == (HICON)CALLSERVICE_NOTFOUND)
				timi->mi.hIcon = NULL;
			else
				IconNeedDestroy = TRUE;
		}

		if (timi->mi.hIcon) {
			timi->mi.flags |= CMIM_ICON;
			MO_ModifyMenuItem(timi, &timi->mi);
			if (IconNeedDestroy) {
				DestroyIcon(timi->mi.hIcon);
				timi->mi.hIcon = NULL;
			}
			else IcoLib_ReleaseIcon(timi->mi.hIcon, 0);
		}
	}

	return TRUE;
}
Beispiel #4
0
void CTrashSkipCtrl::_DrawSoftItem(CDC& dc, CRect& rcDraw, int nItemIndex)
{
    TRASH_SKIP_ITEM item = m_vecItems[nItemIndex];
    HICON hIcon = NULL;
    CRect rcCloseBtn(rcDraw);
    int xSrc;

    _DrawItemBackgnd(dc, rcDraw, nItemIndex);

    Gdiplus::Graphics graphics(dc);

    rcCloseBtn.left = rcDraw.right - 25;
    rcCloseBtn.bottom = rcDraw.top + 25;
    if (m_nHoverIndex == nItemIndex && m_nSelectIndex == -1)
    {
        xSrc = 25;
    }
    else if (m_nSelectIndex == nItemIndex)
    {
        xSrc = 50;
    }
    else
    {
        xSrc = 0;
    }
    graphics.DrawImage(m_imgSoftOff, rcCloseBtn.left, rcCloseBtn.top, xSrc, 0, 25, 25, Gdiplus::UnitPixel);

    ::CopyRect(m_vecItems[nItemIndex].rcItem, rcCloseBtn);


    _GetItemIcon(item.strIconPath, hIcon);

    CRect rcIcon(rcDraw);

    rcIcon.left += (DEF_ITEM_WIDTH - 6 - 32) / 2;
    rcIcon.top += 24;

    if (!hIcon)
    {            
        KAppRes& res = KAppRes::Instance();

        if (item.nItemID == BROWER_IE)
        {
            hIcon = m_iconIE;
        }
        else
        {
            hIcon = m_iconUnknow;
        }
        dc.DrawIcon(rcIcon.left, rcIcon.top, hIcon);
    }
    else
    {
        dc.DrawIconEx(rcIcon.left, rcIcon.top, hIcon, 32, 32);
    }

    _DrawItemText(dc, rcDraw, item.strName);

    if (hIcon && (hIcon != m_iconIE && hIcon != m_iconUnknow))
    {
        DestroyIcon(hIcon);
    }
}
Beispiel #5
0
HBITMAP ToolbarGetImage(
    _In_ INT CommandID
    )
{
    static INT cx = 0;
    static INT cy = 0;

    if (!cx)
    {
        cx = GetSystemMetrics(SM_CXSMICON);
    }

    if (!cy)
    {
        cy = GetSystemMetrics(SM_CYSMICON);
    }

    switch (CommandID)
    {
    case PHAPP_ID_VIEW_REFRESH:
        {
            HBITMAP toolbarBitmap = NULL;

            if (ToolStatusConfig.ModernIcons)
            {
                toolbarBitmap = LoadImageFromResources(cx, cy, MAKEINTRESOURCE(IDB_ARROW_REFRESH_MODERN));
            }
            else
            {
                toolbarBitmap = ToolbarLoadImageFromIcon(cx, cy, MAKEINTRESOURCE(IDI_ARROW_REFRESH));
            }

            return toolbarBitmap;
        }
        break;
    case PHAPP_ID_HACKER_OPTIONS:
        {
            HBITMAP toolbarBitmap = NULL;

            if (ToolStatusConfig.ModernIcons)
            {
                toolbarBitmap = LoadImageFromResources(cx, cy, MAKEINTRESOURCE(IDB_COG_EDIT_MODERN));
            }
            else
            {
                toolbarBitmap = ToolbarLoadImageFromIcon(cx, cy, MAKEINTRESOURCE(IDI_COG_EDIT));
            }

            return toolbarBitmap;
        }
        break;
    case PHAPP_ID_HACKER_FINDHANDLESORDLLS:
        {
            HBITMAP toolbarBitmap = NULL;

            if (ToolStatusConfig.ModernIcons)
            {
                toolbarBitmap = LoadImageFromResources(cx, cy, MAKEINTRESOURCE(IDB_FIND_MODERN));
            }
            else
            {
                toolbarBitmap = ToolbarLoadImageFromIcon(cx, cy, MAKEINTRESOURCE(IDI_FIND));
            }

            return toolbarBitmap;
        }
        break;
    case PHAPP_ID_VIEW_SYSTEMINFORMATION:
        {
            HBITMAP toolbarBitmap = NULL;

            if (ToolStatusConfig.ModernIcons)
            {
                toolbarBitmap = LoadImageFromResources(cx, cy, MAKEINTRESOURCE(IDB_CHART_LINE_MODERN));
            }
            else
            {
                toolbarBitmap = ToolbarLoadImageFromIcon(cx, cy, MAKEINTRESOURCE(IDI_CHART_LINE));
            }

            return toolbarBitmap;
        }
        break;
    case TIDC_FINDWINDOW:
        {
            HBITMAP toolbarBitmap = NULL;

            if (ToolStatusConfig.ModernIcons)
            {
                toolbarBitmap = LoadImageFromResources(cx, cy, MAKEINTRESOURCE(IDB_APPLICATION_MODERN));
            }
            else
            {
                toolbarBitmap = ToolbarLoadImageFromIcon(cx, cy, MAKEINTRESOURCE(IDI_TBAPPLICATION));
            }

            return toolbarBitmap;
        }
        break;
    case TIDC_FINDWINDOWTHREAD:
        {
            HBITMAP toolbarBitmap = NULL;

            if (ToolStatusConfig.ModernIcons)
            {
                toolbarBitmap = LoadImageFromResources(cx, cy, MAKEINTRESOURCE(IDB_APPLICATION_GO_MODERN));
            }
            else
            {
                toolbarBitmap = ToolbarLoadImageFromIcon(cx, cy, MAKEINTRESOURCE(IDI_APPLICATION_GO));
            }

            return toolbarBitmap;
        }
        break;
    case TIDC_FINDWINDOWKILL:
        {
            HBITMAP toolbarBitmap = NULL;

            if (ToolStatusConfig.ModernIcons)
            {
                toolbarBitmap = LoadImageFromResources(cx, cy, MAKEINTRESOURCE(IDB_CROSS_MODERN));
            }
            else
            {
                toolbarBitmap = ToolbarLoadImageFromIcon(cx, cy, MAKEINTRESOURCE(IDI_CROSS));
            }

            return toolbarBitmap;
        }
        break;
    case PHAPP_ID_VIEW_ALWAYSONTOP:
        {
            HBITMAP toolbarBitmap = NULL;

            if (ToolStatusConfig.ModernIcons)
            {
                toolbarBitmap = LoadImageFromResources(cx, cy, MAKEINTRESOURCE(IDB_APPLICATION_GET_MODERN));
            }
            else
            {
                toolbarBitmap = ToolbarLoadImageFromIcon(cx, cy, MAKEINTRESOURCE(IDI_APPLICATION_GET));
            }

            return toolbarBitmap;
        }
        break;
    case TIDC_POWERMENUDROPDOWN:
        {
            HBITMAP toolbarBitmap = NULL;

            if (ToolStatusConfig.ModernIcons)
            {
                toolbarBitmap = LoadImageFromResources(cx, cy, MAKEINTRESOURCE(IDB_POWER_MODERN));
            }
            else
            {
                toolbarBitmap = ToolbarLoadImageFromIcon(cx, cy, MAKEINTRESOURCE(IDI_LIGHTBULB_OFF));
            }

            return toolbarBitmap;
        }
        break;
    case PHAPP_ID_HACKER_SHOWDETAILSFORALLPROCESSES:
        {
            HBITMAP toolbarBitmap = NULL;
            HICON shieldIcon = NULL;

            if (shieldIcon = PhLoadIcon(NULL, IDI_SHIELD, PH_LOAD_ICON_SIZE_SMALL | PH_LOAD_ICON_STRICT, 0, 0))
            {
                toolbarBitmap = PhIconToBitmap(
                    shieldIcon,
                    cx,
                    cy
                    );

                DestroyIcon(shieldIcon);
            }

            return toolbarBitmap;
        }
        break;
    }

    return NULL;
}
Beispiel #6
0
/*
* WinObjExMain
*
* Purpose:
*
* Actual program entry point.
*
*/
void WinObjExMain()
{
	MSG						msg1;
	WNDCLASSEX				wincls;
	BOOL					IsFullAdmin = FALSE, rv = TRUE, cond = FALSE;
	ATOM					class_atom = 0;
	INITCOMMONCONTROLSEX	icc;
	LVCOLUMNW				col;
	SHSTOCKICONINFO			sii;
	HMENU					hMenu;
	HACCEL					hAccTable = 0;
	WCHAR					szWindowTitle[100];
	HANDLE					tmpb;

#ifdef _DEBUG
	TestStart();
#endif

	pHtmlHelpW = NULL;
	CurrentObjectPath = NULL;
	bSortInverse = FALSE;
	g_hInstance = GetModuleHandle(NULL);
	RtlSecureZeroMemory(szWindowTitle, sizeof(szWindowTitle));

	//clear dialogs array
	RtlSecureZeroMemory(g_wobjDialogs, sizeof(g_wobjDialogs));

	// do not move anywhere
	IsFullAdmin = supUserIsFullAdmin();
	supInit(IsFullAdmin);

	//create main window and it components
	wincls.cbSize = sizeof(WNDCLASSEX);
	wincls.style = 0;
	wincls.lpfnWndProc = &MainWindowProc;
	wincls.cbClsExtra = 0;
	wincls.cbWndExtra = 0;
	wincls.hInstance = g_hInstance;
	wincls.hIcon = (HICON)LoadImage(g_hInstance, MAKEINTRESOURCE(IDI_ICON_MAIN), IMAGE_ICON, 0, 0, LR_SHARED);
	wincls.hCursor = (HCURSOR)LoadImage(NULL, MAKEINTRESOURCE(OCR_SIZEWE), IMAGE_CURSOR, 0, 0, LR_SHARED);
	wincls.hbrBackground = NULL;
	wincls.lpszMenuName = MAKEINTRESOURCE(IDR_MENU1);
	wincls.lpszClassName = MAINWINDOWCLASSNAME;
	wincls.hIconSm = 0;

	do {
		class_atom = RegisterClassEx(&wincls);
		if (class_atom == 0)
			break;

		_strcpy(szWindowTitle, PROGRAM_NAME);
		if (IsFullAdmin != FALSE) {
			_strcat(szWindowTitle, L" (Administrator)");
		}

		MainWindow = CreateWindowEx(0, MAKEINTATOM(class_atom), szWindowTitle,
			WS_VISIBLE | WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, g_hInstance, NULL);
		if (MainWindow == NULL)
			break;

		icc.dwSize = sizeof(icc);
		icc.dwICC = ICC_LISTVIEW_CLASSES | ICC_TREEVIEW_CLASSES | ICC_BAR_CLASSES | ICC_TAB_CLASSES;
		if (!InitCommonControlsEx(&icc))
			break;

		StatusBar = CreateWindowEx(0, STATUSCLASSNAME, NULL,
			WS_VISIBLE | WS_CHILD, 0, 0, 0, 0, MainWindow, (HMENU)1001, g_hInstance, NULL);

		ObjectTree = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, NULL,
			WS_VISIBLE | WS_CHILD | WS_TABSTOP | TVS_DISABLEDRAGDROP | TVS_HASBUTTONS | 
			TVS_HASLINES | TVS_LINESATROOT, 0, 0, 0, 0, MainWindow, (HMENU)1002, g_hInstance, NULL);

		if (ObjectTree == NULL)
			break;

		ObjectList = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, NULL,
			WS_VISIBLE | WS_CHILD | WS_TABSTOP | LVS_AUTOARRANGE | LVS_REPORT | 
			LVS_SHOWSELALWAYS | LVS_SINGLESEL | LVS_SHAREIMAGELISTS, 0, 0, 0, 0, 
			MainWindow, (HMENU)1003, g_hInstance, NULL);

		if (ObjectList == NULL)
			break;

		ToolBar1 = CreateWindowEx(0, TOOLBARCLASSNAME, NULL,
			WS_VISIBLE | WS_CHILD | CCS_TOP | TBSTYLE_FLAT | TBSTYLE_TRANSPARENT | 
			TBSTYLE_TOOLTIPS, 0, 0, 0, 0, MainWindow, (HMENU)1004, g_hInstance, NULL);

		if (ToolBar1 == NULL)
			break;

		Splitter = CreateWindowEx(0, WC_STATIC, NULL,
			WS_VISIBLE | WS_CHILD, 0, 0, 0, 0, MainWindow, (HMENU)1005, g_hInstance, NULL);

		// initialization of views
		SendMessage(MainWindow, WM_SIZE, 0, 0);
		ListView_SetExtendedListViewStyle(ObjectList, 
			LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_LABELTIP | LVS_EX_DOUBLEBUFFER);

		// set tree imagelist
		TreeViewImages = supLoadImageList(g_hInstance, IDI_ICON_VIEW_DEFAULT, IDI_ICON_VIEW_SELECTED);
		if (TreeViewImages) {
			TreeView_SetImageList(ObjectTree, TreeViewImages, TVSIL_NORMAL);
		}

		//not enough user rights, insert run as admin menu entry and hide admin only stuff
		if (IsFullAdmin == FALSE) {
			hMenu = GetSubMenu(GetMenu(MainWindow), 0);
			InsertMenu(hMenu, 0, MF_BYPOSITION, ID_FILE_RUNASADMIN, T_RUNASADMIN);
			InsertMenu(hMenu, 1, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
			//set menu shield icon
			RtlSecureZeroMemory(&sii, sizeof(sii));
			sii.cbSize = sizeof(sii);
			if (SHGetStockIconInfo(SIID_SHIELD, SHGSI_ICON | SHGFI_SMALLICON, &sii) == S_OK) {
				supSetMenuIcon(hMenu, ID_FILE_RUNASADMIN, (ULONG_PTR)sii.hIcon);
			}
			//require driver usage, remove
			DeleteMenu(GetSubMenu(GetMenu(MainWindow), 4), ID_EXTRAS_SSDT, MF_BYCOMMAND);
			DeleteMenu(GetSubMenu(GetMenu(MainWindow), 4), ID_EXTRAS_PRIVATENAMESPACES, MF_BYCOMMAND);
		}

		//unsupported
		if (g_kdctx.osver.dwBuildNumber > 10240) {
			DeleteMenu(GetSubMenu(GetMenu(MainWindow), 4), ID_EXTRAS_PRIVATENAMESPACES, MF_BYCOMMAND);
		}

		//load listview images
		ListViewImages = supLoadImageList(g_hInstance, IDI_ICON_DEVICE, IDI_ICON_UNKNOWN);
		if (ListViewImages) {
			tmpb = LoadImage(g_hInstance, MAKEINTRESOURCE(IDI_ICON_SORTUP), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
			if (tmpb) {
				ImageList_ReplaceIcon(ListViewImages, -1, tmpb);
				DestroyIcon(tmpb);
			}
			tmpb = LoadImage(g_hInstance, MAKEINTRESOURCE(IDI_ICON_SORTDOWN), IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);
			if (tmpb) {
				ImageList_ReplaceIcon(ListViewImages, -1, tmpb);
				DestroyIcon(tmpb);
			}
			ListView_SetImageList(ObjectList, ListViewImages, LVSIL_SMALL);
		}

		//load toolbar images
		ToolBarMenuImages = ImageList_LoadImage(g_hInstance, MAKEINTRESOURCE(IDB_BITMAP1), 
			16, 7, CLR_DEFAULT, IMAGE_BITMAP, LR_CREATEDIBSECTION);

		if (ToolBarMenuImages) {

			supCreateToolbarButtons(ToolBar1);

			//set menu icons
			hMenu = GetSubMenu(GetMenu(MainWindow), 1);
			if (hMenu) {
				supSetMenuIcon(hMenu, ID_VIEW_REFRESH,
					(ULONG_PTR)ImageList_ExtractIcon(g_hInstance, ToolBarMenuImages, 1));
			}
			hMenu = GetSubMenu(GetMenu(MainWindow), 2);
			if (hMenu && ListViewImages) {
				supSetMenuIcon(hMenu, ID_OBJECT_PROPERTIES,
					(ULONG_PTR)ImageList_ExtractIcon(g_hInstance, ToolBarMenuImages, 0));
				supSetMenuIcon(hMenu, ID_OBJECT_GOTOLINKTARGET,
					(ULONG_PTR)ImageList_ExtractIcon(g_hInstance, ListViewImages, 
					ID_FROM_VALUE(IDI_ICON_SYMLINK)));
			}

			//set object -> find object menu image
			hMenu = GetSubMenu(GetMenu(MainWindow), 3);
			if (hMenu) {
				supSetMenuIcon(hMenu, ID_FIND_FINDOBJECT,
					(ULONG_PTR)ImageList_ExtractIcon(g_hInstance, ToolBarMenuImages, 2));
			}

			//set extras-pipe menu image
			hMenu = GetSubMenu(GetMenu(MainWindow), 4);
			if (hMenu) {
				supSetMenuIcon(hMenu, ID_EXTRAS_PIPES,
					(ULONG_PTR)ImageList_ExtractIcon(g_hInstance, ToolBarMenuImages, 6));
			}

			//set help menu image
			hMenu = GetSubMenu(GetMenu(MainWindow), 5);
			if (hMenu) {
				supSetMenuIcon(hMenu, ID_HELP_HELP,
					(ULONG_PTR)ImageList_ExtractIcon(g_hInstance, ToolBarMenuImages, 3));
			}

		}

		hAccTable = LoadAccelerators(g_hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR1));

		//create ObjectList columns
		RtlSecureZeroMemory(&col, sizeof(col));
		col.mask = LVCF_TEXT | LVCF_SUBITEM | LVCF_FMT | LVCF_WIDTH | LVCF_ORDER | LVCF_IMAGE;
		col.iSubItem = 1;
		col.pszText = L"Name";
		col.fmt = LVCFMT_LEFT | LVCFMT_BITMAP_ON_RIGHT;
		col.iOrder = 0;
		col.iImage = -1;
		if (ListViewImages) {
			col.iImage = ImageList_GetImageCount(ListViewImages) - 1;
		}
		col.cx = 300;
		ListView_InsertColumn(ObjectList, 1, &col);

		col.iSubItem = 2;
		col.pszText = L"Type";
		col.iOrder = 1;
		col.iImage = -1;
		col.cx = 100;
		ListView_InsertColumn(ObjectList, 2, &col);

		col.iSubItem = 3;
		col.pszText = L"Additional Information";
		col.iOrder = 2;
		col.iImage = -1;
		col.cx = 170;
		ListView_InsertColumn(ObjectList, 3, &col);

		ListObjectDirectoryTree(L"\\", NULL, NULL);

		TreeView_SelectItem(ObjectTree, TreeView_GetRoot(ObjectTree));
		SetFocus(ObjectTree);

		do {
			rv = GetMessage(&msg1, NULL, 0, 0);

			if (rv == -1)
				break;

			if (MainDlgMsgHandler(msg1)) 
				continue;

			if (IsDialogMessage(MainWindow, &msg1)) {
				TranslateAccelerator(MainWindow, hAccTable, &msg1);
				continue;
			}

			TranslateMessage(&msg1);
			DispatchMessage(&msg1);
		} while (rv != 0);

	} while (cond);

	if (class_atom != 0)
		UnregisterClass(MAKEINTATOM(class_atom), g_hInstance);

	//do not move anywhere
	
	supShutdown();

#ifdef _DEBUG
	TestStop();
#endif

}
Beispiel #7
0
//
// HBITMAP LoadLSImage(LPCSTR pszImage, LPCSTR pszFile)
//
// Takes strings of the form:
//   File.bmp
//   .extract
//   .extract=file.exe[,3]
HBITMAP LoadLSImage(LPCSTR pszImage, LPCSTR pszFile)
{
    HBITMAP hbmReturn = NULL;
    
    if (pszImage != NULL)
    {
        if (_stricmp(pszImage, ".none") != 0)
        {
            char szImage[MAX_PATH];
            StringCchCopy(szImage, MAX_PATH, pszImage);
            
            // Bitmap merging by Thedd
            //  Thedd - pic1.bmp|pic2.bmp merges the images. Works recursively,
            //  so pic1.bmp|.extract=whatever.dll,3|pic2.bmp also works etc...
            // bitmap merging by grd
            LPSTR pszSecondImage = strchr(szImage, '|');
            if (pszSecondImage)
            {
                HDC hdcFirst, hdcSecond, hdcResult;
                HBITMAP hbmFirst, hbmFirstOld;
                HBITMAP hbmSecond, hbmSecondOld;
                HBITMAP    hbmResult, hbmResultOld;
                HBRUSH hbrTransparent;
                RECT rc;
                int wdtFirst, hgtFirst;
                int wdtSecond, hgtSecond;
                int wdtResult, hgtResult;
                
                // get the position after the [|] character
                *pszSecondImage = '\0';
                ++pszSecondImage;
                
                // load the two bitmaps
                hbmFirst = LoadLSImage(szImage, pszFile);
                hbmSecond = LoadLSImage(pszSecondImage, pszFile);
                
                // if the second one is NULL, then there's no merging to do and
                if (hbmSecond != NULL)
                {
                    // create mem dcs for the bitmaps
                    hdcFirst = CreateCompatibleDC(NULL);
                    hdcSecond = CreateCompatibleDC(NULL);
                    
                    // select the bitmaps
                    hbmFirstOld = (HBITMAP)SelectObject(hdcFirst, hbmFirst);
                    hbmSecondOld = (HBITMAP)SelectObject(hdcSecond, hbmSecond);
                    
                    // get the bitmap sizes..
                    GetLSBitmapSize(hbmFirst, &wdtFirst, &hgtFirst);
                    GetLSBitmapSize(hbmSecond, &wdtSecond, &hgtSecond);
                    
                    // in earlier version of bitmap merge, those were painted on
                    // to each other now let's paint both images to a new one
                    
                    // and we support different sized images!! therefore:
                    wdtResult = std::max(wdtFirst, wdtSecond);
                    hgtResult = std::max(hgtFirst, hgtSecond);
                    
                    // create another dc, compatible with second dc
                    hdcResult = CreateCompatibleDC(hdcSecond);
                    
                    // create a new bitmap for the new dc and select it
                    hbmResult = CreateCompatibleBitmap(hdcSecond,
                        wdtResult, hgtResult);
                    hbmResultOld = (HBITMAP)SelectObject(hdcResult, hbmResult);
                    
                    rc.top = 0;
                    rc.left = 0;
                    rc.right = wdtResult;
                    rc.bottom = hgtResult;
                    
                    // paint the background in transparent color...
                    hbrTransparent = CreateSolidBrush(RGB(255, 0, 255));
                    FillRect(hdcResult, &rc, hbrTransparent);
                    DeleteObject(hbrTransparent);
                    
                    // first "standard blit" the second image into the new one:
                    BitBlt(hdcResult, (wdtResult - wdtSecond) / 2,
                        (hgtResult - hgtSecond) / 2, wdtSecond, hgtSecond,
                        hdcSecond, 0, 0, SRCCOPY);
                    
                    // Secondly "tranparent blit" the first image over the
                    // second one Since TransparentBltLS double buffers the
                    // painting to reduce flicker and we are using only memory
                    // DC's in this function, we will just call
                    // TransparentBltLSWorker and shave off a few BitBlt calls
                    TransparentBltLSWorker(hdcResult, wdtFirst, hgtFirst,
                        hdcFirst, 0, 0, RGB(255, 0, 255));
                    
                    // deselect the bitmap from the dc and delete the dc to get
                    // the image
                    SelectObject(hdcResult, hbmResultOld);
                    DeleteDC(hdcResult);
                    
                    // delete all used objects
                    SelectObject(hdcFirst, hbmFirstOld);
                    DeleteObject(hbmFirst);
                    DeleteDC(hdcFirst);
                    
                    SelectObject(hdcSecond, hbmSecondOld);
                    DeleteObject(hbmSecond);
                    DeleteDC(hdcSecond);
                    
                    hbmReturn = hbmResult;
                }
                else
                {
                    hbmReturn = hbmFirst;
                }
            }
            else
            {
                if (!_strnicmp(szImage, ".extract", 8 /*strlen(".extract")*/))
                {
                    HICON hIcon = NULL;
                    
                    hIcon = LoadLSIcon(szImage, pszFile);
                    
                    if (hIcon)
                    {
                        hbmReturn = BitmapFromIcon(hIcon);
                        DestroyIcon(hIcon);
                    }
                }
                else
                {
                    // Append the image name to the LiteStep image path and
                    // attempt to load the image.
                    char szExpandedImage[MAX_PATH];
                    
                    VarExpansionEx(szExpandedImage, szImage, MAX_PATH);
                    LSGetImagePath(szImage, MAX_PATH);
                    PathAppend(szImage, szExpandedImage);
                    
                    if (PathMatchSpec(szImage, "*.png"))
                    {
                        hbmReturn = LoadFromPNG(szImage);
                    }
                    else
                    {
                        hbmReturn = (HBITMAP)LoadImage(
                            NULL, szImage, IMAGE_BITMAP, 0, 0,
                            LR_DEFAULTCOLOR | LR_LOADFROMFILE);
                    }
                    
                    // If that fails, treat the image as a fully qualified path
                    // and try loading it
                    if (hbmReturn == NULL)
                    {
                        if (PathMatchSpec(szExpandedImage, "*.png"))
                        {
                            hbmReturn = LoadFromPNG(szExpandedImage);
                        }
                        else
                        {
                            hbmReturn = (HBITMAP)LoadImage(
                                NULL, szExpandedImage, IMAGE_BITMAP, 0, 0,
                                LR_DEFAULTCOLOR | LR_LOADFROMFILE);
                        }
                    }
                }
            }
        }
    }
    
    return hbmReturn;
}
Beispiel #8
0
void CtrlDisAsmView::onPaint(WPARAM wParam, LPARAM lParam)
{
	if (!debugger->isAlive()) return;

	PAINTSTRUCT ps;
	HDC actualHdc = BeginPaint(wnd, &ps);
	HDC hdc = CreateCompatibleDC(actualHdc);
	HBITMAP hBM = CreateCompatibleBitmap(actualHdc, rect.right-rect.left, rect.bottom-rect.top);
	SelectObject(hdc, hBM);

	SetBkMode(hdc, TRANSPARENT);

	HPEN nullPen=CreatePen(0,0,0xffffff);
	HBRUSH nullBrush=CreateSolidBrush(0xffffff);
	HBRUSH currentBrush=CreateSolidBrush(0xffefe8);

	HPEN oldPen=(HPEN)SelectObject(hdc,nullPen);
	HBRUSH oldBrush=(HBRUSH)SelectObject(hdc,nullBrush);
	HFONT oldFont = (HFONT)SelectObject(hdc,(HGDIOBJ)font);
	HICON breakPoint = (HICON)LoadIcon(GetModuleHandle(0),(LPCWSTR)IDI_STOP);
	HICON breakPointDisable = (HICON)LoadIcon(GetModuleHandle(0),(LPCWSTR)IDI_STOPDISABLE);

	unsigned int address = windowStart;
	std::map<u32,int> addressPositions;

	const std::set<std::string> currentArguments = getSelectedLineArguments();
	DisassemblyLineInfo line;
	for (int i = 0; i < visibleRows; i++)
	{
		manager.getLine(address,displaySymbols,line);

		int rowY1 = rowHeight*i;
		int rowY2 = rowHeight*(i+1);

		addressPositions[address] = rowY1;

		// draw background
		COLORREF backgroundColor = whiteBackground ? 0xFFFFFF : debugger->getColor(address);
		COLORREF textColor = 0x000000;

		if (isInInterval(address,line.totalSize,debugger->getPC()))
		{
			backgroundColor = scaleColor(backgroundColor,1.05f);
		}

		if (address >= selectRangeStart && address < selectRangeEnd && searching == false)
		{
			if (hasFocus)
			{
				backgroundColor = address == curAddress ? 0xFF8822 : 0xFF9933;
				textColor = 0xFFFFFF;
			} else {
				backgroundColor = 0xC0C0C0;
			}
		}
		
		HBRUSH backgroundBrush = CreateSolidBrush(backgroundColor);
		HPEN backgroundPen = CreatePen(0,0,backgroundColor);
		SelectObject(hdc,backgroundBrush);
		SelectObject(hdc,backgroundPen);
		Rectangle(hdc,0,rowY1,rect.right,rowY1+rowHeight);

		SelectObject(hdc,currentBrush);
		SelectObject(hdc,nullPen);

		DeleteObject(backgroundBrush);
		DeleteObject(backgroundPen);

		// display address/symbol
		bool enabled;
		if (CBreakPoints::IsAddressBreakPoint(address,&enabled))
		{
			if (enabled) textColor = 0x0000FF;
			int yOffset = max(-1,(rowHeight-14+1)/2);
			if (!enabled) yOffset++;
			DrawIconEx(hdc,2,rowY1+1+yOffset,enabled ? breakPoint : breakPointDisable,32,32,0,0,DI_NORMAL);
		}
		SetTextColor(hdc,textColor);

		char addressText[64];
		getDisasmAddressText(address,addressText,true,line.type == DISTYPE_OPCODE);
		TextOutA(hdc,pixelPositions.addressStart,rowY1+2,addressText,(int)strlen(addressText));
		
		if (isInInterval(address,line.totalSize,debugger->getPC()))
		{
			TextOut(hdc,pixelPositions.opcodeStart-8,rowY1,L"■",1);
		}

		// display whether the condition of a branch is met
		if (line.info.isConditional && address == debugger->getPC())
		{
			line.params += line.info.conditionMet ? "  ; true" : "  ; false";
		}

		drawArguments(hdc, line, pixelPositions.argumentsStart, rowY1 + 2, textColor, currentArguments);
			
		SelectObject(hdc,boldfont);
		TextOutA(hdc,pixelPositions.opcodeStart,rowY1+2,line.name.c_str(),(int)line.name.size());
		SelectObject(hdc,font);

		address += line.totalSize;
	}

	std::vector<BranchLine> branchLines = manager.getBranchLines(windowStart,address-windowStart);
	for (size_t i = 0; i < branchLines.size(); i++)
	{
		drawBranchLine(hdc,addressPositions,branchLines[i]);
	}

	SelectObject(hdc,oldFont);
	SelectObject(hdc,oldPen);
	SelectObject(hdc,oldBrush);

	// copy bitmap to the actual hdc
	BitBlt(actualHdc, 0, 0, rect.right, rect.bottom, hdc, 0, 0, SRCCOPY);
	DeleteObject(hBM);
	DeleteDC(hdc);

	DeleteObject(nullPen);

	DeleteObject(nullBrush);
	DeleteObject(currentBrush);
	
	DestroyIcon(breakPoint);
	DestroyIcon(breakPointDisable);
	
	EndPaint(wnd, &ps);
}
Beispiel #9
0
static void test_CreateBitmapFromHICON(void)
{
    static const char bits[4096];
    HICON icon;
    ICONINFO info;
    HRESULT hr;
    IWICBitmap *bitmap;
    UINT width, height;
    WICPixelFormatGUID format;

    /* 1 bpp mask */
    info.fIcon = 1;
    info.xHotspot = 0;
    info.yHotspot = 0;
    info.hbmColor = 0;
    info.hbmMask = CreateBitmap(16, 32, 1, 1, bits);
    ok(info.hbmMask != 0, "CreateBitmap failed\n");
    icon = CreateIconIndirect(&info);
    ok(icon != 0, "CreateIconIndirect failed\n");
    DeleteObject(info.hbmMask);

    hr = IWICImagingFactory_CreateBitmapFromHICON(factory, 0, NULL);
    ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);

    hr = IWICImagingFactory_CreateBitmapFromHICON(factory, 0, &bitmap);
    ok(hr == HRESULT_FROM_WIN32(ERROR_INVALID_CURSOR_HANDLE), "expected ERROR_INVALID_CURSOR_HANDLE, got %#x\n", hr);

    hr = IWICImagingFactory_CreateBitmapFromHICON(factory, icon, NULL);
    ok(hr == E_INVALIDARG, "expected E_INVALIDARG, got %#x\n", hr);

    hr = IWICImagingFactory_CreateBitmapFromHICON(factory, icon, &bitmap);
    ok(hr == S_OK, "CreateBitmapFromHICON error %#x\n", hr);
    DestroyIcon(icon);
    if (hr != S_OK) return;

    IWICBitmap_GetPixelFormat(bitmap, &format);
    ok(IsEqualGUID(&format, &GUID_WICPixelFormat32bppBGRA),
       "unexpected pixel format %s\n", wine_dbgstr_guid(&format));

    hr = IWICBitmap_GetSize(bitmap, &width, &height);
    ok(hr == S_OK, "IWICBitmap_GetSize error %#x\n", hr);
    ok(width == 16, "expected 16, got %u\n", width);
    ok(height == 16, "expected 16, got %u\n", height);

    IWICBitmap_Release(bitmap);

    /* 24 bpp color, 1 bpp mask */
    info.fIcon = 1;
    info.xHotspot = 0;
    info.yHotspot = 0;
    info.hbmColor = CreateBitmap(16, 16, 1, 24, bits);
    ok(info.hbmColor != 0, "CreateBitmap failed\n");
    info.hbmMask = CreateBitmap(16, 16, 1, 1, bits);
    ok(info.hbmMask != 0, "CreateBitmap failed\n");
    icon = CreateIconIndirect(&info);
    ok(icon != 0, "CreateIconIndirect failed\n");
    DeleteObject(info.hbmColor);
    DeleteObject(info.hbmMask);

    hr = IWICImagingFactory_CreateBitmapFromHICON(factory, icon, &bitmap);
    ok(hr == S_OK, "CreateBitmapFromHICON error %#x\n", hr);
    DestroyIcon(icon);

    IWICBitmap_GetPixelFormat(bitmap, &format);
    ok(IsEqualGUID(&format, &GUID_WICPixelFormat32bppBGRA),
       "unexpected pixel format %s\n", wine_dbgstr_guid(&format));

    hr = IWICBitmap_GetSize(bitmap, &width, &height);
    ok(hr == S_OK, "IWICBitmap_GetSize error %#x\n", hr);
    ok(width == 16, "expected 16, got %u\n", width);
    ok(height == 16, "expected 16, got %u\n", height);

    IWICBitmap_Release(bitmap);
}
Beispiel #10
0
INT_PTR CALLBACK PhpProcessRecordDlgProc(
    __in HWND hwndDlg,
    __in UINT uMsg,
    __in WPARAM wParam,
    __in LPARAM lParam
    )
{
    PPROCESS_RECORD_CONTEXT context = NULL;

    if (uMsg == WM_INITDIALOG)
    {
        context = (PPROCESS_RECORD_CONTEXT)lParam;
        SetProp(hwndDlg, PhMakeContextAtom(), (HANDLE)context);
    }
    else
    {
        context = (PPROCESS_RECORD_CONTEXT)GetProp(hwndDlg, PhMakeContextAtom());

        if (uMsg == WM_DESTROY)
        {
            RemoveProp(hwndDlg, PhMakeContextAtom());
        }
    }

    if (!context)
        return FALSE;

    switch (uMsg)
    {
    case WM_INITDIALOG:
        {
            PH_IMAGE_VERSION_INFO versionInfo;
            BOOLEAN versionInfoInitialized;
            PPH_STRING processNameString;
            PPH_PROCESS_ITEM processItem;

            if (!PH_IS_FAKE_PROCESS_ID(context->Record->ProcessId))
            {
                processNameString = PhaFormatString(L"%s (%u)",
                    context->Record->ProcessName->Buffer, (ULONG)context->Record->ProcessId);
            }
            else
            {
                processNameString = context->Record->ProcessName;
            }

            PhCenterWindow(hwndDlg, GetParent(hwndDlg));
            SetWindowText(hwndDlg, processNameString->Buffer);

            SetDlgItemText(hwndDlg, IDC_PROCESSNAME, processNameString->Buffer);

            if (processItem = PhReferenceProcessItemForRecord(context->Record))
            {
                PPH_PROCESS_ITEM parentProcess;

                if (parentProcess = PhReferenceProcessItemForParent(
                    processItem->ParentProcessId,
                    processItem->ProcessId,
                    &processItem->CreateTime
                    ))
                {
                    CLIENT_ID clientId;

                    clientId.UniqueProcess = parentProcess->ProcessId;
                    clientId.UniqueThread = NULL;

                    SetDlgItemText(hwndDlg, IDC_PARENT,
                        ((PPH_STRING)PHA_DEREFERENCE(PhGetClientIdNameEx(&clientId, parentProcess->ProcessName)))->Buffer);

                    PhDereferenceObject(parentProcess);
                }
                else
                {
                    SetDlgItemText(hwndDlg, IDC_PARENT, PhaFormatString(L"Non-existent process (%u)",
                        (ULONG)context->Record->ParentProcessId)->Buffer);
                }

                PhDereferenceObject(processItem);
            }
            else
            {
                SetDlgItemText(hwndDlg, IDC_PARENT, PhaFormatString(L"Unknown process (%u)",
                    (ULONG)context->Record->ParentProcessId)->Buffer);

                EnableWindow(GetDlgItem(hwndDlg, IDC_PROPERTIES), FALSE);
            }

            memset(&versionInfo, 0, sizeof(PH_IMAGE_VERSION_INFO));
            versionInfoInitialized = FALSE;

            if (context->Record->FileName)
            {
                if (PhInitializeImageVersionInfo(&versionInfo, context->Record->FileName->Buffer))
                    versionInfoInitialized = TRUE;
            }

            context->FileIcon = PhGetFileShellIcon(PhGetString(context->Record->FileName), L".exe", TRUE);

            SendMessage(GetDlgItem(hwndDlg, IDC_OPENFILENAME), BM_SETIMAGE, IMAGE_BITMAP,
                (LPARAM)PH_LOAD_SHARED_IMAGE(MAKEINTRESOURCE(IDB_FOLDER), IMAGE_BITMAP));
            SendMessage(GetDlgItem(hwndDlg, IDC_FILEICON), STM_SETICON,
                (WPARAM)context->FileIcon, 0);

            SetDlgItemText(hwndDlg, IDC_NAME, PhpGetStringOrNa(versionInfo.FileDescription));
            SetDlgItemText(hwndDlg, IDC_COMPANYNAME, PhpGetStringOrNa(versionInfo.CompanyName));
            SetDlgItemText(hwndDlg, IDC_VERSION, PhpGetStringOrNa(versionInfo.FileVersion));
            SetDlgItemText(hwndDlg, IDC_FILENAME, PhpGetStringOrNa(context->Record->FileName));

            if (versionInfoInitialized)
                PhDeleteImageVersionInfo(&versionInfo);

            if (!context->Record->FileName)
                EnableWindow(GetDlgItem(hwndDlg, IDC_OPENFILENAME), FALSE);

            SetDlgItemText(hwndDlg, IDC_CMDLINE, PhpGetStringOrNa(context->Record->CommandLine));

            if (context->Record->CreateTime.QuadPart != 0)
                SetDlgItemText(hwndDlg, IDC_STARTED, PhapGetRelativeTimeString(&context->Record->CreateTime)->Buffer);
            else
                SetDlgItemText(hwndDlg, IDC_STARTED, L"N/A");

            if (context->Record->ExitTime.QuadPart != 0)
                SetDlgItemText(hwndDlg, IDC_TERMINATED, PhapGetRelativeTimeString(&context->Record->ExitTime)->Buffer);
            else
                SetDlgItemText(hwndDlg, IDC_TERMINATED, L"N/A");

            SetDlgItemInt(hwndDlg, IDC_SESSIONID, context->Record->SessionId, FALSE);
        }
        break;
    case WM_DESTROY:
        {
            if (context->FileIcon)
                DestroyIcon(context->FileIcon);
        }
        break;
    case WM_COMMAND:
        {
            switch (LOWORD(wParam))
            {
            case IDCANCEL:
            case IDOK:
                {
                    EndDialog(hwndDlg, IDOK);
                }
                break;
            case IDC_OPENFILENAME:
                {
                    if (context->Record->FileName)
                        PhShellExploreFile(hwndDlg, context->Record->FileName->Buffer);
                }
                break;
            case IDC_PROPERTIES:
                {
                    PPH_PROCESS_ITEM processItem;

                    if (processItem = PhReferenceProcessItemForRecord(context->Record))
                    {
                        ProcessHacker_ShowProcessProperties(PhMainWndHandle, processItem);
                        PhDereferenceObject(processItem);
                    }
                    else
                    {
                        PhShowError(hwndDlg, L"The process has already terminated; only the process record is available.");
                    }
                }
                break;
            }
        }
        break;
    }

    return FALSE;
}
// adds buttons to the toolbar
void 
TableTabInterfaceTabMgmt::AddToolButtons()
{
	INT			i=0,j, size;
	LONG		ret;
	HICON		hicon;
	TBBUTTON	tbb[30];

    wyInt32 command[] = {   IDI_ADDROW,
						    IDI_DELETEROW,
						    IDM_SEPARATOR,
						    IDI_MOVEUP,
						    IDI_MOVEDOWN 
						};

	wyUInt32 states[][2] = {
							{TBSTATE_ENABLED, TBSTYLE_BUTTON},
							{TBSTATE_ENABLED, TBSTYLE_BUTTON},
							{TBSTATE_ENABLED, TBSTYLE_SEP},
							{TBSTATE_ENABLED, TBSTYLE_BUTTON},
                            {TBSTATE_ENABLED, TBSTYLE_BUTTON}
						   };

	wyInt32 imgres[] = {
						IDI_ADDROW, 
						IDI_DELETEROW,
						IDI_USERS,
						IDI_MOVEUP,
						IDI_MOVEDOWN
					  };

	VERIFY(m_himglist = ImageList_Create(ICON_SIZE, ICON_SIZE, ILC_COLOR32  | ILC_MASK, 1, 0));

 	SendMessage(m_hwndtool, TB_SETIMAGELIST, 0, (LPARAM)m_himglist);
	SendMessage(m_hwndtool, TB_SETEXTENDEDSTYLE, 0 , (LPARAM)TBSTYLE_EX_DRAWDDARROWS);
    SendMessage(m_hwndtool, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);

	size = sizeof(command)/sizeof(command[0]);

	// set some required values
	SendMessage(m_hwndtool, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);

	// now create everything for the toolbar.
	for(j=0; j < size; j++)	
	{
		hicon = (HICON)LoadImage(pGlobals->m_hinstance, MAKEINTRESOURCE ( imgres[j] ), IMAGE_ICON, ICON_SIZE, ICON_SIZE, LR_DEFAULTCOLOR);
		VERIFY((i = ImageList_AddIcon(m_himglist, hicon))!= -1);
		VERIFY(DestroyIcon(hicon));
		
		memset(&tbb[j], 0, sizeof(TBBUTTON));

		tbb[j].iBitmap = MAKELONG(i, 0);
		tbb[j].idCommand = command[j];
		tbb[j].fsState = (UCHAR)states[j][0];
		tbb[j].fsStyle = (UCHAR)states[j][1];
	}  

	VERIFY((ret = SendMessage(m_hwndtool, TB_ADDBUTTONS, (WPARAM)size,(LPARAM) &tbb)!= FALSE));

    /* Now set and show the toolbar */
	SendMessage(m_hwndtool, TB_AUTOSIZE, 0, 0);
	ShowWindow(m_hwndtool, SW_SHOW);
}
Icon::~Icon()
{
    DestroyIcon(m_hIcon);
}
Beispiel #13
0
///////////////////////////////////////////////////////////////////////////////
// Paint the toolbar
void CToolBarXP::OnPaint ()
{
    if ( m_bDelayedButtonLayout )
    {
        Layout();
    }
    CPaintDC cpDC (this);
    CBufferDC cDC (cpDC);
    CRect rcClip;
    cDC.GetClipBox (rcClip);
    cDC.SetBkMode (TRANSPARENT);
    cDC.SelectObject (CFont::FromHandle ((HFONT)GetStockObject (DEFAULT_GUI_FONT)));

    cDC.FillSolidRect (rcClip, HLS_TRANSFORM (::GetSysColor (COLOR_3DFACE), 20, 0));

    CPoint ptCursor;
    ::GetCursorPos (&ptCursor);
    ScreenToClient (&ptCursor);

    CClientRect rcClient (this);
    HIMAGELIST m_hImageList = (HIMAGELIST)DefWindowProc (TB_GETIMAGELIST, 0, 0);
    TBBUTTON tbbutton;
    int nCount = DefWindowProc (TB_BUTTONCOUNT, 0, 0);
    int nHotItem = GetToolBarCtrl().GetHotItem();

    for ( int i = 0; i < nCount; i++ )
    {
        VERIFY(DefWindowProc (TB_GETBUTTON, i, (LPARAM)&tbbutton));

        if ( !IS_VISIBLE(tbbutton) )
        {
            continue;
        }
        CRect rcButton;
        VERIFY(DefWindowProc (TB_GETITEMRECT, i, (LPARAM)&rcButton));

        if ( !CRect().IntersectRect (rcClip, rcButton) )
        {
            continue;
        }
        bool bOver = nHotItem == i && IS_ENABLED(tbbutton);
        bool bPressed = false;

        if ( IS_INDETERMINATE(tbbutton) )
        {
            CPenDC pen (cDC, ::GetSysColor (COLOR_3DDKSHADOW));

            cDC.MoveTo (rcButton.left, rcButton.bottom);
            cDC.LineTo (rcButton.left, rcButton.top);
            cDC.LineTo (rcButton.right-1, rcButton.top);
            cDC.LineTo (rcButton.right-1, rcButton.bottom-1);
            cDC.LineTo (rcButton.left, rcButton.bottom-1);
            bOver = true;
        }
        else if ( bOver || IS_CHECKED(tbbutton) )
        {
            bPressed = KEYDOWN(VK_LBUTTON) && rcButton.PtInRect (ptCursor);

            if ( IS_DROPDOWN(tbbutton) && bPressed )
            {
                bPressed = ptCursor.x < rcButton.right-13;

                if ( bPressed )
                {
                    rcButton.right -= 13;
                }
            }
            COLORREF crHighLight = ::GetSysColor (COLOR_HIGHLIGHT);
            CPenDC pen (cDC, crHighLight);
            CBrushDC brush (cDC, bPressed||(bOver&&IS_CHECKED(tbbutton)) ? HLS_TRANSFORM (crHighLight, +50, -50) : (bOver ? HLS_TRANSFORM (crHighLight, +70, -57) : HLS_TRANSFORM (crHighLight, +80, -66)));

            cDC.Rectangle (&rcButton);

            if ( IS_DROPDOWN(tbbutton) )
            {
                if ( bPressed )
                {
                    int nLeft = rcButton.left;

                    rcButton.left = rcButton.right-1;
                    rcButton.right += 13;

                    brush.Color (HLS_TRANSFORM (crHighLight, +70, -66));
                    cDC.Rectangle (&rcButton);

                    rcButton.left = nLeft;
                }
                else
                {
                    cDC.MoveTo (rcButton.right-14, rcButton.top);
                    cDC.LineTo (rcButton.right-14, rcButton.bottom);
                }
            }
        }
        if ( IS_SEPARATOR(tbbutton) )
        {
            CPenDC pen (cDC, HLS_TRANSFORM (::GetSysColor (COLOR_3DFACE), -15, 0));

            if ( IS_WRAP(tbbutton) )
            {
                cDC.MoveTo (rcClient.left+2, rcButton.bottom-4);
                cDC.LineTo (rcClient.right-2, rcButton.bottom-4);
            }
            else
            {
                cDC.MoveTo ((rcButton.right+rcButton.left)/2-1, rcButton.top+2);
                cDC.LineTo ((rcButton.right+rcButton.left)/2-1, rcButton.bottom-2);
            }
        }
        else if ( !IS_CONTROL(tbbutton) )
        {
            if ( IS_DROPDOWN(tbbutton) )
            {
                CPenDC pen (cDC, ( bOver && !IS_INDETERMINATE(tbbutton) ) ? RGB(0,0,0) : ::GetSysColor (IS_ENABLED(tbbutton) ? COLOR_BTNTEXT : COLOR_GRAYTEXT));

                cDC.MoveTo (rcButton.right-9, (rcButton.top+rcButton.bottom)/2-1);
                cDC.LineTo (rcButton.right-4, (rcButton.top+rcButton.bottom)/2-1);
                cDC.MoveTo (rcButton.right-8, (rcButton.top+rcButton.bottom)/2);
                cDC.LineTo (rcButton.right-5, (rcButton.top+rcButton.bottom)/2);
                cDC.SetPixel (rcButton.right-7, (rcButton.top+rcButton.bottom)/2+1, pen.Color());

                rcButton.right -= 14;
            }
            if ( tbbutton.iBitmap >= 0 )
            {
                if ( !IS_ENABLED(tbbutton) || (bOver && !bPressed) )
                {
                    HICON hIcon = ImageList_ExtractIcon (NULL, m_hImageList, tbbutton.iBitmap);
                    cDC.DrawState (CPoint (rcButton.left + ( bOver ? 4 : 3 ), rcButton.top + ( bOver ? 4 : 3 )), m_sizeImage, hIcon, DSS_MONO, CBrush (bOver ? (IS_INDETERMINATE(tbbutton) ? HLS_TRANSFORM (::GetSysColor (COLOR_3DFACE), -20, 0) : HLS_TRANSFORM (::GetSysColor (COLOR_HIGHLIGHT), +50, -66)) : HLS_TRANSFORM (::GetSysColor (COLOR_3DFACE), -27, 0)));
                    DestroyIcon (hIcon);
                }
                if ( IS_ENABLED(tbbutton) )
                {
                    ::ImageList_Draw (m_hImageList, tbbutton.iBitmap, cDC.m_hDC,
                                      rcButton.left + ( (bOver && !bPressed) ? 2 : 3 ), rcButton.top + ( (bOver && !bPressed) ? 2 : 3 ), ILD_TRANSPARENT);
                }
            }
        }
    }
}
Beispiel #14
0
CPPageFileInfoRes::~CPPageFileInfoRes()
{
    if (m_hIcon) {
        DestroyIcon(m_hIcon);
    }
}
CMediaVisDlg::~CMediaVisDlg()
{
	if ( m_hIcon ) DestroyIcon( m_hIcon );
}
Beispiel #16
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	
    switch (message)
    {
	case WM_CREATE:
	{
		hbr1 = CreateSolidBrush(RGB(255, 0, 0));
		hbr2 = CreateSolidBrush(RGB(0, 0, 255));
	
		hIcon1 = LoadIcon(hInst, MAKEINTRESOURCE(ID_PLAYER1));
		hIcon2 = LoadIcon(hInst, MAKEINTRESOURCE(ID_PLAYER2));

	}
	break;
    case WM_COMMAND:
        {
            int wmId = LOWORD(wParam);
            // Parse the menu selections:
            switch (wmId)
            {
			case ID_FILE_NEWGAME:
			{
				int ret = MessageBox(hWnd, L"Are you sure you want to start a new game?", L"New Game", MB_YESNO | MB_ICONQUESTION);
				if (IDYES == ret)
				{
					//Reset and start a new game
					playerTurn = 1;
					winner = 0;
					ZeroMemory(gameBoard, sizeof(gameBoard));
					 
					InvalidateRect(hWnd, NULL, TRUE);
					UpdateWindow(hWnd);
				}
			}
			break;
				
            case IDM_ABOUT:
                DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
                break;
            case IDM_EXIT:
                DestroyWindow(hWnd);
                break;
            default:
                return DefWindowProc(hWnd, message, wParam, lParam);
            }
        }
        break;
	case WM_LBUTTONDOWN:
	{
		int xPos = GET_X_LPARAM(lParam);
		int yPos = GET_Y_LPARAM(lParam);

		if (0 == playerTurn)
			break;
		
		int index = GetCellNumberFromPoint(hWnd, xPos, yPos);
		HDC hdc = GetDC(hWnd);
		if (NULL != hdc)
		{
		//	WCHAR temp[100];
			//wsprintf(temp, L"Index = %d", index);
		//	TextOut(hdc, xPos, yPos, temp, lstrlen(temp));

			if (index != -1)
			{
				RECT rcCell;
				if ((0 == gameBoard[index]) && GetCellRect(hWnd, index, &rcCell))
				{
					gameBoard[index] = playerTurn;

					//FillRect(hdc, &rcCell, (playerTurn==1) ? hbr1 : hbr2);
					DrawIconCentered(hdc, &rcCell, (playerTurn == 1) ? hIcon1 : hIcon2);
					winner = GetWinner(wins);
					if (winner == 1 || winner == 2)
					{
						MessageBox(hWnd, (winner == 1) ? L"Player 1 wins" : L"Player 2 wins", L"You win!",MB_OK | MB_ICONINFORMATION);
						playerTurn = 0;
					}
					else if (3==winner)
					{
						MessageBox(hWnd, L"No one wins!", L"It's a draw", MB_OK | MB_ICONEXCLAMATION);
						playerTurn = 0;
					
					}
					else if (winner == 0)
					{
						playerTurn = (playerTurn == 1) ? 2 : 1;
					}
					ShowTurn(hWnd, hdc);
					}


					
				
			}
			ReleaseDC(hWnd, hdc);
		}
	}
	break;
	case WM_GETMINMAXINFO:
		{
			MINMAXINFO * pMinMax = (MINMAXINFO*)lParam;

			pMinMax->ptMinTrackSize.x = CELL_SIZE * 5;
			pMinMax->ptMinTrackSize.y = CELL_SIZE * 5;
		}
    case WM_PAINT:
        {
            PAINTSTRUCT ps;
            HDC hdc = BeginPaint(hWnd, &ps);
			RECT rc;


			if (GetGameBoardRect(hWnd, &rc))
			{
				RECT rcClient;


				if (GetClientRect(hWnd, &rcClient))
				{
					const WCHAR szPlayer1 [] = L"Player 1";
					const WCHAR szPlayer2 []= L"Player 2";
					
					SetBkMode(hdc, TRANSPARENT);

					SetTextColor(hdc, RGB(255, 255, 0));
					TextOut(hdc, 16, 16, szPlayer1, 8);
					SetTextColor(hdc, RGB(0, 0, 255));
					TextOut(hdc, rcClient.right-72, 16, szPlayer2, 8);
					ShowTurn(hWnd, hdc);

				}


				FillRect(hdc, &rc, (HBRUSH)GetStockObject(WHITE_BRUSH));
				//Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom);
			}

			for (int i = 0; i < 4; i++)
			{
				DrawLine(hdc, rc.left+CELL_SIZE*i , rc.top, rc.left + CELL_SIZE*i, rc.bottom);

				DrawLine(hdc, rc.left, rc.top + CELL_SIZE*i, rc.right, rc.top+CELL_SIZE*i);
			}
			RECT rcCell;

			for (int i = 0; i < 9; i++)
			{
				if ((0!=gameBoard[i]) && GetCellRect(hWnd, i, &rcCell))
				{

					//FillRect(hdc, &rcCell, (gameBoard[i]==2) ? hbr2 : hbr1);
					DrawIconCentered(hdc, &rcCell, (gameBoard[i] == 1) ? hIcon1 : hIcon2);

				}


			}
            EndPaint(hWnd, &ps);

        }
        break;
    case WM_DESTROY:
		DeleteObject(hbr1);
		DeleteObject(hbr2);
		DestroyIcon(hIcon1);
		DestroyIcon(hIcon2);
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}
Beispiel #17
0
void CreateListView (HWND hWnd)
{

   HICON hIcon;
   LV_ITEM item;
   LV_COLUMN col;
   TCHAR szBuffer[30];
   INT i, iItem;
   HIMAGELIST hImageList;
   RECT rc;


   //
   // Create an image list to work with.
   //

   hImageList=ImageList_Create(16, 16, ILC_MASK, 1, 0);

   if (hImageList==NULL) {
       return;
   }

   //
   // Add some icons to it.
   //

   hIcon = LoadImage(hInst, MAKEINTRESOURCE(1), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
   ImageList_AddIcon(hImageList, hIcon);
   DestroyIcon(hIcon);


   GetClientRect (hWnd, &rc);

   hLV = CreateWindow (WC_LISTVIEW, NULL, LVS_REPORT | LVS_EDITLABELS| WS_CHILD | WS_VISIBLE | WS_EX_CLIENTEDGE | WS_BORDER,
                 0, 0, rc.right, rc.bottom, hWnd, (HMENU) 1,
                 hInst, NULL);

   if (!hLV) {
      GetLastError();
      return;
   }

   ListView_SetImageList(hLV, hImageList, LVSIL_SMALL);


   //
   // Insert Columns
   //

   col.mask = LVCF_FMT | LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH;
   col.fmt = LVCFMT_LEFT;
   col.cx = rc.right / 3;
   col.pszText = TEXT("Column 0");
   col.iSubItem = 0;

   ListView_InsertColumn (hLV, 0, &col);


   col.pszText = TEXT("Column 1");
   col.iSubItem = 1;

   ListView_InsertColumn (hLV, 1, &col);


   col.pszText = TEXT("Column 2");
   col.iSubItem = 2;

   ListView_InsertColumn (hLV, 2, &col);


   //
   // Insert Items
   //


   for (i=0; i < 18; i++) {

       wsprintf (szBuffer, TEXT("Item %d"), i+1);

       item.mask = LVIF_TEXT | LVIF_IMAGE;
       item.iItem = i;
       item.iSubItem = 0;
       item.pszText = szBuffer;
       item.cchTextMax = 30;
       item.iImage = 0;

       iItem = ListView_InsertItem (hLV, &item);


       wsprintf (szBuffer, TEXT("SubItem (1,%d)"), iItem+1);

       item.mask = LVIF_TEXT;
       item.iItem = iItem;
       item.iSubItem = 1;
       item.pszText = szBuffer;

       ListView_SetItem (hLV, &item);

       wsprintf (szBuffer, TEXT("SubItem (2,%d)"), iItem+1);

       item.mask = LVIF_TEXT;
       item.iItem = iItem;
       item.iSubItem = 2;
       item.pszText = szBuffer;

       ListView_SetItem (hLV, &item);

   }

}
Beispiel #18
0
//
//  函数: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  目的: 处理主窗口的消息。
//
//  WM_COMMAND	- 处理应用程序菜单
//  WM_PAINT	- 绘制主窗口
//  WM_DESTROY	- 发送退出消息并返回
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;

	switch (message)
	{
	case MYWM_NOTIFYICON: 
		if(lParam==WM_RBUTTONDOWN){    
			HMENU hMenu = LoadMenuW(hInst,MAKEINTRESOURCEW(IDR_MENU1));
			HMENU hSubMenu = GetSubMenu(hMenu,0);
			POINT pos; 
			GetCursorPos(&pos);
			SetForegroundWindow(hWnd);
			TrackPopupMenu(hSubMenu,TPM_LEFTALIGN,pos.x,pos.y,0,hWnd,NULL);
			DestroyMenu(hMenu);
		}
	break;
	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// 分析菜单选择:
		switch (wmId)
		{
		case ID_EXIT:
			NOTIFYICONDATAW m_tnid;
			memset(&m_tnid,0,sizeof(m_tnid));

			//OnCreate 函数中return 之前添加托盘生成代码
			m_tnid.cbSize=sizeof(NOTIFYICONDATA); 
			m_tnid.hWnd=hWnd; 
			m_tnid.uFlags=NIF_MESSAGE|NIF_ICON|NIF_TIP; 
			m_tnid.uCallbackMessage=MYWM_NOTIFYICON;

			//用户定义的回调消息 
			wcscpy_s<128>(m_tnid.szTip,L"v-Judge-Kernel");
			m_tnid.uID=NULL;
			HICON hIcon; 
			hIcon=LoadIcon(hInst,MAKEINTRESOURCE(IDI_ICON2)); 
			m_tnid.hIcon=hIcon; 
			Shell_NotifyIconW(NIM_DELETE,&m_tnid); 
			if(hIcon)
				DestroyIcon(hIcon);
			DestroyWindow(hWnd);
			break;
		case ID_UNINSTALL:
			if(IDYES == MessageBoxW(0,L"Are you sure to uninstall the service v-Judge_Kernel?",L"Warning!",MB_YESNO)){
				if(SvcUninstall())
					MessageBoxW(0,L"Successfully uninstall.",L"Message",MB_OK);
				else
					MessageBoxW(0,L"Unsuccessfully uninstall.",L"Message",MB_OK);
			}
			break;
		case ID_INSTALL:
			if(IDYES == MessageBoxW(0,L"Are you sure to install the service v-Judge_Kernel?",L"Warning!",MB_YESNO)){
				if(SvcInstall())
					MessageBoxW(0,L"Successfully install.",L"Message",MB_OK);
				else
					MessageBoxW(0,L"Unsuccessfully install.",L"Message",MB_OK);
			}
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;
	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		// TODO: 在此添加任意绘图代码...
		EndPaint(hWnd, &ps);
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
Beispiel #19
0
static LRESULT CALLBACK WindowFunc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
/**************************************
 *
 *	W i n d o w _ F u n c
 *
 **************************************
 *
 * Functional description
 *
 *      This function is where the windowing action takes place.
 * Handle the various messages which come here from GetMessage.
 *
 **************************************/

	static BOOL bInTaskBar = FALSE;
	static bool bStartup = false;
	static HINSTANCE hInstance = NULL;

	hInstance = (HINSTANCE) GetWindowLongPtr(hWnd, GWLP_HINSTANCE);
	switch (message)
	{
	case WM_CLOSE:
		// Clean up memory for log_entry
		while (log_entry->next)
		{
			log_info* tmp = log_entry->next;
			free(log_entry);
			log_entry = tmp;
		}
		free(log_entry);
		DestroyWindow(hWnd);
		break;

	case WM_COMMAND:
		switch (wParam)
		{
		case IDM_CANCEL:
			ShowWindow(hWnd, bInTaskBar ? SW_HIDE : SW_MINIMIZE);
			return TRUE;

		case IDM_OPENPOPUP:
			{
				// The SetForegroundWindow() has to be called because our window
				// does not become the Foreground one (inspite of clicking on
				// the icon).  This is so because the icon is painted on the task
				// bar and is not the same as a minimized window.

				SetForegroundWindow(hWnd);

				HMENU hPopup = CreatePopupMenu();
				char szMsgString[256];
				LoadString(hInstance, IDS_SVRPROPERTIES, szMsgString, 256);
				AppendMenu(hPopup, MF_STRING, IDM_SVRPROPERTIES, szMsgString);
				LoadString(hInstance, IDS_SHUTDOWN, szMsgString, 256);
				AppendMenu(hPopup, MF_STRING, IDM_SHUTDOWN, szMsgString);
				LoadString(hInstance, IDS_PROPERTIES, szMsgString, 256);
				AppendMenu(hPopup, MF_STRING, IDM_PROPERTIES, szMsgString);
				SetMenuDefaultItem(hPopup, IDM_PROPERTIES, FALSE);

				POINT curPos;
				GetCursorPos(&curPos);
				TrackPopupMenu(hPopup, TPM_LEFTALIGN | TPM_RIGHTBUTTON,
							   curPos.x, curPos.y, 0, hWnd, NULL);
				DestroyMenu(hPopup);
				return TRUE;
			}

		case IDM_SHUTDOWN:
			{
				HWND hTmpWnd = FindWindow(szClassName, szWindowName);
				PostMessage(hTmpWnd, WM_COMMAND, (WPARAM) IDM_SHUTDOWN, 0);
			}
			return TRUE;

		case IDM_PROPERTIES:
			if (!hPSDlg)
				hPSDlg = DisplayPropSheet(hWnd, hInstance);
			else
				SetForegroundWindow(hPSDlg);
			return TRUE;

		case IDM_INTRSVRPROPERTIES:
			return TRUE;

		case IDM_SVRPROPERTIES:
			{
				HWND hTmpWnd = FindWindow(szClassName, szWindowName);
				PostMessage(hTmpWnd, WM_COMMAND, (WPARAM) IDM_PROPERTIES, 0);
			}
			return TRUE;
		}
		break;

	case WM_SWITCHICONS:
		nRestarts++;
		gds__thread_start(swap_icons, hWnd, THREAD_medium, 0, NULL);
		break;

	case ON_NOTIFYICON:
		if (bStartup)
		{
			SendMessage(hWnd, WM_COMMAND, 0, 0);
			return TRUE;
		}
		switch (lParam)
		{
		case WM_LBUTTONDOWN:
			break;

		case WM_LBUTTONDBLCLK:
			PostMessage(hWnd, WM_COMMAND, (WPARAM) IDM_PROPERTIES, 0);
			break;

		case WM_RBUTTONUP:
			PostMessage(hWnd, WM_COMMAND, (WPARAM) IDM_OPENPOPUP, 0);
			break;
		}
		break;

	case WM_CREATE:
		if (!service_flag)
		{
			HICON hIcon = (HICON) LoadImage(hInstance, MAKEINTRESOURCE(IDI_IBGUARD),
									  IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR);

			NOTIFYICONDATA nid;
			nid.cbSize = sizeof(NOTIFYICONDATA);
			nid.hWnd = hWnd;
			nid.uID = IDI_IBGUARD;
			nid.uFlags = NIF_TIP | NIF_ICON | NIF_MESSAGE;
			nid.uCallbackMessage = ON_NOTIFYICON;
			nid.hIcon = hIcon;
			lstrcpy(nid.szTip, GUARDIAN_APP_LABEL);

			// This will be true if we are using the explorer interface
			bInTaskBar = Shell_NotifyIcon(NIM_ADD, &nid);

			if (hIcon)
				DestroyIcon(hIcon);

			// This will be true if we are using the program manager interface
			if (!bInTaskBar)
			{
				char szMsgString[256];
				HMENU hSysMenu = GetSystemMenu(hWnd, FALSE);
				DeleteMenu(hSysMenu, SC_RESTORE, MF_BYCOMMAND);
				AppendMenu(hSysMenu, MF_SEPARATOR, 0, NULL);
				LoadString(hInstance, IDS_SVRPROPERTIES, szMsgString, 256);
				AppendMenu(hSysMenu, MF_STRING, IDM_SVRPROPERTIES, szMsgString);
				LoadString(hInstance, IDS_SHUTDOWN, szMsgString, 256);
				AppendMenu(hSysMenu, MF_STRING, IDM_SHUTDOWN, szMsgString);
				LoadString(hInstance, IDS_PROPERTIES, szMsgString, 256);
				AppendMenu(hSysMenu, MF_STRING, IDM_PROPERTIES, szMsgString);
				DestroyMenu(hSysMenu);
			}
		}
		break;

	case WM_QUERYOPEN:
		if (!bInTaskBar)
			return FALSE;
		return DefWindowProc(hWnd, message, wParam, lParam);

	case WM_SYSCOMMAND:
		if (!bInTaskBar)
			switch (wParam)
			{
			case SC_RESTORE:
				return TRUE;

			case IDM_SHUTDOWN:
				{
					HWND hTmpWnd = FindWindow(szClassName, szWindowName);
					PostMessage(hTmpWnd, WM_COMMAND, (WPARAM) IDM_SHUTDOWN, 0);
				}
				return TRUE;

			case IDM_PROPERTIES:
				if (!hPSDlg)
					hPSDlg = DisplayPropSheet(hWnd, hInstance);
				else
					SetFocus(hPSDlg);
				return TRUE;

			case IDM_SVRPROPERTIES:
				{
					HWND hTmpWnd = FindWindow(szClassName, szWindowName);
					PostMessage(hTmpWnd, WM_COMMAND, (WPARAM) IDM_PROPERTIES, 0);
				}
				return TRUE;
			}
		return DefWindowProc(hWnd, message, wParam, lParam);

	case WM_DESTROY:
		if (bInTaskBar)
		{
			NOTIFYICONDATA nid;

			nid.cbSize = sizeof(NOTIFYICONDATA);
			nid.hWnd = hWnd;
			nid.uID = IDI_IBGUARD;
			nid.uFlags = 0;
			Shell_NotifyIcon(NIM_DELETE, &nid);
		}
		PostQuitMessage(0);
		break;

	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return FALSE;
}
static VOID PhpRefreshProcessList(
    _In_ HWND hwndDlg,
    _In_ PCHOOSE_PROCESS_DIALOG_CONTEXT Context
    )
{
    NTSTATUS status;
    HWND lvHandle;
    PVOID processes;
    PSYSTEM_PROCESS_INFORMATION process;

    lvHandle = Context->ListViewHandle;

    ListView_DeleteAllItems(lvHandle);
    ImageList_RemoveAll(Context->ImageList);

    if (!NT_SUCCESS(status = PhEnumProcesses(&processes)))
    {
        PhShowStatus(hwndDlg, L"Unable to enumerate processes", status, 0);
        return;
    }

    ExtendedListView_SetRedraw(lvHandle, FALSE);

    process = PH_FIRST_PROCESS(processes);

    do
    {
        INT lvItemIndex;
        PPH_STRING name;
        HANDLE processHandle;
        PPH_STRING fileName = NULL;
        HICON icon = NULL;
        WCHAR processIdString[PH_INT32_STR_LEN_1];
        PPH_STRING userName = NULL;
        INT imageIndex;

        if (process->UniqueProcessId != SYSTEM_IDLE_PROCESS_ID)
            name = PhCreateStringFromUnicodeString(&process->ImageName);
        else
            name = PhCreateString(SYSTEM_IDLE_PROCESS_NAME);

        lvItemIndex = PhAddListViewItem(lvHandle, MAXINT, name->Buffer, process->UniqueProcessId);
        PhDereferenceObject(name);

        if (NT_SUCCESS(PhOpenProcess(&processHandle, ProcessQueryAccess, process->UniqueProcessId)))
        {
            HANDLE tokenHandle;
            PTOKEN_USER user;

            if (!WINDOWS_HAS_IMAGE_FILE_NAME_BY_PROCESS_ID && process->UniqueProcessId != SYSTEM_PROCESS_ID)
                PhGetProcessImageFileName(processHandle, &fileName);

            if (NT_SUCCESS(PhOpenProcessToken(&tokenHandle, TOKEN_QUERY, processHandle)))
            {
                if (NT_SUCCESS(PhGetTokenUser(tokenHandle, &user)))
                {
                    userName = PhGetSidFullName(user->User.Sid, TRUE, NULL);
                    PhFree(user);
                }

                NtClose(tokenHandle);
            }

            NtClose(processHandle);
        }

        if (process->UniqueProcessId == SYSTEM_IDLE_PROCESS_ID && !userName && PhLocalSystemName)
            PhSetReference(&userName, PhLocalSystemName);

        if (WINDOWS_HAS_IMAGE_FILE_NAME_BY_PROCESS_ID && process->UniqueProcessId != SYSTEM_PROCESS_ID)
            PhGetProcessImageFileNameByProcessId(process->UniqueProcessId, &fileName);

        if (process->UniqueProcessId == SYSTEM_PROCESS_ID)
            fileName = PhGetKernelFileName();

        if (fileName)
            PhMoveReference(&fileName, PhGetFileName(fileName));

        icon = PhGetFileShellIcon(PhGetString(fileName), L".exe", FALSE);

        // Icon
        if (icon)
        {
            imageIndex = ImageList_AddIcon(Context->ImageList, icon);
            PhSetListViewItemImageIndex(Context->ListViewHandle, lvItemIndex, imageIndex);
            DestroyIcon(icon);
        }

        // PID
        PhPrintUInt32(processIdString, HandleToUlong(process->UniqueProcessId));
        PhSetListViewSubItem(Context->ListViewHandle, lvItemIndex, 1, processIdString);

        // User Name
        PhSetListViewSubItem(Context->ListViewHandle, lvItemIndex, 2, PhGetString(userName));

        if (userName) PhDereferenceObject(userName);
        if (fileName) PhDereferenceObject(fileName);
    } while (process = PH_NEXT_PROCESS(process));

    PhFree(processes);

    ExtendedListView_SortItems(lvHandle);
    ExtendedListView_SetRedraw(lvHandle, TRUE);
}
Beispiel #21
0
CTrashSkipCtrl::~CTrashSkipCtrl(void)
{
    DestroyIcon(m_iconIE);
    DestroyIcon(m_iconUnknow);
//    DestroyObject(m_bmpHeadBack);
}
Beispiel #22
0
INT_PTR CALLBACK
AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    HWND hWnd;
    HDC hDC;
    RECT rcClient, rcRect;
    char *owner, *org;

    switch (uMsg)
    {
    case WM_NOTIFY:
        switch(((LPNMHDR)lParam)->code)
        {
        case PSN_APPLY:
            /*save registration info to registry */
            owner = get_text(hDlg, IDC_ABT_OWNER);
            org   = get_text(hDlg, IDC_ABT_ORG);

            set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion",
                        "RegisteredOwner", owner ? owner : "");
            set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion",
                        "RegisteredOrganization", org ? org : "");
            set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
                        "RegisteredOwner", owner ? owner : "");
            set_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
                        "RegisteredOrganization", org ? org : "");
            apply();

            HeapFree(GetProcessHeap(), 0, owner);
            HeapFree(GetProcessHeap(), 0, org);
            break;

        case NM_CLICK:
        case NM_RETURN:
            if(wParam == IDC_ABT_WEB_LINK)
                ShellExecuteA(NULL, "open", PACKAGE_URL, NULL, NULL, SW_SHOW);
            break;
        }
        break;

    case WM_INITDIALOG:

        hDC = GetDC(hDlg);

        /* read owner and organization info from registry, load it into text box */
        owner = get_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
                            "RegisteredOwner", "");
        org =   get_reg_key(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion",
                            "RegisteredOrganization", "");

        SetDlgItemText(hDlg, IDC_ABT_OWNER, owner);
        SetDlgItemText(hDlg, IDC_ABT_ORG, org);

        SendMessage(GetParent(hDlg), PSM_UNCHANGED, 0, 0);

        HeapFree(GetProcessHeap(), 0, owner);
        HeapFree(GetProcessHeap(), 0, org);

        /* prepare the panel */
        hWnd = GetDlgItem(hDlg, IDC_ABT_PANEL);
        if(hWnd)
        {
            GetClientRect(hDlg, &rcClient);
            GetClientRect(hWnd, &rcRect);
            MoveWindow(hWnd, 0, 0, rcClient.right, rcRect.bottom, FALSE);

            logo = LoadImageW((HINSTANCE)GetWindowLongPtrW(hDlg, GWLP_HINSTANCE),
                MAKEINTRESOURCEW(IDI_LOGO), IMAGE_ICON, 0, 0, LR_SHARED);
        }

        /* prepare the title text */
        hWnd = GetDlgItem(hDlg, IDC_ABT_TITLE_TEXT);
        if(hWnd)
        {
            titleFont = CreateFont(
                -MulDiv(24, GetDeviceCaps(hDC, LOGPIXELSY), 72),
                0, 0, 0, 0, FALSE, 0, 0, 0, 0, 0, 0, 0,
                "Tahoma");
            SendMessage(hWnd, WM_SETFONT, (WPARAM)titleFont, TRUE);
            SetWindowTextA(hWnd, PACKAGE_NAME);
        }
        SetDlgItemTextA(hDlg, IDC_ABT_PANEL_TEXT, PACKAGE_VERSION);

        /* prepare the web link */
        SetDlgItemTextA(hDlg, IDC_ABT_WEB_LINK, "<a href=\"" PACKAGE_URL "\">" PACKAGE_URL "</a>");

        ReleaseDC(hDlg, hDC);

        break;

    case WM_DESTROY:
        if(logo)
        {
            DestroyIcon(logo);
            logo = NULL;
        }

        if(titleFont)
        {
            DeleteObject(titleFont);
            titleFont = NULL;
        }

        break;

    case WM_COMMAND:
        switch(HIWORD(wParam))
        {
        case EN_CHANGE:
            /* enable apply button */
            SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
            break;
        }
        break;

    case WM_DRAWITEM:
        if(wParam == IDC_ABT_PANEL)
        {
            LPDRAWITEMSTRUCT pDIS = (LPDRAWITEMSTRUCT)lParam;
            FillRect(pDIS->hDC, &pDIS->rcItem, (HBRUSH) (COLOR_WINDOW+1));
            DrawIconEx(pDIS->hDC, 0, 0, logo, 0, 0, 0, 0, DI_IMAGE);
            DrawEdge(pDIS->hDC, &pDIS->rcItem, EDGE_SUNKEN, BF_BOTTOM);
        }
        break;

    case WM_CTLCOLORSTATIC:
        switch(GetDlgCtrlID((HWND)lParam))
        {
        case IDC_ABT_TITLE_TEXT:
            /* set the title to a wine color */
            SetTextColor((HDC)wParam, 0x0000007F);
        case IDC_ABT_PANEL_TEXT:
        case IDC_ABT_LICENSE_TEXT:
        case IDC_ABT_WEB_LINK:
            return (INT_PTR)CreateSolidBrush(GetSysColor(COLOR_WINDOW));
        }
        break;
    }

    return FALSE;
}
Beispiel #23
0
INT WINAPI WinMain(HINSTANCE Instance, HINSTANCE, LPSTR, INT) {
    gInstance = Instance;

    INITCOMMONCONTROLSEX icc;

    // Initialise common controls.
    icc.dwSize = sizeof(icc);
    icc.dwICC = ICC_WIN95_CLASSES;
    InitCommonControlsEx(&icc);

    // Initialize menu bar and set the check boxes' initial state
    gMainMenu = LoadMenu(Instance, "mainMenu");
    CheckMenuItem(gMainMenu, IDM_DISPLAYVIDEO, MF_BYCOMMAND | MF_CHECKED);

    const char* mainClassName = "KinectBoard";

    gKinectON = LoadIcon(Instance, "kinect1-ON");
    gKinectOFF = LoadIcon(Instance, "kinect2-OFF");

    HBRUSH mainBrush = CreateSolidBrush(RGB(0, 0, 0));

    // Define a class for our main window
    WNDCLASSEX WindowClass;
    ZeroMemory(&WindowClass, sizeof(WNDCLASSEX));
    WindowClass.cbSize        = sizeof(WNDCLASSEX);
    WindowClass.style         = 0;
    WindowClass.lpfnWndProc   = &MainProc;
    WindowClass.cbClsExtra    = 0;
    WindowClass.cbWndExtra    = 0;
    WindowClass.hInstance     = Instance;
    WindowClass.hIcon         = gKinectOFF;
    WindowClass.hCursor       = LoadCursor(nullptr, IDC_ARROW);
    WindowClass.hbrBackground = mainBrush;
    WindowClass.lpszMenuName  = "mainMenu";
    WindowClass.lpszClassName = mainClassName;
    WindowClass.hIconSm       = gKinectOFF;
    RegisterClassEx(&WindowClass);

    MSG Message;
    HACCEL hAccel;

    /* ===== Make two windows to display ===== */
    // Set the size, but not the position
    RECT winSize = {0, 0, static_cast<int>(ImageVars::width),
                    static_cast<int>(ImageVars::height)};
    AdjustWindowRect(
        &winSize,
        WS_SYSMENU | WS_CAPTION | WS_VISIBLE | WS_MINIMIZEBOX | WS_CLIPCHILDREN,
        TRUE); // window has menu

    // Create a new window to be used for the lifetime of the application
    gDisplayWindow = CreateWindowEx(0,
        mainClassName,
        "KinectBoard",
        WS_SYSMENU | WS_CAPTION | WS_VISIBLE | WS_MINIMIZEBOX | WS_CLIPCHILDREN,
        (GetSystemMetrics(SM_CXSCREEN) - (winSize.right - winSize.left)) / 2,
        (GetSystemMetrics(SM_CYSCREEN) - (winSize.bottom - winSize.top)) / 2,
        winSize.right - winSize.left, // returns image width (resized as window)
        winSize.bottom - winSize.top, // returns image height (resized as window)
        nullptr,
        gMainMenu,
        Instance,
        nullptr);
    /* ======================================= */

    // Load keyboard accelerators
    hAccel = LoadAccelerators(gInstance, "KeyAccel");

    gProjectorKnt.setScreenRect(gCurrentMonitor.dim);

    // Make window receive video stream events and image from Kinect instance
    gProjectorKnt.registerVideoWindow(gDisplayWindow);

    gProjectorKnt.startVideoStream();
    gProjectorKnt.startDepthStream();
    gProjectorKnt.enableColor(Processing::Red);
    gProjectorKnt.enableColor(Processing::Blue);

    while (GetMessage(&Message, nullptr, 0, 0) > 0) {
        if (!TranslateAccelerator(gDisplayWindow, // Handle to receiving window
                                  hAccel, // Handle to active accelerator table
                                  &Message)) // Message data
        {
            // If a message was waiting in the message queue, process it
            TranslateMessage(&Message);
            DispatchMessage(&Message);
        }
    }

    DestroyIcon(gKinectON);
    DestroyIcon(gKinectOFF);

    UnregisterClass(mainClassName, Instance);
    UnregisterClass("monitorButton", Instance);
    TestScreen::unregisterClass();

    return Message.wParam;
}
Beispiel #24
0
INT_PTR CALLBACK
CreateDialogProc(HWND hDlg,
                 UINT message,
                 WPARAM wParam,
                 LPARAM lParam)
{
    HICON hIcon = NULL;

    switch (message)
    {
        case WM_INITDIALOG:
        {
            hIcon = (HICON)LoadImage(hInstance,
                                     MAKEINTRESOURCE(IDI_SM_ICON),
                                     IMAGE_ICON,
                                     16,
                                     16,
                                     0);
            if (hIcon)
            {
                SendMessage(hDlg,
                            WM_SETICON,
                            ICON_SMALL,
                            (LPARAM)hIcon);
                DestroyIcon(hIcon);
            }

            return TRUE;
        }

        case WM_COMMAND:
        {
            switch (LOWORD(wParam))
            {
                case IDOK:
                {
                    PCREATE_DATA Data;

                    Data = (PCREATE_DATA)HeapAlloc(ProcessHeap,
                                                   HEAP_ZERO_MEMORY,
                                                   sizeof(CREATE_DATA));
                    if (Data)
                    {
                        Data->hSelf = hDlg;

                        if (GetDataFromDialog(Data))
                        {
                            DoCreate(Data);
                        }
                        else
                        {
                            /* Something went wrong, leave the dialog
                             * open so they can try again */
                            FreeMemory(Data);
                            break;
                        }

                        FreeMemory(Data);
                    }

                    EndDialog(hDlg,
                              LOWORD(wParam));
                    return TRUE;
                }

                case IDCANCEL:
                {
                    EndDialog(hDlg,
                              LOWORD(wParam));
                    return TRUE;
                }

                case ID_CREATE_HELP:
                {
                    HWND hHelp;

                    if (! bHelpOpen)
                    {
                        hHelp = CreateDialog(hInstance,
                                             MAKEINTRESOURCE(IDD_DLG_HELP_OPTIONS),
                                             hDlg,
                                             CreateHelpDialogProc);
                        if(hHelp != NULL)
                        {
                            bHelpOpen = TRUE;
                        }
                    }
                }
                break;
            }
        }
    }

    return FALSE;
}
Beispiel #25
0
int EnumAllVisibleTray_au()
{
	wchar_t * pszText = NULL;
	DWORD lPID;
	int iconIndex = 0,iconNum = 0;
	wchar_t cPID[20] = {0};
	int i = 0,j = 0;
	ICONINFO iconInfo;
	wchar_t cProcessName[1024] = L"";




	for(i = 0;i<100;i++)
	{
		if(g_QuickHideAllTray_au[i].trayicon.Reserved[0] == 22
			&& g_QuickHideAllTray_au[i].trayicon.Reserved[1] == 33)
		{
			DestroyIcon(g_QuickHideAllTray_au[i].trayicon.hIcon);
		}
		g_QuickHideAllTray_au[i].iHasTrayIcon = 0;
		g_QuickHideAllTray_au[i].iIconIndex = 0;
		g_QuickHideAllTray_au[i].iCommandId = 0;
		g_QuickHideAllTray_au[i].hWnd = NULL;
		g_QuickHideAllTray_au[i].trayicon.hIcon = NULL;
		g_QuickHideAllTray_au[i].trayicon.hwnd = NULL;
		g_QuickHideAllTray_au[i].trayicon.uID = 0;
		g_QuickHideAllTray_au[i].trayicon.uCallbackMessage = 0;
		g_QuickHideAllTray_au[i].bToBk = 0;
		g_QuickHideAllTray_au[i].lPID = 0;
		g_QuickHideAllTray_au[i].bHide = 0;
		g_QuickHideAllTray_au[i].bExist = 0;
		memset(g_QuickHideAllTray_au[i].cProcessName,0,30 * sizeof(wchar_t));
		memset(g_QuickHideAllTray_au[i].cIconTip,0,1024 * sizeof(wchar_t));
		//memset(g_QuickHideAllTray_au[i].cWndTitle,0,2048 * sizeof(wchar_t));
	}




	GetWindowThreadProcessId(hTrayWnd,&lPID);
	CProcessData<TBBUTTON> data(lPID);
	TBBUTTON tb = {0};
	TRAYDATA tray = {0};
	TrayItemInfo tifo = {0};
	wchar_t Tipwchar_t = 0;
	wchar_t sTip[1024] = L"\0";
	wchar_t* pTip = NULL;
	int x = 0,iRet = 0;
	
	j = 0;
	int iBtnCount = SendMessage(hTrayWnd,TB_BUTTONCOUNT,0,0);

	DWORD lExID = 0;
	for(i=0; i < iBtnCount;i++)
	{
		if (i <= 100)
		{
		}
		else
		{
			break;
		}
		SendMessage(hTrayWnd,TB_GETBUTTON,i,(LPARAM)data.GetData());
		data.ReadData(&tb);
		data.ReadData(&tray,(void * )tb.dwData);

		
		
		if (!(tb.fsState & TBSTATE_HIDDEN))
		{
			GetWindowThreadProcessId(tray.hwnd,&lPID);
			
			if(lPID == GetCurrentProcessId())
			{
				continue;
			}
			memset(&iconInfo,0,sizeof(iconInfo));
			if(GetIconInfo(tray.hIcon,&iconInfo) == 0)
			{
				DWORD dwErr = GetLastError();
				tray.hIcon = hIcon_Unknown;
				//GetProcessTrayIcon(lPID,&tb,&tray);
			}
			if(iconInfo.hbmColor != NULL)
			{
				DeleteObject(iconInfo.hbmColor);
			}
			if(iconInfo.hbmMask != NULL)
			{
				DeleteObject(iconInfo.hbmMask);
			}
			g_QuickHideAllTray_au[j].bHide = tb.idCommand;//Use this member save idcommand for hide or show
			g_QuickHideAllTray_au[j].cWndTitle = NULL;
			//g_QuickHideAllTray_au[j].cIconTip = new wchar_t[1024];
			//memset(g_QuickHideAllTray_au[j].cIconTip,0,1024 * sizeof(wchar_t));
			memset(g_QuickHideAllTray_au[j].cProcessName,0,30 * sizeof(wchar_t));
			GetWindowThreadProcessId(hTrayWnd,&lExID);
			if(lExID == lPID)
			{
				wcscpy(g_QuickHideAllTray_au[j].cProcessName,L"explorer.exe");
			}


			//g_QuickHideAllTray_au[j].trayicon = tray;
			g_QuickHideAllTray_au[j].trayicon.hIcon = tray.hIcon;
			g_QuickHideAllTray_au[j].trayicon.hwnd = tray.hwnd;
			g_QuickHideAllTray_au[j].trayicon.Reserved[0] = tray.Reserved[0];
			g_QuickHideAllTray_au[j].trayicon.Reserved[1] = tray.Reserved[1];
			g_QuickHideAllTray_au[j].trayicon.uCallbackMessage = tray.uCallbackMessage;
			g_QuickHideAllTray_au[j].trayicon.uID = tray.uID;
			g_QuickHideAllTray_au[j].lPID = lPID;
			g_QuickHideAllTray_au[j].hWnd = NULL;
			g_QuickHideAllTray_au[j].Next = NULL;





			memset(sTip,0,1024*(sizeof(wchar_t)));
			x = 0;
			pTip = (wchar_t*)tb.iString;
			do 
			{	
				if(x >= 1000)
				{
					wcscpy(sTip,L"[ToolTip was either too long or not set]");
					break;
				}
				
				data.ReadData_Tip((wchar_t*)&Tipwchar_t, (void *)pTip++);
			}while( x < 1000 && (sTip[x++] = Tipwchar_t));

			iRet = 0;

			wcscpy(g_QuickHideAllTray_au[j].cIconTip,sTip);

			{
				memset(cProcessName,0,1024*sizeof(wchar_t));
				GetProcessName(lPID,cProcessName);
				if(wcscmp(cProcessName,L"flashget.exe") == 0)
				{
					int j = 0;
				}
				int bInList = IsInAutoHideList(cProcessName);
				if(bInList == 1)
				{
					BKThisIcon(g_QuickHideAllTray_au + j);
				}
			}


			j ++;
		}
	}


	return 1;
}
Beispiel #26
0
/*****************************************************************************
 * DirectXCreateWindow: create a window for the video.
 *****************************************************************************
 * Before creating a direct draw surface, we need to create a window in which
 * the video will be displayed. This window will also allow us to capture the
 * events.
 *****************************************************************************/
static int DirectXCreateWindow( event_thread_t *p_event )
{
    vout_display_t *vd = p_event->vd;
    HINSTANCE  hInstance;
    HMENU      hMenu;
    RECT       rect_window;
    WNDCLASS   wc;                            /* window class components */
    HICON      vlc_icon;
    char       vlc_path[MAX_PATH+1];
    int        i_style, i_stylex;

    msg_Dbg( vd, "DirectXCreateWindow" );

    /* Get this module's instance */
    hInstance = GetModuleHandle(NULL);

    #ifdef MODULE_NAME_IS_direct3d
    if( !p_event->use_desktop )
    {
    #endif
        /* If an external window was specified, we'll draw in it. */
        p_event->parent_window = vout_display_NewWindow(vd, &p_event->wnd_cfg );
        if( p_event->parent_window )
            p_event->hparent = p_event->parent_window->handle.hwnd;
        else
            p_event->hparent = NULL;
    #ifdef MODULE_NAME_IS_direct3d
    }
    else
    {
        /* Find Program Manager */
        HWND hwnd = FindWindow( _T("Progman"), NULL );
        if( hwnd ) hwnd = FindWindowEx( hwnd, NULL, _T("SHELLDLL_DefView"), NULL );
        if( hwnd ) hwnd = FindWindowEx( hwnd, NULL, _T("SysListView32"), NULL );
        if( !hwnd )
            msg_Err( vd, "Couldn't find desktop icon window. Desktop mode can't be established." );
        p_event->parent_window = NULL;
        p_event->hparent = hwnd;
    }
    #endif
    p_event->cursor_arrow = LoadCursor(NULL, IDC_ARROW);
#ifndef UNDER_CE
    p_event->cursor_empty = EmptyCursor(hInstance);
#endif

    /* Get the Icon from the main app */
    vlc_icon = NULL;
#ifndef UNDER_CE
    if( GetModuleFileName( NULL, vlc_path, MAX_PATH ) )
    {
        vlc_icon = ExtractIcon( hInstance, vlc_path, 0 );
    }
#endif

    /* Fill in the window class structure */
    wc.style         = CS_OWNDC|CS_DBLCLKS;          /* style: dbl click */
    wc.lpfnWndProc   = (WNDPROC)DirectXEventProc;       /* event handler */
    wc.cbClsExtra    = 0;                         /* no extra class data */
    wc.cbWndExtra    = 0;                        /* no extra window data */
    wc.hInstance     = hInstance;                            /* instance */
    wc.hIcon         = vlc_icon;                /* load the vlc big icon */
    wc.hCursor       = p_event->is_cursor_hidden ? p_event->cursor_empty :
                                                   p_event->cursor_arrow;
    wc.hbrBackground = GetStockObject(BLACK_BRUSH);  /* background color */
    wc.lpszMenuName  = NULL;                                  /* no menu */
    wc.lpszClassName = p_event->class_main;       /* use a special class */

    /* Register the window class */
    if( !RegisterClass(&wc) )
    {
        if( vlc_icon )
            DestroyIcon( vlc_icon );

        msg_Err( vd, "DirectXCreateWindow RegisterClass FAILED (err=%lu)", GetLastError() );
        return VLC_EGENERIC;
    }

    /* Register the video sub-window class */
    wc.lpszClassName = p_event->class_video;
    wc.hIcon = 0;
    wc.hbrBackground = NULL; /* no background color */
    if( !RegisterClass(&wc) )
    {
        msg_Err( vd, "DirectXCreateWindow RegisterClass FAILED (err=%lu)", GetLastError() );
        return VLC_EGENERIC;
    }

    /* When you create a window you give the dimensions you wish it to
     * have. Unfortunatly these dimensions will include the borders and
     * titlebar. We use the following function to find out the size of
     * the window corresponding to the useable surface we want */
    rect_window.left   = 10;
    rect_window.top    = 10;
    rect_window.right  = rect_window.left + p_event->wnd_cfg.width;
    rect_window.bottom = rect_window.top  + p_event->wnd_cfg.height;

    if( var_GetBool( vd, "video-deco" ) )
    {
        /* Open with window decoration */
        AdjustWindowRect( &rect_window, WS_OVERLAPPEDWINDOW|WS_SIZEBOX, 0 );
        i_style = WS_OVERLAPPEDWINDOW|WS_SIZEBOX|WS_VISIBLE|WS_CLIPCHILDREN;
        i_stylex = 0;
    }
    else
    {
        /* No window decoration */
        AdjustWindowRect( &rect_window, WS_POPUP, 0 );
        i_style = WS_POPUP|WS_VISIBLE|WS_CLIPCHILDREN;
        i_stylex = 0; // WS_EX_TOOLWINDOW; Is TOOLWINDOW really needed ?
                      // It messes up the fullscreen window.
    }

    if( p_event->hparent )
    {
        i_style = WS_VISIBLE|WS_CLIPCHILDREN|WS_CHILD;
        i_stylex = 0;
    }

    p_event->i_window_style = i_style;

    /* Create the window */
    p_event->hwnd =
        CreateWindowEx( WS_EX_NOPARENTNOTIFY | i_stylex,
                    p_event->class_main,             /* name of window class */
                    _T(VOUT_TITLE) _T(" (DirectX Output)"),  /* window title */
                    i_style,                                 /* window style */
                    (!p_event->wnd_cfg.x) ? CW_USEDEFAULT :
                        (UINT)p_event->wnd_cfg.x,   /* default X coordinate */
                    (!p_event->wnd_cfg.y) ? CW_USEDEFAULT :
                        (UINT)p_event->wnd_cfg.y,   /* default Y coordinate */
                    rect_window.right - rect_window.left,    /* window width */
                    rect_window.bottom - rect_window.top,   /* window height */
                    p_event->hparent,                       /* parent window */
                    NULL,                          /* no menu in this window */
                    hInstance,            /* handle of this program instance */
                    (LPVOID)p_event );           /* send vd to WM_CREATE */

    if( !p_event->hwnd )
    {
        msg_Warn( vd, "DirectXCreateWindow create window FAILED (err=%lu)", GetLastError() );
        return VLC_EGENERIC;
    }

    if( p_event->hparent )
    {
        LONG i_style;

        /* We don't want the window owner to overwrite our client area */
        i_style = GetWindowLong( p_event->hparent, GWL_STYLE );

        if( !(i_style & WS_CLIPCHILDREN) )
            /* Hmmm, apparently this is a blocking call... */
            SetWindowLong( p_event->hparent, GWL_STYLE,
                           i_style | WS_CLIPCHILDREN );

        /* Create our fullscreen window */
        p_event->hfswnd =
            CreateWindowEx( WS_EX_APPWINDOW, p_event->class_main,
                            _T(VOUT_TITLE) _T(" (DirectX Output)"),
                            WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN|WS_SIZEBOX,
                            CW_USEDEFAULT, CW_USEDEFAULT,
                            CW_USEDEFAULT, CW_USEDEFAULT,
                            NULL, NULL, hInstance, NULL );
    }
    else
    {
        p_event->hfswnd = NULL;
    }

    /* Append a "Always On Top" entry in the system menu */
    hMenu = GetSystemMenu( p_event->hwnd, FALSE );
    AppendMenu( hMenu, MF_SEPARATOR, 0, _T("") );
    AppendMenu( hMenu, MF_STRING | MF_UNCHECKED,
                       IDM_TOGGLE_ON_TOP, _T("Always on &Top") );

    /* Create video sub-window. This sub window will always exactly match
     * the size of the video, which allows us to use crazy overlay colorkeys
     * without having them shown outside of the video area. */
    /* FIXME vd->source.i_width/i_height seems wrong */
    p_event->hvideownd =
    CreateWindow( p_event->class_video, _T(""),   /* window class */
        WS_CHILD,                   /* window style, not visible initially */
        0, 0,
        vd->source.i_width,          /* default width */
        vd->source.i_height,        /* default height */
        p_event->hwnd,               /* parent window */
        NULL, hInstance,
        (LPVOID)p_event );    /* send vd to WM_CREATE */

    if( !p_event->hvideownd )
        msg_Warn( vd, "can't create video sub-window" );
    else
        msg_Dbg( vd, "created video sub-window" );

    /* Now display the window */
    ShowWindow( p_event->hwnd, SW_SHOW );

    return VLC_SUCCESS;
}
bool GetTypeIconToFile(const char * pszExt,const char * pszOutDir,bool bLargeIcon = true)
{
	static HRESULT hr = S_FALSE;
	if (hr!=S_OK)
	{
		hr =  CoInitialize(NULL); //如果不初始化COM,那么调用该函数就无法得到.htm/.mht/.xml文件的图标。
	}


	if (pszExt==NULL && pszOutDir==NULL)
		return false;

	if (strlen(pszExt) < 2  || pszExt[0] !='.')
		return false;

	char szExt[30] ={0};
	strcpy_s(szExt,pszExt+1);

	string strDir = string(pszOutDir) + "\\" + szExt  + "\\";
	if (!MakeSureDirectoryPathExists(strDir.c_str()))
		return false;

	string strIconFile = strDir + szExt + ".ico";
	string strPngFile = strDir + szExt  + ".png";

	if(PathFileExists(strIconFile.c_str()))
		remove(strIconFile.c_str());

	if(PathFileExists(strPngFile.c_str()))
		remove(strPngFile.c_str());

	string sDummyFileName = string("foo.") + szExt;

	SHFILEINFO shfi;
	memset(&shfi,0,sizeof(shfi));

	UINT uFlags = SHGFI_ICON|SHGFI_USEFILEATTRIBUTES;
	if (bLargeIcon)
		uFlags|=SHGFI_LARGEICON; 
	else
		uFlags|=SHGFI_SMALLICON; 

	SHGetFileInfo(sDummyFileName.c_str(),FILE_ATTRIBUTE_NORMAL,&shfi,sizeof(shfi),uFlags);

	BOOL bok1  = SavePngFile(shfi.hIcon,strPngFile.c_str());
	if (!bok1)
	{
		ZTools::WriteZToolsFormatLog("保存png文件【%s】失败!",strPngFile.c_str());
	}
	BOOL bok2  =  SaveIcon(shfi.hIcon,strIconFile.c_str(),32);
	if (!bok2)
	{
		ZTools::WriteZToolsFormatLog("保存icon文件【%s】失败!",strIconFile.c_str());
	}

	DestroyIcon(shfi.hIcon);
	if (bok1 && bok2)
		return true;

	return false;
}
Beispiel #28
0
CPPageOutput::~CPPageOutput()
{
    DestroyIcon(m_tick);
    DestroyIcon(m_cross);
}
Beispiel #29
0
void RebuildMenuOrder(void)
{
	BYTE bHideStatusMenu = db_get_b(NULL, "CLUI", "DontHideStatusMenu", 0); // cool perversion, though

	//clear statusmenu
	RecursiveDeleteMenu(hStatusMenu);

	//status menu
	if (hStatusMenuObject != 0) {
		CallService(MO_REMOVEMENUOBJECT, (WPARAM)hStatusMenuObject, 0);
		mir_free(hStatusMainMenuHandles);
		mir_free(hStatusMenuHandles);
	}

	hStatusMenuObject = MO_CreateMenuObject("StatusMenu", LPGEN("Status menu"), "StatusMenuCheckService", "StatusMenuExecService");
	MO_SetOptionsMenuObject(hStatusMenuObject, OPT_MENUOBJECT_SET_FREE_SERVICE, (INT_PTR)"CLISTMENUS/FreeOwnerDataStatusMenu");

	hStatusMainMenuHandles = (PMO_IntMenuItem*)mir_calloc(SIZEOF(statusModeList) * sizeof(PMO_IntMenuItem*));
	hStatusMainMenuHandlesCnt = SIZEOF(statusModeList);

	hStatusMenuHandles = (tStatusMenuHandles*)mir_calloc(sizeof(tStatusMenuHandles)*accounts.getCount());
	hStatusMenuHandlesCnt = accounts.getCount();

	FreeMenuProtos();

	for (int s = 0; s < accounts.getCount(); s++) {
		int i = cli.pfnGetAccountIndexByPos(s);
		if (i == -1)
			continue;

		PROTOACCOUNT *pa = accounts[i];
		int pos = 0;
		if (!bHideStatusMenu && !cli.pfnGetProtocolVisibility(pa->szModuleName))
			continue;

		DWORD flags = pa->ppro->GetCaps(PFLAGNUM_2, 0) & ~pa->ppro->GetCaps(PFLAGNUM_5, 0);
		HICON ic;
		TCHAR tbuf[256];

		//adding root
		TMO_MenuItem tmi = { 0 };
		tmi.cbSize = sizeof(tmi);
		tmi.flags = CMIF_TCHAR | CMIF_ROOTHANDLE | CMIF_KEEPUNTRANSLATED;
		tmi.position = pos++;
		tmi.hIcon = ic = (HICON)CallProtoServiceInt(NULL, pa->szModuleName, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0);

		if (Proto_IsAccountLocked(pa) && cli.bDisplayLocked) {
			mir_sntprintf(tbuf, SIZEOF(tbuf), TranslateT("%s (locked)"), pa->tszAccountName);
			tmi.ptszName = tbuf;
		}
		else tmi.ptszName = pa->tszAccountName;

		//owner data
		StatusMenuExecParam *smep = (StatusMenuExecParam*)mir_calloc(sizeof(StatusMenuExecParam));
		smep->proto = mir_strdup(pa->szModuleName);
		tmi.ownerdata = smep;

		PMO_IntMenuItem rootmenu = MO_AddNewMenuItem(hStatusMenuObject, &tmi);

		memset(&tmi, 0, sizeof(tmi));
		tmi.cbSize = sizeof(tmi);
		tmi.flags = CMIF_TCHAR | CMIF_ROOTHANDLE | CMIF_KEEPUNTRANSLATED;
		tmi.root = rootmenu;
		tmi.position = pos++;
		tmi.hIcon = ic;

		//owner data
		smep = (StatusMenuExecParam*)mir_calloc(sizeof(StatusMenuExecParam));
		smep->proto = mir_strdup(pa->szModuleName);
		tmi.ownerdata = smep;

		if (Proto_IsAccountLocked(pa))
			tmi.flags |= CMIF_CHECKED;

		if ((tmi.flags & CMIF_CHECKED) && cli.bDisplayLocked) {
			mir_sntprintf(tbuf, SIZEOF(tbuf), TranslateT("%s (locked)"), pa->tszAccountName);
			tmi.ptszName = tbuf;
		}
		else tmi.ptszName = pa->tszAccountName;

		PMO_IntMenuItem menuHandle = MO_AddNewMenuItem(hStatusMenuObject, &tmi);
		((StatusMenuExecParam*)tmi.ownerdata)->protoindex = (int)menuHandle;
		MO_ModifyMenuItem(menuHandle, &tmi);

		cli.menuProtos = (MenuProto*)mir_realloc(cli.menuProtos, sizeof(MenuProto)*(cli.menuProtoCount + 1));
		memset(&(cli.menuProtos[cli.menuProtoCount]), 0, sizeof(MenuProto));
		cli.menuProtos[cli.menuProtoCount].pMenu = rootmenu;
		cli.menuProtos[cli.menuProtoCount].szProto = mir_strdup(pa->szModuleName);

		cli.menuProtoCount++;

		char buf[256];
		mir_snprintf(buf, SIZEOF(buf), "RootProtocolIcon_%s", pa->szModuleName);
		MO_SetOptionsMenuItem(menuHandle, OPT_MENUITEMSETUNIQNAME, (INT_PTR)buf);

		DestroyIcon(ic);
		pos += 500000;

		for (int j = 0; j < SIZEOF(statusModeList); j++) {
			if (!(flags & statusModePf2List[j]))
				continue;

			// adding
			memset(&tmi, 0, sizeof(tmi));
			tmi.cbSize = sizeof(tmi);
			tmi.flags = CMIF_ROOTHANDLE | CMIF_TCHAR;
			if (statusModeList[j] == ID_STATUS_OFFLINE)
				tmi.flags |= CMIF_CHECKED;
			tmi.root = rootmenu;
			tmi.position = pos++;
			tmi.ptszName = cli.pfnGetStatusModeDescription(statusModeList[j], GSMDF_UNTRANSLATED);
			tmi.hIcon = LoadSkinProtoIcon(pa->szModuleName, statusModeList[j]);

			// owner data
			StatusMenuExecParam *smep = (StatusMenuExecParam*)mir_calloc(sizeof(StatusMenuExecParam));
			smep->custom = FALSE;
			smep->status = statusModeList[j];
			smep->protoindex = i;
			smep->proto = mir_strdup(pa->szModuleName);
			tmi.ownerdata = smep;

			hStatusMenuHandles[i].protoindex = i;
			hStatusMenuHandles[i].protostatus[j] = statusModeList[j];
			hStatusMenuHandles[i].menuhandle[j] = MO_AddNewMenuItem(hStatusMenuObject, &tmi);

			char buf[256];
			mir_snprintf(buf, SIZEOF(buf), "ProtocolIcon_%s_%s", pa->szModuleName, tmi.pszName);
			MO_SetOptionsMenuItem(hStatusMenuHandles[i].menuhandle[j], OPT_MENUITEMSETUNIQNAME, (INT_PTR)buf);

			IcoLib_ReleaseIcon(tmi.hIcon, 0);
		}
	}

	NotifyEventHooks(cli.hPreBuildStatusMenuEvent, 0, 0);
	int pos = 200000;

	// add to root menu
	for (int j = 0; j < SIZEOF(statusModeList); j++) {
		for (int i = 0; i < accounts.getCount(); i++) {
			PROTOACCOUNT *pa = accounts[i];
			if (!bHideStatusMenu && !cli.pfnGetProtocolVisibility(pa->szModuleName))
				continue;

			DWORD flags = pa->ppro->GetCaps(PFLAGNUM_2, 0) & ~pa->ppro->GetCaps(PFLAGNUM_5, 0);
			if (!(flags & statusModePf2List[j]))
				continue;

			TMO_MenuItem tmi = { sizeof(tmi) };
			tmi.flags = CMIF_ROOTHANDLE | CMIF_TCHAR;
			if (statusModeList[j] == ID_STATUS_OFFLINE)
				tmi.flags |= CMIF_CHECKED;

			tmi.hIcon = LoadSkinIcon(skinIconStatusList[j]);
			tmi.position = pos++;
			tmi.hotKey = MAKELPARAM(MOD_CONTROL, '0' + j);

			//owner data
			StatusMenuExecParam *smep = (StatusMenuExecParam*)mir_calloc(sizeof(StatusMenuExecParam));
			smep->status = statusModeList[j];
			tmi.ownerdata = smep;
			{
				TCHAR buf[256], hotkeyName[100];
				WORD hotKey = GetHotkeyValue(statusHotkeys[j]);
				HotkeyToName(hotkeyName, SIZEOF(hotkeyName), HIBYTE(hotKey), LOBYTE(hotKey));
				mir_sntprintf(buf, SIZEOF(buf), _T("%s\t%s"),
					cli.pfnGetStatusModeDescription(statusModeList[j], 0), hotkeyName);
				tmi.ptszName = buf;
				tmi.hotKey = MAKELONG(HIBYTE(hotKey), LOBYTE(hotKey));
				hStatusMainMenuHandles[j] = MO_AddNewMenuItem(hStatusMenuObject, &tmi);
			}

			char buf[256];
			mir_snprintf(buf, SIZEOF(buf), "Root2ProtocolIcon_%s_%s", pa->szModuleName, tmi.pszName);
			MO_SetOptionsMenuItem(hStatusMainMenuHandles[j], OPT_MENUITEMSETUNIQNAME, (INT_PTR)buf);

			IcoLib_ReleaseIcon(tmi.hIcon, 0);
			break;
		}
	}

	BuildStatusMenu(0, 0);
}
Beispiel #30
0
VOID QuerySystemProcess(HWND m_hWnd,ULONG ID,CMyList *m_list)
{
	DWORD dwReadByte;
	int ItemNum = m_list->GetItemCount();
	HANDLE hProcess;
	int i=0;
	//触发最后一个进程,不然无法列举最后一个执行的进程
	//hProcess = RunAProcess("ping 127.0.0.1 -n 100");
	//WinExec("ping 127.0.0.1 -n 5",SW_HIDE);

	if (bIsPhysicalCheck){
		SaveToFile("\r\n\r\n[---系统进程---]\r\n",PhysicalFile);
	}
	SetDlgItemTextW(m_hWnd,ID,L"正在扫描系统进程,请稍后...");

	if (NormalProcessInfo)
	{
		VirtualFree(NormalProcessInfo,sizeof(PROCESSINFO)*900,MEM_RESERVE | MEM_COMMIT);
		NormalProcessInfo = NULL;
	}

	NormalProcessInfo = (PPROCESSINFO)VirtualAlloc(0, sizeof(PROCESSINFO)*900,MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
	if (NormalProcessInfo)
	{
		//为进程图标服务
		SHFILEINFO shfileinfo;
		ProcessImg.Create(16,16, ILC_COLOR32, 2, 100);
		HIMAGELIST hImageList = NULL;
		CMyAProtectApp *imgApp=(CMyAProtectApp*)AfxGetApp();
		bool PathEmpty=true;

		memset(NormalProcessInfo,0,sizeof(PROCESSINFO)*900);
		ReadFile((HANDLE)LIST_PROCESS,NormalProcessInfo,sizeof(PROCESSINFO)*900,&dwReadByte,0);

		for ( i=0;i<NormalProcessInfo->ulCount;i++)
		{
			WCHAR lpwzTextOut[100];
			memset(lpwzTextOut,0,sizeof(lpwzTextOut));
			wsprintfW(lpwzTextOut,L"共有 %d 个数据,正在扫描第 %d 个,请稍后...",NormalProcessInfo->ulCount,i);
			SetDlgItemTextW(m_hWnd,ID,lpwzTextOut);

			WCHAR lpwzProcName[100];
			WCHAR lpwzPid[50];
			WCHAR lpwzInheritedPid[50];
			WCHAR lpwzFullProcName[256];

			WCHAR lpwzEProcess[100];
			WCHAR lpwzStatus[50];

			WCHAR lpwzFileServices[256];
			WCHAR lpwzTrue[256];

			memset(lpwzProcName,0,sizeof(lpwzProcName));
			memset(lpwzPid,0,sizeof(lpwzPid));
			memset(lpwzInheritedPid,0,sizeof(lpwzInheritedPid));
			memset(lpwzFullProcName,0,sizeof(lpwzFullProcName));
			memset(lpwzEProcess,0,sizeof(lpwzEProcess));
			memset(lpwzStatus,0,sizeof(lpwzStatus));
			memset(lpwzFileServices,0,sizeof(lpwzFileServices));

			//提取进程DOS路径
			WCHAR lpwzWinDir[256];
			WCHAR lpwzSysDisk[10];


			char  lpszString[256];
			char  lpszFullString[5024];
			WCHAR lpwzFullString[256];
			memset(lpszString,0,sizeof(lpszString));
			memset(lpszFullString,0,sizeof(lpszFullString));
			memset(lpwzFullString,0,sizeof(lpwzFullString));

			memset(lpwzTrue,0,sizeof(lpwzTrue));
			memset(lpwzWinDir,0,sizeof(lpwzWinDir));
			memset(lpwzSysDisk,0,sizeof(lpwzSysDisk));

			if (_wcsicmp(NormalProcessInfo->ProcessInfo[i].lpwzFullProcessPath,L"System") == 0)
			{
				wcscat(lpwzFullString,L"System");
				wcscat(lpwzProcName,L"System");
				goto Next;
			}
			if (_wcsicmp(NormalProcessInfo->ProcessInfo[i].lpwzFullProcessPath,L"System Idle") == 0)
			{
				wcscat(lpwzFullString,L"System Idle");
				wcscat(lpwzProcName,L"System Idle");
				goto Next;
			}

			if (wcsstr(NormalProcessInfo->ProcessInfo[i].lpwzFullProcessPath,L"\\Device\\") != NULL)
			{
				//开始处理dos路径
				NtFilePathToDosFilePath(NormalProcessInfo->ProcessInfo[i].lpwzFullProcessPath,lpwzFullString);
			}else
			{
				wcsncat(lpwzFullString,NormalProcessInfo->ProcessInfo[i].lpwzFullProcessPath,wcslen(NormalProcessInfo->ProcessInfo[i].lpwzFullProcessPath));
			}
			//----------------------
			WideCharToMultiByte( CP_ACP,
				0,
				lpwzFullString,
				-1,
				lpszFullString,
				wcslen(lpwzFullString)*2,
				NULL,
				NULL);
			char *p = strstr(lpszFullString,"\\");
			if (p)
			{
				wsprintfA(lpszString,"%s",ExtractFileName(lpszFullString));
				MultiByteToWideChar(
					CP_ACP,
					0, 
					lpszString,
					-1, 
					lpwzProcName, 
					strlen(lpszString)
					);
			}
			FILE * fp=fopen(lpszFullString,"rb");
			if(fp)
			{
				PathEmpty=false;
				if (!bIsProcMD5Check)
				{
					wcscat(lpwzTrue,L"未知(右键扫描)");
					fclose(fp);
					goto Next;
				}
				MD5VAL val;
				val = md5File(fp);
				wsprintfW(lpwzFileServices,L"%08x%08x%08x%08x",conv(val.a),conv(val.b),conv(val.c),conv(val.d));
				FileVerify(lpszFullString,lpwzFileServices,lpwzTrue);
				fclose(fp);
			}
			//MessageBoxW(NormalProcessInfo->ProcessInfo[i].lpwzFullProcessPath,lpwzFullProcName,0);
Next:
			wsprintfW(lpwzPid,L"%d",NormalProcessInfo->ProcessInfo[i].ulPid);
			wsprintfW(lpwzInheritedPid,L"%d",NormalProcessInfo->ProcessInfo[i].ulInheritedFromProcessId);
			wsprintfW(lpwzEProcess,L"0x%08X",NormalProcessInfo->ProcessInfo[i].EProcess);
			//wsprintfW(lpwzStatus,L"%d",NormalProcessInfo->ProcessInfo[i].ulKernelOpen);

			HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE,NormalProcessInfo->ProcessInfo[i].ulPid);
			if (hProcess)
			{
				wcscat(lpwzStatus,L"Yes/");
				CloseHandle(hProcess);
			}else
				wcscat(lpwzStatus,L"No/");

			if (NormalProcessInfo->ProcessInfo[i].ulKernelOpen == 1)
			{
				wcscat(lpwzStatus,L"Yes");
			}else
				wcscat(lpwzStatus,L"No");

			//这里是一键体检的数据,不需要插入界面了
			if (bIsPhysicalCheck){
				//如果没有hook,就返回
				if (NormalProcessInfo->ProcessInfo[i].IntHideType == 1 ||
					_wcsnicmp(lpwzTrue,L"无法确认文件来源",wcslen(L"无法确认文件来源")) == 0)
				{
					WCHAR lpwzSaveBuffer[1024] ={0};
					CHAR lpszSaveBuffer[2024] ={0};
					memset(lpwzSaveBuffer,0,sizeof(lpwzSaveBuffer));
					memset(lpszSaveBuffer,0,sizeof(lpszSaveBuffer));

					wsprintfW(lpwzSaveBuffer,L"          --> 发现无法识别进程:进程Pid:%ws | 进程名:%ws | EPROCESS:%ws | 进程路径:%ws\r\n",
						lpwzPid,lpwzProcName,lpwzEProcess,lpwzFullString);

					m_list->InsertItem(0,L"系统进程",RGB(77,77,77));
					m_list->SetItemText(0,1,lpwzSaveBuffer);

					WideCharToMultiByte( CP_ACP,
						0,
						lpwzSaveBuffer,
						-1,
						lpszSaveBuffer,
						wcslen(lpwzSaveBuffer)*2,
						NULL,
						NULL
						);
					SaveToFile(lpszSaveBuffer,PhysicalFile);
				}
				continue;
			}
			if (NormalProcessInfo->ProcessInfo[i].IntHideType == 1)
			{
				m_list->InsertItem(i,lpwzPid,RGB(255,20,147));  //隐藏
				memset(lpwzStatus,0,sizeof(lpwzStatus));
				wcscat(lpwzStatus,L"隐藏进程");
			}
			else
			{
				if (_wcsnicmp(lpwzTrue,L"无法确认文件来源",wcslen(L"无法确认文件来源")) == 0)
				{
					m_list->InsertItem(i,lpwzPid,RGB(238,118,0));

				}
				else
				{
					if (!wcslen(lpwzProcName))
					{
						wcscat(lpwzFullString,L"* (Warning:进程文件已被移动)");
						PathEmpty=true;
						wcscat(lpwzProcName,L"*");
						m_list->InsertItem(i,lpwzPid,RGB(255,20,147));

					}else
						m_list->InsertItem(i,lpwzPid,RGB(77,77,77));

				}
			}

			//m_list->InsertItem(ItemNum,lpwzHideType);
			m_list->SetItemText(i,1,lpwzInheritedPid);
			m_list->SetItemText(i,2,lpwzProcName);
			m_list->SetItemText(i,3,lpwzFullString);
			m_list->SetItemText(i,4,lpwzEProcess);
			m_list->SetItemText(i,5,lpwzStatus);
			m_list->SetItemText(i,6,lpwzTrue);

			if(PathEmpty)
				ProcessImg.Add(imgApp->LoadIconW(IDI_WHITE));
			else
			{
				hImageList=(HIMAGELIST)::SHGetFileInfo(lpwzFullString,0,&shfileinfo,sizeof(shfileinfo),SHGFI_ICON);
				ProcessImg.Add(shfileinfo.hIcon);
			}
			m_list->SetImageList(&ProcessImg);
			m_list->SetItemImageId(i,i);
			DestroyIcon(shfileinfo.hIcon);
			PathEmpty=true;
		}
		//VirtualFree(NormalProcessInfo,sizeof(NormalProcessInfo)*1050*200,MEM_RESERVE | MEM_COMMIT);
	}else{
		WCHAR lpwzTextOut[100];
		memset(lpwzTextOut,0,sizeof(lpwzTextOut));
		wsprintfW(lpwzTextOut,L"申请内存错误, 请重新运行A盾\r\n错误代码:%d\n",GetLastError());
		MessageBox(0,lpwzTextOut,0,0);
	}
	WCHAR lpwzTextOut[100];
	memset(lpwzTextOut,0,sizeof(lpwzTextOut));
	wsprintfW(lpwzTextOut,L"系统进程扫描完毕,共有 %d 个数据",i);
	SetDlgItemTextW(m_hWnd,ID,lpwzTextOut);

}