Click here to Skip to main content
16,012,061 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Unmanaged Threading Pin
Joe Woodbury13-Jun-06 13:07
professionalJoe Woodbury13-Jun-06 13:07 
GeneralRe: Unmanaged Threading Pin
Arvind Bharti13-Jun-06 20:23
Arvind Bharti13-Jun-06 20:23 
GeneralRe: Unmanaged Threading Pin
Joe Woodbury13-Jun-06 21:19
professionalJoe Woodbury13-Jun-06 21:19 
GeneralRe: Unmanaged Threading Pin
Sarath C13-Jun-06 19:40
Sarath C13-Jun-06 19:40 
GeneralRe: Unmanaged Threading Pin
Jun Du14-Jun-06 4:15
Jun Du14-Jun-06 4:15 
QuestionCButton, BS_BITMAP, LoadImage Issue and Question. Pin
Maximilien13-Jun-06 10:38
Maximilien13-Jun-06 10:38 
QuestionRe: CButton, BS_BITMAP, LoadImage Issue and Question. Pin
David Crow13-Jun-06 10:43
David Crow13-Jun-06 10:43 
QuestionWriteConsole() problem Pin
CoffeeAddict1913-Jun-06 10:00
CoffeeAddict1913-Jun-06 10:00 
I'm have a problem using the Win32 WriteConsole() function. It's just printing random characters, but I'm not getting any compiler errors. Can you take a look?

Client code:
<br />
//global class defenitions:<br />
MainWindowManagement MainConsole;<br />
<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
	MainConsole.SwitchBuffers(1);<br />
	MainConsole.WriteStreamBuffer1<<"It dosen't work!\n";<br />
	MainConsole.WriteStreamBuffer2<<"No sh*t!\n";<br />
	MainConsole.WriteStreamToBuffer(1);<br />
	MainConsole.SetBufferCursorPos(2, 20, 20);<br />
	MainConsole.WriteStreamToBuffer(2);<br />
	MainConsole.SwitchBuffers(2);<br />
	cin.get();<br />
<br />
	return 0;<br />
}<br />

Specification file for higher level class (directly below):
<br />
class MainWindowManagement<br />
{<br />
public:<br />
	MainWindowManagement(); //defalut constructor<br />
	MainWindowManagement(string NewWindowTitle); //optional constructor<br />
	void WriteStreamToBuffer(int BufferNum); :sigh:<br />
	void SwitchBuffers(int BufferNum); //sets the active output buffer<br />
	void SetWindowFillColor(PrintColorType NewFillColor); //set new fill color for window<br />
	void SetBufferTextColor(int BufferNum, PrintColorType NewTextColorFore, PrintColorType NewTextColorBack); //set new text color for buffer<br />
	void SetBufferCursorPos(int BufferNum, int NewX, int NewY);<br />
	void SetWindowTitle(string NewWindowTitle); //set new title for window<br />
	void SetWindowSize(int NewX, int NewY); //set new window size<br />
	void SetBufferSize(int NewX, int NewY); //set new buffer size<br />
	string ReturnCurrentWindowTitle() const;<br />
	PrintColorType ReturnCurrentFillColor() const;<br />
	PrintColorType ReturnCurrentTextColor() const;<br />
	stringstream WriteStreamBuffer1;// (stringstream::out); X| <br />
	stringstream WriteStreamBuffer2;// (stringstream::out); X| <br />
protected:<br />
	MainWindowSpecs ConsoleBuffer1;<br />
	MainWindowSpecs ConsoleBuffer2;<br />
	Win32WindowInfo MainConsoleWindowInfo;<br />
private:<br />
	int CurrentlyActiveBuffer;<br />
};<br />

Upper level write function:
<br />
void MainWindowManagement::WriteStreamToBuffer(int BufferNum)<br />
{<br />
	switch(BufferNum)<br />
	{<br />
	case 1	:	ConsoleBuffer1.WriteBuffer(WriteStreamBuffer1);<br />
				break;<br />
	case 2	:	ConsoleBuffer2.WriteBuffer(WriteStreamBuffer2);<br />
				break;<br />
	default	:	cerr<<"Client error. Invalid buffer number [1,2]."<<endl;<br />
				break;<br />
	}<br />
}<br />

