当前位置: 首页>>代码示例>>C++>>正文


C++ SetConsoleCursorPosition函数代码示例

本文整理汇总了C++中SetConsoleCursorPosition函数的典型用法代码示例。如果您正苦于以下问题:C++ SetConsoleCursorPosition函数的具体用法?C++ SetConsoleCursorPosition怎么用?C++ SetConsoleCursorPosition使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SetConsoleCursorPosition函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: interrupt_test

bool interrupt_test(_WORD CardNr, string &ErrorMessage, bool ScreenOut, int loop)
{
	_DWORD Status	  = 0;
	_DWORD ErrorStatus = 0;
	_DWORD IntAktiv	  = 0;
	_WORD ErrorCounter = 0;

	_DWORD InMask; 
	_WORD myDta_Rdy = 0x2;
	_WORD myDta_Req = 0x4;

	_BYTE ErrorChar [24];

	string ausgabe;

	bool EVFifoNotEmpty = true;
	bool error = false;
	
	COORD coordScreen;

// -------------- Windows Version (NT oder 2000) ------------------

	OSVERSIONINFO lVerInfo;
	lVerInfo.dwOSVersionInfoSize = sizeof (lVerInfo);
	GetVersionEx (&lVerInfo);
	

// ----------------------------------------------------------------

	if(ScreenOut)
	{
		ClearScreen();
		InMask = 0x6; // Auf Dta_Rdy oder Dta_Req interrupten
	}
	else
	{
		InMask = 0x2; // Nur auf Dta_Rdy interrupten
	}

	PCI_PCIcardReset(CardNr, ErrorStatus);

	if(ScreenOut)
	{
		SetConsoleTextAttribute(hConsoleOut, BACKGROUND_BLUE | FOREGROUND_WHITE);   
		cout<<"Kleiner Interrupt Test auf Karten Nr.: "<<CardNr<<endl<<endl;
		SetConsoleTextAttribute(hConsoleOut, BACKGROUND_BLACK | FOREGROUND_WHITE);

		SetConsoleTextAttribute(hConsoleOut, BACKGROUND_RED | FOREGROUND_WHITE);   
		cout<<"Bitte einen Mil-Bus-Monitor mit der PCI-Mil-Karte verbinden.        "<<endl;
		cout<<"Mit den Tastern DRDY oder DREQ koennen interrupts ausgeloest werden."<<endl<<endl;

		SetConsoleTextAttribute(hConsoleOut, BACKGROUND_BLACK | FOREGROUND_WHITE);


		cout<<"Press Enter to go on...."<<endl;
		getchar();
		getchar();

		ClearScreen();
	}

	
	// Text Ausgabe
	// -------------
	if(ScreenOut)
	{
		SetConsoleTextAttribute(hConsoleOut, BACKGROUND_GREEN | FOREGROUND_RED);  
		cout<<"\nHinweis : Sollte der Rechner haengen bleiben, so koennte keine      "<<endl;

		coordScreen.X = 9;
		coordScreen.Y = 2;
		SetConsoleCursorPosition(hConsoleOut, coordScreen);
		
		cout<<" Verbindung zum Mil-Monitor da sein, ansonsten viel glueck."<<endl<<endl;
		SetConsoleTextAttribute(hConsoleOut, BACKGROUND_BLACK | FOREGROUND_WHITE);

		cout <<"Interrupts enabeln         :"<<endl;
		cout <<"Interrupt Maske definieren :"<<endl;
		cout <<"Wait interrupt             :"<<endl;
		cout <<"Interrupts disabeln        :"<<endl;
		cout <<""<<endl;

		coordScreen.X = 28;
		coordScreen.Y = 3;
		SetConsoleCursorPosition(hConsoleOut, coordScreen);
    }

	// Interrupts enabeln
	Status = PCI_IntEnable (CardNr, NULL, NULL, IntSetPriorityNormal,ErrorStatus);
	
	if(ScreenOut)
	{
		coordScreen.X = 28;
		coordScreen.Y = 4;
		SetConsoleCursorPosition(hConsoleOut, coordScreen);
	}

	if(Status != StatusOK)
	{
		if(ScreenOut)
//.........这里部分代码省略.........
开发者ID:zweig1971,项目名称:PCIMilCardDriver,代码行数:101,代码来源:interrupt_test.cpp

示例2: main


//.........这里部分代码省略.........
					case 10: hero->Armor = &(arcgmage_robe); break;
					case 11: hero->Armor = &(elven_armor); break;
				}
				if (status != 1){
					hero->health += hero->Armor->health;
					hero->damage += hero->Armor->damage;
					hero->mag_damage += hero->Armor->mag_damage;
					hero->mana += hero->Armor->mana;
					hero->magic_protect += hero->Armor->magic_protect;
					hero->armor += hero->Armor->armor;
					hero->critical_damage += hero->Armor->critical_damage - 1;
					hero->critical_chanse += hero->Armor->critical_chanse;
				}
				switch (Weapon_type)
				{
					case -1: status = -1; break;
					case 0: hero->Weapon = &(steel_sword); break;
					case 1: hero->Weapon = &(magic_stick); break;
					case 2: hero->Weapon = &(steel_dagger); break;
					case 3: hero->Weapon = &(great_sword); break;
					case 4: hero->Weapon = &(wood_scepter); break;
					case 5: hero->Weapon = &(thief_dagger); break;
				}
				if (status != -1){
					hero->health += hero->Weapon->health;
					hero->damage += hero->Weapon->damage;
					hero->mag_damage += hero->Weapon->mag_damage;
					hero->mana += hero->Weapon->mana;
					hero->magic_protect += hero->Weapon->magic_protect;
					hero->armor += hero->Weapon->armor;
					hero->attack_speed = hero->Weapon->attack_speed;
					hero->critical_damage += hero->Weapon->critical_damage - 1;
					hero->critical_chanse += hero->Weapon->critical_chanse;
				}
				true = 1;
				
			}
			else 
				printf("error input");
			fclose(fp);	
			break;
		case 2 : printRec(); goto metka;break;
		
	}
	
	
	while (true)
	{
		shop(hero, &(mage), &(warrior), &(thief));
		true = battle(hero, &(bot1), &(bot2), &(bot3));
		if (true == 2)
			;
		else if (true)
			printf("WIN\n");
		else
			printf("LOSE\n");
		getchar();
	}
	system("cls");
	posHead.X = 34;
	posHead.Y = 10;
	SetConsoleCursorPosition(hConsole, posHead);
	SetConsoleTextAttribute(hConsole, FOREGROUND_RED);
	puts("GAME OVER");
	posHead.Y = 11;
	SetConsoleCursorPosition(hConsole, posHead);
	printf("your result is %i", hero->gold);
	posHead.Y++;
	SetConsoleCursorPosition(hConsole, posHead);
	printf("enter your nickname\n");
	char nick[20];
	posHead.Y++;
	SetConsoleCursorPosition(hConsole, posHead);
	gets(nick);
	if (nick[0] == '\0')
		strcpy(nick, "noName");
	int record[10];
	char temp[10][20];
	FILE * fp = NULL;
	fp = fopen("reclab4.txt", "r");
	if (NULL == fp)
		return 0;
	for (int i = 0; i < 10; i++){
		fscanf(fp, "%i %s", &record[i], temp[i]);
		//printf("%i. %8i  %s\n", i + 1, record, nick);
		if (record[i] > hero->gold)
			p = i;
	}
	fclose(fp);
	fp = fopen("reclab4.txt", "w");
	for (int i = 0; i < 10; i++){
		if (p == i - 1)
			fprintf(fp, "%i %s\n", hero->gold, nick);
		fprintf(fp, "%i %s\n", record[i], temp[i]);
	}
	SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_GREEN);
	getchar();
	fclose(fp);
	return EXIT_SUCCESS;
}
开发者ID:antonmazun,项目名称:courses,代码行数:101,代码来源:main.c

