コード例 #1
0
ファイル: NT_Compatible.c プロジェクト: bochaqos/trmnl
void _setcursortype(int cur_t)
{
    CONSOLE_CURSOR_INFO  ConsoleCursorInfo;

    if (!StdHandle)
    {
        StdHandle = TRUE;
        hStdout = GetStdHandle (STD_OUTPUT_HANDLE);
    } /* endif */

    switch (cur_t)
    {
    case _NORMALCURSOR:
    case _SOLIDCURSOR:
        GetConsoleCursorInfo (hStdout, &ConsoleCursorInfo);
        ConsoleCursorInfo.bVisible = TRUE;
        SetConsoleCursorInfo (hStdout, &ConsoleCursorInfo);
        break;

    case _NOCURSOR:
        GetConsoleCursorInfo (hStdout, &ConsoleCursorInfo);
        ConsoleCursorInfo.bVisible = FALSE;
        SetConsoleCursorInfo (hStdout, &ConsoleCursorInfo);
        break;

    } /* endswitch */
}
コード例 #2
0
ファイル: console.cpp プロジェクト: nbei/myTetris
bool Console::RemoveCursor(void) {
	CONSOLE_CURSOR_INFO cci;
	if (!GetConsoleCursorInfo(hStdOutput, &cci)) return false;
	cci.bVisible = false;
	if (!SetConsoleCursorInfo(hStdOutput, &cci)) return false;
	if (!GetConsoleCursorInfo(hStdError, &cci)) return false;
	cci.bVisible = false;
	if (!SetConsoleCursorInfo(hStdError, &cci)) return false;
	return true;
}
コード例 #3
0
ファイル: ntconio.c プロジェクト: OS2World/APP-EDITOR-Vile
static void
ntconio_open(void)
{
    CONSOLE_CURSOR_INFO newcci;
    BOOL newcci_ok;

    TRACE(("ntconio_open\n"));

    set_colors(NCOLORS);
    set_palette(initpalettestr);

    hOldConsoleOutput = 0;
    hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
    origcci_ok = GetConsoleCursorInfo(hConsoleOutput, &origcci);
    GetConsoleScreenBufferInfo(hConsoleOutput, &csbi);
    if (csbi.dwMaximumWindowSize.Y !=
	csbi.srWindow.Bottom - csbi.srWindow.Top + 1
	|| csbi.dwMaximumWindowSize.X !=
	csbi.srWindow.Right - csbi.srWindow.Left + 1) {
	TRACE(("..creating alternate screen buffer\n"));
	hOldConsoleOutput = hConsoleOutput;
	hConsoleOutput = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE,
						   0, NULL,
						   CONSOLE_TEXTMODE_BUFFER, NULL);
	SetConsoleActiveScreenBuffer(hConsoleOutput);
	GetConsoleScreenBufferInfo(hConsoleOutput, &csbi);
	newcci_ok = GetConsoleCursorInfo(hConsoleOutput, &newcci);
	if (newcci_ok && origcci_ok && newcci.dwSize != origcci.dwSize) {
	    /*
	     * Ensure that user's cursor size prefs are carried forward
	     * in the newly created console.
	     */
	    show_cursor(TRUE, origcci.dwSize);
	}
    }

    originalAttribute = csbi.wAttributes;

    crow = csbi.dwCursorPosition.Y;
    ccol = csbi.dwCursorPosition.X;

    nfcolor = cfcolor = gfcolor;
    nbcolor = cbcolor = gbcolor;
    set_current_attr();

    newscreensize(csbi.dwMaximumWindowSize.Y, csbi.dwMaximumWindowSize.X);
    hConsoleInput = GetStdHandle(STD_INPUT_HANDLE);
    SetConsoleCtrlHandler(nthandler, TRUE);
}
コード例 #4
0
// draw the field
// argument - width and height of the field
// resizes console window for no reason
// prints instructions how to interact
void drawTable(COORD size)
{
	DWORD cWritten;
	HANDLE con = GetStdHandle(STD_OUTPUT_HANDLE);

	CONSOLE_CURSOR_INFO     cursorInfo;
	GetConsoleCursorInfo(con, &cursorInfo);
	cursorInfo.bVisible = false;
	SetConsoleCursorInfo(con, &cursorInfo);
	
	HWND console = GetConsoleWindow();
	RECT r;
	GetWindowRect(console, &r);
	MoveWindow(console, r.left, r.top, 800, 480, TRUE);

	FillConsoleOutputCharacter(con, '+', 1, { 0, 3 }, &cWritten);
	FillConsoleOutputCharacter(con, '+', 1, { size.X, 3 }, &cWritten);
	FillConsoleOutputCharacter(con, '-', size.X - 1, { 1, 3 }, &cWritten);
	FillConsoleOutputCharacter(con, '_', 4, { 3, 1 }, &cWritten);

	for (int i = 0; i < size.Y; ++i)
	{
		if (i != 3)
		{
			FillConsoleOutputCharacter(con, '|', 1, { 0, i }, &cWritten);
			FillConsoleOutputCharacter(con, '|', 1, { size.X, i }, &cWritten);
		}
	}

	print({size.X + 2, 1}, "COWS AND BULLS");
	print({size.X + 2, 3}, "0-9 - add digit");
	print({size.X + 2, 4}, "Backspace - remove last digit");
	print({size.X + 2, 5}, "Enter - confirm");
	print({size.X + 2, 6}, "Esc - quit");
}
コード例 #5
0
ファイル: maze-game.c プロジェクト: hxhb/cppcode
void hidden(){//隐藏光标
	HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
	CONSOLE_CURSOR_INFO cci;
	GetConsoleCursorInfo(hOut, &cci);
	cci.bVisible = 0; //赋1为显示,赋0为隐藏
	SetConsoleCursorInfo(hOut, &cci);
}
コード例 #6
0
ファイル: maze.c プロジェクト: ktk1015/tk_test_c
void removeCursor(void)
{
    CONSOLE_CURSOR_INFO cur;
    GetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cur);
    cur.bVisible=0;
    SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE),&cur);
}
コード例 #7
0
ファイル: WConsole.cpp プロジェクト: VladimirTyrin/ConEmu
BOOL apiPauseConsoleOutput(HWND hConWnd, bool bPause)
{
	BOOL bOk = FALSE, bCi = FALSE;
	DWORD_PTR dwRc = 0;
	DWORD nTimeout = 15000;

	if (bPause)
	{
		CONSOLE_CURSOR_INFO ci = {};
		bCi = GetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &ci);

		bOk = (SendMessageTimeout(hConWnd, WM_SYSCOMMAND, 65522, 0, SMTO_NORMAL, nTimeout, &dwRc) != 0);

		// In Win2k we can't be sure about active selection,
		// so we check for cursor height equal to 100%
		gbPauseConsoleWasRequested = (bCi && ci.dwSize < 100);
	}
	else
	{
		bOk = (SendMessageTimeout(hConWnd, WM_KEYDOWN, VK_ESCAPE, 0, SMTO_NORMAL, nTimeout, &dwRc) != 0);
		gbPauseConsoleWasRequested = false;
	}

	return bOk;
}
 void cursor_visible(bool state){
     static auto handle = GetStdHandle(STD_OUTPUT_HANDLE);
     CONSOLE_CURSOR_INFO     cursorInfo;
     GetConsoleCursorInfo(handle, &cursorInfo);
     cursorInfo.bVisible = state; // set the cursor visibility
     SetConsoleCursorInfo(handle, &cursorInfo);
 }
