|
I have researched adding a MessageBox to an application. However the sealed class does not give you much. The solution is always to create your own.
I figure you could use the Win32 Version and import it into C#. but that does not take care of the background color. in MFC you call setdlgBackColor or something like that and the entire application is converted to the new color (skin).
in C# you do not have that. is this exposed in VB.NET? I was thinking I could link in a VB.NET DLL with the functionality.
still there are several dialogs in windows that act this way. one of them is the fileopen dialog.
does anyone have an elegant solution that does not involve recoding the entire functionality, LOL, of the dialog / MessageBox in question? there are many people on the web running into this problem, especially if they are skinning their apps or providing custom colors for customer requirements.
Thanks
-Pete
|
|
|
|
|
|
This is a great Article - Thanks!
I could not figure out how to change the background color though.
I did not see anything in the code of the project that allowed you to do that.
-Pete
|
|
|
|
|
peterdrozd wrote: I could not figure out how to change the background color though.
You could try posting your question on the article forum to see if the author has any idea. I suspect you may find it quicker just to use a custom dialog with all your own controls and formats.
|
|
|
|
|
You must have to write a custom control to do that...
|
|
|
|
|
Can anyone suggest me an open source and/or commercial winform control to display multi colored/format textbox (just like RichTextBox).
It doesn't need to be capable of doing syntax highlighting. Just enough to be able to manually format the text I append to it. I intend to use as a textbox to display process logging which every occurence of different info/status to be logged/appended to the textbox in different format (text color, bgcolor, bold, italic). E.g: Error message to be hilited red and bold.
I've tried using RichTextBox but when the text in it becomes large, it becomes noticeably slow to update the text.
Thanks
|
|
|
|
|
Ajakblackgoat wrote: I've tried using RichTextBox but when the text in it becomes large, it becomes noticeably slow to update the text.
That could grow to a large amount of data, and manipulating large amounts of data costs time. Swapping out the control won't bring much, as it still has to work with a large collection of data.
Substitute it for a textbox. It'll take a bit longer, but even that one will become slow eventually.
As an alternative; you could keep the list in a non-visual component, and only display the top 50 entries from that list.
--edit--
Luc's solution would be the better option; not only due to it's better performance, but also because you wouldn't need to cache things yourself
I are Troll
modified on Friday, January 8, 2010 8:37 AM
|
|
|
|
|
|
Thanks for your reply.
Rich text box control is a full featured control supporting rtf formatting which I do not need in what I want to achieve. I have seen textbox control in some application (such as regexbuddy & powergrep) which does what I need and it's very fast in displaying 100MB++ of text data complete with highlights and formatting. And I believe it's not richtextbox.
So I'm looking for something similar...
|
|
|
|
|
Ajakblackgoat wrote: it's very fast in displaying 100MB++ of text data complete with highlights and formatting. And I believe it's not richtextbox.
It's not the control that makes it fast, it's the way they handle loading. Doing formatting and highlighting on 100Mb+ costs time, but you don't have to highlight what you cannot see. I'd also imagine that such applications load the parts that they're actually working with, as opposed to loading the entire file into memory.
Still, the ListBox would be the way to go. My proposition may sound simpeler, but it really isn't. You'd always be manipulating a large (immutable!) blob of text that's somewhere in memory, while you'd be adding items to a collection if you're using a ListBox.
Further, a ListBox would paint the items that are actually visible, so you wouldn't have to format and highlight 100Mb at a time. You might have to spend some time on owner-drawing[^], but I think it's worth it
I are Troll
|
|
|
|
|
Eddy Vluggen wrote: It's not the control that makes it fast, it's the way they handle loading. Doing formatting and highlighting on 100Mb+ costs time, but you don't have to highlight what you cannot see. I'd also imagine that such applications load the parts that they're actually working with, as opposed to loading the entire file into memory.
Richtextbox doesn't handle it the same way?
Eddy Vluggen wrote: Still, the ListBox would be the way to go.
But still it lacks textbox-like select & copy functionality. I've already done ownerdrawn listbox for other projects, so you don't have to keep pushing me to use it. I know what it's limitation which hinders me from using it for this particular app.
Perhaps I didn't post my question clearly. I was asking if anyone had come across a control which does the same, not how to do it.
|
|
|
|
|
Ajakblackgoat wrote: Richtextbox doesn't handle it the same way?
Nope, a RichTextBox works with a large string that contains all it's data. It's like loading a large textfile into Notepad all at once. One has to read all the characters and count the returns to find line #40.
Ajakblackgoat wrote: But still it lacks textbox-like select & copy functionality.
It doesn't do that out of the box, you're right there. It would still be easier to add that, then to try and outperform it with a RTB.
Ajakblackgoat wrote: I know what it's limitation which hinders me from using it for this particular app.
The limitation is that you can't edit the items directly. If there's a lot of items being put into that component, then you won't have much chance of typing anyway.
Possible solutions would be showing an RTB on the place of the ListBoxItem (as Luc suggested), or a pop-up screen with details.
Ajakblackgoat wrote: Perhaps I didn't post my question clearly. I was asking if anyone had come across a control which does the same, not how to do it.
You're looking for a fast, editable list? I guess that there should be one or two out there
I are Troll
|
|
|
|
|
When the data is line-oriented, as in logging, I always use a ListBox, not a TextBox, since ListBox is line-oriented and scales well; TextBox and RichTextBox require all text to be concatenated and hence slow down when the amount of text increases.
ListBox has an OwerDrawn mode that enables you to paint the items any way you like, look here[^] for an example.
|
|
|
|
|
Thanks for your suggestion.
I already did listbox as my output log control for one of my apps and it serves just fine for that particular type of scenario.
But I need something that supports wrapping to cater longer text such as .net error messages, and user can select text and copy to clipboard (just like textbox), which I think will be tedious if possible to do with ListBox.
|
|
|
|
|
Ajakblackgoat wrote: which I think will be tedious if possible
Not at all. It depends on the details of course, but it is very easy to:
- have arbitrary length text in each item (DrawString can word-wrap text)
- variable height items (OwnerDrawVariable), which adds a MeasureItem event to determine height (with Graphics.MeasureString)
- intercept CTRL/C to get your ToString() representation of an entire item
It would get somewhat more complex if you also need to copy selectable parts of an item.
FWIW: you can add controls to a ListBox item, so you could have a (Rich)TextBox inside each item, however I would not do that, as the lightweight approach is easy enough and much cheaper resource wise.
|
|
|
|
|
I need to create a taskbar in the mdiform just looks like windows taskbar..... when i open a form the name should be displayed in the taskbar when i minimize it should hide on the taskbar....
|
|
|
|
|
how to set default user selected icon for windows application while deploying the windows application. when i installed my deployed win application i am getting default type(file) icon for installed application. can any one suggest step how to do............
|
|
|
|
|
If you're building a C# or VB.NET project, go to the Project menu, Properties, and you'll see an option to set the application's icon on the first page of the dialog that shows up.
|
|
|
|
|
I was not sure where to put this question so I am placing it here...
Has anyone any expedience with importing established NUint tests into VS 2008 to use in the native unit testing environment?
I thought at some point there used to be tons of information about how to accomplish this but I can't seem to locate it now and I really don't want to have to rebuild all my tests from scratch if I don't have to. It would be OK if I had to tweak a but, but re-writing several hundred would a bit of an arduous task and I really would like to get more integrated if I could.
|
|
|
|
|
There's this cool link here[^]. I've not tried these converters myself though.
There are only 10 types of people in this world — those who understand binary, and those who don't. |
|
|
|
|
|
Out of curiosity what are the advantages of doing this as opposed to leaving them as-is and just creating new tests in VSTS? Or does company policy require you to convert to MSTest?
Kevin
|
|
|
|
|
No really policy (yet)... I just know that we are going to be moving over to VSTS soon and figured that i would start prepping to get the unit tests moved over to being part of the solution in that format rather than what NUnit used.
|
|
|
|
|
Can someone tell me why there is an infinite loop below only in release mode? If I add a printf in the while loop, then the infinite loop disappears.
for (long i=1; i<(signed)Expiry_URLs.size(); i++)
DownloadStringInBackground2(gcnew System::String(Expiry_URLs[i].c_str()));
Process_Straddle_View(T, G_OPT, Error_Code); //ASSUMES THAT NO OTHER DOWNLOAD FINISHED BEFORE THIS RUNS
while (!!G_OPT.Running);
void DownloadStringCallback2( System::Object^ sender, System::Net::DownloadStringCompletedEventArgs^ e ) {
// If the request was not canceled and did not throw
// an exception, display the resource.
--G_OPT.Running;
if ( !e->Cancelled && e->Error == nullptr ) {
System::String^ textString = dynamic_cast<system::string^>(e->Result);
System::Console::WriteLine( textString );
}
}
void DownloadStringInBackground2( System::String^ address ) {
++G_OPT.Running;
System::Net::WebClient^ client = gcnew System::Net::WebClient;
System::Uri ^uri = gcnew System::Uri(address);
// Specify that the DownloadStringCallback2 method gets called
// when the download completes.
client->DownloadStringCompleted += gcnew System::Net::DownloadStringCompletedEventHandler( DownloadStringCallback2 );
client->DownloadStringAsync( uri );
}
|
|
|
|
|
You have an empty loop here, and it has 'eaten' all your processor in the release mode:
while (!!G_OPT.Running);
It's not a good way to do such loops for wait until other operation completes.
In such cases synchronization must be used, like events, or AsyncCallbacks.
|
|
|
|
|
In a xml file, there are some characters like ß (part of Schließen(Deutsch) ).
but when i had called the function XmlDocument.Load(), it was fail.
if delete the "ß", then success.
please tell me how to parse the xml file with some characters like ß.
|
|
|
|