示例3: gotoxy

int gotoxy(int x, int y)
{
    COORD cd;
    cd.X = x;cd.Y = y;
    return SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),cd);
}
开发者ID:KnowNo,项目名称:test-code-backup,代码行数:6,代码来源:[C++源码]象棋人机对战.cpp

示例4: gotoxy

void gotoxy(int x,int y)// a function controls the coordenates of the outputs
{
    coord.X=x;
    coord.Y=y;
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),coord);
}
开发者ID:MuhamedTaha,项目名称:X-O-game-project,代码行数:6,代码来源:main.c

示例5: ReadConsoleInput

/*!
    Adds all pending keyboard input to the internal buffer.   The
    implementation uses ReadConsoleInput() which is a non-blocking function.
    All non-keyboard events are ignored.
 */
void ConsoleInputBuffer::AddPendingInputToBuffer() {
  //
  // Read pending events
  //
  DWORD dwRead;
  INPUT_RECORD inRecords[128];
  ::ReadConsoleInput(GetStdHandle(STD_INPUT_HANDLE), &inRecords[0], 128, &dwRead);
  //
  // Process the events
  //
  for (unsigned int i = 0; i < dwRead; ++i) {
    if (inRecords[i].EventType == KEY_EVENT) {
      // Key events include non-character keys like SHIFT.  Filter
      // these out.
      const KEY_EVENT_RECORD& evt = inRecords[i].Event.KeyEvent;
      const char c = evt.uChar.AsciiChar;
      if (evt.bKeyDown) {
        if (c != 0) {
          // Unfortunately since keyboard input is being handled manually
          // behavior such as backspace needs to be manually emulated.
          if (c == '\b') {
            // Do not let the prompt be erased
            if (buffer_.empty())
              continue;

            // Emulate the default behavior by echoing the typed characters
            std::cout << c;

            HANDLE hStdOut = ::GetStdHandle(STD_OUTPUT_HANDLE);
            CONSOLE_SCREEN_BUFFER_INFO info;
            DWORD dwWritten;
            ::GetConsoleScreenBufferInfo(hStdOut, &info);
            ::WriteConsoleOutputCharacter(hStdOut, L" ", 1,
                info.dwCursorPosition, &dwWritten);
            buffer_.pop_back(); // pop the last character
          } else {
            // Emulate the default behavior by echoing the typed characters
            std::cout << c;

            // Add to the buffer
            buffer_ += c;
          }
        } else if (evt.wVirtualKeyCode == VK_UP ||
                   evt.wVirtualKeyCode == VK_DOWN) {
          // Move up/down the history
          bool up = (evt.wVirtualKeyCode == VK_UP);
          if (up) {
            if (history_index_ == 0)
              history_index_ = history_.size();
            else
              --history_index_;
          } else {
            if (history_index_ >= history_.size())
              history_index_ = 0;
            else
              ++history_index_;
          }
          std::string new_command;
          if (history_index_ < history_.size())
            new_command = history_[history_index_];
          // else empty string
          
          HANDLE hStdOut = ::GetStdHandle(STD_OUTPUT_HANDLE);
          CONSOLE_SCREEN_BUFFER_INFO info;
          ::GetConsoleScreenBufferInfo(hStdOut, &info);
          // Clear first
          std::wstring clearStr(buffer_.size(), L' ');
          COORD pos = info.dwCursorPosition;
          pos.X -= static_cast<short>(clearStr.size());
          DWORD dwWritten;
          ::WriteConsoleOutputCharacter(hStdOut, clearStr.c_str(),
                                        static_cast<DWORD>(clearStr.size()),
                                        pos, &dwWritten);
          // Set cursor to the beginning
          SetConsoleCursorPosition(hStdOut, pos);
          // Write the new line
          std::cout << new_command;
          buffer_ = new_command;
        }
      }
    }
  }
}
开发者ID:CEIT729,项目名称:sketchup-ruby-debugger,代码行数:88,代码来源:ConsoleInputBuffer.cpp

示例6: Position

void Position(int x, int y)
{
    COORD pos = { x - 1, y - 1 };
    HANDLE Out = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleCursorPosition(Out, pos);
}
开发者ID:jiangxincode,项目名称:FlappyBird,代码行数:6,代码来源:FlappyBird.cpp

示例7: Execute

int Execute(HANDLE hPlugin,char *CmdStr,int HideOutput,int Silent,int ShowTitle,char *ListFileName)
{
  STARTUPINFO si;
  PROCESS_INFORMATION pi;
  int ExitCode,ExitCode2,LastError;

  memset(&si,0,sizeof(si));
  si.cb=sizeof(si);

  HANDLE hChildStdoutRd,hChildStdoutWr;
  HANDLE StdInput=GetStdHandle(STD_INPUT_HANDLE);
  HANDLE StdOutput=GetStdHandle(STD_OUTPUT_HANDLE);
  HANDLE StdError=GetStdHandle(STD_ERROR_HANDLE);
  HANDLE hScreen=NULL;
  CONSOLE_SCREEN_BUFFER_INFO csbi;

  if (HideOutput)
  {
    SECURITY_ATTRIBUTES saAttr;
    saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
    saAttr.bInheritHandle = TRUE;
    saAttr.lpSecurityDescriptor = NULL;

    if (CreatePipe(&hChildStdoutRd, &hChildStdoutWr, &saAttr, 32768))
    {
      if (Silent)
      {
        /*hScreen=Info.SaveScreen(0,0,-1,0);
        Info.Text(2,0,LIGHTGRAY,GetMsg(MWaitForExternalProgram))*/;
      }
      else
      {
        hScreen=Info.SaveScreen(0,0,-1,-1);
        const char *MsgItems[]={"",GetMsg(MWaitForExternalProgram)};
        Info.Message(Info.ModuleNumber,0,NULL,MsgItems,
                      ARRAYSIZE(MsgItems),0);
      }
      SetStdHandle(STD_OUTPUT_HANDLE,hChildStdoutWr);
      SetStdHandle(STD_ERROR_HANDLE,hChildStdoutWr);
    }
    else
      HideOutput=FALSE;
  }
  else
  {
    Info.Control(hPlugin, FCTL_GETUSERSCREEN, NULL);
    GetConsoleScreenBufferInfo(StdOutput, &csbi);
    COORD C = { 0, csbi.dwCursorPosition.Y };
    SetConsoleCursorPosition(StdOutput, C);
  }


  DWORD ConsoleMode;
  GetConsoleMode(StdInput,&ConsoleMode);
  SetConsoleMode(StdInput,ENABLE_PROCESSED_INPUT|ENABLE_LINE_INPUT|
                 ENABLE_ECHO_INPUT|ENABLE_MOUSE_INPUT);

  char ExpandedCmd[MAX_COMMAND_LENGTH];
  ExpandEnvironmentStrings(CmdStr,ExpandedCmd,sizeof(ExpandedCmd));
  FSF.LTrim(ExpandedCmd); //$ AA 12.11.2001

  char SaveTitle[512];
  GetConsoleTitle(SaveTitle,sizeof(SaveTitle));
  if (ShowTitle)
    SetConsoleTitle(ExpandedCmd);

  /* $ 14.02.2001 raVen
     делать окошку minimize, если в фоне */
  if (Opt.Background)
  {
    si.dwFlags=si.dwFlags | STARTF_USESHOWWINDOW;
    si.wShowWindow=SW_MINIMIZE;
  }
  /* raVen $ */

  ExitCode2=ExitCode=CreateProcess(NULL,ExpandedCmd,NULL,NULL,HideOutput,
            (Opt.Background?CREATE_NEW_CONSOLE:0)|PriorityProcessCode[Opt.PriorityClass],
            NULL,NULL,&si,&pi);

  LastError=!ExitCode?GetLastError():0;
  if (HideOutput)
  {
    SetStdHandle(STD_OUTPUT_HANDLE,StdOutput);
    SetStdHandle(STD_ERROR_HANDLE,StdError);
    CloseHandle(hChildStdoutWr);
  }

  SetLastError(LastError);
  if(!ExitCode2 /*|| !FindExecuteFile(ExecuteName,NULL,0)*/) //$ 06.03.2002 AA
  {
    char Msg[100];
    char ExecuteName[NM];
    lstrcpyn(ExecuteName,ExpandedCmd+(*ExpandedCmd=='"'), NM);
    char *Ptr;
    Ptr=strchr(ExecuteName,(*ExpandedCmd=='"')?'"':' ');
    if(Ptr)
      *Ptr=0;
    FindExecuteFile(ExecuteName,NULL,0);

    char NameMsg[NM];
//.........这里部分代码省略.........
开发者ID:FarGroup,项目名称:FarManager,代码行数:101,代码来源:ArcMix.cpp

示例8: gotoXY

// TODO: 在 STDAFX.H 中
//引用任何所需的附加头文件,而不是在此文件中引用
void gotoXY( int x, int y )
{
	COORD pos = { x*2, y };
	SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), pos );
}
开发者ID:spiritpig,项目名称:myPracticeCode,代码行数:7,代码来源:stdafx.cpp

示例9: SetConsoleCursorPosition

void Consola::gotoxy(int x, int y) {
	COORD coord;
	coord.X = x;
	coord.Y = y;
	SetConsoleCursorPosition(hconsola,coord);
}
开发者ID:ricardopereira,项目名称:cpp.dominer,代码行数:6,代码来源:Consola.cpp

示例10: gotoxy

// Console cursor À̵¿.
void gotoxy(int x, int y)
{
	COORD pos = { static_cast< short >( x ), static_cast< short >( y ) };
	SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), pos );
}
开发者ID:elbaro,项目名称:BattleTetris,代码行数:6,代码来源:tetris.cpp

示例11: consoleGoTo

void consoleGoTo(short int x, short int y) {
	COORD pos = { x, y };
	HANDLE output = GetStdHandle(STD_OUTPUT_HANDLE);
	SetConsoleCursorPosition(output, pos);
}
开发者ID:LibelulaV,项目名称:Game_1D,代码行数:5,代码来源:console.cpp

示例12: gotoxy

void gotoxy(short x, short y) {
    COORD pos = {x, y};
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
开发者ID:surendra1008,项目名称:Networking-Encoding-Techniques,代码行数:4,代码来源:NRZencoding.c

示例13: SetConsoleCursorPosition

//-----------------------------------------------------------------------------
void graphics::set_cursor_pos(int xCo, int yCo)
{
	COORD cursor_pos = {xCo-1, yCo-1};
	SetConsoleCursorPosition(hConsole, cursor_pos);
}
开发者ID:skandhurkat,项目名称:Just-For-Fun,代码行数:6,代码来源:msConGra.cpp

示例14: gotoXY

void gotoXY(COORD c)
{
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),c);
}
开发者ID:lnsensible,项目名称:iOverslept,代码行数:4,代码来源:console.cpp

