Пример #1
0
/*
 * call-seq:
 *   io.winsize = [rows, columns]
 *
 * Tries to set console size.  The effect depends on the platform and
 * the running environment.
 *
 * You must require 'io/console' to use this method.
 */
static VALUE
console_set_winsize(VALUE io, VALUE size)
{
    rb_io_t *fptr;
    rb_console_size_t ws;
#if defined _WIN32
    HANDLE wh;
    int newrow, newcol;
#endif
    VALUE row, col, xpixel, ypixel;
    const VALUE *sz;
    int fd;

    GetOpenFile(io, fptr);
    size = rb_Array(size);
    rb_check_arity(RARRAY_LENINT(size), 2, 4);
    sz = RARRAY_CONST_PTR(size);
    row = sz[0], col = sz[1], xpixel = sz[2], ypixel = sz[3];
    fd = GetWriteFD(fptr);
#if defined TIOCSWINSZ
    ws.ws_row = ws.ws_col = ws.ws_xpixel = ws.ws_ypixel = 0;
#define SET(m) ws.ws_##m = NIL_P(m) ? 0 : (unsigned short)NUM2UINT(m)
    SET(row);
    SET(col);
    SET(xpixel);
    SET(ypixel);
#undef SET
    if (!setwinsize(fd, &ws)) rb_sys_fail(0);
#elif defined _WIN32
    wh = (HANDLE)rb_w32_get_osfhandle(fd);
#define SET(m) new##m = NIL_P(m) ? 0 : (unsigned short)NUM2UINT(m)
    SET(row);
    SET(col);
#undef SET
    if (!NIL_P(xpixel)) (void)NUM2UINT(xpixel);
    if (!NIL_P(ypixel)) (void)NUM2UINT(ypixel);
    if (!GetConsoleScreenBufferInfo(wh, &ws)) {
	rb_syserr_fail(LAST_ERROR, "GetConsoleScreenBufferInfo");
    }
    if ((ws.dwSize.X < newcol && (ws.dwSize.X = newcol, 1)) ||
	(ws.dwSize.Y < newrow && (ws.dwSize.Y = newrow, 1))) {
	if (!SetConsoleScreenBufferSize(wh, ws.dwSize)) {
	    rb_syserr_fail(LAST_ERROR, "SetConsoleScreenBufferInfo");
	}
    }
    ws.srWindow.Left = 0;
    ws.srWindow.Top = 0;
    ws.srWindow.Right = newcol;
    ws.srWindow.Bottom = newrow;
    if (!SetConsoleWindowInfo(wh, FALSE, &ws.srWindow)) {
	rb_syserr_fail(LAST_ERROR, "SetConsoleWindowInfo");
    }
#endif
    return io;
}
Пример #2
0
int main(int argc, char* argv[])