コード例 #9
0
ファイル: Graphics.cpp プロジェクト: GolanSabo/Widget
void Graphics::setCursorVisibility(bool isVisible)
{
	CONSOLE_CURSOR_INFO cci;
	GetConsoleCursorInfo(_console, &cci);
	cci.bVisible = isVisible;
	SetConsoleCursorInfo(_console, &cci);
}
コード例 #10
0
//setting window size and hiding cursor
void Aesthetics::SetWindow(int Width, int Height)
{
	_COORD coord;
	coord.X = Width;
	coord.Y = Height;

	_SMALL_RECT Rect;
	Rect.Top = 0;
	Rect.Left = 0;
	Rect.Bottom = Height - 1;
	Rect.Right = Width - 1;

	HANDLE Handle = GetStdHandle(STD_OUTPUT_HANDLE);      // Get Handle
	SetConsoleScreenBufferSize(Handle, coord);            // Set Buffer Size
	SetConsoleWindowInfo(Handle, TRUE, &Rect);            // Set Window Size


	HANDLE hConsoleOutput;
	CONSOLE_CURSOR_INFO structCursorInfo;
	hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
	GetConsoleCursorInfo(hConsoleOutput, &structCursorInfo);
	structCursorInfo.bVisible = FALSE;
	SetConsoleCursorInfo(hConsoleOutput, &structCursorInfo);

}
コード例 #11
0
ファイル: pdcsetsc.c プロジェクト: Bill-Cosby/CompSciProject
int PDC_curs_set(int visibility)
{
    CONSOLE_CURSOR_INFO cci;
    int ret_vis;

    PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));

    ret_vis = SP->visibility;

    if (GetConsoleCursorInfo(pdc_con_out, &cci) == FALSE)
        return ERR;

    switch(visibility)
    {
    case 0:             /* invisible */
        cci.bVisible = FALSE;
        break;
    case 2:             /* highly visible */
        cci.bVisible = TRUE;
        cci.dwSize = 95;
        break;
    default:            /* normal visibility */
        cci.bVisible = TRUE;
        cci.dwSize = SP->orig_cursor;
        break;
    }

    if (SetConsoleCursorInfo(pdc_con_out, &cci) == FALSE)
        return ERR;

    SP->visibility = visibility;
    return ret_vis;
}
コード例 #12
0
void WinConsoleHelper::ShowConsoleCursor(bool showFlag)
{
	CONSOLE_CURSOR_INFO cursorInfo;
	GetConsoleCursorInfo(hStdOut, &cursorInfo);
	cursorInfo.bVisible = showFlag;
	SetConsoleCursorInfo(hStdOut, &cursorInfo);
}
コード例 #13
0
ファイル: sys_win32.cpp プロジェクト: smarmy/HellRogue
 void _hide_cursor(HANDLE handle)
 {
   CONSOLE_CURSOR_INFO cci;
   GetConsoleCursorInfo(handle, &cci);
   cci.bVisible = false;
   SetConsoleCursorInfo(handle, &cci);
 }
