Exemplo n.º 1
0
void GetTaskinformationForWindowAction(TASKINFORMATION* taskInfo, int nCode, WPARAM wParam, LPARAM lParam)
{
		taskInfo->WindowName = GetWindowName((HWND)wParam);
		taskInfo->WindowHandle = (HWND)wParam;
		taskInfo->SystemMenu = GetSystemMenu(taskInfo->WindowHandle, TRUE);
		taskInfo->WindowIcon = GetWindowIcon((HWND)wParam);
		if(nCode == HSHELL_WINDOWREPLACED)
		{
			taskInfo->NewWindowHandle = (HWND)lParam;
		}
}
Exemplo n.º 2
0
TrayIcon::TrayIcon(HWND hWnd)
{
	ZeroMemory(&nid, sizeof(NOTIFYICONDATA));

	nid.cbSize = sizeof(NOTIFYICONDATA);
	nid.hWnd = hWnd;
	nid.uID = uId ? ++uId : uId = 1;
	nid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
	nid.uCallbackMessage = TRAYICON_MESSAGE;
	nid.hIcon = GetWindowIcon(hWnd);
	GetWindowText(hWnd, nid.szTip, 128);
	nid.uVersion = NOTIFYICON_VERSION;
}
Exemplo n.º 3
0
static void AddToTray(int i) {
	NOTIFYICONDATA nid;
	ZeroMemory(&nid, sizeof(nid));
	nid.cbSize           = NOTIFYICONDATA_V2_SIZE;
	nid.hWnd             = _hwndHook;
	nid.uID              = (UINT)i;
	nid.uFlags           = NIF_MESSAGE | NIF_ICON | NIF_TIP;
	nid.uCallbackMessage = WM_TRAYCMD;
	nid.hIcon            = GetWindowIcon(_hwndItems[i]);
	GetWindowText(_hwndItems[i], nid.szTip, sizeof(nid.szTip) / sizeof(nid.szTip[0]));
	nid.uVersion         = NOTIFYICON_VERSION;
	Shell_NotifyIcon(NIM_ADD, &nid);
	Shell_NotifyIcon(NIM_SETVERSION, &nid);
}
Exemplo n.º 4
0
static void
AddToTray(int i)
{
    NOTIFYICONDATA nid;

    nid.cbSize           = sizeof(NOTIFYICONDATA);
    nid.hWnd             = hwndHook;
    nid.uID              = (UINT)list[i];
    nid.uFlags           = NIF_MESSAGE | NIF_ICON | NIF_TIP;
    nid.uCallbackMessage = WM_TRAYCMD;
    nid.hIcon            = GetWindowIcon(list[i]);
    GetWindowText(list[i], nid.szTip, MAXTEXT);

    Shell_NotifyIcon(NIM_ADD, &nid);
}
Exemplo n.º 5
0
LRESULT CALLBACK
HookWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    NOTIFYICONDATA nid;
    int i;
    char buff[255];
    //  DWORD ProcessId;
    HMENU hSysMenu;
    switch (msg) {
    case WM_COMMAND:
        switch (LOWORD(wParam))
        {
        case IDM_RESTORE:
            ShowTheWindow(CurrentWindow);
            break;
        case IDM_EXIT:
            SendMessage(hwndHook,WM_DESTROY,0,0);
            break;
        case IDM_CLOSE:
            CloseTheWindow(CurrentWindow);
            break;
        case IDM_ABOUT:
            DialogBox(thisInstance, MAKEINTRESOURCE(IDD_DIALOG1), hwndHook, (DLGPROC)AboutDlgProc );
            break;
        case IDM_DESTROY:
            if(MessageBox(NULL,"Kill the window?","RBTray",MB_YESNO | MB_ICONWARNING )==IDYES)DestroyTheWindow(CurrentWindow);
            break;
        case IDM_SHOWKEY:
            showKeyb = !showKeyb;
            keyState = -1;
            SetKbdCfg(showKeyb);
            ShowKeyState();
            break;
        };
        break;
    case WM_MYCMD:
        switch (wParam)
        {
            /*
        case IDM_LOTUSEDIT:
            buff[0] = '\0';
            GetWindowText((HWND)lParam, buff, 10);
            //buff[250] = '\0';
            MessageBox(NULL,buff,"code",MB_OK);
            break;
            */
        case IDM_SIZE:
            Resize((HWND)lParam);
            break;
        case IDM_TRAY:
            // prohibit hiding of explorer's taskbar			
            GetClassName((HWND)lParam, buff, 255);
            if(strcasecmp("Shell_TrayWnd", buff) == 0) break;
            if(strcasecmp("DV2ControlHost", buff) == 0) break;
            //MessageBox(NULL, buff, "RBTray", MB_OK);
            for(i = 0 ; i < MAXCOUNT ;i++) { 
                if(!list[i]) break;
            }
            if (i == MAXCOUNT) break;

            list[i]=(HWND)lParam;
            ShowWindow((HWND)lParam, SW_HIDE);
            ShowWindow((HWND)lParam, SW_MINIMIZE);
            AddToTray(i);
            ShowWindow((HWND)lParam, SW_HIDE);
            ShowWindow(GetParent((HWND)lParam), SW_HIDE);
            UpdMenu((HWND)lParam,(LPARAM)TRUE);
            break;
            /*
            case IDM_KEY:
            // Fix chars typed in incorrect keyboard layout
            FixChars();
            break;
            */
        case IDM_KEYSTAT:
            ShowKeyState();
            break;
        case IDM_ONTOP:
            hSysMenu=GetSystemMenu((HWND)lParam, FALSE);
            if(hSysMenu)
            {
                if(GetMenuState(hSysMenu, IDM_ONTOP,MF_BYCOMMAND) & MF_CHECKED)
                    //GetWindowLong((HWND)lParam,GWL_EXSTYLE)&WS_EX_TOPMOST)
                {
                    CheckMenuItem(hSysMenu,IDM_ONTOP,MF_BYCOMMAND |MF_UNCHECKED);
                    SetWindowPos((HWND)lParam,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOREDRAW);
                }
                else
                {
                    CheckMenuItem(hSysMenu,IDM_ONTOP,MF_BYCOMMAND |MF_CHECKED);
                    SetWindowPos((HWND)lParam,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOREDRAW);
                }
            }
            break;
        }
    case WM_DELTRAY:
        CloseTheWindow((HWND)wParam);
        break;
    case WM_TRAYCMD:
        switch ((UINT)lParam) {
    case WM_LBUTTONDOWN:
        // Hmm, there's probably a better way to do this... SetCapture maybe?
        // But I don't feel like messing with it :)
        lastLButtonDown = GetTickCount();
        break;
    case WM_LBUTTONUP:
        if ((GetTickCount() - lastLButtonDown) <= 1000) {
            ShowTheWindow((HWND)wParam);
        }
        break;
    case WM_RBUTTONUP:
        CurrentWindow=(HWND)wParam;
        ExecuteMenu();
        break;
    case WM_MOUSEMOVE:
        if (!IsWindow((HWND)wParam))
            DelFromTray(FindInTray((HWND)wParam));
        else {
            nid.uID              = (UINT)wParam;
            nid.uFlags           = NIF_ICON | NIF_TIP;
            nid.hIcon            = GetWindowIcon((HWND)wParam);
            GetWindowText((HWND)wParam, nid.szTip, MAXTEXT);
            Shell_NotifyIcon(NIM_MODIFY, &nid);
        }
        }
        break;
    case WM_DESTROY:
        for (i = 0; i < MAXCOUNT; i++)
            if (list[i])
            {
                ShowIt(list[i]);
                DelFromTray(i);
            }
            showKeyb = FALSE;
            ShowKeyState();
            UnRegisterHook();
            FreeLibrary(hLib);
            EnumWindows((WNDENUMPROC)UpdMenu,FALSE);
            PostQuitMessage(0);
            ExitProcess(0);
            break;
    }


    // I can't put this in the switch since WM_TASKBAR_CREATED isn't constant
    if (msg == WM_TASKBAR_CREATED) {
        for (i = 0; i < MAXCOUNT; i++) {
            if (list[i]) {
                AddToTray(i);
            }
        }
    }

    return DefWindowProc(hwnd, msg, wParam, lParam);
}
Exemplo n.º 6
0
 SkBitmap WidgetDelegate::GetWindowAppIcon()
 {
     // Use the window icon as app icon by default.
     return GetWindowIcon();
 }