{
	/*
	char arg[200]={0};
	arg[0]='\"';
	strcpy(arg+1, argv[0]);
	int len=int(strlen(arg));
	arg[len]='\"';
	
	HWND hWnd=FindWindow(NULL, arg); //找到程序运行窗口的句柄
	HDC hDC=GetDC(hWnd);//通过窗口句柄得到该窗口的设备场境句柄
	HPEN hPen, hOldPen; //画笔
	int j=0;
	
	for(; j<500; ++j)
		SetPixel(hDC, 10+j, 10+j, 0x0000ff);//用画点的办法画一根线,最后一个参数是颜色(32位)
	hPen=CreatePen(PS_SOLID, 2, 0x00ff00);//生成绿色画笔
	hOldPen=(HPEN)SelectObject(hDC, hPen);//把画笔引入设备场境
	
	MoveToEx(hDC, 20, 50, NULL); //设置画线起点
	LineTo(hDC, 520, 550);      //画到终点
	
	Arc(hDC, 100, 100, 300, 300, 350, 500, 350, 500);//画圆
	
	SelectObject(hDC, hOldPen);
	
	//下面是对比,表明它确实是控制台程序
	
	printf("hello console");
	system("pause");
*/
	HANDLE   hOut   =   GetStdHandle(STD_OUTPUT_HANDLE);  
	//   获取标准输出设备句柄  
	CONSOLE_SCREEN_BUFFER_INFO   bInfo;   //   窗口缓冲区信息  
	GetConsoleScreenBufferInfo(hOut,   &bInfo   );  
	//   获取窗口缓冲区信息  
	
	SetConsoleTextAttribute(hOut,   FOREGROUND_GREEN);  
	char   strTitle[255];  
	GetConsoleTitle(strTitle,   255);   //   获取窗口标题  
	printf("当前窗口标题是:%s\n",   strTitle);  
	_getch();  
	SetConsoleTitle("控制台窗口操作");   //   获取窗口标题  
	_getch();  
	COORD   size   =   {80,   25};  
	SetConsoleScreenBufferSize(hOut,size);   //   重新设置缓冲区大小  
	_getch();  
	SMALL_RECT   rc   =   {0,0,   80-1,   25-1};   //   重置窗口位置和大小  
	SetConsoleWindowInfo(hOut,true   ,&rc);  
    CloseHandle(hOut);   //   关闭标准输出设备句柄   

	
	
}
void WinConsoleHelper::SetConsoleSize(int x, int y)
{
	UpdateCSBI();
	COORD windowSize = { csbi.srWindow.Right - csbi.srWindow.Left + 1, csbi.srWindow.Bottom - csbi.srWindow.Top + 1 };
	if (windowSize.X > x || windowSize.Y > y)
	{
		SMALL_RECT info =
		{
			0,
			0,
			x < windowSize.X ? x - 1 : windowSize.X - 1,
			y < windowSize.Y ? y - 1 : windowSize.Y - 1
		};

		SetConsoleWindowInfo(hStdOut, TRUE, &info);
	}
	SMALL_RECT info = { 0, 0, x - 1, y - 1 };
	SetConsoleScreenBufferSize(hStdOut, { (SHORT)x, (SHORT)y });
	SetConsoleWindowInfo(hStdOut, TRUE, &info);
}
Пример #4
0
void SetConsoleInfo()
{
    HANDLE      hConsole    = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD       BufferSize  = {108, 320};
    SMALL_RECT  WinRect     = {0, 0, BufferSize.X - 1, 27};

    SetConsoleScreenBufferSize(hConsole, BufferSize);
    SetConsoleWindowInfo(hConsole, true, &WinRect);
    SetConsoleTextAttribute(hConsole, FOREGROUND_GREEN);

}
Пример #5
0
/* get the display metrics */
void ossgmx(int *max_linep, int *max_columnp)
{
    CONSOLE_SCREEN_BUFFER_INFO info;

    /* get the console handle */
    G_out_bufhdl = GetStdHandle(STD_OUTPUT_HANDLE);

    /* get the size of the screen and return it to the caller's variables */
    if (GetConsoleScreenBufferInfo(G_out_bufhdl, &info))
    {
        /* 
         *   If it's scrolled down, scroll it to the top.  If the screen
         *   buffer size is larger than the window size, reduce the buffer
         *   size to match the window size: we do all of the scrolling
         *   ourselves, so we don't want to do that on top of a separate
         *   scrolling canvas managed by the system. 
         */
        if (!os_f_plain
            && (info.srWindow.Top != 0 || info.srWindow.Left != 0
                || info.dwSize.X > info.srWindow.Right + 1
                || info.dwSize.Y > info.srWindow.Bottom + 1))
        {
            COORD buf_size;
            
            /* scroll it to the top left */
            info.srWindow.Bottom -= info.srWindow.Top;
            info.srWindow.Top = 0;
            info.srWindow.Right -= info.srWindow.Left;
            info.srWindow.Left = 0;
            SetConsoleWindowInfo(G_out_bufhdl, TRUE, &info.srWindow);

            /* remember the original buffer size */
            S_orig_buffer_size = info.dwSize;

            /* set the window buffer size to equal the window size */
            buf_size.X = info.srWindow.Right + 1;
            buf_size.Y = info.srWindow.Bottom + 1;
            SetConsoleScreenBufferSize(G_out_bufhdl, buf_size);
        }
        
        /* got the information - use the current window size */
        *max_columnp = info.srWindow.Right - info.srWindow.Left;
        *max_linep = info.srWindow.Bottom - info.srWindow.Top;
    }
    else
    {
        /* failed to get info - use default sizes */
        *max_columnp = 79;
        *max_linep = 24;
    }

    /* note the screen width for our own use */
    S_scrwid = info.dwMaximumWindowSize.X;
}
Пример #6
0
// sets the size of the console
void setConsoleSize(unsigned short consoleWidth, unsigned short consoleHeight)
{
    SMALL_RECT windowSize = {0, 0, consoleWidth-1, consoleHeight-1};
    COORD buffSize = {consoleWidth, consoleHeight};

    HANDLE hConsole = hScreenBuffer;//GetStdHandle( STD_OUTPUT_HANDLE );
    BOOL bSuccess = SetConsoleWindowInfo(hConsole, TRUE, &windowSize);
    PERR( bSuccess, "SetConsoleWindowInfo" );
    bSuccess = SetConsoleScreenBufferSize(hConsole, buffSize);
	PERR( bSuccess, "SetConsoleWindowInfo" );
}
Пример #7
0
void Win32EnableConsole()
{
    int consoleHandle;
    long stdHandle;
    CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
    FILE *file;

    const int bufferSize = 500;

    // allocate a console for this app
    AllocConsole();

    // set the screen buffer to be big enough to let us scroll text

    GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &consoleInfo);
    consoleInfo.dwSize.Y = bufferSize;
    SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), consoleInfo.dwSize);

    // redirect unbuffered STDOUT to the console
    stdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
    consoleHandle = _open_osfhandle(stdHandle, _O_TEXT);
    file = _fdopen(consoleHandle, "w");
    *stdout = *file;
    setvbuf(stdout, NULL, _IONBF, 0);

    // redirect unbuffered STDIN to the console
    stdHandle = (long)GetStdHandle(STD_INPUT_HANDLE);
    consoleHandle = _open_osfhandle(stdHandle, _O_TEXT);
    file = _fdopen(consoleHandle, "r");
    *stdin = *file;
    setvbuf(stdin, NULL, _IONBF, 0);

    // redirect unbuffered STDERR to the console
    stdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);
    consoleHandle = _open_osfhandle(stdHandle, _O_TEXT);
    file = _fdopen(consoleHandle, "w");
    *stderr = *file;
    setvbuf(stderr, NULL, _IONBF, 0);

    // make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog point to console as well
    std::ios::sync_with_stdio();

    GetConsoleScreenBufferInfo((HANDLE)consoleHandle, &consoleInfo);
    consoleInfo.srWindow.Top = 800;
    SetConsoleWindowInfo((HANDLE)consoleHandle, false, &consoleInfo.srWindow);
    
