• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            隨筆 - 2, 文章 - 73, 評(píng)論 - 60, 引用 - 0
            數(shù)據(jù)加載中……

            Symbian 中各種提示、輸入對(duì)話框的使用

            1、非阻塞提示框

            symbian定義了幾個(gè)提示類,分別是:
            confirm類:CAknConfirmationNote
            info類: CAknInformationNote
            warning類:CAknWarningNote
            error類:CAknErrorNote

            頭文件:aknnotewrappers.h
            lib: avkon.lib   eikcdlg.lib   eikctl.lib

            Code:
            TBuf<32> buf;
            buf.Copy(_L("info note"));
            CAknInformationNote* iInfoNote = new (ELeave) CAknInformationNote;
            iInfoNote->ExecuteLD(buf);

            2、阻塞提示框

            void CEikonEnv::AlertWin(const TDesC& aMsg);
            void CEikonEnv::AlertWin(const TDesC& aMsg1,const TDesC& aMsg2);
            static void CEikonEnv::InfoWinL(const TDesC& aFirstLine,const TDesC& aSecondLine);

            AlertWin為CEikonEnv類的非靜態(tài)成員函數(shù),InfoWinL為CEikonEnv類的靜態(tài)成員函數(shù)。
            AlertWin只能在ui、view和container中使用,使用方法如下:

            Code:
            iEikonEnv->AlertWin(_L("text"));

            InfoWinL可以在任意類中使用,使用方法如下:
            Code:
            CEikonEnv::Static()->InfoWinL(_L("note:"), _L("text"));

            為方便使用,常定義宏來(lái)使用這類提示框,如:

            Code:
            #define DEBUG_DIALOG(x) iEikonEnv->AlertWin(##x);
            #define DEBUG_DIALOG1(x) CEikonEnv::Static()->InfoWinL(_L("note:"), ##x);
            #define DEBUG_DIALOG2(x,y) CEikonEnv::Static()->InfoWinL(##x, ##y);

            可以這么使用:
            TBuf<32> buf;
            buf.Copy(_L("test"));
            DEBUG_DIALOG(buf);
            DEBUG_DIALOG1(buf);
            DEBUG_DIALOG2(buf,_L("text"));

            此類提示框阻塞線程,只有用戶按鍵退出提示框后,后面的程序才能接著運(yùn)行。

            3、進(jìn)度條對(duì)話框

            進(jìn)度條對(duì)話框類為:
            CAknProgressDialog
            頭文件:aknprogressdialog.h
            lib:avkon.lib   eikcdlg.lib   eikctl.lib

            Code:

            //初始化進(jìn)度條
            CAknProgressDialog* iProgressDialog;
            CEikProgressInfo* iProgressInfo;
            iProgressDialog = new ( ELeave ) CAknProgressDialog( reinterpret_cast
                                                                    <CEikDialog**>
                                                                    ( &iProgressDialog ) );
            iProgressDialog->SetCallback( this );
            iProgressDialog->PrepareLC( R_RESOURCE_PROGRESS_NOTE );   //從資源文件構(gòu)造對(duì)話框,資源見下面的定義
            iProgressInfo = iProgressDialog->GetProgressInfoL();
            iProgressInfo->SetFinalValue( aMaxValue );   //設(shè)置進(jìn)度條的最大值(結(jié)束值)
            iProgressDialog->RunLD();
              
            //更新進(jìn)度條
            iProgressInfo->IncrementAndDraw( aStep );  

            //結(jié)束進(jìn)度條
            iProgressDialog->ProcessFinishedL();
            delete iProgressDialog;

            RESOURCE DIALOG R_RESOURCE_PROGRESS_NOTE   //進(jìn)度條對(duì)話框資源
                 {
                 flags = EAknProgressNoteFlags;
                 buttons = R_AVKON_SOFTKEYS_CANCEL;
                 items =
                     {
                     DLG_LINE
                         {
                         type = EAknCtNote;
                         id = EMagicBoxCtrlIdProgressNote;
                         control = AVKON_NOTE
                             {
                             layout = EProgressLayout;
                             singular_label = "對(duì)話框中顯示的文字";
                             plural_label = "download";
                             imagefile = AVKON_BMPFILE_NAME;    //第二版中 圖標(biāo)文件為 #define AVKON_BMPFILE_NAME "z:\\system\\data\\avkon.mbm"
                             imageid = EMbmAvkonQgn_note_sml;   //這兩項(xiàng)可更改顯示不同圖標(biāo)
                             imagemask = EMbmAvkonQgn_note_sml_mask;
                             };
                         }
                     };
                 }

            注意:In Series 60 3rd edition, avkon.mbm was replaced by avkon2.mbm and moved to a different location (and the SDK forgot to mention this and still provides erroneous location).
            Old entry:
                           imagefile = "z:\\system\data\avkon.mbm";
            New entry:
                           imagefile = "z:\\resource\apps\avkon2.mbm";


            4、等待對(duì)話框

            等待對(duì)話框要用到的類:CAknGlobalNote
            頭文件:aknglobalnote.h
            lib:aknnotify.lib eiksrv.lib

            Code:

            //顯示等待對(duì)話框
               CAknGlobalNote* globalNote = CAknGlobalNote::NewL();
               CleanupStack::PushL( globalNote );
               TInt iWaitNoteId = globalNote->ShowNoteL( EAknGlobalWaitNote, _L("對(duì)話框中顯示的文字") );
               CleanupStack::PopAndDestroy();
              
               //結(jié)束等待對(duì)話框
               CAknGlobalNote * note = CAknGlobalNote::NewL();
               CleanupStack::PushL( note );
               note->CancelNoteL( iWaitNoteId );
               CleanupStack::PopAndDestroy();

            注意:
            CAknGlobalNote類除了顯示等待對(duì)話框外還可顯示多種類型的全局對(duì)話框,具體類型可通過ShowNoteL的第一個(gè)參數(shù)指定,可能的類型如下:


            Code:

            enum TAknGlobalNoteType
            {
            EAknGlobalInformationNote = 1,
            EAknGlobalWarningNote,
            EAknGlobalConfirmationNote,
            EAknGlobalErrorNote,
            EAknGlobalChargingNote,
            EAknGlobalWaitNote,
            EAknGlobalPermanentNote,
            EAknGlobalNotChargingNote,
            EAknGlobalBatteryFullNote,
            EAknGlobalBatteryLowNote,
            EAknGlobalRechargeBatteryNote,
            EAknCancelGlobalNote,
            EAknGlobalTextNote
            };

            5、詢問對(duì)話框

            詢問對(duì)話框用到的類:CAknQueryDialog
            頭文件:AknQueryDialog.h
            lib:avkon.lib

            Code:

            CAknQueryDialog* dlg;
            dlg = CAknQueryDialog::NewL( CAknQueryDialog::ENoTone );
            dlg->PrepareLC( R_RESOURCE_QUERY_DIALOG ); //從資源文件構(gòu)造對(duì)話框,資源見下面的定義
            TInt ret = dlg->RunLD();   //若用戶選擇“是”,返回非0,選擇“否”,則返回0

            RESOURCE DIALOG R_RESOURCE_QUERY_DIALOG   //詢問對(duì)話框資源
                 {
                 flags = EGeneralQueryFlags;
                 buttons = R_AVKON_SOFTKEYS_YES_NO;   //CBA顯示“是”和“否”兩個(gè)按鈕
                 items =
                     {
                     DLG_LINE
                         {
                         type = EAknCtQuery;
                         id = EGeneralQuery;
                         control = AVKON_CONFIRMATION_QUERY    //表示這是confirm詢問對(duì)話框,用戶選擇“是”或“否”
                             {
                             layout = EConfirmationQueryLayout;
                             label = "對(duì)話框中顯示的文字";
                             };
                         }
                     };
                 }

            此類對(duì)話框可以有聲音提示,由NewL的const TTone& aTone參數(shù)指定,可能的值如下:

            Code:

            enum TTone {
                 /// No tone is played
                 ENoTone = 0,        
                 /// A confirmation tone is played
                 EConfirmationTone = EAvkonSIDConfirmationTone,
                 /// A warning tone is played
                 EWarningTone = EAvkonSIDWarningTone,      
                 /// An error tone is played  
                 EErrorTone = EAvkonSIDErrorTone         
                 };

            通過定義不同的詢問對(duì)話框資源,可實(shí)現(xiàn)不同的詢問對(duì)話框,如讓用戶輸入文字的詢問對(duì)話框資源定義如下:

            Code:

            RESOURCE DIALOG R_RESOURCE_DATA_QUERY
               {
               flags = EGeneralQueryFlags;
               buttons = R_AVKON_SOFTKEYS_OK_CANCEL;   //CBA按鈕顯示“確定”和“取消”
               items =
                   {
                   DLG_LINE
                       {
                       type = EAknCtQuery;
                       id = EGeneralQuery;
                       control = AVKON_DATA_QUERY   //表示這是data詢問對(duì)話框,需要用戶輸入內(nèi)容
                           {
                           layout = EDataLayout;
                           label = "提示內(nèi)容";
                           control = EDWIN
                               {
                               flags = EEikEdwinNoHorizScrolling | EEikEdwinResizable;
                               width = 30;
                               lines = 2;
                               maxlength = 159;
                               };
                           };
                       }
                   };
               }    

            Code:

            TBuf<128> msg;
            CAknTextQueryDialog* dlg = new (ELeave) CAknTextQueryDialog(msg,CAknQueryDialog::ENoTone);
               TInt ret = dlg->ExecuteLD(R_RESOURCE_DATA_QUERY);

            用戶輸入內(nèi)容后按“確定”,內(nèi)容就存儲(chǔ)到msg中,函數(shù)返回非0;按“取消”,函數(shù)返回0。

            這里用到的類是CAknQueryDialog的子類CAknTextQueryDialog。
            CAknQueryDialog的子類有:

            Code:

            CAknFloatingPointQueryDialog   //This class should be used when user is reguest to enter a flotaing point number
               CAknFixedPointQueryDialog      //...
               CAknDurationQueryDialog        //This class should be used when user is reguest to enter duration
               CAknIpAddressQueryDialog       //This class should be used when user is reguest to enter IP address,@since 2.1
               CAknMultiLineDataQueryDialog   //Query Dialog with data input on more than one line (2 lines at the moment)
                              Create using NewL methods and passing parameters as appropriate.
                              Attention: When deriving from this class, you must call SetDataL during
                              second phase construction.
               CAknMultiLineIpQueryDialog     //...
               CAknNumberQueryDialog          //This class should be used when user is reguest to enter number
               CAknTextQueryDialog            //This class should be used when user is reguest to enter plain text, secret text, phonenumber or PIN-code
            CAknTimeQueryDialog            //This class should be used when user is reguest to enter time or date

            使用不同的類,資源文件會(huì)有所不同。

            另外,在資源中定義EDWIN時(shí),可指定輸入發(fā),如:

            Code:

            control = EDWIN
               {
                 flags = EEikEdwinNoHorizScrolling | EEikEdwinResizable;
                 width = 11;
                 lines = 1;
                 maxlength = 11;
               avkon_flags = EAknEditorFlagFixedCase |
                     EAknEditorFlagNoT9 | EAknEditorFlagSupressShiftMenu;   //EAknEditorFlagSupressShiftMenu屏蔽切換輸入法鍵
               allowed_input_modes = EAknEditorNumericInputMode;
               default_input_mode = EAknEditorNumericInputMode;
               numeric_keymap = EAknEditorPlainNumberModeKeymap;
               };

            以上寫法表示默認(rèn)輸入法為數(shù)字,并且屏蔽了輸入法切換鍵,即不能通過輸入法切換鍵來(lái)切換輸入法。


            6、編輯框

            編輯框使用的類:CEikGlobalTextEditor
            頭文件:eikgted.h

            Code:

            CEikGlobalTextEditor* iGKeyEd;
            TBuf<128> iKeyText;
            TResourceReader reader;
            iCoeEnv->CreateResourceReaderLC( reader, R_RESOURCE_EDITOR );   //從資源文件構(gòu)造編輯框,資源見下面的定義
            iGKeyEd = new ( ELeave ) CEikGlobalTextEditor;
            iGKeyEd->SetContainerWindowL( *this );
            iGKeyEd->ConstructFromResourceL( reader );
            CleanupStack::PopAndDestroy();   // Resource reader

            //設(shè)置編輯框的初始文本和位置,編輯框大小在資源中定義
            TBuf<32> buf;
            buf.Copy(_L("demo"));
            iGKeyEd->SetTextL(&buf);
            iGKeyEd->SetExtent( TPoint(5,2), iGKeyEd->MinimumSize() );
            iGKeyEd->SetFocus(ETrue);
            // iGKeyEd->SetReadOnly(ETrue);   //設(shè)置編輯框?yàn)橹蛔x

            //使文字居中
            CParaFormat      paraFormat; 
            TParaFormatMask paraFormatMask;
            paraFormatMask.SetAttrib( EAttAlignment );     // set mask
            paraFormat.iHorizontalAlignment = CParaFormat::ECenterAlign;
            iGKeyEd->ApplyParaFormatL( &paraFormat, paraFormatMask );
              
            iGKeyEd->GetText(iKeyText); //獲取編輯框中的內(nèi)容,保存到iKeyText中

            RESOURCE GTXTED R_RESOURCE_EDITOR   //編輯框資源  
               {
                 flags = EAknEditorFlagDefault;
                 width = 53;
                 height = 16;
                 numlines = 1;
                 textlimit= 1;
                 fontcontrolflags = EGulFontControlAll;
                 fontnameflags = EGulNoSymbolFonts;

            //這里也可設(shè)置輸入法
            //    avkon_flags = EAknEditorFlagFixedCase |
                                               EAknEditorFlagNoT9 | EAknEditorFlagSupressShiftMenu;   //EAknEditorFlagSupressShiftMenu屏蔽切換輸入法鍵
            //     allowed_input_modes = EAknEditorNumericInputMode;
            //     default_input_mode = EAknEditorNumericInputMode;
            //     numeric_keymap = EAknEditorPlainNumberModeKeymap;  
               }

            注意,要使編輯框正常顯示,記得更改container的CountComponentControls和ComponentControl函數(shù),正確處理控件數(shù)目和編輯框指針。另外,要使編輯框能正常接收按鍵事件,要顯示調(diào)用編輯框的OfferKeyEventL函數(shù),如下:

            Code:

            TKeyResponse CMobileGuardSetKeyContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
            {
                 return iGKeyEd->OfferKeyEventL( aKeyEvent, aType );
            }

            posted on 2007-11-06 15:18 郭天文 閱讀(5430) 評(píng)論(2)  編輯 收藏 引用 所屬分類: S60

            評(píng)論

            # re: Symbian 中各種提示、輸入對(duì)話框的使用  回復(fù)  更多評(píng)論   

            這么好的文章沒有人,頂。
            2010-09-09 11:07 | hherima

            # re: Symbian 中各種提示、輸入對(duì)話框的使用[未登錄]  回復(fù)  更多評(píng)論   

            好東西,頂一個(gè)
            2010-09-19 13:59 | l
            日本精品久久久久中文字幕| 亚洲国产精品婷婷久久| A级毛片无码久久精品免费| 亚洲狠狠婷婷综合久久蜜芽| 性欧美大战久久久久久久| 精品视频久久久久| 久久不见久久见免费影院www日本| 2021久久国自产拍精品| 久久成人国产精品| 久久精品国产亚洲av日韩| 久久久久人妻一区精品色| 三上悠亚久久精品| 久久久久久毛片免费播放| 久久99精品久久久久子伦| 亚洲欧美日韩中文久久| 久久成人国产精品| 久久精品国产精品国产精品污| 狠狠干狠狠久久| 国产精品亚洲综合专区片高清久久久 | 亚洲国产成人久久综合一区77| 久久亚洲精品无码观看不卡| 久久亚洲AV无码精品色午夜 | 久久综合视频网| 人妻精品久久无码专区精东影业| 久久久久久亚洲精品成人| 四虎国产精品免费久久5151| 久久亚洲AV永久无码精品| 亚洲色欲久久久综合网东京热| 久久99精品国产99久久6男男| 久久亚洲色一区二区三区| 无码人妻精品一区二区三区久久久| 久久久久高潮毛片免费全部播放| 国产毛片久久久久久国产毛片| 日韩欧美亚洲综合久久| 久久久久四虎国产精品| 亚洲午夜久久久| 国产日产久久高清欧美一区| 欧美久久久久久| 亚洲一本综合久久| 久久亚洲国产精品成人AV秋霞| 久久综合狠狠综合久久激情 |