GlobalNote problem (newbie here)

Login to reply to this topic.
Tue, 2007-07-17 17:25
Joined: 2007-07-17
Forum posts: 8

Hi All,

Intro:
A week ago I was searching how I could create symbian OS programs for my own use. I have installed Carbide C++ V1.2 and installed the S60 3rd SDK.
Carbide is working and have found the SDK. So I wanted to create a simple application whit actually no function but just to check out what carbide, C++ etc is all about.

Question:
How do I pop up a GlobalNote when I have selected (for example:) Options -> Item1 (which I created earlier in de UI designer).
When I look at the event of Item1 I get to see this code:

TBool CCastContainerView::HandleItem1MenuItemSelectedL( TInt aCommand )
        {
        // TODO: implement selected event handler

        return ETrue;
        }

I think I understand that I have to write the code, between the brackets {} , that will pop up my global note.
In the UIdesign I have added the Global Note (Pallete -> Notes and Dialogs -> Global Note).

After adding the Global Note I have noticed that the following code appears in the code section for use:

void CCastContainerView::RunGlobalNote1L( const TDesC* aOverrideText )
        {
        CAknGlobalNote* globalNote = CAknGlobalNote::NewLC();
        if ( aOverrideText == NULL )
                {
                HBufC* noteText = StringLoader::LoadLC( R_CAST_CONTAINER_GLOBAL_NOTE1 );
                globalNote->ShowNoteL( EAknGlobalErrorNote, *noteText );
                CleanupStack::PopAndDestroy( noteText );
                }
        else
                {
                globalNote->ShowNoteL( EAknGlobalErrorNote, *aOverrideText );
                }
        CleanupStack::PopAndDestroy( globalNote );
        }

But how do I use this piece of code to run the Global Note when I have pushed Item1 in the option menu?

Outro:
I understand this is a very stupid question but I am wrestling with this for over 2 hours and have tried several (to me logical) things.
Thanks in advance,

Devoney


Tue, 2007-07-17 17:37
Joined: 2003-09-22
Forum posts: 27
Re: GlobalNote problem (newbie here)

Hi, I'm not sure that I understand your query.

The function HandleItem1MenuItemSelectedL should be called by HandleCommandL function in your Appui. However as i don't see any obvious benefit to calling HandleItem1MenuItemSelectedL

The function header for RunGlobalNote1L should look like
void CCastContainerView::RunGlobalNote1L( const TDesC& aOverrideText ) in oder to comply with symbian conventions
and the line globalNote->ShowNoteL( EAknGlobalErrorNote, *aOverrideText ); should be changed to globalNote->ShowNoteL( EAknGlobalErrorNote, aOverrideText );

You call RunGlobalNote1L in your HandleCommandL with some simple code like:

_LIT(KText,"Hello");
RunGlobalNote1L (KText);

Does this answer your question?

Tue, 2007-07-17 17:49
Joined: 2007-07-17
Forum posts: 8
Re: GlobalNote problem (newbie here)

Thanks for your quick help. Micarulous the function works by only calling RunGlobalNote1L (and I swear I tried that). But now I have a problem with the text to appear. What you gave me trows an error. I will try to figure it out.

Tue, 2007-07-17 17:58
Joined: 2007-07-17
Forum posts: 8
Re: GlobalNote problem (newbie here)

Sorry for double post, can I edit a reply?

Why do I have to change * to & as you instructed me to do. The works without changing.

When the variable aOverrideText is specified (so it is not NULL) it uses the contents of aOverrideText instead of the text specified in UIdesigner (which is "Error").
As you can see in this code:

if ( aOverrideText == NULL )
                {
                HBufC* noteText = StringLoader::LoadLC( R_CAST_CONTAINER_GLOBAL_NOTE1 );
                globalNote->ShowNoteL( EAknGlobalErrorNote, *noteText );
                CleanupStack::PopAndDestroy( noteText );
                }
        else
                {
                globalNote->ShowNoteL( EAknGlobalErrorNote, *aOverrideText );
                }
        CleanupStack::PopAndDestroy( globalNote );
        }

I am figuring out how to specify aOverrideText. I have no experience with C++. I do with Assembler in Windows and Visual Basic and PHP so I still have to learn the syntax of C++.

Where can I find all the APIs that can be used in a Symbian OS application? Thanks.

Devoney

Tue, 2007-07-17 18:21
Joined: 2003-09-22
Forum posts: 27
Re: GlobalNote problem (newbie here)

Hi,
I suggested to change the * to & as symbian os guidelines specify that if you dont need to edit a variable you should do so. Anyhow its not so important.

Why don't you keep your function simple for the moment. and specify the function header (in your .h file) as

void RunGlobalNote1L( );

and implementation (in your .cpp file) as

void CCastContainerView::RunGlobalNote1L( )
{
_LIT(KText,"Global Note Text");
CAknGlobalNote* globalNote = CAknGlobalNote::NewLC();
globalNote->ShowNoteL( EAknGlobalErrorNote, KText);
CleanupStack::PopAndDestroy( globalNote );
}

String handling is one of the more difficult concepts to understand in Symbian even if you come from a C++ background!
In order to get started you should look through the examples in the SDK and forums such as this one.
A book that I cannot recommend enough is Symbian OS explained by Jo Stichbury. It explains all of the basic types and concepts. Beforehand it may be worth familiarising yourself with some of the basic c++ stuff such as pointers, references etc.

Tue, 2007-07-17 18:39
Joined: 2007-07-17
Forum posts: 8
Re: GlobalNote problem (newbie here)

Thanks very much for your help. I feel like I have made a start (at last).

I am following the tutorial from www.cplusplus.com

I have searched for a Symbian programming guide or some sort in our biggest book dealer (www.bol.com) but all the books are over 50 euros (which is I think 60 dollars) Maybe I can find a good alternative on the internet.

By the way. I also have an options menu can I also kill that by using
CleanupStack::PopAndDestroy( optionsMenu );

Thanks again!

Wed, 2007-07-18 10:34
Joined: 2003-09-22
Forum posts: 27
Re: GlobalNote problem (newbie here)

Hi Devoney,
You cannot kill your options menu using CleanupStack::PopAndDestroy( optionsMenu );. CleanupStack is Symbian OS's replacement for normal c++ try catch statements which you will read about.
The book i recommended about is available for roughly €40 on Amazon.
Brian

Wed, 2007-07-18 13:56
Joined: 2007-07-17
Forum posts: 8
Re: GlobalNote problem (newbie here)

Why don't you keep your function simple for the moment. and specify the function header (in your .h file) as

void RunGlobalNote1L( );

and implementation (in your .cpp file) as

void CCastContainerView::RunGlobalNote1L( )
{
_LIT(KText,"Global Note Text");
CAknGlobalNote* globalNote = CAknGlobalNote::NewLC();
globalNote->ShowNoteL( EAknGlobalErrorNote, KText);
CleanupStack::PopAndDestroy( globalNote );
}

I have searched for a .h file like you said. I have found
#include <aknglobalnote.h>
Is this wat you mean? So when I change it in their will this function always be changed on whatever project I am working?

  • Login to reply to this topic.