Exemplo n.º 7
0
bool emX11WindowPort::Cycle()
{
	XWindowAttributes attr;
	XSizeHints xsh;
	emString str;
	emCursor cur;
	::Window win;
	::Cursor xcur;
	emX11WindowPort * wp;
	double vrx,vry,vrw,vrh,fx,fy,fw,fh;
	int i,x,y,w,h;
	Status xs;

	if (
		FullscreenUpdateTimer &&
		IsSignaled(FullscreenUpdateTimer->GetSignal())
	) {
		Screen.GetVisibleRect(&vrx,&vry,&vrw,&vrh);
		if (
			fabs(PaneX-vrx)>0.51 || fabs(PaneY-vry)>0.51 ||
			fabs(PaneW-vrw)>0.51 || fabs(PaneH-vrh)>0.51
		) {
			PosForced=true;
			PosPending=true;
			SizeForced=true;
			SizePending=true;
			SetViewGeometry(vrx,vry,vrw,vrh,Screen.PixelTallness);
		}

		// Workaround for lots of focus problems with several window managers:
		if (Screen.GrabbingWinPort==this) {
			XMutex.Lock();
			XGetInputFocus(Disp,&win,&i);
			XMutex.Unlock();
			wp=NULL;
			for (i=Screen.WinPorts.GetCount()-1; i>=0; i--) {
				if (Screen.WinPorts[i]->Win==win) {
					wp=Screen.WinPorts[i];
					break;
				}
			}
			if (wp==this) {
				if (!Focused) {
					Focused=true;
					SetViewFocused(true);
					emWarning("emX11WindowPort: Focus workaround 1 applied.");
				}
			}
			else {
				while (wp) {
					if (wp==this) break;
					wp=wp->Owner;
				}
				if (!wp) {
					XMutex.Lock();
					xs=XGetWindowAttributes(Disp,Win,&attr);
					XMutex.Unlock();
					if (xs && attr.map_state==IsViewable) {
						XMutex.Lock();
						XSetInputFocus(Disp,Win,RevertToNone,CurrentTime);
						XMutex.Unlock();
						emWarning("emX11WindowPort: Focus workaround 2 applied.");
					}
				}
			}
		}
	}

	if (
		!PostConstructed && !PosForced && Owner &&
		(GetWindowFlags()&emWindow::WF_FULLSCREEN)==0
	) {
		Screen.GetVisibleRect(&vrx,&vry,&vrw,&vrh);
		fx=Owner->GetViewX()-Owner->BorderL;
		fy=Owner->GetViewY()-Owner->BorderT;
		fw=Owner->GetViewWidth()+Owner->BorderL+Owner->BorderR;
		fh=Owner->GetViewHeight()+Owner->BorderT+Owner->BorderB;
		fx+=fw*0.5;
		fy+=fh*0.5;
		fw=GetViewWidth()+BorderL+BorderR;
		fh=GetViewHeight()+BorderT+BorderB;
		fx-=fw*0.5+emGetDblRandom(-0.03,0.03)*vrw;
		fy-=fh*0.5+emGetDblRandom(-0.03,0.03)*vrh;
		if (fx>vrx+vrw-fw) fx=vrx+vrw-fw;
		if (fy>vry+vrh-fh) fy=vry+vrh-fh;
		if (fx<vrx) fx=vrx;
		if (fy<vry) fy=vry;
		SetViewGeometry(
			fx+BorderL,fy+BorderT,
			GetViewWidth(),GetViewHeight(),
			Screen.PixelTallness
		);
		PosPending=true;
		PosForced=true;
	}

	if (PosPending || SizePending) {
		x=((int)GetViewX())-BorderL;
		y=((int)GetViewY())-BorderT;
		w=(int)GetViewWidth();
		h=(int)GetViewHeight();
		memset(&xsh,0,sizeof(xsh));
		xsh.flags     =PMinSize;
		xsh.min_width =MinPaneW;
		xsh.min_height=MinPaneH;
		if (PosForced) {
			xsh.flags|=PPosition|USPosition;
			xsh.x=x;
			xsh.y=y;
		}
		if (SizeForced) {
			xsh.flags|=PSize|USSize;
			xsh.width=w;
			xsh.height=h;
		}
		XMutex.Lock();
		XSetWMNormalHints(Disp,Win,&xsh);
		if (PosPending && SizePending) {
			XMoveResizeWindow(Disp,Win,x,y,w,h);
		}
		else if (PosPending) {
			XMoveWindow(Disp,Win,x,y);
		}
		else {
			XResizeWindow(Disp,Win,w,h);
		}
		XMutex.Unlock();
		PosPending=false;
		SizePending=false;
	}

	if (TitlePending) {
		str=GetWindowTitle();
		if (Title!=str) {
			Title=str;
			XMutex.Lock();
			XmbSetWMProperties(Disp,Win,Title.Get(),NULL,NULL,0,NULL,NULL,NULL);
			XMutex.Unlock();
		}
		TitlePending=false;
	}

	if (IconPending) {
		SetIconProperty(GetWindowIcon());
		IconPending=false;
	}

	if (CursorPending) {
		cur=GetViewCursor();
		if (Cursor!=cur) {
			Cursor=cur;
			xcur=Screen.GetXCursor(cur);
			XMutex.Lock();
			XDefineCursor(Disp,Win,xcur);
			XMutex.Unlock();
		}
		CursorPending=false;
	}

	if (!PostConstructed) {
		PostConstruct();
		PostConstructed=true;
	}

	if (!InvalidRects.IsEmpty() && Mapped) {
		UpdatePainting();
		if (!LaunchFeedbackSent) {
			LaunchFeedbackSent=true;
			SendLaunchFeedback();
		}
	}

	return false;
}
Exemplo n.º 8
0
// Inserts new item into the tab control for specified MDIChild. If bRedraw is
// set to TRUE then framework will be redrawn in order to show new item.
BOOL COXTabWorkspace::InsertTabItem(int nIndex, const CWnd* pChildWnd, 
									BOOL bRedraw/*=TRUE*/, BOOL bOnlyVisible/*=TRUE*/)
{
	ASSERT(pChildWnd!=NULL);
	ASSERT(::IsWindow(pChildWnd->GetSafeHwnd()));
	ASSERT(nIndex>=0 && nIndex<=m_arrTab.GetSize());

	// Make sure we add MDIChild window
	if((pChildWnd->GetExStyle()&WS_EX_MDICHILD)==0)
		return FALSE;

	// Make sure it is visible at the moment
	if(bOnlyVisible && (pChildWnd->GetStyle()&WS_VISIBLE)==0)
		return FALSE;

	// Work out window class
	TCHAR sWndClass[512];
	::GetClassName(pChildWnd->GetSafeHwnd(),sWndClass,
		sizeof(sWndClass)/sizeof(TCHAR));
//	WNDCLASSEX classInfo={ sizeof(WNDCLASSEX) };
//	::GetClassInfoEx(AfxGetInstanceHandle(),sWndClass,&classInfo);
    
	// Get icon
	HICON hIcon=GetWindowIcon(pChildWnd->GetSafeHwnd());
	int nImageIndex=(hIcon==NULL ? -1 : AddTabItemIcon(hIcon));

	// Set item text to window text
	CString sWindowText=GetTextForTabItem(pChildWnd);

	TC_ITEM tci;
	tci.mask=TCIF_TEXT|TCIF_IMAGE;
	tci.pszText=(TCHAR*)(void*)(const TCHAR*)sWindowText;
	tci.iImage=nImageIndex;

	// Insert new tab control item
	VERIFY(InsertItem(nIndex,&tci)!=-1);

	// Redraw the tab control
	if(!m_arrTab.GetSize() && bRedraw)
		InvalidateRect(NULL);

	// Save information about new entry
	TAB_ITEM_ENTRY newTabItemEntry;
	m_arrTab.Add(newTabItemEntry);
	for(int nTabItemIndex=PtrToInt(m_arrTab.GetSize())-1; nTabItemIndex>nIndex; nTabItemIndex--)
	{
		m_arrTab[nTabItemIndex]=m_arrTab[nTabItemIndex-1];
	}
	newTabItemEntry.sText=sWindowText;
	newTabItemEntry.pWnd=(CWnd*)pChildWnd;
	newTabItemEntry.bFound=TRUE;
	newTabItemEntry.sWndClass=sWndClass;
	m_arrTab.SetAt(nIndex,newTabItemEntry);

	// Update the size and position of the tab control and MDIClient window
	if(bRedraw)
	{
		ASSERT(::IsWindow(GetParentFrame()->GetSafeHwnd()));
		GetParentFrame()->RecalcLayout();
	}

	return TRUE;
}
Exemplo n.º 9
0
// Scans through all MDIChild windows and refreshes window names and 
// current active window. If bAddNewWindows is set to TRUE then if any
// new MDIChild is found it will be added to the tab control
void COXTabWorkspace::UpdateContents(BOOL bAddNewWindows/*=FALSE*/, 
									 BOOL bUpdateWindowsInfo/*=FALSE*/)
{
	ASSERT(m_pTabClientWnd!=NULL);

    // Check MDI windows
    CMDIFrameWnd* pFrameWnd=GetParentFrame();
    if(pFrameWnd==NULL)
	{
		return;
	}

	BOOL bRecalc=m_pTabClientWnd->m_bForceToRecalc;

	// Get pointer to currently active MDIChild
    CWnd* pActiveChildWnd=pFrameWnd->MDIGetActive(NULL);

    CMDIChildWnd* pChildWnd=NULL;
    int nActiveIndex=-1;

	// Start enumerating from currently active MDIChild
    if(pActiveChildWnd!=NULL)
	{
		pChildWnd=(CMDIChildWnd*)pActiveChildWnd->GetWindow(GW_HWNDFIRST);
	}

    // Flag all current tabs as unfound (for debug purposes in order to check
	// the integrity of the framework)
#ifdef _DEBUG
	int nIndex=0;
    for(nIndex=0; nIndex<m_arrTab.GetSize(); nIndex++)
	{
		m_arrTab[nIndex].bFound=FALSE;
	}
#endif

	int nInsertIndex= PtrToInt(m_arrTab.GetSize());

	// Enumerate all child windows
    while(pChildWnd!=NULL)
    {
		// Window text
		CString sWindowText=GetTextForTabItem(pChildWnd);

		// see if can find it
		int nFoundItem=FindTabItem(pChildWnd->GetSafeHwnd());

		if(nFoundItem!=-1)
		{
			if((pChildWnd->GetStyle()&WS_VISIBLE)==WS_VISIBLE)
			{
				if(pChildWnd==pActiveChildWnd)
				{
					// Found currently active MDIChild
					nActiveIndex=nFoundItem;
				}

#ifdef _DEBUG
				m_arrTab[nFoundItem].bFound=TRUE;
#endif

				// Update text if necessary
				if(m_arrTab[nFoundItem].sText!=sWindowText)
				{
					m_arrTab[nFoundItem].sText=sWindowText;

					//replace "&" characters for doubles "&&"
					int nFind=sWindowText.Find(TEXT('&'));
					while (nFind != -1)
					{
						if (nFind<sWindowText.GetLength())
						{
//							if (sWindowText.GetAt(nFind+1)!=TEXT('&'))
							sWindowText.Insert(nFind+1,TEXT('&'));
							nFind=sWindowText.Find(TEXT('&'),nFind+2);
						}
						else
							nFind=-1;
					}


					TC_ITEM tci;
					tci.mask=TCIF_TEXT;
					tci.pszText=(LPTSTR)(LPCTSTR)sWindowText;
					SetItem(nFoundItem,&tci);

					bRecalc=TRUE;
				}

				if(bUpdateWindowsInfo)
				{
					TC_ITEM tci;
					tci.mask=TCIF_IMAGE;
					GetItem(nFoundItem,&tci);
					// Update icon if necessary
					HICON hIcon=GetWindowIcon(pChildWnd->GetSafeHwnd());
					int nImageIndex=(hIcon==NULL ? -1 : AddTabItemIcon(hIcon));
					if(nImageIndex!=tci.iImage)
					{
						tci.iImage=nImageIndex;
						SetItem(nFoundItem,&tci);
					}
				}
			}
			else
			{
				nInsertIndex--;
				if(nActiveIndex!=-1 && nActiveIndex>nFoundItem)
				{
					nActiveIndex--;
				}
				RemoveTabItem(pChildWnd,FALSE);
				bRecalc=TRUE;
			}
		}
		else if(bAddNewWindows)
		{
			if(nActiveIndex!=-1 && nActiveIndex>=nInsertIndex)
			{
				nActiveIndex++;
			}
			// add item
			InsertTabItem(nInsertIndex,pChildWnd,FALSE);
			bRecalc=TRUE;
		}

		// Get next MDIChild
		pChildWnd=(CMDIChildWnd*)pChildWnd->GetWindow(GW_HWNDNEXT);
    }

#ifdef _DEBUG
    for(nIndex=0; nIndex<m_arrTab.GetSize(); nIndex++)
	{
		ASSERT(m_arrTab[nIndex].bFound);
	}
#endif

	// Set the active item
    if(nActiveIndex>=0 && GetCurSel()!=nActiveIndex)
	{
		SetCurSel(nActiveIndex);
		bRecalc=TRUE;
	}

	if(bRecalc)
	{
		// Update the size and position of the tab control and MDIClient window
		if(::IsWindow(GetParentFrame()->GetSafeHwnd()))
		{
			GetParentFrame()->RecalcLayout();
		}
		m_pTabClientWnd->m_bForceToRecalc=FALSE;
	}
}