×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    39

    Question [moved] Displaying a Simple Dialog

    I am trying to display a simple dialog following
    instructions in a book called S60 programming a tutorial
    approach, but I am having trouble compiling the project.

    I add the following to my resource file:

    RESOURCE DIALOG r_setname_dialog
    {
    flags = EEikDialogFlagNoDrag | EEikDialogFlagCbaButtons |
    EEikDialogFlagWait;
    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
    items =
    {
    DLG_LINE
    {
    id = ESetNameEditor;
    type = EEikCtEdwin;
    control = EDWIN
    {
    maxlength = KMaxNameLength;
    width = KMaxNameLength;
    };
    }
    };
    }

    Then I create the following class:

    class CSetNameDialog : public CAknDialog
    {
    public:
    static TInt RunDlgLD(TDes& aName);
    protected:
    TBool OkToExitL(TInt aButtonId);
    void PreLayoutDynInitL();
    private: // Constructor
    inline CSetNameDialog(TDes& aName) : iName(aName) { }
    private: // data
    TDes& iName;
    };


    with this implementation:

    TInt CSetNameDialog::RunDlgLD(TDes& aName)
    {
    CSetNameDialog* nameDialog = new(ELeave) CSetNameDialog(aName);
    return nameDialog->ExecuteLD(R_SETNAME_DIALOG);
    }

    TBool CSetNameDialog::OkToExitL(TInt aButtonId)
    {
    if (EAknSoftkeyOk == aButtonId)
    {
    CEikEdwin* editor;
    editor = static_cast<CEikEdwin*>(Control(ESetnameEditor));
    if (editor)
    editor->GetText(iName);
    }
    return ETrue;
    }

    _LIT(KLabelText, "Label Text");
    void CSetNameDialog::PreLayoutDynInitL()
    {
    CEikLabel* label = static_cast<CEikLabel*> (Control(ELabelDialog));
    if(label)
    {
    label->SetTextL(KLabelText);
    }
    }

    Also i created a secondg class in order to run the above code
    as the book says by adding:

    _LIT(KEditorPrompt, "Type Name Here");
    TBuf<KMaxItemLength> item(KEditorPrompt);
    TInt okPressed = CSetNameDialog::RunDlgLD(item);

    in the class as follows :

    #include <eikstart.h>
    #include "CSetNameDialog.h"

    GLDEF_C TInt E32Main()
    {
    _LIT(KEditorPrompt, "Type Name Here");
    TBuf<KMaxItemLength> item(KEditorPrompt);
    TInt okPressed = CSetNameDialog::RunDlgLD(item);

    }

    which is also probably wrong but the
    book does not explain what the structure of the
    "runner" class should be and in which method i should add
    the above code.

    When I try to compile i get the following error message:
    unidenified identifier 'R_SETNAME_DIALOG' from the
    above function RunDlgLD().

    I am completely new to Symbian and the book does not
    explain what I should include where so i dont know
    why it would not recognize the identifier.
    From what I can see it is the name of the resource
    as I have declared above
    "RESOURCE DIALOG r_setname_dialog" but in all caps.
    I tried using all lowercase letters instead but it still
    gives me the same error.
    I don't know if I need to add something else to the
    resource file or what, but I am completely stuck
    at this point and would greately appreciate any
    help.

    Thank you in advance,
    Burim

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,672

    Re: Displaying a Simple Dialog

    Generally you can always test a dialog/form resource via instantiating the parent class (CAknDialog/CAknForm), and running it with your resource.
    And yes, what you declare in lower case in xy.rss, will be accessible from 'outside' via its all-uppercase variant, which appears in xy.rsg (g as g generated, and it is going to be generated to the epoc32\include folder of the SDK, thus has to #include-d with <>-s)
    In your particular case you should really read some introductory guide/book first. Although a Symbian GUI app also starts with E32Main, it has to implement classes from the application architecture before doing anything. You can generate GUI application skeletons with Carbide, and try adding your modifications there (for example the HandleCommandL method of the CSomethingAppUi class is an ideal place for that).
    You can find threads about getting started in the General Symbian C++ section, and here are some resources I remember:
    - search for Getting started in the Wiki
    - visit FN main site (www.forum.nokia.com), there are a lot of documents, Symbian documentation is under Documentation/Symbian C++ (on the left panel), there will also be a Getting started section.

    Others will probably suggest more (or they have already suggested - I will know after clicking on "Post Quick Reply" :-)

  3. #3
    Registered User
    Join Date
    Jun 2008
    Posts
    39

    Re: Displaying a Simple Dialog

    Ok so I tried to include #include <SimpleDialog.rsg> in
    CSetNameDialog.cpp but the compiler is saying it can not be oppened.
    This is my complete project structure can you tell me what I am
    doing wrong:

    SimpleDialog.rss contains:

    // RESOURCE IDENTIFIER
    NAME SIMP // 4 letter ID


    // INCLUDES
    #include <eikon.rh>
    #include <avkon.rsg>
    #include <avkon.rh>
    #include <appinfo.rh>
    #include "SimpleDialog.hrh"
    #include "SimpleDialog.rls"
    #include "Globals.h"
    // RESOURCE DEFINITIONS
    // -----------------------------------------------------------------------------
    //
    // Define the resource file signature
    // This resource should be empty.
    //
    // -----------------------------------------------------------------------------
    //
    RESOURCE RSS_SIGNATURE
    {
    }

    // -----------------------------------------------------------------------------
    //
    // Default Document Name
    //
    // -----------------------------------------------------------------------------
    //
    RESOURCE TBUF r_default_document_name
    {
    buf="SIMP";
    }

    // -----------------------------------------------------------------------------
    //
    // Define default menu and CBA key.
    //
    // -----------------------------------------------------------------------------
    //
    RESOURCE EIK_APP_INFO
    {
    menubar = r_menubar;
    cba = R_AVKON_SOFTKEYS_OPTIONS_EXIT;
    }


    RESOURCE DIALOG r_setname_dialog
    {
    flags = EEikDialogFlagNoDrag | EEikDialogFlagCbaButtons |
    EEikDialogFlagWait;
    buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
    items =
    {
    DLG_LINE
    {
    id = ESetNameEditor;
    type = EEikCtEdwin;
    control = EDWIN
    {
    maxlength = KMaxNameLength;
    width = KMaxNameLength;
    };
    }
    };
    }

    // -----------------------------------------------------------------------------
    //
    // r_menubar
    // Main menubar
    //
    // -----------------------------------------------------------------------------
    //
    RESOURCE MENU_BAR r_menubar
    {
    titles =
    {
    MENU_TITLE { menu_pane = r_menu; }
    };
    }


    // -----------------------------------------------------------------------------
    //
    // r_menu
    // Menu for "Options"
    //
    // -----------------------------------------------------------------------------
    //
    RESOURCE MENU_PANE r_menu
    {
    items =
    {
    // added the new Options menu command here
    MENU_ITEM
    {
    command = ECommand1;
    txt = qtn_command1;
    },
    MENU_ITEM
    {
    command = ECommand2;
    txt = qtn_command2;
    },
    MENU_ITEM
    {
    command = EHelp;
    txt = qtn_help;
    },
    MENU_ITEM
    {
    command = EAbout;
    txt = qtn_about;
    },
    MENU_ITEM
    {
    command = EAknSoftkeyExit;
    txt = qtn_exit;
    }
    };
    }

    // -----------------------------------------------------------------------------
    //
    // About dialog resource.
    //
    // -----------------------------------------------------------------------------
    //
    RESOURCE DIALOG r_about_query_dialog
    {
    flags = EGeneralQueryFlags | EEikDialogFlagNoBorder | EEikDialogFlagNoShadow;
    buttons = R_AVKON_SOFTKEYS_OK_EMPTY;
    items=
    {
    DLG_LINE
    {
    type = EAknCtPopupHeadingPane;
    id = EAknMessageQueryHeaderId;
    itemflags = EEikDlgItemNonFocusing;
    control = AVKON_HEADING
    {
    };
    },
    DLG_LINE
    {
    type = EAknCtMessageQuery;
    id = EAknMessageQueryContentId;
    control = AVKON_MESSAGE_QUERY
    {
    };
    }
    };
    }


    // -----------------------------------------------------------------------------
    //
    // Resources for messages.
    //
    // -----------------------------------------------------------------------------
    //
    RESOURCE TBUF32 r_caption_string { buf=qtn_caption_string; }
    RESOURCE TBUF32 r_about_dialog_title { buf=qtn_about_dialog_title; }
    RESOURCE TBUF r_about_dialog_text { buf=qtn_about_dialog_text; }
    RESOURCE TBUF r_command1_text { buf=qtn_command1_text; }


    // ----------------------------------------------------------------------------
    //
    // r_localisable_app_info
    //
    // ----------------------------------------------------------------------------
    //
    RESOURCE LOCALISABLE_APP_INFO r_localisable_app_info
    {
    short_caption = qtn_caption_string;
    caption_and_icon =
    CAPTION_AND_ICON_INFO
    {
    caption = qtn_caption_string;

    number_of_icons = 1;
    icon_file = "\\resource\\apps\\SimpleDialog_0xEB7A78CC.mif";
    };
    }


    SimpleDialog_reg.rss is:

    #include "SimpleDialog.hrh"
    #include "SimpleDialog.rls"
    #include <appinfo.rh>
    #include <SimpleDialog_0xEB7A78CC.rsg>

    UID2 KUidAppRegistrationResourceFile
    UID3 _UID3

    RESOURCE APP_REGISTRATION_INFO
    {
    app_file="SimpleDialog_0xEB7A78CC";
    localisable_resource_file = qtn_loc_resource_file_1;
    localisable_resource_id = R_LOCALISABLE_APP_INFO;

    embeddability=KAppNotEmbeddable;
    newfile=KAppDoesNotSupportNewFile;
    }

    SimpleDialog.rls is:

    // LOCALISATION STRINGS

    // Caption string for app.
    #define qtn_caption_string "SimpleDialog"

    // First item in "Options" menu pane
    #define qtn_command1 "Message"

    // Second item in "Options" menu pane
    #define qtn_command2 "Message from file"

    #define qtn_help "Help"

    #define qtn_about "About"

    // Third item in "Options" menu pane
    #define qtn_exit "Exit"

    // When user requests ECommand1 event, text below is shown.
    #define qtn_command1_text "Hello World!"

    #define qtn_loc_resource_file_1 "\\resource\\apps\\SimpleDialog_0xEB7A78CC"

    #define qtn_about_dialog_title "About"

    #define qtn_about_dialog_text "SimpleDialog Version 1.0.0\n\nAuthor: \n\nSupport: support@mycompany.com\n\n(c) Your copyright notice"

    CSetNameDialog.h is:
    #ifndef CSETNAMEDIALOG_H_
    #define CSETNAMEDIALOG_H_

    #include <AknDialog.h>
    #include <barsread.h>
    #include <eikedwin.h>
    #include "SimpleDialog.hrh"
    #include <avkon.hrh>


    class CSetNameDialog: public CAknDialog
    {
    public:
    static TInt RunDlgLD(TDes& aName);
    protected:
    TBool OkToExitL(TInt aButtonId);
    void PreLayoutDynInitL();
    private: // Constructor
    inline CSetNameDialog(TDes& aName) : iName(aName) { }
    private: // data
    TDes& iName;
    };


    #endif /*CSETNAMEDIALOG_H_*/

    Globals.h is :

    #ifndef GLOBALS_H_
    #define GLOBALS_H_

    #define KMaxNameLength 50
    #define KMaxItemLength 50

    #endif /*GLOBALS_H_*/


    SimpleDialog.hrh is :

    #ifndef __SIMPLEDIALOG_HRH__
    #define __SIMPLEDIALOG_HRH__

    #define _UID3 0xEB7A78CC

    // SimpleDialog enumerate command codes
    enum TSimpleDialogIds
    {
    ECommand1 = 0x6001, // start value must not be 0
    ECommand2,
    EHelp,
    EAbout,
    ESetNameEditor
    };

    #endif // __SIMPLEDIALOG_HRH__


    CSetNameDialog.cpp is :
    #include "CSetNameDialog.h"
    #include <SimpleDialog.rsg>

    TInt CSetNameDialog::RunDlgLD(TDes& aName)
    {
    CSetNameDialog* nameDialog = new(ELeave) CSetNameDialog(aName);
    return nameDialog->ExecuteLD( R_SETNAME_DIALOG );
    }


    TBool CSetNameDialog::OkToExitL(TInt aButtonId)
    {
    if (EAknSoftkeyOk == aButtonId )
    {
    CEikEdwin* editor;
    editor = static_cast<CEikEdwin*>(Control(ESetNameEditor));
    if (editor)
    editor->GetText(iName);
    }
    return ETrue;
    }

    _LIT(KLabelText, "Label Text");
    void CSetNameDialog::PreLayoutDynInitL()
    {
    //CEikLabel* label = static_cast<CEikLabel*> (Control(ELabelDialog));
    //if(label)
    // {
    // label->SetTextL(KLabelText);
    //}
    }

    And is have a SimpleDialog.cpp file without a .h file as:

    /*
    ============================================================================
    Name : SimpleDialog.cpp
    Author :
    Copyright : Your copyright notice
    Description : Main application class
    ============================================================================
    */

    // INCLUDE FILES
    #include <eikstart.h>
    #include "Globals.h"
    #include "CSetNameDialog.h"

    GLDEF_C TInt E32Main()
    {
    _LIT(KEditorPrompt, "Type Name Here");
    TBuf<KMaxItemLength> item(KEditorPrompt);
    TInt okPressed = CSetNameDialog::RunDlgLD(item);
    //return EikStart::RunApplication( NewApplication );
    }

    SimpleDialog.mmp is:
    TARGET SimpleDialog_0xEB7A78CC.exe
    TARGETTYPE exe
    UID 0x100039CE 0xEB7A78CC

    SOURCEPATH ..\src
    SOURCE SimpleDialog.cpp

    SOURCEPATH ..\data

    START RESOURCE SimpleDialog.rss
    HEADER
    TARGET SimpleDialog_0xEB7A78CC
    TARGETPATH resource\apps
    END //RESOURCE

    START RESOURCE SimpleDialog_reg.rss
    TARGET SimpleDialog_0xEB7A78CC_reg
    TARGETPATH \private\10003a3f\apps
    END //RESOURCE



    USERINCLUDE ..\inc
    USERINCLUDE ..\help

    SYSTEMINCLUDE \epoc32\include

    LIBRARY euser.lib
    LIBRARY apparc.lib
    LIBRARY cone.lib
    LIBRARY eikcore.lib
    LIBRARY avkon.lib
    LIBRARY commonengine.lib
    LIBRARY efsrv.lib
    LIBRARY estor.lib
    LIBRARY aknnotify.lib
    LIBRARY hlplch.lib


    LANG SC

    VENDORID 0
    SECUREID 0xEB7A78CC
    CAPABILITY ReadUserData

    #ifdef ENABLE_ABIV2_MODE
    DEBUGGABLE
    #endif
    // End of File
    SOURCEPATH ..\src
    SOURCE CSetNameDialog.cpp
    Can you plese tell me what exactly I need to add or change in order
    to be able to compile this example, I have been at it all day today
    and I would greately appreciate your help.

  4. #4
    Registered User
    Join Date
    Oct 2007
    Posts
    22

    Re: Displaying a Simple Dialog

    Ok so I tried to include #include <SimpleDialog.rsg> in
    CSetNameDialog.cpp but the compiler is saying it can not be oppened.
    what build tools are you using? Plz provide what are you doing to build your project and past complete ouput, and may ne i can help you:)

  5. #5
    Super Contributor
    Join Date
    Jul 2007
    Posts
    596

    Smile Re: [moved] Displaying a Simple Dialog

    Hi Burim,

    Compile ur .rss independently either from console or from ur id and be sure that ur .rsg generated successfully.

    Another thing it is not always wise to put ur whole code in a post........


    Thanks

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,672

    Re: Displaying a Simple Dialog

    Also note that if you surround your code with [CODE ] and [/CODE ] tags (without the space), the format is going to be preserved - since you inserted your code indented
    [CODE ]RESOURCE DIALOG r_setname_dialog
    {
    ....flags = EEikDialogFlagNoDrag | EEikDialogFlagCbaButtons |
    ....EEikDialogFlagWait;
    ....buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
    ....items =
    ........{
    ........DLG_LINE
    ............{
    ............id = ESetNameEditor;
    ............type = EEikCtEdwin;
    ............control = EDWIN
    ............{
    ............maxlength = KMaxNameLength;
    ............width = KMaxNameLength;
    ............};
    ........}
    ....};
    }[/CODE ](where the ....-s are tabulators in your original)
    is going to be
    Code:
    RESOURCE DIALOG r_setname_dialog
    {
    	flags = EEikDialogFlagNoDrag | EEikDialogFlagCbaButtons |
    	EEikDialogFlagWait;
    	buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
    	items =
    	{
    		DLG_LINE
    		{
    			id = ESetNameEditor;
    			type = EEikCtEdwin;
    			control = EDWIN
    			{
    			maxlength = KMaxNameLength;
    			width = KMaxNameLength;
    			};
    		}
    	};
    }

  7. #7
    Registered User
    Join Date
    Jun 2008
    Posts
    39

    Smile Re: [moved] Displaying a Simple Dialog

    Hi Guys,
    First I would like to thank all those that posted on my thread
    and tried to help me.

    But I finally figured out what the problem was.
    I was using the carbide wizards to create a new application
    UI and the *.mmp file uses the following syntax:

    START RESOURCE CardGame.rss
    HEADER
    TARGET CardGame_0xE223437E
    TARGETPATH resource\apps
    END //RESOURCE

    As you can see the CardGame.rss is renamed to CardGame_0xE223437E
    so if you try to #include<CardGame.rsg> instead of
    #include <CardGame_0xE223437E.rsg> it will complain that
    it can not open the file like in my case.

    p.s
    This might
    seem like a stupid mistake, but I am completely
    new to this and the book that I am reading does not
    explain all the little details like this.

Similar Threads

  1. Launching a dialog when the application starts
    By Uriah Eisenstein in forum Symbian User Interface
    Replies: 10
    Last Post: 2009-03-31, 09:06
  2. How to create a simple dialog
    By symb_devel in forum Symbian User Interface
    Replies: 4
    Last Post: 2008-05-09, 12:48
  3. [announce] wait dialog wrapper 0.2
    By lfd in forum Symbian
    Replies: 10
    Last Post: 2008-03-21, 11:03
  4. how to updated the list box on dialog box before it is displaying it.
    By manjunaths in forum Symbian User Interface
    Replies: 3
    Last Post: 2008-03-20, 10:37
  5. pls help! sample code for a simple dialog with text input for 9210
    By edmundkkchan in forum Symbian User Interface
    Replies: 1
    Last Post: 2002-06-21, 17:23

Posting Permissions

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