MFC Collections Architecture

Hello,

	Just starting out with MFC. Could anyone help me with this? Why is
CArray, not defined using template? The reason I am asking is that, no
doubt I could use special _type_safe_ classes like CTypedPtrList. Won't
it have been better if there existed a mechanism like std::vector,
which promotes compile time type checking rather than dynamic type
checking.

-- 
Imanpreet Singh Arora

0
imanpreet (2)
4/13/2005 1:38:03 AM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
472 Views

Similar Articles

[PageSpeed] 33

CArray does use templates.

From MSDN:
template < class TYPE, class ARG_TYPE = const TYPE& >
class CArray :
   public CObject



<imanpreet@gmail.com> wrote in message 
news:1113356283.837061.16860@l41g2000cwc.googlegroups.com...
> Hello,
>
> Just starting out with MFC. Could anyone help me with this? Why is
> CArray, not defined using template? The reason I am asking is that, no
> doubt I could use special _type_safe_ classes like CTypedPtrList. Won't
> it have been better if there existed a mechanism like std::vector,
> which promotes compile time type checking rather than dynamic type
> checking.
>
> -- 
> Imanpreet Singh Arora
> 


0
burnette1 (19)
4/13/2005 4:09:59 AM
h=E4ns wrote:
> I use STL collections even in MFC apps. You can easily do it.
>
> cheers,
> H=E4ns
>

Ooops, I blooped. But STL classes don't provide the Serialization that
is provided by MFC. I am looking for both

a)            Serialization
b)            Mechanism like that in STL

0
imanpreet (2)
4/13/2005 7:01:01 PM
<imanpreet@gmail.com> wrote in message 
news:1113418747.344341.174320@l41g2000cwc.googlegroups.com...

h�ns wrote:
>> I use STL collections even in MFC apps. You can easily do it.
>>
>> cheers,
>> H�ns
>>
>
>Ooops, I blooped. But STL classes don't provide the Serialization that
>is provided by MFC. I am looking for both>
>
>a)            Serialization
>b)            Mechanism like that in STL

see the Serialization library that is part of www.boost.org.

Jeff Flinn 


0
not1 (120)
4/13/2005 7:10:09 PM
Reply:

Similar Artilces:

WTL vs MFC : Same question as Yesterday
Does someone knows how to convert a CFormView to WTL. For now I have converted my CMainFrame like this: class CMainFrame : public CFrameWindowImpl<CMainFrame>, public CUpdateUI<CMainFrame>, public CAppWindow<CMainFrame>, public CFullScreenFrame<CMainFrame>, public CMessageFilter, public CIdleHandler { ... }; And now I would like to display some views inside. How can I do this ? If someone has some experience with this framework, I am all eyes. On Thu, 05 Apr 2007 14:46:22 +0200, mosfet wrote: > Does someone knows how to convert a CFormView to WTL. >...

Exceptions and MFC
Hi, sometime the following line produces an exception: ((CMessageDialog*)vec->at(0))->EndDialog(1); Now I want to catch this Exception, tried it with c++ and mfc exception handling, like: C++ in MFC try { ((CMessageDialog*)vec->at(0))->EndDialog(1); } catch(CException *e) { } --------------------------------------------------------- MFC Makro TRY { ((CMessageDialog*)vec->at(0))->EndDialog(1); } CATCH(CNotSupportedException, pEx) { } END_CATCH The Debugger still shows exceptions but never enters the chatch area..... Can anyone please help me, why the exception is not ca...

MFC .exe gets access violation exception in release version but not debug
Hello, thanks for trying to help. I have an MFC .exe that gets an access violation (C0000005) exception in the release version but not the debug version. So I don't know what line of code causes it. But why should they act differently in this way at all? The exception occurs when a tab on a property sheet is being clicked. The only output in the debug screen when the tab is being clicked is "Warning: skipping non-radio button in group." Would that cause it? Does tab order determine groups along with the tab stop property? What are reasons why MFC code would get an access ...

Multipage, controls-collection and events (XL2003, VBA)
Dear Group, I have a Userform with a Multipage control, which is dynamically filled with textboxes and comboboxes using Controls.Add like this: Set aTextBox = aUserForm.aMultiPage.Pages(strCurrentRegister).Controls.Add("Forms.TextBox.1", "txt" & strText, True) Set aComboBox = aUserForm.aMultiPage.Pages(strCurrentRegister).Controls.Add("Forms.ComboBox.1", "txt" & strText, True) This is working fine, but what I miss is any way to assign eventhandlers. Is there any way to do this? If not, I could use existing controls, which...

Developing MFC Activex Control
I need to develop an Activex control that introduces some user interface to the client similar to a dialog box(with some buttons and other controls). . I have both VC 6.0 and VC 2005 installed. I have a few questions - 1. Are there samples/examples in any of the MSDN corresponding versions? 2. Are there any other reference/books that nay help in the Internet? Thanks in advance Jack > I need to develop an Activex control that introduces some user interface to > the client similar to a dialog box(with some buttons and other controls). . > I have both VC 6.0 and VC 2005 installed. ...