コード例 #14
0
ファイル: Project.c プロジェクト: chcola/prUNI
// 커서 숨기기 : true, T(보이기), false, F(숨기기)
// 인터넷 참고
void CursorVisible(bool blnCursorVisible)    // Console.CursorVisible = false;
{
    CONSOLE_CURSOR_INFO cursorInfo;
    GetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursorInfo);
    cursorInfo.bVisible = blnCursorVisible;
    SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursorInfo);
}
コード例 #15
0
ファイル: tconsole.c プロジェクト: oldfaber/wzsh
void nt_init_term(void)
{
	DWORD dwmode;
	CONSOLE_SCREEN_BUFFER_INFO scrbuf;
	HANDLE hinput = GetStdHandle(STD_INPUT_HANDLE);

	if (GetConsoleMode(hinput, &dwmode)) {
		if (!SetConsoleMode(hinput, dwmode | ENABLE_WINDOW_INPUT))
			dbgprintf(PR_ERROR, "!!! %s(): SetConsoleMode(0x%p, ..) error %ld\n", __FUNCTION__, hinput, GetLastError());
	}
	/* defaults */
	glines = 25;
	gcolumns = 80;
	hConOut = CreateFile("CONOUT$", GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
	if (hConOut == INVALID_HANDLE_VALUE) {
		dbgprintf(PR_ERROR, "!!! %s(): CreateFile(\"CONOUT$\", ..) error %ld\n", __FUNCTION__, GetLastError());
		return;
	}
	if (!GetConsoleScreenBufferInfo(hConOut, &scrbuf)) {
		dbgprintf(PR_ERROR, "!!! %s(): GetConsoleScreenBufferInfo(0x%p, ..) error %ld\n", __FUNCTION__, hConOut, GetLastError());
		/* fail all remaining calls */
		hConOut = INVALID_HANDLE_VALUE;
		return;
	}
	if (!GetConsoleCursorInfo(hConOut, &cursinfo))
		dbgprintf(PR_ERROR, "!!! %s(): GetConsoleCursorInfo(0x%p, ..) error %ld\n", __FUNCTION__, hConOut, GetLastError());
        cursinfo_valid = TRUE;
	glines = scrbuf.srWindow.Bottom - scrbuf.srWindow.Top + 1;
	gcolumns = scrbuf.srWindow.Right - scrbuf.srWindow.Left + 1;
}
コード例 #16
0
ファイル: console_win.cpp プロジェクト: nythil/kgascii
ConsoleImpl::ConsoleImpl()
{
    hndSavedOutput_ = GetStdHandle(STD_OUTPUT_HANDLE);
    GetConsoleScreenBufferInfo(hndSavedOutput_, &csbiSaved_);
    GetConsoleCursorInfo(hndSavedOutput_, &cciSaved_);
    hndOutput_ = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL);
}
コード例 #17
0
/**
 * Prepare console on program initialization: change console font codepage
 * according to program options and hide cursor.
 */
