Archived

This topic is now archived and is closed to further replies.

Pipo DeClown

M$VC+=

Recommended Posts

Pipo DeClown    804
hi! I wanted to discuss M$VC+=. The reason is, that im getting lots of not-wanted code. When I use Console Functions like this:
int x=15,y=15;
HANDLE outh;
COORD pos={ x,y};
SetConsoleCursorPosition(outh,pos);
cout<<"haha";
 
Am I doing something wrong in my code, or are my settings wrong? Also when I''m using system("cls"); ,I get "cls" on the wrong moments! Can someone help me with this problem? _________________________________________________________________________ Can someone be nice and help me on my way to be the next Hideo Kojima? Thought So...

Share this post


Link to post
Share on other sites
siaspete    208
Firstly it''s called MSVC++. Unless there''s a huge typo on your box. It''s been known to happen, we have a GeForce 4 "gpaphics" card in work!

Anyway, you probably have to initialise your outh handle to something before using it. Lastly getting your cls at the wrong time probably has something to do with whenever your console output gets flushed. I think that using and << endl in your output may flush it before the cls (which is what you want) but there may be a nicer way.


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions

Share this post


Link to post
Share on other sites
Pipo DeClown    804
Code Here:


    
#include <windows.h>

int x=15,y=15;
HANDLE outputh,inputh;
COORD coord={x,y};

int main()
{


outputh = GetStdHandle(STD_OUTPUT_HANDLE);
inputh = GetStdHandle(STD_INPUT_HANDLE);
long unsigned char_char;
SetConsoleCursorPosition(outputh,coord);
WriteConsole(outputh,"Send Email",10,&char_char,NULL);
INPUT_RECORD IR;
long unsigned event;
bool a=true;
while (a){
ReadConsoleInput(inputh,&IR,1,&event);
if((IR.Event.MouseEvent.dwMousePosition.X>14 &&
IR.Event.MouseEvent.dwMousePosition.X<25) &&
IR.Event.MouseEvent.dwMousePosition.Y==15 &&
IR.Event.MouseEvent.dwEventFlags ==0){
ShellExecute( NULL, "open","mailto:rick_rackplayer@hotmail.com", NULL, NULL, SW_SHOWNORMAL);
a=false;

}}
system("CLS");
x=0;
y=0;

SetConsoleCursorPosition(outputh,coord);
WriteConsole(outputh,"QUIT",10,&char_char,NULL);

return 0;
}


however system("CLS") doesnt work......

[edit] nothing

[edited by - Pipo declown on June 9, 2002 12:21:52 PM]

Share this post


Link to post
Share on other sites
Fruny    1658
WIn32SDK help entry Q99261 Provides :


    
/* Standard error macro for reporting API errors */

#define PERR(bSuccess, api){if(!(bSuccess)) printf("%s:Error %d from %s on line %d\n", __FILE__, GetLastError(), api, __LINE__);}


void cls( HANDLE hConsole )
{
COORD coordScreen = { 0, 0 }; /* here's where we'll home the cursor */
BOOL bSuccess;
DWORD cCharsWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi; /* to get buffer info */
DWORD dwConSize; /* number of character cells in the current buffer */

/* get the number of character cells in the current buffer */
bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );
PERR( bSuccess, "GetConsoleScreenBufferInfo" );
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;

/* fill the entire screen with blanks */
bSuccess = FillConsoleOutputCharacter( hConsole, (TCHAR) ' ', dwConSize, coordScreen, &cCharsWritten );
PERR( bSuccess, "FillConsoleOutputCharacter" );

/* get the current text attribute */
bSuccess = GetConsoleScreenBufferInfo( hConsole, &csbi );
PERR( bSuccess, "ConsoleScreenBufferInfo" );

/* now set the buffer's attributes accordingly */
bSuccess = FillConsoleOutputAttribute( hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten );
PERR( bSuccess, "FillConsoleOutputAttribute" );

/* put the cursor at (0, 0) */

bSuccess = SetConsoleCursorPosition( hConsole, coordScreen );
PERR( bSuccess, "SetConsoleCursorPosition" );
return;
}


Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]


[edited by - Fruny on June 9, 2002 12:40:49 PM]

Share this post


Link to post
Share on other sites