Help with MFC Theory
Hello, I have written a program that sits in the system tray and uses a hidden window to receive messages from a separate component. Its job is simply to do stuff when messages arrive. I seem to have fallen into a trap where I've had to make all of my methods and objects static, simply because I can't call them from a static window procedure unless they are also static. Most of the functionality exists in the application object. What has been my mistake? How could I redesign this app so that I don't have to make all of the functions and objects static? Keep in mind that...

Why set_terminate is not working in MFC under VC 7.0
Cast your mind back to this post from April last year: http://groups.google.co.uk/groups?hl=en&lr=&ie=UTF-8&selm=x5Rn5jdBDHA.1120%40cpmsftngxa06.phx.gbl > >> Does any body know why set_terminate not working in MFC 7.0? > > I took an extensive look at this. I can reproduce the symptoms you > are seeing. We'll get back to you shortly. > It seems quite a number of people have had this problem too, including us, yet I can't find a public solution anywhere. Please share the solution with the newsgroup. Regards, Dave Elcock. ...

MFC MDI with a c# as a child
Hell I was wondering if there is a way to put a c# (managed ofcourse) window as an MFC MDI child Thanks in advance. ...

Use Win32 Api in MFC Applications
Hello! How I can use win32 api in a MFC application? Thanx in advance. You can just call them. Most API's header files are ready included in MFC projects. If the header is not included, you can include it yourself. Most API function has a different parameter list with the version wrapped in a class, so there won't be ambiguity when you are calling an API. But to make sure that you are calling the API function but not the class member, and to make the code clearer to read, you can use :: before API function call. e.g. ::SetWindowText(...); If fact that is the usual way of calli...

Automatic documentation MFC/C++
Hello, I have a question - is there any standard tool to use for automated documentation of MFC/C++ source code? NDoc works great for C# apps - but is there anything out there that is industry standard for C++? Seems to be a lot of different ones out there but is there any as standard as NDoc? Thanks, Greg Cetti greg@ram-software.com > I have a question - is there any standard tool to use for automated > documentation of MFC/C++ source code? > > NDoc works great for C# apps - but is there anything out there that is > industry standard for C++? Seems to be a lot of differe...

console to MFC
Hi, I have an application in console. I'm trying to convert it into an MFC application. If anyone could help... The console starts its execution with a function declare as below: int _tmain (int argc, char* argv[]) { /* * This is responsible for memory management of * GraphBuilder. */ AimlFacade aiml; /* * Get the GraphBuilder concrete class that * was created inside of AimlFacade. * DO NOT try to delete GraphBuilder. Let * AimlFacade handle that when it falls out * of scope. */ GraphBuilder &builder = aiml.getGraphBuilder(); cout<&...