void setup_console(void)
{
	HANDLE hOut;
	CONSOLE_CURSOR_INFO cci;

	int cp = (opt.flags&OPT_UTF8 ? CP_UTF8 : opt.flags&OPT_ANSI ? GetACP() : GetOEMCP());
	rhash_data.saved_console_codepage = -1;
	/* note: we are using numbers 1 = _fileno(stdout), 2 = _fileno(stderr) */
	/* cause _fileno() is undefined,  when compiling as strict ansi C. */
	if(cp > 0 && IsValidCodePage(cp) && (isatty(1) || isatty(2)) )
	{
		rhash_data.saved_console_codepage = GetConsoleOutputCP();
		SetConsoleOutputCP(cp);
		setlocale(LC_CTYPE, opt.flags&OPT_UTF8 ? "C" :
			opt.flags&OPT_ANSI ? ".ACP" : ".OCP");
		rsh_exit = rhash_exit;
	}

	if((opt.flags & OPT_PERCENTS) != 0) {
		hOut = GetStdHandle(STD_ERROR_HANDLE);
		if(hOut != INVALID_HANDLE_VALUE) {
			/* store current cursor size and visibility flag */
			GetConsoleCursorInfo(hOut, &cci);
			rhash_data.saved_cursor_size = (cci.bVisible ? cci.dwSize : 0);

			/* now hide cursor */
			cci.bVisible = 0;
			SetConsoleCursorInfo(hOut, &cci); /* hide cursor */
		}
	}
}
コード例 #18
0
ファイル: NCursesFrontend.cpp プロジェクト: sanderjo/nzbget
NCursesFrontend::NCursesFrontend()
{
	m_summary = true;
	m_fileList = true;

	m_showNzbname = g_Options->GetCursesNzbName();
	m_showTimestamp = g_Options->GetCursesTime();
	m_groupFiles = g_Options->GetCursesGroup();

	// Setup curses
#ifdef WIN32
	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

	CONSOLE_CURSOR_INFO ConsoleCursorInfo;
	GetConsoleCursorInfo(hConsole, &ConsoleCursorInfo);
	ConsoleCursorInfo.bVisible = false;
	SetConsoleCursorInfo(hConsole, &ConsoleCursorInfo);
	if (IsRemoteMode())
	{
		SetConsoleTitle("NZBGet - remote mode");
	}
	else
	{
		SetConsoleTitle("NZBGet");
	}
#else
	m_window = initscr();
	if (m_window == nullptr)
	{
		printf("ERROR: m_pWindow == nullptr\n");
		exit(-1);
	}
	keypad(stdscr, true);
	nodelay((WINDOW*)m_window, true);
	noecho();
	curs_set(0);
	m_useColor = has_colors();
#endif

	if (m_useColor)
	{
#ifndef WIN32
		start_color();
#endif
		init_pair(0,							COLOR_WHITE,	COLOR_BLUE);
		init_pair(NCURSES_COLORPAIR_TEXT,		COLOR_WHITE,	COLOR_BLACK);
		init_pair(NCURSES_COLORPAIR_INFO,		COLOR_GREEN,	COLOR_BLACK);
		init_pair(NCURSES_COLORPAIR_WARNING,	COLOR_MAGENTA,	COLOR_BLACK);
		init_pair(NCURSES_COLORPAIR_ERROR,		COLOR_RED,		COLOR_BLACK);
		init_pair(NCURSES_COLORPAIR_DEBUG,		COLOR_WHITE,	COLOR_BLACK);
		init_pair(NCURSES_COLORPAIR_DETAIL,		COLOR_GREEN,	COLOR_BLACK);
		init_pair(NCURSES_COLORPAIR_STATUS,		COLOR_BLUE,		COLOR_WHITE);
		init_pair(NCURSES_COLORPAIR_KEYBAR,		COLOR_WHITE,	COLOR_BLUE);
		init_pair(NCURSES_COLORPAIR_INFOLINE,	COLOR_WHITE,	COLOR_BLUE);
		init_pair(NCURSES_COLORPAIR_TEXTHIGHL,	COLOR_BLACK,	COLOR_CYAN);
		init_pair(NCURSES_COLORPAIR_CURSOR,		COLOR_BLACK,	COLOR_YELLOW);
		init_pair(NCURSES_COLORPAIR_HINT,		COLOR_WHITE,	COLOR_RED);
	}
}
コード例 #19
0
ファイル: incwidth.cpp プロジェクト: Maximus5/ms-bug-1
void main()
{
	CONSOLE_SCREEN_BUFFER_INFO csbi = {};
	CONSOLE_CURSOR_INFO ci = {};
	HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
	GetConsoleScreenBufferInfo(hOut, &csbi);
	BOOL lb1 = GetConsoleCursorInfo(hOut, &ci);
	printf("Cursor height before=%i%% (rc=%u)\r\n", ci.dwSize, lb1);
	SetConsoleTitle(_T("Increasing ScreenBufferSize"));
	Sleep(2500);
	csbi.dwSize.X++;
	SetConsoleScreenBufferSize(hOut, csbi.dwSize);
	SetConsoleTitle(_T("Quering current cursor information"));
	Sleep(2500);
	BOOL lb2 = GetConsoleCursorInfo(hOut, &ci);
	printf("Cursor height after=%i%% (rc=%u)\r\n", ci.dwSize, lb2);
}
コード例 #20
0
/////////////////////////////////////////////////
// cursorOn(): switches between on/off cursor
void cursorOnOffSwitch()
{
	CONSOLE_CURSOR_INFO cursorInfo;
	HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
	GetConsoleCursorInfo( hStdOut, &cursorInfo);
	
	cursorInfo.bVisible = !cursorInfo.bVisible;
}
コード例 #21
0
ファイル: HARDWRVR.cpp プロジェクト: gdobra/tvision
THardwareInfo::THardwareInfo()
{
    consoleHandle[cnInput] = GetStdHandle( STD_INPUT_HANDLE );
    consoleHandle[cnOutput] = GetStdHandle( STD_OUTPUT_HANDLE );
    GetConsoleMode( consoleHandle[cnInput], &consoleMode );
    GetConsoleCursorInfo( consoleHandle[cnOutput], &crInfo );
    GetConsoleScreenBufferInfo( consoleHandle[cnOutput], &sbInfo );
}
コード例 #22
0
ファイル: consoleOperations.cpp プロジェクト: maxiss/myDFK
void hideConsoleCursor()
{
   HANDLE hOuput = GetStdHandle( STD_OUTPUT_HANDLE );
   CONSOLE_CURSOR_INFO cInfo;
   GetConsoleCursorInfo( hOuput, &cInfo );
   cInfo.bVisible = false;
   SetConsoleCursorInfo( hOuput, &cInfo );
}
コード例 #23
0
/**
 * @brief CON_Init
 */
