|
Hi All,
I am developing one 'Text editor' kind of application. I want to put a menu item for showing the line numbers.
Can any one please tell me how can i show the line numbers ???
Regards,
Sanjeeva K Kanakam.
|
|
|
|
|
Erm... you're not going to get any useful answers without giving more information.
How are you displaying the text? If you're drawing it yourself, then I'm sure you have the skill to use TextOut / DrawText and turn a number into a string.
If you're using a rich text control, then have a look at some of the articles on CP. I remember Mr Rosengren's article have line numbers in them.
If you're doing another way, then you'll still need to tell us.
Good luck,
Iain.
|
|
|
|
|
Will your editor be based on some sort of an edit control?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Can you more explain,please?
|
|
|
|
|
Does anybody know how to work with libww(the open source w3c library for network programming)?
I'm trying to use it to build a HTTP proxy server, since it provides a lot of APIs for parsing,generating and handling HTTP.
Any help will be really appreciated..
|
|
|
|
|
Hi all,
Still I'm learning C++ and I'll try my best used most better ways in my works.
When I'm coding, I mean use of try, catch or if, else etc..., always used a single line of code. Here it is...
cout << "Error. GetLastError reports " << GetLastError() << endl;
In simple word find the error code and correct way. If I'm working on MFC, cout replaced by a message box.
My question is what is the best way to display errors for users. Displaying error codes is not prefer for users. Is that a separate section in C++, handling errors/exceptions.
I appreciate your help all the time...
Eranga
|
|
|
|
|
This kind of error reporting is simple and clean, well suited for the developer.
Usually the user expects a more friendly approach, like a text message, anyway I suggest you to always report the error number together with such message.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
CPallini wrote: This kind of error reporting is simple and clean, well suited for the developer.
Yes it is. All the time I use it and depend on that, and try to corrected errors as much possible.
CPallini wrote: Usually the user expects a more friendly approach, like a text message
That is why I really looking for it. I found on MSDN FormatMessage function used in Windows. But seems it is more complicated at the time for me. I'll try to figure it out.
CPallini wrote: I suggest you to always report the error number together with such message.
Ok, actually there is only a word "Error" depend on the code I change it, "Error in opening file." or something like that.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Eranga Thennakoon wrote: That is why I really looking for it. I found on MSDN FormatMessage function used in Windows. But seems it is more complicated at the time for me
You're right. Luckily enough, they give sample code using it.
http://msdn2.microsoft.com/en-us/library/ms680582(VS.85).aspx[^]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Yep....
I appreciate your help all the time...
Eranga
|
|
|
|
|
Eranga Thennakoon wrote: But seems it is more complicated...
What's complicated about calling one function to retrieve a message?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Well, to his (and mine) justification, I have to say FormatMessage hasn't the most appealing prototype I ever seen.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
Eranga Thennakoon wrote: Displaying error codes is not prefer for users.
According to me users are most probably not bothered about exact the reason behind the error. So what I used to do was telling the user about failure happened in simple sentence and add some message that is helpful for the developer.
For example, see this error message.
Fatal Error<br />
Error: Could not load the image file.<br />
Failed to load the image in CMainWindow::InitInstance.
What I noted that, user who is getting the error will inform the developer (ofcourse not directly) that the program ceased to work and shows a message as ...
So the developer got a chance to identify the problem while sitting in his seat.
PS: This may not be feasible for large scale productions. But for small scale of productions I have found it is useful.
|
|
|
|
|
That is right. Most of the time users are not worried about the error message, only looking available options like Retry, Abort, Cancel etc...
I appreciate your help all the time...
Eranga
|
|
|
|
|
Eranga Thennakoon wrote: only looking available options like Retry, Abort, Cancel etc...
|
|
|
|
|
I would suggest displaying both the error code and the error description for a couple of reasons. First, IME, numeric error codes are likely to be read back to a support person correctly as opposed to a possibly long error message text. Some users find it insulting when you have to keep asking them to "read back the error message exactly as shown," and even then may skip a word or paraphrase.
Second, if being used on a non-English version of Windows, the error message text may be unfamiliar to your support staff, but the error code will remain the same.
I tend to format errors as follows: [ActionAndOrContext]:[ErrorCode]-[ErrorMessage] . Examples:
Unable to open the data file: 5-Access is denied.
Unable to process the data file: 8-Not enough storage is available to process this command. If you are writing a Windows GUI application (using MFC or not), I would suggest using Message Boxes.
Lastly - do not forget (Correct) logging. Having an accurate log of what took place before an error is invaluable.
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Ok thanks a lot.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Hello everyone,
What is wrong with the code, I just want to allocate an array of 100 void* pointers.
int main()
{
void** p;
p = new (void*) [100];
return 0;
}
d:\visual studio 2008\projects\test_void1\test_void1\main.cpp(5) : error C2143: syntax error : missing ';' before '['
d:\visual studio 2008\projects\test_void1\test_void1\main.cpp(5) : error C3409: empty attribute block is not allowed
d:\visual studio 2008\projects\test_void1\test_void1\main.cpp(5) : error C2143: syntax error : missing ']' before 'constant'
d:\visual studio 2008\projects\test_void1\test_void1\main.cpp(5) : error C2143: syntax error : missing ';' before 'constant'
d:\visual studio 2008\projects\test_void1\test_void1\main.cpp(5) : error C2143: syntax error : missing ';' before ']'
d:\visual studio 2008\projects\test_void1\test_void1\main.cpp(5) : error C2143: syntax error : missing ';' before ']'
thanks in advance,
George
|
|
|
|
|
Just remove the paranthesis.
|
|
|
|
|
Thanks Cedric,
Your solution works! Why adding an additional () will block compiler?
regards,
George
|
|
|
|
|
George_George wrote: Why adding an additional () will block compiler?
The bigger question is, why would you think they'd be necessary?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi DavidCrow,
I want to allocate 100 void* type, so I add () besides void*, it is natural thinking, right?
regards,
George
|
|
|
|
|
George_George wrote: it is natural thinking, right?
How would you allocate 100 ints or chars?
int *n = new int[100];
int *c = new char[100]; Why would void* be any different?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi DavidCrow,
The same for int*. Here is my code,
int main()
{
int** p;
p = new (int*) [100];
delete[] p;
return 0;
}
regards,
George
|
|
|
|
|
George_George wrote: p = new (int*) [100];
You've already been told this will not work. Why do you continue to suggest it should?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|