|
1. The OpenFileDialog and SaveFileDialog let you interact with the user to determine which file he wants opened or saved, that is not what you want.
2. There is no universal control (or app) that can visualize any file you choose, unless in a very low-level form, such as a hex editor would do. So you will have to restrict the list of allowable file types, and/or use several controls, picking the one at run-time that corresponds to the current file type.
3. I have no idea what you mean by "attaching a file to a form".
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
|
|
|
|
|
Here is a scenario. Form1 is for the manager. From form1 he can enter a description of a project, assign a lead, and enter comments. With most projects, there are associated .doc, .pdf, or .xls files. By attach, I mean that the manager can add those files, similar to an email, so that the lead, from Form2 can see the files. I don't want the files to be viewable/opened from Form2, I'm looking for a way for the manager to add these files, and then have the project lead receive the files from Form2. Sorry if this is a confusing description, I do appreciate the help.
[Insert Witty Sig Here]
|
|
|
|
|
OK, so "Project" would be one of your classes; your manager would use a "ProjectEditForm" to view and alter a Project, he would have some means to add ("attach") relevant files to the Project (maybe through an OpenFileDialog indeed), and the list of attached files should be kept in a collection (maybe a List<string>) and displayed somehow (maybe a ListBox or a TreeView).
The lead does not get the files from the manager's form, he should have his view on the same Project, maybe through a "ProjectViewForm" which could be similar to a "ProjectEditForm" with fewer privileges (and maybe also more details).
In my view you want to persist a Project somehow, maybe in an XML file, maybe in a database.
Conclusion: it is not form-communicates-to-other-form, it is an object-needing-persistence-and-multiple-views.
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
|
|
|
|
|
Can anyone know why the case for i=2 is not executed? stateA, B, C & D are object of my small classes.
The problem is that node5 & node6 are put into the arrays but node3 & node4 are not.
I debugged my program to watch closely step by step but I did not find out what is wrong.
Anyone?
CODE:
for(System::Int32 i=0; i<numOfBits_int+3; i++){
switch(i)
{
case 0:
stateA^ node0 = gcnew stateA(i,0,-1,-1);
aux_trellis1a[i] = node0;
break;
case 1:
String^ str1 = encodedBits2->Text->Substring((position + 1)+(i-1)*3,2);
String^ str2 = aux_trellis1a[i-1]->output0;
String^ str3 = aux_trellis1a[i-1]->output1;
stateA^ node1 = gcnew stateA(i,aux_trellis1a[i-1]->metric + compareStrings(str1,str2),i-1,0);
stateB^ node2 = gcnew stateB(i,aux_trellis1a[i-1]->metric + compareStrings(str1,str3),i-1,1);
aux_trellis1a[i] = node1;
aux_trellis1b[i] = node2;
break;
case 2:
String^ str4 = encodedBits2->Text->Substring((position + 1)+(i-1)*3,2);
String^ str5 = aux_trellis1a[i-1]->output0;
String^ str6 = aux_trellis1a[i-1]->output1;
stateA^ node3 = gcnew stateA(i,aux_trellis1a[i-1]->metric + compareStrings(str4,str5),i-1,0);
stateB^ node4 = gcnew stateB(i,aux_trellis1a[i-1]->metric + compareStrings(str4,str6),i-1,1);
aux_trellis1a[i] = node3;
aux_trellis1b[i] = node4;
String^ str7 = encodedBits2->Text->Substring((position + 1)+(i-1)*3,2);
String^ str8 = aux_trellis1b[i-1]->output0;
String^ str9 = aux_trellis1b[i-1]->output1;
stateC^ node5 = gcnew stateC(i,aux_trellis1b[i-1]->metric + compareStrings(str7,str10),i-1,0);
stateD^ node6 = gcnew stateD(i,aux_trellis1b[i-1]->metric + compareStrings(str7,str11),i-1,1);
aux_trellis1c[i] = node5;
aux_trellis1d[i] = node6;
break;
}
}
modified on Thursday, May 26, 2011 7:11 AM
|
|
|
|
|
I don't see how it couldn't work unless numOfBits_int is <= -1.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
We don't have enough to go on.
What's numOfBits set to?
Do you reach the assignment statements or skip case 2 altogether?
Do any of the object ctors accept i by reference and change it?
John
|
|
|
|
|
numOfBits is always bigger than 3, so it's not a problem.
Case 2 is not skipped entirely because aux_trellis1c[2] and aux_trellis1d[2] are filled with appropriate nodes (node5 and node6). I worry why aux_trellis1a[2] and aux_trellis1b[2] are not filled when i has already reached value 3.
"i" is not changed by any other object, it is only internal argument for for loop.
Sorry for so lame description, I'm bad at programming, that is why I have stupid problems and probably the solution is very easy but I just can't see it:/
|
|
|
|
|
please use PRE tags when showing code snippets; they preserve indentation and improve readability. You could still edit your existing message!
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
|
|
|
|
|
OK, I don't see how it would be possible to execute the bottom half of a case.
I can only suggest you set a breakpoint at the first statement of case2 and single-step from there (assuming it goes wrong the very first time).
Luc Pattyn [My Articles] Nil Volentibus Arduum
The quality and detail of your question reflects on the effectiveness of the help you are likely to get. Please use <PRE> tags for code snippets, they improve readability. CP Vanity has been updated to V2.3
|
|
|
|
|
Hi,
I planed to create a form application with menubar and toolbar. I should let the program have the scroll bar, so I setted the AutoScroll = True, AutoScrollMinSize=(2000, 1000). And then the form application did have the scroll bar (both vertical and horizional).
However, there was a problem when I scrolled down the scroll bar, the menubar and the toolbar were scrolled down too. So when I scrolled the scroll bar, the menubar and the toolbar disappeared. very strange!
I had written some winform programs with VC++ 6.0 before, those components(menubar and toolbar) will not be disappeared when scrolling. Why the c++/cli winform program cannot work?
BTW, I'm using VC++ Express 2008. Maybe it's a very simple question, Can any kind man help me and tell me why?
Thanks in advance.
Joul
|
|
|
|
|
try this:
- fill the Form with your menubar, your toolbar, and a Panel (if the Form is resizable, make the Panel anchored or docked).
- make the Panel scroll (ScrollBars property).
- add all actual content to the Panel, not the Form.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Thanks for your kind reply.
hello!
|
|
|
|
|
You're welcome.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
BTW,I did some test right now, I added some painting codes in panel's on_paint function. However, the painting can not be double buffered, and the panel's double buffered property is private.
If I want to do some painting in the panel, there are some blinks when painting.
How about your idea about this?
Thanks.
Joul
|
|
|
|
|
There are two ways I know of:
1.
you derive your own DoubleBufferedPanel from the normal Panel, then in its constructor you can set the double-buffered property (as it is protected). Once you build a project with such DoubleBufferedPanel class present (but still unused), Visual Designer should have it available and now you can replace the Panel by a DoubleBufferedPanel.
2.
you can change the properties of a regular Panel at run-time, something akin to:
panel.SetStyle(System.Windows.Forms.ControlStyles.DoubleBuffer,true);
panel.SetStyle(System.Windows.Forms.ControlStyles.AllPaintingInWmPaint,true);
panel.SetStyle(System.Windows.Forms.ControlStyles.UserPaint,true);
oanel.UpdateStyles();
This also works on pre-2.0 .NET versions where Control.DoubleBuffered didn't exist.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hi,
I did some test again, but panel.SetStyle is the private function, and I can not use that function.
For the first way, I can make a DoubleBufferedPanel class, but it's not convinent for visual designer.
I don't know if there is another way. Thanks.
hello!
|
|
|
|
|
Indeed, SetStyle isn't public either, my mistake. So you have to create your own Panel.
Here[^] is an article where I did exactly that; there is a download near the end. It is in C#, I trust it would be basically the same in C++//CLI. Getting Visual Designer to find the new controls depends on a number of factors, I don't think I know them all; one is your code has to compile; another may well be the new Control has to be the first (or only?) class in its source file.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Hi Luc,
I had created a user constrol derived from panel class. and it's easy to add the new Control to the Visual Designer.
I provide a method named setDB to set if the panel can be doublebuffered. And it works.
Thanks for your kind help.
BTW, I had read your article about animation demo, it's greate.
Joul
|
|
|
|
|
Hey guys,
I have a question that's been plaguing me for a day or so. I'll try to explain as best as possible. No code this time, just some general questions.
I have a hierarchy of Windows forms, MainForm->AdminForm->JobDetailsForm. JobDetailsForm requires objects from MainForm, and AdminForm is just a middle man. Is there a slick way to get information from an object in MainForm to JobDetails form without passing the object through AdminForm? The object is an ArrayList of Objects called Users. I set information in the MainForm, and then I get that information inside of JobDetailsForm. Currently I'm doing something similar to
Pseudo Code:
MainForm
ArrayList users;
...
new AdminForm(users);
AdminForm
...
//no operations on users
new JobDetailsForm(users)
JobDetailsForm
...
//some operations on users
AdminForm has no use for users, it simply displays some information unrelated to users. If possible, I'd also like the operations preformed in JobDetailsForm to be reflected in the users object used in MainForm. I'm thinking a global or static variable could solve this, but from what I understand, there are no global or static variables in managed C++/CLI. Any ideas or suggestions?
[Insert Witty Sig Here]
|
|
|
|
|
VonHagNDaz wrote: I'm thinking a global or static variable could solve this, but from what I understand, there are no global or static variables in managed C++/CLI.
If you choose that route, you can have a ref class with a static constructor and static member methods/properties/fields...How to: Define Static Constructors in a Class or Struct[^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Try something like this...
String ^temp = "5/26/2011";
DateTime start;
if (DateTime::TryParse(temp, start))
{
}
...or this...
String ^temp = "5/26/2011";
try
{
DateTime start = DateTime::Parse(temp);
}
catch (Exception ^)
{
}
Mark Salsbery
Microsoft MVP - Visual C++
modified on Monday, May 16, 2011 2:32 PM
|
|
|
|
|
That works! I'm a bit confused as to why your code works and mine doesn't. What is the difference between SomeDateTimeObject.Parse, and DateTime::Parse?
[Insert Witty Sig Here]
|
|
|
|
|
All the Parse() methods are static (AFAIK) so they return a new DateTime object instead of altering the one you were calling Parse() on.
This would have worked;
start = start->Parse(temp);
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I see, MSDN wasn't too clear on that. It lead me to believe temp would be modified. Thank you, 5's for both.
[Insert Witty Sig Here]
|
|
|
|
|