void CON_Init(void)
{
	CONSOLE_CURSOR_INFO        curs;
	CONSOLE_SCREEN_BUFFER_INFO info;
	int                        i;

	// handle Ctrl-C or other console termination
	SetConsoleCtrlHandler(CON_CtrlHandler, TRUE);

	qconsole_hin = GetStdHandle(STD_INPUT_HANDLE);
	if (qconsole_hin == INVALID_HANDLE_VALUE)
	{
		return;
	}

	qconsole_hout = GetStdHandle(STD_OUTPUT_HANDLE);
	if (qconsole_hout == INVALID_HANDLE_VALUE)
	{
		return;
	}

	GetConsoleMode(qconsole_hin, &qconsole_orig_mode);

	// allow mouse wheel scrolling
	SetConsoleMode(qconsole_hin,
	               qconsole_orig_mode & ~ENABLE_MOUSE_INPUT);

	FlushConsoleInputBuffer(qconsole_hin);

	GetConsoleScreenBufferInfo(qconsole_hout, &info);
	qconsole_attrib = info.wAttributes;

#ifdef DEDICATED
	SetConsoleTitle(ET_VERSION " Dedicated Server Console");
#else
	SetConsoleTitle(ET_VERSION " Client Console");
#endif

	// make cursor invisible
	GetConsoleCursorInfo(qconsole_hout, &qconsole_orig_cursorinfo);
	curs.dwSize   = 1;
	curs.bVisible = FALSE;
	SetConsoleCursorInfo(qconsole_hout, &curs);

	qconsole_backgroundAttrib = qconsole_attrib & (BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY);

	// initialize history
	for (i = 0; i < QCONSOLE_HISTORY; i++)
	{
		qconsole_history[i][0] = '\0';
	}

	// set text color to white
	SetConsoleTextAttribute(qconsole_hout, CON_ColorCharToAttrib(COLOR_WHITE));

	// set process output translation
	SetConsoleOutputCP(CP_UTF8);
}
コード例 #24
0
void CursorTests::TestGetSetConsoleCursorInfo()
{
    DWORD dwSize;
    bool bVisible;

    VERIFY_SUCCEEDED_RETURN(TestData::TryGetValue(L"dwSize", dwSize), L"Get size parameter");
    VERIFY_SUCCEEDED_RETURN(TestData::TryGetValue(L"bVisible", bVisible), L"Get visibility parameter");

    // Get initial state of the cursor
    CONSOLE_CURSOR_INFO cciInitial = { 0 };
    BOOL bResult = GetConsoleCursorInfo(Common::_hConsole, &cciInitial);
    VERIFY_WIN32_BOOL_SUCCEEDED(bResult, L"Retrieve initial cursor state.");

    // Fill a structure with the value under test
    CONSOLE_CURSOR_INFO cciTest = { 0 };
    cciTest.bVisible = bVisible;
    cciTest.dwSize = dwSize;

    // If the cursor size is out of range, we expect a failure on set
    BOOL fExpectedResult = TRUE;
    if (cciTest.dwSize < 1 || cciTest.dwSize > 100)
    {
        fExpectedResult = FALSE;
    }

    // Attempt to set and verify that we get the expected result
    bResult = SetConsoleCursorInfo(Common::_hConsole, &cciTest);
    VERIFY_ARE_EQUAL(bResult, fExpectedResult, L"Ensure that return matches success/failure state we were expecting.");

    // Get the state of the cursor again
    CONSOLE_CURSOR_INFO cciReturned = { 0 };
    bResult = GetConsoleCursorInfo(Common::_hConsole, &cciReturned);
    VERIFY_WIN32_BOOL_SUCCEEDED(bResult, L"GET back the cursor information we just set.");

    if (fExpectedResult)
    {
        // If we expected the set to be successful, the returned structure should match the test one
        VERIFY_ARE_EQUAL(cciReturned, cciTest, L"If we expected SET success, the values we set should match what we retrieved.");
    }
    else
    {
        // If we expected the set to fail, the returned structure should match the initial one
        VERIFY_ARE_EQUAL(cciReturned, cciInitial, L"If we expected SET failure, the initial values before the SET should match what we retrieved.");
    }
}
コード例 #25
0
void Show_Console_Cursor(
    bool Show_Flag)  // Controls the visibility of the console cursor
{
  HANDLE out = GetStdHandle(STD_OUTPUT_HANDLE);
  CONSOLE_CURSOR_INFO cursorInfo;
  GetConsoleCursorInfo(out, &cursorInfo);
  cursorInfo.bVisible = Show_Flag;  // Sets the cursor visibility
  SetConsoleCursorInfo(out, &cursorInfo);
}
コード例 #26
0
ファイル: pdcscrn.c プロジェクト: wmcbrine/PDCurses
static void _set_console_info(void)
{
    CONSOLE_SCREEN_BUFFER_INFO csbi;
    CONSOLE_CURSOR_INFO cci;
    DWORD dwConsoleOwnerPid;
    HANDLE hProcess;
    HANDLE hSection, hDupSection;
    PVOID ptrView;

    /* Each-time initialization for console_info */

    GetConsoleCursorInfo(pdc_con_out, &cci);
    console_info.CursorSize = cci.dwSize;

    GetConsoleScreenBufferInfo(pdc_con_out, &csbi);
    console_info.ScreenBufferSize = csbi.dwSize;

    console_info.WindowSize.X = csbi.srWindow.Right - csbi.srWindow.Left + 1;
    console_info.WindowSize.Y = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;

    console_info.WindowPosX = csbi.srWindow.Left;
    console_info.WindowPosY = csbi.srWindow.Top;

    /* Open the process which "owns" the console */

    GetWindowThreadProcessId(console_info.Hwnd, &dwConsoleOwnerPid);

    hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwConsoleOwnerPid);

    /* Create a SECTION object backed by page-file, then map a view of
       this section into the owner process so we can write the contents
       of the CONSOLE_INFO buffer into it */

    hSection = CreateFileMapping(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE,
                                 0, sizeof(console_info), 0);

    /* Copy our console structure into the section-object */

    ptrView = MapViewOfFile(hSection, FILE_MAP_WRITE|FILE_MAP_READ,
                            0, 0, sizeof(console_info));

    memcpy(ptrView, &console_info, sizeof(console_info));

    UnmapViewOfFile(ptrView);

    /* Map the memory into owner process */

    DuplicateHandle(GetCurrentProcess(), hSection, hProcess, &hDupSection,
                    0, FALSE, DUPLICATE_SAME_ACCESS);

    /* Send console window the "update" message */

    SendMessage(console_info.Hwnd, WM_SETCONSOLEINFO, (WPARAM)hDupSection, 0);

    CloseHandle(hSection);
    CloseHandle(hProcess);
}
コード例 #27
0
/////////////////////////////////////////////////
// cursorOff(): cursor invisible.
void cursorOff()
{
	CONSOLE_CURSOR_INFO cursorInfo;   
	HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); 

	GetConsoleCursorInfo( hStdOut, &cursorInfo);
	cursorInfo.bVisible = FALSE;
	SetConsoleCursorInfo( hStdOut, &cursorInfo);
}
コード例 #28
0
ファイル: pdcgetsc.c プロジェクト: EvilTeach/Github
int PDC_get_cursor_mode(void)
{
    CONSOLE_CURSOR_INFO ci;
    
    PDC_LOG(("PDC_get_cursor_mode() - called\n"));

    GetConsoleCursorInfo(pdc_con_out, &ci);

    return ci.dwSize;
}
コード例 #29
0
ファイル: GUI.cpp プロジェクト: Ye-Yong-Chi/ChineseChess
GUI::GUI()
{
	system("chcp 950");
	system("mode con: cols=104 lines=24");
	SetConsoleTitle("¶H´ׁ¹Cְ¸");
	GetConsoleScreenBufferInfo(hConsole, &srInfo);
	GetConsoleCursorInfo(hConsole, &crInfo);
	if (hConsole == INVALID_HANDLE_VALUE)
		exit(EXIT_FAILURE);
}
コード例 #30
0
ファイル: svctlcui.cpp プロジェクト: zukisoft/external
inline const VKEY ConsoleUI::GetVkResponse(PCVKEY rgvkCriteria) const
{
	CONSOLE_CURSOR_INFO	cursorInfo;			// Console cursor information
	DWORD				dwInputMode;		// Console input mode flags
	bool				bValid = false;		// Loop termination flag
	INPUT_RECORD		recInput;			// INPUT_RECORD from console input
	DWORD				cEvents;			// Number of events read from console
	VKEY				vkInput;			// Virtual key code read from the console
	PCVKEY				pvk;				// Pointer to a virtual key code

	if(!rgvkCriteria) return NULL;			// No criteria codes to work with
	
	GetConsoleCursorInfo(m_hout, &cursorInfo);		// Get console cursor info
	
	cursorInfo.bVisible = FALSE;					// Turn off the cursor
	SetConsoleCursorInfo(m_hout, &cursorInfo);		// Set new cursor info
	
	// Remove the LINE_INPUT and ECHO_INPUT flags from the console input handle

	GetConsoleMode(m_hin, &dwInputMode);
	SetConsoleMode(m_hin, dwInputMode & ~ENABLE_LINE_INPUT & ~ENABLE_ECHO_INPUT);

	FlushConsoleInputBuffer(m_hin);					// Flush the console input buffer

	// Loop until the user presses one of the valid virtual keys
	
	while(!bValid) {

		vkInput = NULL;

		// Read in the next event from the console's input buffer, and discard
		// it if it's not a KEY_EVENT indicating a key down signal

		if(!ReadConsoleInput(m_hin, &recInput, 1, &cEvents)) break;
		
		if(recInput.EventType != KEY_EVENT) continue;		// Not a KEY_EVENT
		if(!recInput.Event.KeyEvent.bKeyDown) continue;		// Not a keydown event

		vkInput = recInput.Event.KeyEvent.wVirtualKeyCode;

		// Check to see if this virtual key code matches any of the specified
		// valid codes, and break the while() loop if it does

		for(pvk = rgvkCriteria; *pvk; pvk++) 
			if(vkInput == *pvk) { bValid = true; break; }
	};

	SetConsoleMode(m_hin, dwInputMode);				// Restore input mode flags
	
	cursorInfo.bVisible = TRUE;						// Turn the cursor back on
	SetConsoleCursorInfo(m_hout, &cursorInfo);		// Restore the cursor state
		
	return vkInput;
}