Example #1
0
int main() {

	hMutex = CreateMutex( NULL, FALSE, LPCWSTR( "MyMutex"));
	
	if (GetLastError() == ERROR_ALREADY_EXISTS || GetLastError() == ERROR_ACCESS_DENIED) 
			return 1 ;
	

	programHandle = GetModuleHandle(NULL);
	firstCursor = CopyCursor(LoadCursor(NULL, IDC_IBEAM));
	hookHandle = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardHook, programHandle, 0);	
	timerHandle = SetTimer(NULL, timerHandle, 200, UpdateCursor);

	
	HCURSOR cursorHandle = LoadCursor(programHandle, MAKEINTRESOURCE(1033));
	SetSystemCursor(cursorHandle, OCR_IBEAM);

	MSG message;
	while (	GetMessage(&message, 0, 0, 0))
	{
		TranslateMessage(&message);
		DispatchMessage(&message);
	}

		SetSystemCursor(firstCursor, OCR_IBEAM);			
		DestroyCursor(firstCursor);
		UnhookWindowsHookEx(hookHandle);
		ReleaseMutex(hMutex);

	return 0;
}
Example #2
0
bool Show_Cursor(bool bShow)
{
	if (!hcArrowCopy || !hAlphaCursorCopy)
		return false;

	if (visible && bShow)
		return false;

	if (!visible && !bShow)
		return false;

	if (bShow)
	{
		SetSystemCursor(hcArrowCopy, OCR_NORMAL);
		hcArrowCopy = CopyCursor(hcArrow); 
		visible = true;
		return true;
	}
	else
	{
		SetSystemCursor(hAlphaCursorCopy, OCR_NORMAL);
		hAlphaCursorCopy = CopyCursor(hAlphaCursor);
		visible = false;
		return true;
	}
	return false;
}
Example #3
0
void	GMouse::HideCursor(void)
{
#if defined(GWIN)
	HCURSOR hcurseur = LoadCursor(GetModuleHandle(NULL),"IDC_CURSOR");
	HCURSOR hcopiecurseur = CopyCursor(hcurseur);
	SetSystemCursor(hcopiecurseur, OCR_APPSTARTING);
	hcopiecurseur = CopyCursor(hcurseur);
	SetSystemCursor(hcopiecurseur, OCR_NORMAL);
#endif
}
Example #4
0
void CALLBACK UpdateCursor(HWND /* hWnd */, UINT /* uMsg */, UINT_PTR /* idEvent */, DWORD /* dwTime */)
{
	HKL layout = GetKeyboardLayout(GetWindowThreadProcessId(GetForegroundWindow(), NULL));

	if (layout != _layout)
	{
		_layout=layout;		
		//cout<<(int(layout)&0xFFFF)<<endl;
		HCURSOR cursorHandle = LoadCursor(programHandle, MAKEINTRESOURCE(int(layout)&0xFFFF));		
		if (cursorHandle)
			SetSystemCursor(cursorHandle, OCR_IBEAM);
		else	
			SetSystemCursor(firstCursor, OCR_IBEAM);
	}
}
Example #5
0
LRESULT CALLBACK LowLevelKeyboardHook(int actionCode, WPARAM wParam, LPARAM lParam)
{
	if (actionCode == HC_ACTION)
	{
		KBDLLHOOKSTRUCT *key = (KBDLLHOOKSTRUCT*)lParam;		
		if (key->vkCode==VK_F12)
		{			
			SetSystemCursor(firstCursor, OCR_IBEAM);			
			DestroyCursor(firstCursor);
			UnhookWindowsHookEx(hookHandle);
			ReleaseMutex(hMutex);
			exit(0);
		}
	}		
	return CallNextHookEx(hookHandle, actionCode, wParam, lParam);
}
Example #6
0
BOOL I4C3DCursor::SetTransparentCursor(LPCTSTR szFilePath)
{
	HCURSOR hCursor = NULL;

	hCursor = LoadCursorFromFile(szFilePath);
	if (hCursor == NULL) {
		LoggingMessage(Log_Error, _T(MESSAGE_ERROR_CURSOR_MISSING), GetLastError(), g_FILE, __LINE__);

		return FALSE;
	}

	if (SetSystemCursor(hCursor, 32512)) {
		return TRUE;
	} else {
		RestoreCursor();
	}
	DestroyCursor(hCursor);	// 現在使用中のカーソルはDestroyすることはできない。

	return FALSE;
}
Example #7
0
void CursorTerminate_platform()
{
	if (hcArrowCopy)
		SetSystemCursor(hcArrowCopy, OCR_NORMAL);
	//Add any platform-specific termination code here
}
Example #8
0
BOOL ZSetSystemCursor(HCURSOR hcur,DWORD id)
{
    return    SetSystemCursor( hcur, id) ;
}
Example #9
-1
void TfrmMain::wmTimer(WPARAM wParam, LPARAM lParam) {
    if (wParam == ID_bvlTarget) { // Timer for Target selector
        static int primarymouse;
        if(!m_hTargetHighlighter) {
            primarymouse=GetSystemMetrics(SM_SWAPBUTTON)?VK_RBUTTON:VK_LBUTTON;
            m_hTargetHighlighter=CreateWindowEx(WS_EX_LAYERED|WS_EX_TRANSPARENT|WS_EX_TOOLWINDOW,(LPTSTR)g_clsTargetHighlighter,NULL,WS_POPUP,0,0,0,0,NULL,NULL,hInst,NULL);
            if(!m_hTargetHighlighter) return;
            SetLayeredWindowAttributes(m_hTargetHighlighter,0,123,LWA_ALPHA);
            SetSystemCursor(CopyCursor(IcoLib_GetIcon(ICO_PLUG_SSTARGET)),OCR_NORMAL);
            Hide();
        }
        if(!(GetAsyncKeyState(primarymouse)&0x8000)) {
            KillTimer(m_hWnd,ID_bvlTarget);
            SystemParametersInfo(SPI_SETCURSORS,0,NULL,0);
            DestroyWindow(m_hTargetHighlighter),m_hTargetHighlighter=NULL;
            SetTargetWindow(m_hTargetWindow);
            Show();
            return;
        }
        POINT point;
        GetCursorPos(&point);
        m_hTargetWindow=WindowFromPoint(point);
        if(!((GetAsyncKeyState(VK_SHIFT)|GetAsyncKeyState(VK_MENU))&0x8000))
            for(HWND hTMP; (hTMP=GetParent(m_hTargetWindow)); m_hTargetWindow=hTMP);
        if(m_hTargetWindow!=m_hLastWin) {
            m_hLastWin=m_hTargetWindow;
            RECT rect;
            GetWindowRect(m_hLastWin,&rect);
            int width=rect.right-rect.left;
            int height=rect.bottom-rect.top;
            if(g_iTargetBorder) {
                SetWindowPos(m_hTargetHighlighter,NULL,0,0,0,0,SWP_HIDEWINDOW|SWP_NOMOVE|SWP_NOSIZE);
                if(width>g_iTargetBorder*2 && height>g_iTargetBorder*2) {
                    HRGN hRegnNew=CreateRectRgn(0,0,width,height);
                    HRGN hRgnHole=CreateRectRgn(g_iTargetBorder,g_iTargetBorder,width-g_iTargetBorder,height-g_iTargetBorder);
                    CombineRgn(hRegnNew,hRegnNew,hRgnHole,RGN_XOR);
                    DeleteObject(hRgnHole);
                    SetWindowRgn(m_hTargetHighlighter,hRegnNew,FALSE);//cleans up hRegnNew
                } else SetWindowRgn(m_hTargetHighlighter,NULL,FALSE);
            }
            SetWindowPos(m_hTargetHighlighter,HWND_TOPMOST,rect.left,rect.top,width,height,SWP_SHOWWINDOW|SWP_NOACTIVATE);
        }
        return;
    }
    if (wParam == ID_chkTimed) { // Timer for Screenshot
#ifdef _DEBUG
        OutputDebugStringA("SS Bitmap Timer Start\r\n" );
#endif
        if(!m_bCapture) {		//only start once
            if (m_Screenshot) {
                FIP->FI_Unload(m_Screenshot);
                m_Screenshot = NULL;
            }
            m_bCapture = true;
            switch (m_opt_tabCapture) {
            case 0:
                m_Screenshot = CaptureWindow(m_hTargetWindow, m_opt_chkClientArea);
                break;
            case 1:
                m_Screenshot = CaptureMonitor((m_opt_cboxDesktop > 0) ? m_Monitors[m_opt_cboxDesktop-1].szDevice : NULL);
                break;
            default:
                KillTimer(m_hWnd,ID_chkTimed);
                m_bCapture = false;
#ifdef _DEBUG
                OutputDebugStringA("SS Bitmap Timer Stop (no tabCapture)\r\n" );
#endif
                return;
            }
            if (!m_Screenshot) m_bCapture = false;
        }
        if (m_Screenshot) {
            KillTimer(m_hWnd,ID_chkTimed);
            m_bCapture = false;
#ifdef _DEBUG
            OutputDebugStringA("SS Bitmap Timer Stop (CaptureDone)\r\n" );
#endif
            SendMessage(m_hWnd,UM_EVENT, 0, (LPARAM)EVT_CaptureDone);
        }
    }
}