[RESOLVED] the hidecaret() function isn't ok?
what i need for hide the caret?
Code:
bool GetCaretVisible()
{
return blCaretVisible;
}
void SetCaretVisible(bool Visible)
{
if (Visible==true)
{
ShowCaret(hwnd());
}
else
{
HideCaret( hwnd());
}
}
__declspec ( property ( put = SetCaretVisible, get = GetCaretVisible ) ) bool CaretVisible ;
the caret isn't hided, i test the GetLastError() and gives me 0(zero). so what i need for hide the caret?
(more 1 property for my class;))
Re: the hidecaret() function isn't ok?
At this rate, I might as well just post you my console class!:D As per other thread, when dealing with the console, you use console handles and not window handles and you do things the console way not the window way!
Code:
//Turn cursor on
DWORD CursorOn(HANDLE sout)
{
CONSOLE_CURSOR_INFO cur;
if (!GetConsoleCursorInfo(sout, &cur)) {
return (GetLastError());
}
cur.bVisible = TRUE;
return (!SetConsoleCursorInfo(sout, &cur) ? GetLastError() : 0);
}
//Turn cursor off
DWORD CursorOff(HANDLE sout)
{
CONSOLE_CURSOR_INFO cur;
if (!GetConsoleCursorInfo(sout, &cur)) {
return (GetLastError());
}
cur.bVisible = FALSE;
return (!SetConsoleCursorInfo(sout, &cur) ? GetLastError() : 0);
}
//Get cursor size
DWORD GetCursorSize(HANDLE sout, DWORD& size)
{
CONSOLE_CURSOR_INFO cur;
if (!GetConsoleCursorInfo(sout, &cur)) {
return (GetLastError());
}
size = cur.dwSize;
return (0);
}
//Set cursor size
DWORD SetCursorSize(HANDLE sout, DWORD size)
{
CONSOLE_CURSOR_INFO cur;
if (!GetConsoleCursorInfo(sout, &cur)) {
return (GetLastError());
}
cur.dwSize = size;
return (!SetConsoleCursorInfo(sout, &cur) ? GetLastError() : 0);
}
Re: the hidecaret() function isn't ok?
Quote:
Originally Posted by
2kaud
At this rate, I might as well just post you my console class!:D As per other thread, when dealing with the console, you use console handles and not window handles and you do things the console way not the window way!
Code:
//Turn cursor on
DWORD CursorOn(HANDLE sout)
{
CONSOLE_CURSOR_INFO cur;
if (!GetConsoleCursorInfo(sout, &cur)) {
return (GetLastError());
}
cur.bVisible = TRUE;
return (!SetConsoleCursorInfo(sout, &cur) ? GetLastError() : 0);
}
//Turn cursor off
DWORD CursorOff(HANDLE sout)
{
CONSOLE_CURSOR_INFO cur;
if (!GetConsoleCursorInfo(sout, &cur)) {
return (GetLastError());
}
cur.bVisible = FALSE;
return (!SetConsoleCursorInfo(sout, &cur) ? GetLastError() : 0);
}
//Get cursor size
DWORD GetCursorSize(HANDLE sout, DWORD& size)
{
CONSOLE_CURSOR_INFO cur;
if (!GetConsoleCursorInfo(sout, &cur)) {
return (GetLastError());
}
size = cur.dwSize;
return (0);
}
//Set cursor size
DWORD SetCursorSize(HANDLE sout, DWORD size)
{
CONSOLE_CURSOR_INFO cur;
if (!GetConsoleCursorInfo(sout, &cur)) {
return (GetLastError());
}
cur.dwSize = size;
return (!SetConsoleCursorInfo(sout, &cur) ? GetLastError() : 0);
}
thanks.
maybe you like these line(the last line):
Code:
bool GetCaretVisible()
{
return blCaretVisible;
}
void SetCaretVisible(bool Visible)
{
if (Visible==true)
{
CursorOn(handle());
}
else
{
CursorOff(handle());
}
blCaretVisible=Visible;
}
__declspec ( property ( put = SetCaretVisible, get = GetCaretVisible ) ) bool CaretVisible ;
thanks for all
Re: the hidecaret() function isn't ok?
Quote:
Originally Posted by
Cambalinho
thanks.
maybe you like these line(the last line):
Code:
__declspec ( property ( put = SetCaretVisible, get = GetCaretVisible ) ) bool CaretVisible ;
thanks for all
What's that? That line is not C++, and it certainly has nothing to do with the Windows API (the topic of this forum).
Regards,
Paul McKenzie
Re: the hidecaret() function isn't ok?
Quote:
Originally Posted by
Paul McKenzie
What's that? That line is not C++, and it certainly has nothing to do with the Windows API (the topic of this forum).
Regards,
Paul McKenzie
i think is C++;)
is for transform that 2 subs in properties;)
see that 2 subs?
GetCaretVisible() and SetCaretVisible(bool Visible). they are overloading subs, but the line:
Code:
__declspec ( property ( put = SetCaretVisible, get = GetCaretVisible ) ) bool CaretVisible ;
'transform' that 2 sub in 1 property: CaretVisible .
now is more easy to use:
Code:
Console a;
a.CaretVisible=false;
Sleep= 5000; //wait 5 seconds
a.CaretVisible=true;
a.Read(); //wait until press any key;)
is more easy to use... that's why i share;)
(but, of course, we can use that 2 subs too(GetCaretVisible() and SetCaretVisible(bool Visible)).
thanks for all
Re: the hidecaret() function isn't ok?
Quote:
Originally Posted by
Cambalinho
i think is C++;)
is for transform that 2 subs in properties;)
That last line of code is not C++, and it has nothing to do with the Windows API.
Regards,
Paul McKenzie
Re: the hidecaret() function isn't ok?
Quote:
Originally Posted by
Paul McKenzie
That last line of code is not C++, and it has nothing to do with the Windows API.
Regards,
Paul McKenzie
so isn't compatible with Dev C++\ANSI?
Re: the hidecaret() function isn't ok?
Quote:
Originally Posted by
Cambalinho
so isn't compatible with Dev C++\ANSI?
Dev C++ is not a C++ compiler. It is an integrated development environment. It uses an old version of gcc as the compiler (3.x).
Second, that code is not ANSI C++, unless you can create some sort of tricky macros to get that line of code to compile. If you want proof, try to create a small program and get that line to compile here:
http://www.compileonline.com/compile_cpp_online.php
Regards,
Paul McKenzie
Re: the hidecaret() function isn't ok?
Quote:
Originally Posted by
Paul McKenzie
Dev C++ is not a C++ compiler. It is an integrated development environment. It uses an old version of gcc as the compiler (3.x).
Second, that code is not ANSI C++, unless you can create some sort of tricky macros to get that line of code to compile. If you want proof, try to create a small program and get that line to compile here:
http://www.compileonline.com/compile_cpp_online.php
Regards,
Paul McKenzie
like you understand my experience with C++ isn't the best. so i can't create that line easly:(
maybe i can with temples, but i don't know how:(