represent XML in classes/collections (C#)
Hi I want to represent the following XML structure in a class or classes. <CATEGORY NAME="BASE"> <PERSON NAME="PERSON">M. Johnson</PERSON> <JOBTITLE NAME="JOBTITLE">Director</JOBTITLE> <SUBCATEGORY NAME="SUB"> <BUILDING NAME="BUILDING">Paris</BUILDING> <FLOOR NAME="FLOOR">5</FLOOR> <ROOM NAME="ROOM">6A</ROOM> </SUBCATEGORY> <PHONE NAME="PHONE">555-5626</PHONE> <SCALE NAME="...

Record Fields Collection
I'm trying to set one of the fields in the current record, which I assume I can do if I have the right name for the collection. I thought it was "Fields", but either that's wrong or how I've used it here is wrong????? Me.Fields("SubCat" & level "ID") = lngNewID Where the current record contains fields of: SubCat1ID, SubCat2ID,,,,,,,,,SubCatxID. Bill Bill wrote: >I'm trying to set one of the fields in the current >record, which I assume I can do if I have the >right name for the collection. I thought it was >"Fields"...

How to deserialize null collections
Hi, There appears to be a difference in how null arrays and collections are deserialized using XmlSerializer. A null array is serialized into nothing, then deserialized back to null again (which one could argue is the correct behaviour), while a collection is serialized into nothing (like the array) but then deserialized into a collection instance with 0 elements. Obviously, you'd have trouble telling the difference between a null collection and an empty one after serilization. For example, the class below would deserialize to an instance with MyArray = null and MyCollection = StringCo...

Windows Service using MFC
Reading the MFC docs, it states that using MFC inside a service is a bad idea. From the MSDN Library: "Although it is possible to build a Windows service using pieces of MFC, you will need to be very careful about which pieces you use." Does anyone know, which MFC pieces would be safe to use inside a service? Current, we have a service that uses some of the non-window classes i.e. CString, threading/synchronization classes, data structures classes (arrays/maps) Thanks It's okay to use MFC in the service program itself - just not when you are administering the service. Any ...

How to access the SQL server express from mfc application?
I have an mfc application that received data from the internet and want to store the data in a SQL server express database. How do I do it (including connecting to the database, retrieving, updating, or inserting the data to the data tables) search "Visual C++ ADO Programming" in MSDN. -- Sheng Jiang Microsoft MVP in VC++ "Kueishiong Tu" <KueishiongTu@discussions.microsoft.com> wrote in message news:EF4F4775-4601-4F79-A09A-C35DC53C11A5@microsoft.com... > I have an mfc application that received data from the internet and want to > store the > data in a SQ...

Overloading new and delete operators with MFC
I have overloaded new and delete operators in a library that I use in every program I create. Everything is fine EXCEPT when I use my library in a MFC project. My overload functions are : void *operator new(size_t size) { return my_alloc(size) ; } void operator delete(void *ptr) { if (ptr) my_free(ptr) ; } The functions my_alloc() and my_free() are just calling malloc() and free(), but in debug version they add size counter and special data that are used to verify memory leak and buffer overflow. All this works perfectly well in non-MFC projects, but when I try linking my library i...

State Pattern in MFC
Hello, I wonder if someone have some info or/and a sample of how to implement State Pattern in MFC? // Anders -- English is not my first, or second, language so anything strange, or insulting, is due to the translation. Please correct me so I may improve my English! "Anders Eriksson" <andis59@gmail.com> wrote in message news:cj1xmuhhlboh$.dlg@ostling.com... > Hello, > > I wonder if someone have some info or/and a sample of how to implement > State Pattern in MFC? > > > // Anders I Googled for: "State Pattern in C++" http://www.codeguru.co...

placement new in MFC
I can use placement new operator in a console programe like this without any problem: char ch[sizeof(std::string)]; std::string * p = new(&ch[0])std::string(); //....do somthing p->~string(); But when I copy this code into a MFC project,it will report some "syntax error" . I don't know why. Who can tell me? Thanks! Hi zade, In MFC, the 'placement new' operator is replaced by a debug version of new when you are running in the debug mode. You can see the following set of lines at the start of your .cpp file. #if...

MFC DLL with a C interface
Hi, is it possible to write a DLL using C++ and MFC, and expose a C interface for the DLL? Thanks in advance K Look at MFC Regular DLL. --- Ajay ...

primary key using mfc
Hi all, is there a way using mfc to determine what field in a database table is the primary key? John MFC provides nothing to support what you are trying to do. However, you could use either an ODBC call or ADO call to the database to query the schema to get constraints on the table. What is the backend database? In Oracle, we would do something like this: Select b.column_name From user_constraints a, user_cons_columns b Where a.table_name='MASTER_KEYS" and a.constraint_type='P' and a.constraint_name=b.constraint_name If you have a recordset based on this Select ...

Display Alerts property in MFC
Hi, I am writing an Excel automation program using C++ and MFC. I am setting several properties for the Application class and most are working. However, the DisplayAlerts property is giving me an error. If I step through in the debugger, it works fine. But when I run it, I get the message "Unable to set the Display Alerts property of the Application class". Any ideas??? Here is a code snipet: //Then get the worksheet's application. app = wb.GetApplication(); app.SetDisplayFormulaBar(FALSE); // Works Fine app.SetDisplayAlerts(FALSE); //Gives error message T...

MFC threads and critical section
Hi, I am interested in understanding the threads communicaiton behavior inside an MFC based application. Suppose, an MFC application creates 2 secondary threads. Threads need to update a shared integer array at times. So when first thread is accessing array, the second thread should not be allowed access to the array and vice-versa. I am reading a book on operating systems and main emphasis is on UNIX OS and I want to make sure I understand the Windows part of it as well. I did some basic research and it seems Windows provides API that can take care of synchronization issues for us. It ...

Implementing Html help in MFC application
I'm trying to add a html help to my application. I have a compiled *.chm file, where each page is a description of one dialog and I want the help viewer to be open with the correct page when I click the F1 key. It doesn't seem to be a difficult task but I can't figure out anything from the documentation ( I added EnableHtmlHelp() to CWinApp constructor already ) Is it sufficient to set CDialog::SetWindowContextId() in each dialog and expect that the framework does the rest ? How can I assign numeric id's for the files inside *.chm ? Or maybe I should add a message handler...

MFC serialization of HICON
I'm using standard MFC serialization mechanism to save an icon. After upgrade to VS 2008 my serialization code stop working. Saving seems to work fine, but when it comes to open HICON can not be loaded. I have narrowed it down to GDIplus dll trying to create mask bitmap for the icon from stream (standard MFC serialization). This operation always fails. Here is my simple serialization code: void CMyObject::Serialize(CArchive &ar) { CObject::Serialize(ar); if( ar.IsStoring() ) { ar << m_hIcon; } else { ar >> m_hIcon; } } m_hIcon obviously is type of the HICON....