|
You could use 3 instances of the same dialog.
CYourDialog m_Tab1Dialog;
CYourDialog m_Tab2Dialog;
CYourDialog m_Tab3Dialog;
and switch between them
|
|
|
|
|
That's what I'm trying to do, but it doesn't seem to work. Instead when I switch tabs, the dialog goes blank. I think the problem might be that both tabs point to the IDD_INVITATION_LIST_VIEW resource, so when the tab control tries to hide/show the items, it can't hide/show the right ones (because they're the same resource). Does that sound at all correct, or way off?
Header File:
VInvitationListView m_historyListView;
VInvitationListView m_patientListView;
CPP File:
if (m_historyListView.Create(IDD_INVITATION_LIST_VIEW, &m_TabControl) == FALSE)
{
//Log Error and return
}
m_historyListView.ShowWindow(SW_SHOW);
CString str("History List");
m_TabControl.InsertItem(0, str, m_historyListView.GetSafeHwnd());
CXTPTabManagerItem* tab = m_TabControl.GetItem(0);
tab->SetData(eInvitationsTab);
m_TabControl.SetSelectedItem(tab);
m_TabControl.Reposition();
Elsewhere in same CPP File (I only add the second tab in certain scenarios):
if (m_patientListView.Create(IDD_INVITATION_LIST_VIEW, &m_TabControl) == FALSE)
{
//Log Error and return
}
m_patientListView.ShowWindow(SW_SHOW);
m_TabControl.InsertItem(1, sFullFormattedName, m_patientListView.GetSafeHwnd());
CXTPTabManagerItem* tab = m_TabControl.GetItem(1);
tab->SetData(ePatientSpecificTab);
m_TabControl.SetSelectedItem(tab);
m_TabControl.Reposition();
Izk
|
|
|
|
|
Just wanted to follow up and say that I think the problem was the code jock (3rd party) tab control being used after all. I ended up using the CXTTabCtrl instead of the CXTPTabControl. Instead of using the "InsertItem" method, I used "AddControl" and now the tabs seem to work just fine even though they both show the same class (separate instances).
Izk
|
|
|
|
|
Upon further review, CXTPTabControl works just fine. The solution to using the same dialog resource multiple times is to do the following on the create:
m_historyListView.Create(VInvitationListView::IDD, &m_TabControl)
m_patientListView.Create(VInvitationListView::IDD, &m_TabControl)
instead of:
m_historyListView.Create(IDD_INVITATION_LIST_VIEW, &m_TabControl)
m_patientListView.Create(IDD_INVITATION_LIST_VIEW, &m_TabControl)
I don't know the reasoning here, but I think using ::IDD allows the enum to give the windows different resource IDs or control IDs or something. Anyway, lesson learned for me and hopefully it helps someone else. I still think this is at least somewhat related to MFC/VC++ and not just the third party control. Although I never tried it with the standard CTabCtrl to be sure.
Izk
|
|
|
|
|
I'm working on a C project, but all my experience is with C++. Any recommendations for a good C website? Preferably with a good, active community like CodeProject's for questions I might have.
Thanks
|
|
|
|
|
Mark J. Miller wrote: Any recommendations for a good C website?
I'm a pretty avid C programmer myself and I tend to find a lot of use out of CP still. Granted. I can never use much code from most articles as is (not that I would anyway), but the concepts are generally translatable.
What in particular are you after? The C way of life? Differences between C and C++ (like how myFunc(void) is interpreted differently between the two for instance), etc.?
Actually, if you're used to C++ I think it'll benefit you in a procedural world. I think employing some OOP concepts in C (within reason) is a better way of going about things than most traditional procedural texts bother to teach (they never focus on design IMO).
|
|
|
|
|
I have a school project which includes part of the code already written in C. I either need to translate what has been written into C++ or I need a good reference which can tell me how to do in C what I already know in C++.
|
|
|
|
|
I have found on several occasions that doing even a simplistic ( one file == one class ) port of C code to C++ has helped me to understand the code much better than any amount of time spent simply reading it. There are also numerous potential advantages in porting the code from spotting bugs to taking advantage of newer technologies. There's always the risk of introducing new bugs of course but most of this can be offset by being able to test in direct comparison to the original code. If it was me I'd probably C++ the code as straight forwardly as possible, make it work, and then look at ways to improve it if the schedule allowed.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Mark J. Miller wrote: I either need to translate what has been written into C++ or I need a good reference which can tell me how to do in C what I already know in C++.
Actually, you're in luck, one of the design goals of C++ was to be able to compile C code. However, if the program wasn't written with some OOP principles (like treating a file.c as a class, etc.) then a direct port may be an issue.
For the most part you'll feel at home in C, but there are a few gotchas along the way. Here's one link for example:
http://people.cs.uchicago.edu/~iancooke/osstuff/ccc.html[^]
|
|
|
|
|
I am surprised no one pointed this out. If you want to include C code into a C++ project then wrap the C headers in an extern “C” {headers here} block or place the block in the header files themselves (Hint: See the C header file included with C++).
As an alternative you can change the names of the C sources files from “.c” to “.cpp” and they will be compiled as C++. Since C++ is a superset of C, they should compile without any problems. There are some differences you need to look out for, but if you do not need to modify the C code it should be ok. If you need to modify the C code, then either use the block method or learn the minor differences (Hint: sizeof works differently in C).
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Mark J. Miller wrote: Any recommendations for a good C website?
What's wrong with this one? If you are already familar with C++, then there's very little about C that will surprise you.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
May be we should ask Chris to rename the forum as C/C++/VC++
Jemmy : Deadline? Pfft, a real programmer eats deadlines for breakfast. :P
Mark: I thought real programmers ignored deadlines
Best wishes to Rexx[^]
|
|
|
|
|
As always I got what I needed. You guys at CP are the best.
|
|
|
|
|
You've got any questions with Assemblers?
Jemmy : Deadline? Pfft, a real programmer eats deadlines for breakfast. :P
Mark: I thought real programmers ignored deadlines
Best wishes to Rexx[^]
|
|
|
|
|
|
Is there a way to serialize an enumerated type using CArchive?
// I have an enumerated type in my header file and a member of that type,
typedef enum
{
ONE,
TWO,
THREE
} SomeType;
SomeType m_someVariable;
When I try to serialize it in the classes serialize method, I get...
error C2679: binary '>>' : no operator found which takes a right-hand operand of type 'CSomething::SomeType' (or there is no acceptable conversion)
|
|
|
|
|
easiest way is to cast the enum to an int when saving, and cast the int to an enum when loading.
|
|
|
|
|
That's not working for me here. Are you on 6.0 or 2003.
I'm going to try this on a VC++ 6.0 project to see what happens as my current project is in VC++ 2003.
Thanks for the advice either way.
|
|
|
|
|
bob16972 wrote: Are you on 6.0 or 2003
doesn't matter. this is a pretty basic C++ issue, the kind of thing you run into everywhere.
int t;
ar >> t;
enumVal = (enumType)t;
ar << (int)enumVal;
|
|
|
|
|
My apologies.
I would never have suspected that was necessary but I live and learn.
Thank you very much for helping me over that hurdle.
|
|
|
|
|
Do you have something similar to:
class CSomething
{
public:
enum
{
ONE,
TWO,
THREE
} SomeType;
void Serialize( CArchive &ar )
{
if (ar.IsStoring())
ar << (int) SomeType;
else
ar >> (int) SomeType;
}
};
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
That's basically it. I needed a typedef in front of the enum. I've tried a couple variations which should effectively be the same thing in the end but none get me past the error.
I tried the cast operation an it didn't change the error.
I'm not sure if this matters, but I've noticed from past posts you use VC++ 6.0 exclusively and this project is on Visual C++ 2003, so if that's working for you in your environment, I'll give it try in a Visual C++ 6.0 project to see if the 2003 compiler just changed the rules.
|
|
|
|
|
bob16972 wrote: ...if that's working for you in your environment, I'll give it try in a Visual C++ 6.0 project...
You might have to tweak it a bit like:
if (ar.IsStoring())
{
int x = SomeType;
ar << x;
}
else
{
int x;
ar >> x;
SomeType = (_SomeType) x;
}
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I feel silly now but a tad bit smarter.
Thanks for helping me out. I learned something new.
|
|
|
|
|
Why have you written the underscore in the casting by loading???
I mean: SomeType = (_SomeType) x;
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|