/*
    SetWindowPos(
        (HWND)GetStdHandle(STD_OUTPUT_HANDLE),
        HWND_TOP,
        1920+100, 800,
        500, 200,
        SWP_NOSIZE | SWP_SHOWWINDOW);*/
    }
Пример #8
0
/*-----------------------------------------------------------------------------
  Console: Static Functions
  ---------------------------------------------------------------------------*/
static void SetWindowSize(HANDLE hOut, int height, int width)
{
	COORD		coPos = {(SHORT)width, (SHORT)height};
	SMALL_RECT  sr	  = {0, 0, (SHORT)(width-1), (SHORT)(height-1)};
	
	if (SetConsoleWindowInfo(hOut, TRUE, &sr) == 0) {
		fprintf(stderr, "error: SetConsoleWindowInfo: %ld\n", GetLastError());
	}
	if (SetConsoleScreenBufferSize(hOut, coPos) == 0) {
		fprintf(stderr, "error: SetConsoleScreenBufferSize: %ld\n", GetLastError());
	}
}
Пример #9
0
/******************************************************************************
 * SetConsoleCursorPosition [KERNEL32.@]
 * Sets the cursor position in console
 *
 * PARAMS
 *    hConsoleOutput   [I] Handle of console screen buffer
 *    dwCursorPosition [I] New cursor position coordinates
 *
 * RETURNS STD
 */
