×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    27

    Unable to save document to file?

    Hi all,
    I am beginner for symbian development and I am using Crystal C++ for my development.

    Could someone please tell where should we write functions for Storing and Restoring documents, ie., it should be in Document class or AppUI class.

    Because in some applns. ie., for example in File Based Application sample programme, it is coded in a seperate class called CBossPuzzle class and in some other applns say, SMSAssist, it is written in AppUI class. Also can I have some sample code for Externailize() for storing a text document to a file.

    Following is the code part I have written for storing and restoring the text. But the TEXT is not stored/saved to the file. and all i have is just a blank file. Any help please. What should i do to save the document to the file.

    ========================================
    void CChattstDocument::RestoreL(const CStreamStore& aStore,const CStreamDictionary& aStreamDic)
    {
    CRichText* text=CRichText::NewL(iParaFormatLayer,iCharFormatLayer);
    CleanupStack::PushL(text);
    TStreamId id=aStreamDic.At(KUidChattst);
    text->RestoreL(aStore,id);
    iEditStore=CONST_CAST(CStreamStore*,&aStore);
    CleanupStack::Pop();
    delete iRichTextOutput;
    iRichTextOutput=text;
    }

    void CChattstDocument::StoreL(CStreamStore& aStore,CStreamDictionary& aStreamDic) const
    {
    TStreamId id=iRichTextOutput->StoreL(aStore);
    aStreamDic.AssignL(KUidChattst,id);
    }


    =======================
    //This will handle the keyboard events,such as entering characters.

    TKeyResponse CChattstAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
    {
    iAppView->KeyEventL(aKeyEvent, aType); // send to view for display
    if (aType == EEventKey)
    {
    TBuf<1> dispChar;
    TBuf8<4> utf8Char;
    dispChar.Append(aKeyEvent.iCode);
    }
    return EKeyWasConsumed;
    }

    //this will generate the message that will be displayed in AppView.
    void CChattstAppUi::MessageGenerated(const TDesC& aMessage)
    {
    iAppView->Print(aMessage); // display message in window
    }

    ==================================
    // Output to console.
    void CChattstAppView::Print(const TDesC& aMessage)
    {
    // Add message 1 char at a time.
    TKeyEvent aKeyEvent;
    for (int i = 0; i < aMessage.Length(); i++)
    {
    aKeyEvent.iCode = aMessage[i];
    aKeyEvent.iScanCode = aMessage[i];
    }
    }

    void CChattstAppView:raw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    // Clear the application view
    gc.Clear();
    // Draw a rectangle round the edge of the application view.
    TRect drawRect=Rect();
    drawRect.Shrink(10,10);
    gc.DrawRect(drawRect);
    }

    Thanks and Regards.
    Uva

  2. #2
    Regular Contributor
    Join Date
    Mar 2003
    Posts
    344

    RE: Unable to save document to file?

    Hi,

    The document class represents the data model for the application.
    If the application is not file based, the purpose of the document class is to create an application for UI object to handle editing of the document.
    If the application is file based then the document class additionally handles storing and restoring of the application's data.
    The roles of the application UI is to get commands to the application, to distribute keystrokes to controls, and to create an initialize the Application views
    Please look in the 9200 SDK help there is lot of information available on how to implement file based and non file based application. Look under developer's guide to crstal >> How to write a crystal application.

    Regards,
    Ravi

Posting Permissions

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