|
try inserting a newline character in header name
|
|
|
|
|
I tried that and it didn't work.
|
|
|
|
|
|
I am not creating an MFC app, just a windows app. I am using the LVCOLUMN structure to create my listview.
|
|
|
|
|
Ok.
The point was, you can use custom draw to achieve this.
It's no different with MFC than without MFC, except where you handle the messages.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi again, I am using Visual Studio 2005 C++/CLI. I have a form that I want to display statistical information. There is a TextBox control on the form named textBox1. When I click on the menu selection to display the statistics form the following code is executed...
private: System::Void waferMapStatisticsToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e)
{
Stats^ statistics = gcnew Stats(); // instantiate a new statistics Form object
TextBox^ text_box = gcnew TextBox(); // instantiate a new TextBox object
text_box->Text::set("This is a test");
statistics->textBox1 = text_box; // this does set the value of textBox1 to "This is a test"
statistics->Text::set("DIALOG TITLE STRING"); // this does change the forms title
statistics->ShowDialog();
}
If I step through the code I can see that the value of the textBox1 control on the statistics Form changes, but when I ShowDialog() the statistics Form title changed but there is nothing displayed in textBox1. I have also tried using statistics->Update() and have tried setting the value of textBox1 through a property definiiton. The results are the same. This seems to be trivial and intuitive but alas. Does anyone know why the textBox1->Text is not displaying on the statistics Form?
Thanks
Buck
|
|
|
|
|
Hi Buck,
I don't know what statistics and statistics->textBox1 are.
My best guess is statistics is some kind of Form, and textBox1 is a public field,
of the TextBox^ kind.
If so the question is when do you add textBox1 to the statistics->Controls?
if you do that before you execute statistics->textBox1 = text_box;
then the original textbox is included in your form, and not the one you
intend to substitute just before the ShowDialog().
The solution would be to make textBox1 private (it is not a good idea to
make Controls public, only some aspects of it need to be public at most),
and to provide another public property to set its text.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi Luc,
Yes, statistics is a Form and textBox1 is a public field of the TextBox^ kind. I have tried this with textBox1 private and accessed through a public property with the same results. If I do statistics->Controls->Add(text_box), a TextBox control appears (where I dont want it) on the form when ShowDialog() is called. But I don't want to add a control, I want to change the text of an existing control. The Form designer in Visual Studio allows me to select TextBox controls from the toolbox and place them on the Form. The default names as they are placed on the Form would be textBox1, textBox2, etc, so these TextBox(es) already exist on the Form (I shouldn,t have to Add() them). All of the docs that I have read simply show changing the TextBox->Text:: property to whatever the text should be. And when I do that you can see (when executing the code one line at a time) the value of the TextBox changes to the text that I want it to be. It just does not appear when the Form is displayed (the TextBox control appears, just with no text in it).
Buck
|
|
|
|
|
Okay, this is the kind of crap that just drives me insane. Once I added the line 'statistics->Controls->Add(TextBox);' and saw that I got a TextBox where I did not want it, then everything began to behave the way I expected to in the first place. In other words, the code snipet in my original posting that would not display the text is NOW DISPLAYING THE TEXT! Lovely, I already have a ghost in my Microsoft machine, what else is new.
Buck
|
|
|
|
|
I can only get this to work using a public field. I can set up a property for TextBox but I haven't figured out how to set up a property for TextBox::Text.
Buck
|
|
|
|
|
Hi Buck,
I can't tell for sure since I have not seen enough of your code, but I am convinced
you have two textboxes where you only need and want one. Hence, the solution is to
get rid of the second one, then make the only one do what you want.
The proper way is through a property, the quick and dirty one is by making the control
public.
I couldn't create correct code for it right away, but it would look like any
other setter property, with a type of String^, where the new value gets assigned
to myTextBox->Text.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I stand corrected on my initial response. That chunk of code probably does not work. I think it had to do with the intellisense. My initial attempt (which turned out to be correct) was Form->textBox1->Text::set("string"); but when I typed the -> after textBox1 I did not get a list of properties supplied by the intellisense, nothing. This morning I did get a list of properties and everything was fine.
Buck
|
|
|
|
|
Yeah, the intellisense is starting to mess with me. I tried earlier to setup the property by assigning textBox1->Text = new_value, but I received no intellisense list after the ->. Now I do. I am under the impression that if intellisense doesn't "see" the -> association the compiler won't recognize it either. When this happened in VC++ 6.0 I would delete my .ncb file and rebuild the solution to get the intellisense working again. Is there a way to insure that the intellisense mechanism is working properly?
Thanks,
Works great, lasts a long time.
Buck
|
|
|
|
|
Hi Buck,
you would not get Intellisense (nor compilable code) when omitting a
using namespace line that you need to find a class.
other than that I don't know, I program in VS C# Express Edition 2005 and
Intellisense works well for me (in C# the class name turns blue if it has been
recognized, so black class is missing a "using" statement).
Wenever strange things happen during editing/building, I tend to delete the debug
folder (that is both obj and bin) and do a "rebuild all"; if bin contains some special
files my app needs, I have to be more selective of course.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi (Luc), I am using Visual Studio 2005 C++/CLI and I am having a problem with a constructor but it looks okay to me. Can anyone tell if this is because I am using a forward declaration?
namespace MySpace {
ref class Class2; // Here is the forward declaration
public ref class Class1 : Form
{
public: Class1(Form form) { Class1 constructor code here }
public: void Print()
{
Class2^ my_class2 = gcnew Class2^(this); // This is causing error
}
}; // end of Class1
public ref class Class2 : PrintDocument
{
public: Class2(Class1^ class_arg){ Class2 constructor code here }
}; // end of Class2
} // end of MySpace namespace
If the single line in the Print() function is remarked out this compiles fine but if it is unremarked out then I get a "no appropriate default constructor" error. I don't see what's wrong with this constructor, does anyone else?
Thanks
Buck
|
|
|
|
|
There's an extra ^ in there
Plus, the compiler won't be able to resolve the parameterized constructor.
Can you do something like this?
namespace MySpace {
public ref class Class1 : Form
{
public: Class1(Form form) { Class1 constructor code here }
public: void Print();
};
public ref class Class2 : PrintDocument
{
public: Class2(Class1^ class_arg){ Class2 constructor code here }
};
inline void Class1::Print()
{
Class2^ my_class2 = gcnew Class2(this);
}
}
Mark
Last modified: 12mins after originally posted --
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes, that did allow me to get the code to compile but it started as someone elses code and now I'm just confused as to why this was supposed to help. I just wanted my Print() and PrintPreview() to have the correct information (size wise) be displayed by PrintPreview() and printed by Print(). I think I'll ditch this whole idea for awhile.
Thanks
Buck
|
|
|
|
|
BuckBrown wrote: but it started as someone elses code and now I'm just confused as to why this was supposed to help
Fun fun!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
It seems I have been providing the fun here, I suggested Buck to look into
my Sokoban article for printing, but then that's in C# and does not know
about circular reference problems...
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
It gets worse when you start using Generics in C++/CLI in this situation!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi George, thanks for the warning. I haven't used generics much yet,
no problems so far...
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I guess you know how to keep yourself away from big issues; however, I don't. In certain situations, even with formal coding techniques, the compiler will still view your class (with a base clase of Foo ) as a basic ref class with just a base class of Object . The only way I was able to get the code to compile was to create an IFoo generic interface and made <class>Foo a Template class.
Geo
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
That's interesting. There's a bug where the C++/CLI compiler won't recognize that a managed array implements System::Array. The result is you can't pass a managed array to a function that takes an argument as IEnumerable<t>^ or something similar. What you're saying makes it sound like this bug might just be a more specific case of a general problem the C++/CLI compiler has with generics. Unless I'm misunderstanding you.
|
|
|
|
|
iddqd515 wrote: There's a bug where the C++/CLI compiler won't recognize that a managed array implements System::Array. The result is you can't pass a managed array to a function that takes an argument as IEnumerable^ or something similar. What you're saying makes it sound like this bug might just be a more specific case of a general problem the C++/CLI compiler has with generics.
I don't know if what I said applies to that. Nevertheless, translating C# code to C++/CLI may require some extensive hoop jumping. On the other hand, with the help of templates and other C++ idiosyncrasies, you can write code not possible in C#. Since I don't currently have time to write articles, I have been posting in my blog on Code Project some C++/CLI code and brief comments. I will be adding some code on this as soon as my wife allows me to. Any, any comments good, bad or indifferent are welcomed.
-- modified at 10:57 Tuesday 21st August, 2007
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
I forgot to read what I posted. I meant a function with an argument of the generic interface IEnumerable<T>^ not IEnumerable^. That's what prompted me to connect your problem with that bug. I'm about to try fiddling with it.
|
|
|
|