BOOL WINAPI SetConsoleCursorPosition(HANDLE hcon, COORD pos)
{
    BOOL 			ret;
    CONSOLE_SCREEN_BUFFER_INFO	csbi;
    int				do_move = 0;
    int				w, h;

    TRACE("%x %d %d\n", hcon, pos.X, pos.Y);

    SERVER_START_REQ(set_console_output_info)
    {
        req->handle         = hcon;
        req->cursor_x       = pos.X;
        req->cursor_y       = pos.Y;
        req->mask           = SET_CONSOLE_OUTPUT_INFO_CURSOR_POS;
        ret = !wine_server_call_err( req );
    }
    SERVER_END_REQ;

    if (!ret || !GetConsoleScreenBufferInfo(hcon, &csbi))
	return FALSE;

    /* if cursor is no longer visible, scroll the visible window... */
    w = csbi.srWindow.Right - csbi.srWindow.Left + 1;
    h = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
    if (pos.X < csbi.srWindow.Left)
    {
	csbi.srWindow.Left   = min(pos.X, csbi.dwSize.X - w);
	do_move++;
    }
    else if (pos.X > csbi.srWindow.Right)
    {
	csbi.srWindow.Left   = max(pos.X, w) - w + 1;
	do_move++;
    }
    csbi.srWindow.Right  = csbi.srWindow.Left + w - 1;

    if (pos.Y < csbi.srWindow.Top)
    {
	csbi.srWindow.Top    = min(pos.Y, csbi.dwSize.Y - h);
	do_move++;
    }
    else if (pos.Y > csbi.srWindow.Bottom)
    {
	csbi.srWindow.Top   = max(pos.Y, h) - h + 1;
	do_move++;
    }
    csbi.srWindow.Bottom = csbi.srWindow.Top + h - 1;

    ret = (do_move) ? SetConsoleWindowInfo(hcon, TRUE, &csbi.srWindow) : TRUE;

    return ret;
}
Пример #10
0
int main()
{
	//////////
	//Setup///
	//////////
	srand( (unsigned)time(0) );	
	Combat* pCombat = new Combat();	
	Report* pDamageReport = new Report( "damage_report.txt" );				
	pDamageReport->mFile.open( pDamageReport->getFilename(), ios::out | ios::app );
	Report* pInitReport   = new Report( "init_report.txt",   false, 1  );	
	pDamageReport->addToReport( "Damage Report\n\n"         );
	pInitReport->addToReport(   "Initialization Report\n\n" );
	pDamageReport->mFile.close();
	
	COORD newConsoleSize = {82,45};										//Resized the console so a more detailed output
	SMALL_RECT rDisplayArea = {0,0,0,0};								//of damage values, criticals, ability names,
	SetConsoleScreenBufferSize( pCombat->getHandle(), newConsoleSize );	//mana costs, and Damage Over Time ticks
	rDisplayArea.Right = newConsoleSize.X - 1;							//could be seen on screen without scrolling
	SetConsoleWindowInfo( pCombat->getHandle(), true, &rDisplayArea );	
	
	Unit* pPlayer = pCombat->charInit();									
	Boss* pBoss = new Boss();												
	pCombat->units = pCombat->enemyInit( GameFunctions::getNumEnemies() );	
	pInitReport->initReport( pPlayer, pCombat->units );						//Output name, health, mana, armor, abilities and their names and values
																			//for player and units vector of enemies
	pCombat->storyMsg( pPlayer->getPlayerName() );	

	stringstream initString;
	initString << "\nPrinting Story Message. Function call: storyMsg( pPlayer->getPlayerName() )"
	    	   << "\nSetting up Game Loop variables..."
			   << "\nDetermining Combat Order..."
			   << "\nEntering Game Loop...";
	pInitReport->addToReport( initString.str() );

	pInitReport->addToReport( "\nStarting Combat..." );		//Final output, switching to Combat report: pDamageReport
	pCombat->startGameCombat( pPlayer, pBoss, pDamageReport, pCombat->units );
	
	delete pPlayer;
	pPlayer= NULL;
	delete pBoss;
	pBoss = NULL;
	delete pCombat;
	pCombat = NULL;
	delete pDamageReport;
	pDamageReport = NULL;
	delete pInitReport;
	pInitReport = NULL;

	cin.ignore( 1000, '\n' );
	cin.get();
	return 0;
}
Пример #11
0
static int init_buffer(HANDLE b)
{
  /* Set console size */
  COORD newSize = {W*2, H+1};
  SetConsoleScreenBufferSize(b, newSize);

  SMALL_RECT newWinSize;
  newWinSize.Left = 0;
  newWinSize.Top = 0;
  newWinSize.Right = W*2-1;
  newWinSize.Bottom = H;
  return SetConsoleWindowInfo(b, TRUE, &newWinSize);
}
Пример #12
0
void Setting::showWindow() {
    HANDLE out_handle = GetStdHandle(STD_OUTPUT_HANDLE);
    SMALL_RECT src = {0, 0, this->getWindowWidth() - 1, this->getWindowHeight() - 1};
    SetConsoleWindowInfo (out_handle, true, &src);
    COORD coord = {this->getWindowWidth(), this->getWindowHeight()};
    SetConsoleScreenBufferSize (out_handle, coord);
    SetConsoleTitle(this->windowTitle.c_str());
    std::string buff;
    buff.append("color");
    buff.append(" ");
    buff.append(this->windowColor);
    system(buff.c_str());
}
Пример #13
0
/* 
	Have to remember where i ripped this code sometime ago.

*/
static void ResizeConsole( HANDLE hConsole, SHORT xSize, SHORT ySize ) {   
	CONSOLE_SCREEN_BUFFER_INFO csbi; // Hold Current Console Buffer Info 
	BOOL bSuccess;   
	SMALL_RECT srWindowRect;         // Hold the New Console Size 
	COORD coordScreen;    
	
	bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );
	
	// Get the Largest Size we can size the Console Window to 
	coordScreen = GetLargestConsoleWindowSize( hConsole );
	
	// Define the New Console Window Size and Scroll Position 
	srWindowRect.Right  = (SHORT)(min(xSize, coordScreen.X) - 1);
	srWindowRect.Bottom = (SHORT)(min(ySize, coordScreen.Y) - 1);
	srWindowRect.Left   = srWindowRect.Top = (SHORT)0;
	
	// Define the New Console Buffer Size    
	coordScreen.X = xSize;
	coordScreen.Y = ySize;
	
	// If the Current Buffer is Larger than what we want, Resize the 
	// Console Window First, then the Buffer 
	if( (DWORD)csbi.dwSize.X * csbi.dwSize.Y > (DWORD) xSize * ySize)
	{
		bSuccess = SetConsoleWindowInfo( hConsole, TRUE, &srWindowRect );
		bSuccess = SetConsoleScreenBufferSize( hConsole, coordScreen );
	}
	
	// If the Current Buffer is Smaller than what we want, Resize the 
	// Buffer First, then the Console Window 
	if( (DWORD)csbi.dwSize.X * csbi.dwSize.Y < (DWORD) xSize * ySize )
	{
		bSuccess = SetConsoleScreenBufferSize( hConsole, coordScreen );
		bSuccess = SetConsoleWindowInfo( hConsole, TRUE, &srWindowRect );
	}
	
	// If the Current Buffer *is* the Size we want, Don't do anything! 
	return;
   }