Specification file for lower level class:
<br />
class MainWindowSpecs<br />
{<br />
public:<br />
	MainWindowSpecs(); //defalut constructor<br />
	Win32StandardHandles ReturnHandles() const; //returns the current windows handles<br />
	bool ReturnHandleErrorState() const; //returns error state of handles, true means they are running fine<br />
	void WriteBuffer(stringstream &TextToWrite); //writes text to buffer<br />
	void RefreshHandles(); //gets new handles<br />
	void SetBufferInfo(int NewXCord, int NewYCord, PrintColorType ForeColor, PrintColorType BackColor, SetBufferType BufferAction); //sets buffer info<br />
	void RefreshBufferInfo(); //refreshes buffer info<br />
	void SetToActiveBuffer(); //sets this console to the active buffer<br />
	CONSOLE_SCREEN_BUFFER_INFO ReturnConsoleBufInfo(); //returns buffer info<br />
protected:<br />
private:<br />
	int SetBufferInfoSetFont(PrintColorType ForeColorToSet, PrintColorType BackColorToSet); //used by SetBufferInfo() to set color<br />
	bool StdHandleErrorState; //error state of the handles, true means they are running fine<br />
	Win32StandardHandles StandardHandles;<br />
	CONSOLE_SCREEN_BUFFER_INFO ConsoleBufInfo;<br />
};<br />

The lower level WriteBuffer() function:
<br />
void MainWindowSpecs::WriteBuffer(stringstream &TextToWrite)<br />
{<br />
	DWORD NumCharsWritten;<br />
	string Text;<br />
<br />
	Text = TextToWrite.str();<br />
<br />
	WriteConsole(StandardHandles.hOut, &TextToWrite, Text.length(), &NumCharsWritten, NULL); :mad:<br />
	if(Text.length() != NumCharsWritten)<br />
		cerr<<"All characters were not written."<<endl;<br />
}<br />

QuestionRe: WriteConsole() problem Pin
David Crow13-Jun-06 10:06
David Crow13-Jun-06 10:06 
AnswerRe: WriteConsole() problem Pin
CoffeeAddict1914-Jun-06 5:45
CoffeeAddict1914-Jun-06 5:45 
QuestionRe: WriteConsole() problem Pin
David Crow14-Jun-06 5:52
David Crow14-Jun-06 5:52 
QuestionNewbie needs help generating html files from user input via windows gui [modified] Pin
dstrain13-Jun-06 9:35
dstrain13-Jun-06 9:35 
AnswerRe: Newbie needs help generating html files from user input via windows gui Pin
Mark F.14-Jun-06 4:54
Mark F.14-Jun-06 4:54 
Questionlaunching notepad.exe and reading the current date/time Pin
Mahhouraaaaaa13-Jun-06 8:30
Mahhouraaaaaa13-Jun-06 8:30 
AnswerRe: launching notepad.exe and reading the current date/time [modified] Pin
Mark F.13-Jun-06 8:59
Mark F.13-Jun-06 8:59 
AnswerRe: launching notepad.exe and reading the current date/time Pin
Hamid_RT13-Jun-06 19:07
Hamid_RT13-Jun-06 19:07 
AnswerRe: launching notepad.exe and reading the current date/time Pin
Laxman Auti13-Jun-06 19:30
Laxman Auti13-Jun-06 19:30 
QuestionC++ Forum Pin
knoxplusplus13-Jun-06 8:24
knoxplusplus13-Jun-06 8:24 
QuestionHello a problem with Cstring :) Pin
Mahhouraaaaaa13-Jun-06 6:16
Mahhouraaaaaa13-Jun-06 6:16 
AnswerRe: Hello a problem with Cstring :) Pin
Neil Van Eps13-Jun-06 6:17
Neil Van Eps13-Jun-06 6:17 
GeneralRe: Hello a problem with Cstring :) Pin
Mahhouraaaaaa13-Jun-06 6:23
Mahhouraaaaaa13-Jun-06 6:23 
JokeRe: Hello a problem with Cstring :) Pin
Laxman Auti13-Jun-06 19:32
Laxman Auti13-Jun-06 19:32 
QuestionGUID array assignment issue Pin
act_x13-Jun-06 5:51
act_x13-Jun-06 5:51 
Questionaccessing a networked hard drive Pin
69 Bay13-Jun-06 5:50
69 Bay13-Jun-06 5:50 
AnswerRe: accessing a networked hard drive Pin
David Crow13-Jun-06 6:00
David Crow13-Jun-06 6:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.