CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11
  1. #1
    Join Date
    May 2009
    Posts
    88

    Post regarding CObject and CTypedPtrArray

    frens m a newbie to vc++ enviornment.....m designin a project for gui ....m nt sure do how to use a template in dis do v need to include ne of pre defined class or nt
    my problm are:

    1.wen defining a class by class wizard m nt getting CObject as base class to select??
    2.aldo i selectd class CCmdTarget as base class for defining my base class which class shall i use as v use CObarray for CObject class??

    wen m writting a statement as
    CTypedPtrArray<CObArray, CBus*>m_array;
    m getting 12 errors in d sam line as
    missing ; b4 <
    CTypedPtrArray : missing storage class or type specifier
    etc etc....
    frens plzz help me out sinc have 2 submit dis project...
    thanx

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: regarding CObject and CTypedPtrArray

    I can't read your post. Get rid of the messenger talking and write in plain English.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

  3. #3
    Join Date
    May 2009
    Posts
    88

    Exclamation Re: regarding CObject and CTypedPtrArray

    Well the problem is that am unable to declare a array as

    CTypedPtrArray<CCmdTarget, CBus*>m_array;

    also am unable to declare a class using class wizard having CObject as its base class the dropdown does not contain CObject as one of its options.....

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: regarding CObject and CTypedPtrArray

    1. Please show the exact error messages.
    2. Read MSDN about CTypedPtrArray and its using (particularly, Requirements section)
    Victor Nijegorodov

  5. #5
    Join Date
    May 2009
    Posts
    88

    Post Re: regarding CObject and CTypedPtrArray

    f:\myprojects\pflow\pflow\pflowdoc.h(25) : error C2143: syntax error : missing ';' before '<'
    f:\myprojects\pflow\pflow\pflowdoc.h(25) : error C2501: 'CTypedPtrArray' : missing storage-class or type specifiers
    f:\myprojects\pflow\pflow\pflowdoc.h(25) : error C2059: syntax error : '<'
    f:\myprojects\pflow\pflow\pflowdoc.h(25) : error C2238: unexpected token(s) preceding ';'
    PflowDoc.cpp
    f:\myprojects\pflow\pflow\pflowdoc.h(25) : error C2143: syntax error : missing ';' before '<'
    f:\myprojects\pflow\pflow\pflowdoc.h(25) : error C2501: 'CTypedPtrArray' : missing storage-class or type specifiers
    f:\myprojects\pflow\pflow\pflowdoc.h(25) : error C2059: syntax error : '<'
    f:\myprojects\pflow\pflow\pflowdoc.h(25) : error C2238: unexpected token(s) preceding ';'
    PflowView.cpp
    f:\myprojects\pflow\pflow\pflowdoc.h(25) : error C2143: syntax error : missing ';' before '<'
    f:\myprojects\pflow\pflow\pflowdoc.h(25) : error C2501: 'CTypedPtrArray' : missing storage-class or type specifiers
    f:\myprojects\pflow\pflow\pflowdoc.h(25) : error C2059: syntax error : '<'
    f:\myprojects\pflow\pflow\pflowdoc.h(25) : error C2238: unexpected token(s) preceding ';'
    Generating Code...
    Error executing cl.exe.

    Pflow.exe - 12 error(s), 0 warning(s)


    and line(25) is
    CTypedPtrArray<CCmdTarget, CBus*>m_array;
    this is declared in doc header file my project....
    thnx

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: regarding CObject and CTypedPtrArray

    Quote Originally Posted by pinnachio View Post
    ...
    f:\myprojects\pflow\pflow\pflowdoc.h(25) : error C2501: 'CTypedPtrArray' : missing storage-class or type specifiers
    As I already pointed out:
    Quote Originally Posted by VictorN View Post
    2. Read MSDN about CTypedPtrArray and its using (particularly, Requirements section)
    Victor Nijegorodov

  7. #7
    Join Date
    May 2009
    Posts
    88

    Re: regarding CObject and CTypedPtrArray

    thanz a lot......

    the problem was der only where u pointed i had not included afxtempl.h in my file......

  8. #8
    Join Date
    May 2009
    Posts
    88

    Re: regarding CObject and CTypedPtrArray

    kindly please tell can i derive a class from CObject class using class wizard,basically i want to use dis class only for serialization...

  9. #9
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: regarding CObject and CTypedPtrArray

    Yes, I can do it (add MFC class derived from CObject) using class wizard in VS 2008.
    In VC++6.0 CObject dos not appear in a list of MFC classes available for deriving. However, you could create a new class as a *generic* class and set CObject as a base class.
    Victor Nijegorodov

  10. #10
    Join Date
    May 2009
    Posts
    88

    Question Re: regarding CObject and CTypedPtrArray

    thnx Victor for that 1 too..........am here with another problem
    i have to draw some shapes on a layout through the application am designing the code in some what it goes as....

    if(bCheckBusVer==1)
    {
    if(pDoc->AddBus(p.x-3,p.y-5*s,p.x+3,p.y+5*s,atol(m_BusNo),0,m_BusType,m_Volts,m_LoadAngle,m_BusName))
    {
    int index = pDoc->GetNumBus();
    pDoc->GetBus(--index)->Bus_Draw(pDC);
    }
    else
    {
    bCheckBusOpt=FALSE;
    ReleaseCapture();
    return;
    }
    }
    if(bCheckBusHor==1)
    {
    if(pDoc->AddBus(p.x-5*s,p.y-3,p.x+5*s,p.y+3,atol(m_BusNo),1,m_BusType,m_Volts,m_LoadAngle,m_BusName))
    {
    int index = pDoc->GetNumBus();
    pDoc->GetBus(--index)->Bus_Draw(pDC);
    }
    else
    {
    bCheckBusOpt=FALSE;
    ReleaseCapture();
    return;
    }

    and bus_draw(pDC) as
    char temp[10];
    ltoa(m_BusNo,temp,10);
    if(m_bOrien)
    pDC->TextOut(m_x2+2,m_y2+4,temp);
    else
    pDC->TextOut(m_x1-2,m_y1,temp);
    COLORREF color=pDC->GetBkColor();
    pDC->FillSolidRect(m_x1,m_y1,m_x2,m_y2,RGB(0,0,255));
    pDC->SetBkColor(color);

    the problem is when i run the code and enter the same set of values for size different size of rectangles are made...... ..plzz help me out am gettin sick of this....

  11. #11
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: regarding CObject and CTypedPtrArray

    The code you've posted is absolutely unreadable. Please, edit your post adding Code tags around code snippet.
    Read about Code and other tags
    Victor Nijegorodov

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured