⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 symbianosbasicslab.cpp

📁 symbian 练习小程序,新手来看看,有意见请指出,谢谢!
💻 CPP
字号:
// SymbianOSBasicsLab.cpp
//
// Copyright (c) 2003 Nokia Ltd.  All rights reserved.


#include <e32cons.h>

// Function prototype
LOCAL_C void UseBasicTypesL();

//////////////////////////////////////////////////////////////////////////////
//
// Main function called by E32
//
//////////////////////////////////////////////////////////////////////////////
GLDEF_C TInt E32Main()
    {

    // Catch any Leaves thrown 
    TRAPD(error, UseBasicTypesL());

	_LIT(KMsgPanic,"Error in Symbian OS Basics Lab: ");
	__ASSERT_ALWAYS(!error, User::Panic(KMsgPanic, error));

	return 0;
    }


//////////////////////////////////////////////////////////////////////////////
//
//
//
//////////////////////////////////////////////////////////////////////////////
LOCAL_C void UseBasicTypesL() 
    {
    // Constant text used for the console app title 
	_LIT(KLabTitle,"Symbian OS Basics Lab");
    
    //
    // 'C' class usage:
    //
    // CConsoleBase derives from CBase and so should be declared on the heap
    // Console::NewL is a special way of doing this we will cover in the 
    // Memory and Resource Management lesson
    CConsoleBase* console = Console::NewL(KLabTitle, TSize(KConsFullScreen, KConsFullScreen));

    //
    // TInt usage
    //
    const TInt KOne = 1;
    const TInt KTwo = 2;

    // STEP 4b: Declare a TInt called <sum> that adds KOne and KTwo 


    _LIT(KSumOutput, "%d + %d is %d\n");
    // STEP 4c: Uncomment the next line (prints KSumOutput to screen)
    // console->Printf(KSumOutput, KOne, KTwo, sum);

    _LIT(KMaxIntOutput, "TInt max: %d\n");
    console->Printf(KMaxIntOutput, KMaxTInt);

    _LIT(KMinIntOutput, "TInt min: %d\n");
    console->Printf(KMinIntOutput, KMinTInt);

    //
    // TBool usage
    //

    // STEP 4d: Declare a TBool called <flag> and initialize to EFalse


    // STEP 4e: Uncomment the next 5 lines
    // if (!flag)
    //     {
    //     _LIT(KFlagFalse, "flag is EFalse\n");
    //     console->Printf(KFlagFalse);
    //     }

    // STEP 4f: Toggle the value of <flag>


    // STEP 4g: Uncomment the next 5 lines    
    // if (flag)
    //     {
    //     _LIT(KFlagTrue, "flag is ETrue\n");
    //     console->Printf(KFlagTrue);
    //     }

    //
    // enum (TKeyCode) and TText usage
    //
    _LIT(KEnterSpace, "Press space to start timer\n");
    console->Printf(KEnterSpace);

    // Look at key input
    TKeyCode key = console->Getch();
    while (EKeySpace != key)
        {
        _LIT(KCharVal, "Char entered is '%c'\n");

        // STEP 6a: Delcare a TText called <keyVal> and set it to <key>.
        //          Note that static_cast<TText>(key) will need to be  
        //          used to prevent a compiler warning.


        // STEP 6b: Uncomment the next line
        // console->Printf(KCharVal, keyVal);
        key = console->Getch();
        }

    //
    // 'R' class usage
    //
    RTimer timer;
    if (KErrNone == timer.CreateLocal())
        {
        TRequestStatus status; // tracks the status of the request
        const TTimeIntervalMicroSeconds32 KTimerInterval = 5000000;
    
        // STEP 6c: Uncomment next line to request timeout of 
        //          KTimerInterval micro seconds
        // timer.After(status, KTimerInterval); 

        // STEP 6d: Uncomment next line to wait synchronously 
        //          for the timer to complete.
        // User::WaitForRequest(status);

        // STEP 6e: Uncomment the next 2 lines that print to the screen
        // _LIT(KTimerComplete, "Timer completed after %d micro secs\n");
        // console->Printf(KTimerComplete, KTimerInterval );
        }
    else
        {
        _LIT(KTimerError, "Error creating timer\n");
        console->Printf(KTimerError);
        }

    timer.Close();

    // Continue
	_LIT(KMsgPressAnyKey,"Press any key to end");
	console->Printf(KMsgPressAnyKey);
	console->Getch();
    
    delete console;
    }




⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -