Files
Avancerad_CPP/Lab7/ntconsle.cpp
2026-03-05 13:16:26 +01:00

122 lines
3.4 KiB
C++

//## begin module.cm preserve=no
// %X% %Q% %Z% %W%
//## end module.cm
//## begin module.cp preserve=no
//## end module.cp
//## Module: NTConsole; Pseudo Package body
//## Subsystem: lab7
//## Source file: H:\kurs\avC++\lab7\NTConsle.cpp
//## begin module.additionalIncludes preserve=no
//## end module.additionalIncludes
//## begin module.includes preserve=yes
//## end module.includes
// NTConsole
#include "NTConsle.h"
//## begin module.additionalDeclarations preserve=yes
#include <iostream.h>
#include <windows.h>
//## end module.additionalDeclarations
// Class NTConsole
NTConsole::NTConsole()
//## begin NTConsole::NTConsole%.hasinit preserve=no
//## end NTConsole::NTConsole%.hasinit
//## begin NTConsole::NTConsole%.initialization preserve=yes
//## end NTConsole::NTConsole%.initialization
{
//## begin NTConsole::NTConsole%.body preserve=yes
//## end NTConsole::NTConsole%.body
}
NTConsole::~NTConsole()
{
//## begin NTConsole::~NTConsole%.body preserve=yes
//## end NTConsole::~NTConsole%.body
}
//## Other Operations (implementation)
void NTConsole::drawWindow (int xpos, int ypos, int width, int height, char* name)
{
//## begin NTConsole::drawWindow%940929802.body preserve=yes
HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
COORD ul;
char buff[] = " ";
LPVOID param;
DWORD written=0;
ul.X = xpos;
ul.Y = ypos;
SetConsoleCursorPosition(h,ul);
SetConsoleTextAttribute(h,FOREGROUND_GREEN|FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_INTENSITY|BACKGROUND_BLUE|BACKGROUND_INTENSITY);
// Print "titlebar"
WriteConsole(h,buff,strlen(buff),&written,param);
WriteConsole(h,name,strlen(name),&written,param);
for(int j=0; j<(width-strlen(name)-1); j++)
WriteConsole(h,buff,strlen(buff),&written,param);
// Print the rest if the window
SetConsoleTextAttribute(h,FOREGROUND_BLUE|FOREGROUND_INTENSITY|BACKGROUND_BLUE|BACKGROUND_GREEN|BACKGROUND_RED);
for(int i=1; i<height; i++){
ul.X = xpos;
ul.Y = ypos+i;
SetConsoleCursorPosition(h,ul);
for(j=0; j<width; j++)
WriteConsole(h,buff,strlen(buff),&written,param);
}
cout << endl;
//## end NTConsole::drawWindow%940929802.body
}
void NTConsole::drawButton (int xpos, int ypos, int width, int height, char* text)
{
//## begin NTConsole::drawButton%940929803.body preserve=yes
HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
COORD ul;
char buff[] = " ";
LPVOID param;
DWORD written=0;
ul.X = xpos;
ul.Y = ypos;
SetConsoleCursorPosition(h,ul);
SetConsoleTextAttribute(h,FOREGROUND_GREEN|FOREGROUND_RED|FOREGROUND_BLUE|BACKGROUND_BLUE|BACKGROUND_GREEN|BACKGROUND_RED|BACKGROUND_INTENSITY);
WriteConsole(h,buff,strlen(buff),&written,param);
WriteConsole(h,text,strlen(text),&written,param);
for(int j=0; j<(width-strlen(text)-1); j++)
WriteConsole(h,buff,strlen(buff),&written,param);
for(int i=1; i<height; i++){
ul.X = xpos;
ul.Y = ypos+i;
SetConsoleCursorPosition(h,ul);
for(j=0; j<width; j++)
WriteConsole(h,buff,strlen(buff),&written,param);
}
//## end NTConsole::drawButton%940929803.body
}
// Additional Declarations
//## begin NTConsole.declarations preserve=yes
//## end NTConsole.declarations
//## begin module.epilog preserve=yes
//## end module.epilog