Пример #14
0
/*
 * call-seq:
 *   io.winsize = [rows, columns]
 *
 * Tries to set console size.  The effect depends on the platform and
 * the running environment.
 *
 * You must require 'io/console' to use this method.
 */
static VALUE
console_set_winsize(VALUE io, VALUE size)
{
    rb_io_t *fptr;
    rb_console_size_t ws;
#if defined _WIN32
    HANDLE wh;
    int newrow, newcol;
#endif
    VALUE row, col, xpixel, ypixel;
#if defined TIOCSWINSZ
    int fd;
#endif

    GetOpenFile(io, fptr);
    size = rb_Array(size);
    rb_scan_args((int)RARRAY_LEN(size), RARRAY_PTR(size), "22",
                &row, &col, &xpixel, &ypixel);
#if defined TIOCSWINSZ
    fd = GetWriteFD(fptr);
    ws.ws_row = ws.ws_col = ws.ws_xpixel = ws.ws_ypixel = 0;
#define SET(m) ws.ws_##m = NIL_P(m) ? 0 : (unsigned short)NUM2UINT(m)
    SET(row);
    SET(col);
    SET(xpixel);
    SET(ypixel);
#undef SET
    if (!setwinsize(fd, &ws)) rb_sys_fail(0);
#elif defined _WIN32
    wh = (HANDLE)rb_w32_get_osfhandle(GetReadFD(fptr));
    newrow = (SHORT)NUM2UINT(row);
    newcol = (SHORT)NUM2UINT(col);
    if (!getwinsize(GetReadFD(fptr), &ws)) {
	rb_sys_fail("GetConsoleScreenBufferInfo");
    }
    if ((ws.dwSize.X < newcol && (ws.dwSize.X = newcol, 1)) ||
	(ws.dwSize.Y < newrow && (ws.dwSize.Y = newrow, 1))) {
	if (!(SetConsoleScreenBufferSize(wh, ws.dwSize) || SET_LAST_ERROR)) {
	    rb_sys_fail("SetConsoleScreenBufferInfo");
	}
    }
    ws.srWindow.Left = 0;
    ws.srWindow.Top = 0;
    ws.srWindow.Right = newcol;
    ws.srWindow.Bottom = newrow;
    if (!(SetConsoleWindowInfo(wh, FALSE, &ws.srWindow) || SET_LAST_ERROR)) {
	rb_sys_fail("SetConsoleWindowInfo");
    }
#endif
    return io;
}
Пример #15
0
static void init()
{
    SetConsoleTitleA("CONSOLE PLAYER");
    COORD size = {80, 25};
    SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), size);
    SMALL_RECT rect = {0, 0, 80, 25};
    SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), false, &rect);
    fmodwrap::Open();
    create_list();
    player = fmodwrap::CreatePlayer();
    player->set_endcallback(on_play_end);
    fmodwrap::master_volume(0.5f);
    current_sound = restore_list_log();
}
Пример #16
0
void Consola::setScreenSize(int nLinhas, int nCols) {
	COORD tam;
	SMALL_RECT DisplayArea;

	tam.X = nCols;
	tam.Y = nLinhas;
	SetConsoleScreenBufferSize(hconsola, tam);   // isto muda o tamanho da matriz de caracteres

	DisplayArea.Top = 0;
	DisplayArea.Left = 0;
	DisplayArea.Bottom = nLinhas-1;
	DisplayArea.Right = nCols-1;
    SetConsoleWindowInfo(hconsola, TRUE, &DisplayArea);  // isto muda o tamanho da area da janela em caracteres
}
Пример #17
0
Console::Console()
{
	Cursor.X = 0;
	Cursor.Y = 0;
	::AllocConsole();
	ConsoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
	system("mode CON: COLS=100 LINES=135");//画面サイズ設定
	freopen("CONIN$","r",stdin);  // 標準入力を割り当てる
	freopen("CONOUT$","w",stdout);  // 標準出力を割り当てる
	SetConsoleTitle("Debug");
	SMALL_RECT rect = {0,0,60,20};
	SetConsoleWindowInfo(ConsoleHandle,TRUE,&rect);
	_Active = false;
}
Пример #18
0
		void update_handle() {
			if (_handle == nullptr || _handle == INVALID_HANDLE_VALUE) 
				_handle = ::CreateConsoleScreenBuffer(GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CONSOLE_TEXTMODE_BUFFER, NULL);
			assert(_handle != INVALID_HANDLE_VALUE);
			DWORD dwMode = 0;
			GetConsoleMode(_handle, &dwMode);
			dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING | ENABLE_PROCESSED_OUTPUT;
			if (_scroll) dwMode |= ENABLE_WRAP_AT_EOL_OUTPUT;
			SetConsoleMode(_handle, dwMode);
			SMALL_RECT rect = { 0,0, short(_width - 1),short(_height - 1) };
			SetConsoleWindowInfo(_handle, TRUE,&rect);
			GetConsoleScreenBufferInfo(_handle, &info);
			_screen_buffer.resize(_width*_height);
		}
Пример #19
0
BOOL CScreen::InitiateScreen(int X, int Y, DWORD cursor_size, BOOL cursor_visable){

	m_cScreenSize.X = X;
	m_cScreenSize.Y = Y;

	CHAR_INFO tempChar;
	tempChar.Char.UnicodeChar = ' ';
	tempChar.Attributes = 0;

	for(int i = 0; i < X * Y; i++){
        m_pDrawn.push_back(tempChar);
	}

	SMALL_RECT screenArea;
	screenArea.Top = 0;
	screenArea.Left = 0;
	screenArea.Right = m_cScreenSize.X - 1;
	screenArea.Bottom = m_cScreenSize.Y - 1;

	CONSOLE_CURSOR_INFO cursor = {cursor_size, cursor_visable};

	m_hBuff1 = GetStdHandle(STD_OUTPUT_HANDLE);
	m_hBuff2 = CreateConsoleScreenBuffer(GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CONSOLE_TEXTMODE_BUFFER, NULL);

	SetConsoleScreenBufferSize(m_hBuff1, m_cScreenSize);
	SetConsoleScreenBufferSize(m_hBuff2, m_cScreenSize);

	SetConsoleCursorInfo(m_hBuff1, &cursor);
	SetConsoleCursorInfo(m_hBuff2, &cursor);

	SetConsoleWindowInfo(m_hBuff1, TRUE, &screenArea);
	SetConsoleWindowInfo(m_hBuff2, TRUE, &screenArea);

	m_hpBuffSwap = &m_hBuff2;

	return TRUE;
}
Пример #20
0
/*
  LetterSpace: SetConsoleScreenBufferSize and SetConsoleWindowInfo are
	dependent on each other, that's the reason for the additional checks.  
*/
void ConsoleListener::BufferWidthHeight(int BufferWidth, int BufferHeight, int ScreenWidth, int ScreenHeight, bool BufferFirst)
{
#ifdef _WIN32
	BOOL SB, SW;
	if (BufferFirst)
	{
		// Change screen buffer size
		COORD Co = {BufferWidth, BufferHeight};
		SB = SetConsoleScreenBufferSize(hConsole, Co);
		// Change the screen buffer window size
		SMALL_RECT coo = {0,0,ScreenWidth, ScreenHeight}; // top, left, right, bottom
		SW = SetConsoleWindowInfo(hConsole, TRUE, &coo);
	}
	else
	{
		// Change the screen buffer window size
		SMALL_RECT coo = {0,0, ScreenWidth, ScreenHeight}; // top, left, right, bottom
		SW = SetConsoleWindowInfo(hConsole, TRUE, &coo);
		// Change screen buffer size
		COORD Co = {BufferWidth, BufferHeight};
		SB = SetConsoleScreenBufferSize(hConsole, Co);
	}
#endif
}
Пример #21
0
VALUE
rb_SetConsoleWindowInfo( VALUE self, VALUE hConsoleOutput, VALUE bAbsolute, 
			 VALUE left, VALUE top, VALUE right, VALUE bottom )
{
   HANDLE handle = ULongToPtr( NUM2ULONG( hConsoleOutput ) );
   
   SMALL_RECT rect;
   rect.Left   = NUM2INT( left );
   rect.Top    = NUM2INT( top );
   rect.Right  = NUM2INT( right );
   rect.Bottom = NUM2INT( bottom );
   if (SetConsoleWindowInfo( handle, NUM2INT( bAbsolute ), &rect ))
      return UINT2NUM(1);
   return rb_getWin32Error();
}
Пример #22
0
void SFDebugConsole::MoveConsole(int x, int y)
{
	Cons_Handle = FindWindow(NULL, CName);

	if(!Cons_Handle == NULL)
		MoveWindow(Cons_Handle, 500, 500, 200, 100, true);
	else
	{
		Cons_Handler = GetStdHandle(STD_OUTPUT_HANDLE);
		SMALL_RECT size = { 0, 0, 200, 100 };
		SetConsoleWindowInfo(Cons_Handler, true, &size);
		COORD coord = { x, y };
		SetConsoleCursorPosition(Cons_Handler, coord);
	}
}
Пример #23
0
void WindowsConsole::setDimensions(short w, short h) {
	HANDLE hCon = GetStdHandle( STD_OUTPUT_HANDLE );
	SMALL_RECT size;
	COORD b_size;

	size.Left = 0;
	size.Top = 0;
	size.Right = w - 1;
	size.Bottom = h - 1;
	b_size.X = w;
	b_size.Y = h;

	SetConsoleWindowInfo( hCon , true , & size );
	SetConsoleScreenBufferSize( hCon , b_size );
}
Пример #24
0
void Console::SetWindowPosition(int16_t left, int16_t top) const
{
	// Window position can never be negative
	if((left < 0) || (top < 0)) throw Exception(E_INVALIDARG);

	// Adjust the current window SMALL_RECT based on the new left and top
	SMALL_RECT window = ScreenBufferInfo(*this).srWindow;
	window.Bottom -= (window.Top - top);
	window.Right -= (window.Left - left);
	window.Left = left;
	window.Top = top;

	// Attempt to set the new console window position
	if(!SetConsoleWindowInfo(m_stdout, TRUE, &window)) throw Win32Exception();
}
Пример #25
0
/******************************************************************
 *		WCUSER_ApplyCurrent
 *
 *
 */
static void WCUSER_ApplyCurrent(struct dialog_info* di, HWND hDlg, enum WCUSER_ApplyTo apply, DWORD val)
{
    switch (apply)
    {
    case WCUSER_ApplyToCursorSize:
        {
            CONSOLE_CURSOR_INFO cinfo;
            cinfo.dwSize = val;
            cinfo.bVisible = di->config->cursor_visible;
            /* this shall update (through notif) curcfg */
            SetConsoleCursorInfo(di->data->hConOut, &cinfo);
        }
        break;
    case WCUSER_ApplyToHistorySize:
        di->config->history_size = val;
        WINECON_SetHistorySize(di->data->hConIn, val);
        break;
    case WCUSER_ApplyToHistoryMode:
        WINECON_SetHistoryMode(di->data->hConIn, val);
        break;
    case WCUSER_ApplyToMenuMask:
        di->config->menu_mask = val;
        break;
    case WCUSER_ApplyToEditMode:
        di->config->quick_edit = val;
        break;
    case WCUSER_ApplyToFont:
        {
            LOGFONT lf;
            WCUSER_FillLogFont(&lf, di->font[val].faceName,
                               di->font[val].height, di->font[val].weight);
            WCUSER_SetFont(di->data, &lf);
        }
        break;
    case WCUSER_ApplyToAttribute:
        di->config->def_attr = val;
        SetConsoleTextAttribute(di->data->hConOut, val);
        break;
    case WCUSER_ApplyToBufferSize:
        /* this shall update (through notif) curcfg */
        SetConsoleScreenBufferSize(di->data->hConOut, *(COORD*)val);
        break;
    case WCUSER_ApplyToWindow:
        /* this shall update (through notif) curcfg */
        SetConsoleWindowInfo(di->data->hConOut, FALSE, (SMALL_RECT*)val);
        break;
    }
}
Пример #26
0
void lConsole::ChangeWindowsize(uint16_t Width, uint16_t 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.
}
Пример #27
0
//***********************************************************
//  This replaces the CXL function of the same name
//***********************************************************
void set_lines(int crt_lines)
   {
   // COORD dwSize = { 80, crt_lines } ;
   // SetConsoleScreenBufferSize(hStdOut, dwSize) ;
   
   //  The preceding method changes the actual buffer size,
   //  not the window size, which may not be what is wanted
   //  under WinNT.  This method changes the actual window
   //  size, but positions the new window at the *top* of
   //  the screen buffer, which may give unexpected results
   //  if used with "don't clear screen" in a large window.
   //  Neither method is exactly correct in all cases,
   //  but will probably suffice most times...
   SMALL_RECT newwin = { 0, 0, 79, crt_lines-1 } ;
   SetConsoleWindowInfo(hStdOut, TRUE, &newwin) ;
   }
Пример #28
0
/*
===============================================================================
   Funktion:      initi()
   in:            -
   out:           -
   Beschreibung:  Initialisiert die Größe des Konsolenfensters
===============================================================================
*/
void initi(void)
{
   // Konsolenfenstergröße einstellen
   HANDLE ConsoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
   BOOL Result;

   if (ConsoleHandle != INVALID_HANDLE_VALUE)
   {
      SMALL_RECT ConsoleRectangle;
      // Größe und Position der Konsole in Zeilen und Spalten
      ConsoleRectangle.Top = 0;
      ConsoleRectangle.Bottom = 60;
      ConsoleRectangle.Left = 0;
      ConsoleRectangle.Right = 75;
      Result = SetConsoleWindowInfo(ConsoleHandle, TRUE, &ConsoleRectangle);
   }
}
Пример #29
0
void Config::ConsoleConfig()
{
	//Declare variables
	HANDLE H;
	HWND hWnd;
	//Get handle
	H = GetStdHandle(STD_OUTPUT_HANDLE);
	//Set the coordinates for the buffer size
	COORD UsersCoord = {161, 51};

	SetConsoleScreenBufferSize(H, UsersCoord);
	SMALL_RECT myWindow = {0, 0, 160, 50};
	SetConsoleWindowInfo(H, TRUE, &myWindow);

	//hWnd = GetConsoleWindow();
	//ShowWindow(hWnd,SW_SHOWMAXIMIZED);	
}
Пример #30
-1
void changeSize(){
	HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
	COORD coord;
	BOOL ok;
	coord.X = WINDOW_WIDTH;
	coord.Y = WINDOW_HEIGHT + 1;
	ok = SetConsoleScreenBufferSize(hStdout, coord);
	SMALL_RECT test = { 0, 0, coord.X - 1, coord.Y - 1 };
	SetConsoleWindowInfo(hStdout, ok, &test);
}