示例15: buf


//.........这里部分代码省略.........
    }

    bool bResult=__hide_alloc_console();
	while((gConWnd = GetConsoleWindow()) == NULL) {
		Sleep(10);
	}
    assert(gConWnd);

	if (!bResult){
		while (!IsWindowVisible(gConWnd)) {
			Sleep(10);
		}
		while(IsWindowVisible(gConWnd)) {
			ShowWindow(gConWnd, SW_HIDE);
			Sleep(10);
		}
	}

    SetConsoleTitle(title.c_str());

    SetConsoleCtrlHandler(sig_handler, TRUE);

    SECURITY_ATTRIBUTES sa;
    sa.nLength = sizeof(sa);
    sa.lpSecurityDescriptor = NULL;
    sa.bInheritHandle = TRUE;

    gStdIn  = CreateFile(L"CONIN$",  GENERIC_READ|GENERIC_WRITE,
            FILE_SHARE_READ|FILE_SHARE_WRITE,
            &sa, OPEN_EXISTING, 0, NULL);
    if(!gStdIn){
        return(FALSE);
    }

    gStdOut = CreateFile(L"CONOUT$",  GENERIC_READ|GENERIC_WRITE,
            FILE_SHARE_READ|FILE_SHARE_WRITE,
            &sa, OPEN_EXISTING, 0, NULL);
    if(!gStdOut){
        return(FALSE);
    }

    gStdErr = CreateFile(L"CONOUT$",  GENERIC_READ|GENERIC_WRITE,
            FILE_SHARE_READ|FILE_SHARE_WRITE,
            &sa, OPEN_EXISTING, 0, NULL);
    if(!gStdErr){
        return(FALSE);
    }

    HINSTANCE hLib = LoadLibraryW( L"KERNEL32.DLL" );
    if (hLib == NULL)
        goto done;

#define GetProc( proc ) \
    do { \
        proc = (proc##T)GetProcAddress( hLib, #proc ); \
        if (proc == NULL) \
        goto freelib; \
    } while (0)
    GetProc( GetConsoleFontInfo );
    GetProc( GetNumberOfConsoleFonts );
    GetProc( SetConsoleFont );
#undef GetProc

    {
        CONSOLE_FONT font[MAX_FONTS];
        DWORD fonts = GetNumberOfConsoleFonts();
        if (fonts > MAX_FONTS){
            fonts = MAX_FONTS;
        }

        GetConsoleFontInfo(gStdOut, 0, fonts, font);
        CONSOLE_FONT minimalFont = { 0, {0, 0}};
        for(DWORD i=0;i<fonts;i++){
            if(minimalFont.dim.X < font[i].dim.X && minimalFont.dim.Y < font[i].dim.Y)
                minimalFont = font[i];
        }
        SetConsoleFont(gStdOut, minimalFont.index);
    }
freelib:
    FreeLibrary( hLib );
done:

    /* set buffer & window size */
    SMALL_RECT sr = {0,0,0,0};
    SetConsoleWindowInfo(gStdOut, TRUE, &sr);
    COORD size;
    size.X = 80;;
    size.Y = 24 + 500;
    SetConsoleScreenBufferSize(gStdOut, size);
    sr.Left = 0;
    sr.Right = 80-1;
    sr.Top = size.Y - 24;
    sr.Bottom = size.Y-1;
    SetConsoleWindowInfo(gStdOut, TRUE, &sr);
    size.X = sr.Left;
    size.Y = sr.Top;
    SetConsoleCursorPosition(gStdOut, size);

    return true;
}
开发者ID:ousttrue,项目名称:ckw-mod,代码行数:101,代码来源:console.cpp


注:本文中的SetConsoleCursorPosition函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。