• 查询练习代码


    查询练习代码

    练习了一下 查询的代码,下面是 rss 文件及 appui 中的代码

    rss

    /*
    * ============================================================================
    * Name : FormTest.rss
    * Part of : FormTest
    * Created : 17.05.2010 by 
    * Description:
    * This file contains all the resources for the FormTest.
    * Initial content was generated by Series 60 Application Wizard.
    * Version :
    * Copyright: 
    * ============================================================================
    */
     
    // RESOURCE IDENTIFIER
    NAME AWIZ // 4 letter ID
     
    // INCLUDES
     
    #include <eikon.rh>
    #include "FormTest.hrh"
    #include "FormTest.loc"
    #include <avkon.rsg>
    #include <avkon.rh>
    #include <avkon.mbg>
     
     
     
    // RESOURCE DEFINITIONS 
     
    RESOURCE RSS_SIGNATURE { }
     
    RESOURCE TBUF { buf = "FormTest"; }
     
    RESOURCE EIK_APP_INFO
        {
        hotkeys = r_formtest_hotkeys;
        menubar = r_formtest_menubar;
        cba = R_AVKON_SOFTKEYS_OPTIONS_BACK;    
        }
     
    //----------------------------------------------------
    //  
    // r_formtest_hotkeys
    //
    //----------------------------------------------------
    //
    RESOURCE HOTKEYS r_formtest_hotkeys
        {
        control =
            {
            HOTKEY { command = EAknCmdExit; key='e'; }
            };
        }
     
    //----------------------------------------------------
    //  
    // r_formtest_menubar
    //
    //----------------------------------------------------
    //
    RESOURCE MENU_BAR r_formtest_menubar
        {
        titles =
            {
            MENU_TITLE { menu_pane = r_formtest_menu; txt = "File"; }
            };
        }
     
    //----------------------------------------------------
    //  
    // r_formtest_menu
    //
    //----------------------------------------------------
    //
    RESOURCE MENU_PANE r_formtest_menu
        {
        items =
            {
            MENU_ITEM { command = EFormTestCmdAppTest; txt = qtn_appl_test; },
            MENU_ITEM { command = 3; txt = "query";cascade = r_query; },
            MENU_ITEM { command = 4; txt = "list";cascade = r_list; },
            MENU_ITEM { command = EAknCmdExit; txt = qtn_appl_exit; }
            };
        }
     
     
    RESOURCE MENU_PANE r_query
        {
            items = 
            {
                    MENU_ITEM { command = 71; txt = "confirm query"; },
                    MENU_ITEM { command = 72; txt = "secret"; },
                    MENU_ITEM { command = 73; txt = "number"; },
                    MENU_ITEM { command = 74; txt = "time"; },
                    MENU_ITEM { command = 75; txt = "date"; },
                    MENU_ITEM { command = 76; txt = "duration"; },
                    MENU_ITEM { command = 77; txt = "float"; },
                    MENU_ITEM { command = 78; txt = "multi"; },
                    MENU_ITEM { command = 79; txt = "confirm"; }
            };
        }
    RESOURCE MENU_PANE r_list
        {
            items = 
            {
                    MENU_ITEM { command = 41; txt = "single list"; },
                    MENU_ITEM { command = 42; txt = "multi list"; }
            };
        }
     
     
    RESOURCE DIALOG r_text_query
        {
            flags = EGeneralQueryFlags;
            buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
            items = 
            {
                    DLG_LINE 
                    {
                        type = EAknCtQuery;
                        id = 711;
                        control = AVKON_DATA_QUERY
                        {
                            layout = EDataLayout;
                            label = "input you name";
                            control = EDWIN
                                {
                                width = 20;
                                maxlength = 18;
                                lines = 1;
                                flags = EEikEdwinNoHorizScrolling | EEikEdwinResizable;
     
                                };
                        };
                    }
            };
     
        }
     
    RESOURCE DIALOG r_secret_query
        {
            flags = EGeneralQueryFlags;
            buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
            items = 
            {
                    DLG_LINE
                        {
                        type=EAknCtQuery;
                        id = 712;
                        control = AVKON_DATA_QUERY
                            {
                                layout = ECodeLayout;
                                label = "input password";
                                control = SECRETED
                                {
                                num_letters = 8;        
                                };
                            };
                        }
            };
        }
     
    RESOURCE DIALOG r_number_query
        {
            flags = EGeneralQueryFlags;
            buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
            items = 
            {
                    DLG_LINE
                        {
                        type=EAknCtQuery;
                        id = 712;
                        control = AVKON_DATA_QUERY
                            {
                                layout = ENumberLayout;
                                label = "input password";
                                control = AVKON_INTEGER_EDWIN
                                {
                                min=0;
                                max = 9999;
                                };
                            };
                        }
            };
        }
     
    RESOURCE DIALOG r_time_query
        {
            flags = EGeneralQueryFlags;
            buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
            items = 
            {
                    DLG_LINE
                        {
                        type = EAknCtQuery;
                        id = 713;
                        control = AVKON_DATA_QUERY
                            {
                                label = "input time";
                                layout = ETimeLayout;
     
                                control = TIME_EDITOR
                                    {
                                        minTime = TIME{second=0;minute=0;hour=0;};
                                        maxTime = TIME{second=59;minute=59;hour=23;};
                                        flags = EEikTimeForce24HourFormat;
                                    };
                            };
                        }
            };
        }
     
    RESOURCE DIALOG r_date_query
        {
        flags = EGeneralQueryFlags;
        buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
        items = 
        {
                DLG_LINE
                    {
                        type = EAknCtQuery;
                        id = 714;
                        control = AVKON_DATA_QUERY
                            {
                            layout = EDateLayout;
                            label = "date query";
                            control = DATE_EDITOR
                            {
                            minDate = DATE{year=1982;};
                            maxDate = DATE{year=2012;};
                            };
                            };
                    }
        };
        }
     
    RESOURCE DIALOG r_duration_query
        {
        flags = EGeneralQueryFlags;
        buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
        items =
        {
                DLG_LINE
                    {
                    type = EAknCtQuery;
                    id = 715;
                    control = AVKON_DATA_QUERY
                        {
                        layout = EDurationLayout;
                        label = "input a duration";
                        control = DURATION_EDITOR
                            {
                                minDuration = DURATION{seconds=0;};
                                maxDuration = DURATION{seconds=3599;};
                                flags = 0;
                            };    
                        };
                    }
        };
        }
     
    RESOURCE DIALOG r_confirm_query
        {
        flags = EGeneralQueryFlags;
        buttons = R_AVKON_SOFTKEYS_YES_NO;
        items = 
        {
                DLG_LINE
                    {
                    type = EAknCtQuery;
                    id = 719;
                    control = AVKON_CONFIRMATION_QUERY
                        {
                        layout=EConfirmationLayout;
                        label ="confirm query";
                        };
                    }
        };
        }
     
     
     
    RESOURCE DIALOG r_duration_layout
        {
        flags = EGeneralQueryFlags;
        buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
        items =
            {
            DLG_LINE
                {
                type = EAknCtQuery;
                id = 7151;
                control = AVKON_DATA_QUERY
                    {
                    layout = EDurationLayout;
                    label = "duration ";
                    control = DURATION_EDITOR
                        {
                        minDuration = DURATION
                            {
                            };
                        maxDuration = DURATION
                            {
                            seconds = 3599;
                            };
                        flags = 0;
                        };
                    };
                }
            };
        }
     
    RESOURCE DIALOG r_float_query
        {
        flags = EGeneralQueryFlags;
        buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
        items = 
        {    
                DLG_LINE
                    {
                        id =7161;
                        type = EAknCtQuery;
     
                        control = AVKON_DATA_QUERY
                            {
                            layout = EFloatingPointLayout;
                            label = "float";
                            control = FLPTED{}; 
     
                            };
                    }
        };
        }
     
     
    RESOURCE DIALOG r_multi_query
        {
        flags = EGeneralQueryFlags;
        buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
        items =
        {
                DLG_LINE
                    {
                        type = EAknCtMultilineQuery;
                        id = EMultilineFirstLine;
                        control = AVKON_DATA_QUERY
                            {
                            layout = EMultiDataFirstEdwin;
                            label = "first number";
                            control = EDWIN{};
                            };
                    },
                DLG_LINE
                    {
                        type=EAknCtMultilineQuery;
                        id = EMultilineSecondLine;
                        control = AVKON_DATA_QUERY
                            {
                            layout=EMultiDataSecondSecEd;
                            label = "second number";
                            control = SECRETED{};
                            };
                    }
        };
        }
     
    RESOURCE DIALOG r_single_list
        {
        flags = EGeneralQueryFlags;
        buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
        items = 
        {
                DLG_LINE
                {
                type = EAknCtListQueryControl;
                id = 411;
                control = AVKON_LIST_QUERY_CONTROL
                    {
                    listtype = EAknCtSinglePopupMenuListBox;
                    listbox = LISTBOX
                        {
                        flags=EAknListBoxMenuList;
                        array_id = r_single_list_array;
                        };
                    heading = "single selection list";
                    };
     
                }
        };
        }
     
     
    RESOURCE ARRAY r_single_list_array
        {
        items =
            {
            LBUF{txt = "1st item";},
            LBUF{txt = "2nd item";},
            LBUF{txt = "3rd item";}
            };
        } 
     
    RESOURCE DIALOG r_multi_list
        {
        flags = EGeneralQueryFlags;
        buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
        items = 
        {
                AVKON_MULTISELECTION_LIST_QUERY_DLG_LINE
                    {
                    control = AVKON_LIST_QUERY_CONTROL
                    {
                    listtype = EAknCtSingleGraphicPopupMenuListBox;
     
                    listbox = AVKON_MULTISELECTION_LIST_QUERY_LIST
                        {   
                        array_id = r_multi_list_array;
                        };
                    heading = "multiSelection list";
                    };
                    }
        };
        }
     
    RESOURCE ARRAY r_multi_list_array
        {
        items =
            {
            LBUF{txt = "1\t1st item";},
            LBUF{txt = "1\t2nd item";},
            LBUF{txt = "1\t3rd item";},
            LBUF{txt = "1\t4rd item";},
            LBUF{txt = "1\t5rd item";}
            };
        }
     
     
    RESOURCE AVKON_MULTISELECTION_LIST_QUERY r_m_q
        {
        flags = EGeneralQueryFlags;
        softkeys = R_AVKON_SOFTKEYS_OK_CANCEL;
        items =
            {
            AVKON_MULTISELECTION_LIST_QUERY_DLG_LINE 
                {
                control = AVKON_LIST_QUERY_CONTROL
                    {
                    listtype = EAknCtSingleGraphicPopupMenuListBox;
                    listbox = AVKON_MULTISELECTION_LIST_QUERY_LIST
                        {
                        array_id=r_guictrls_query_list_multi;
                        };
                    heading = "Multiselection list";
                    };
                }
            };
        }
     
    RESOURCE ARRAY r_guictrls_query_list_multi
        {
        items =
            {
            LBUF{txt = "1\t1st item";},
            LBUF{txt = "1\t2nd item";},
            LBUF{txt = "1\t3rd item";}
            };
        } 
    // End of File

    AppUi 中的   HandleCommand 的代码

    /*
    * ============================================================================
    * Name : CFormTestAppUi from FormTestAppui.cpp
    * Part of : FormTest
    * Created : 17.05.2010 by 
    * Implementation notes:
    * Initial content was generated by Series 60 Application Wizard.
    * Version :
    * Copyright: 
    * ============================================================================
    */
     
    // INCLUDE FILES
    #include "FormTestAppui.h"
    #include "FormTestContainer.h" 
    #include <FormTest.rsg>
    #include "FormTest.hrh"
     
    #include <avkon.hrh>
    #include <aknquerydialog.h>
    #include <e32std.h>
     
     
    // ================= MEMBER FUNCTIONS =======================
    //
    // ----------------------------------------------------------
    // CFormTestAppUi::ConstructL()
    // 
    // ----------------------------------------------------------
    //
    void CFormTestAppUi::ConstructL()
        {
        BaseConstructL();
     
        iAppContainer = new (ELeave) CFormTestContainer;
        iAppContainer->SetMopParent( this );
        iAppContainer->ConstructL( ClientRect() );
        AddToStackL( iAppContainer );
        }
     
    // ----------------------------------------------------
    // CFormTestAppUi::~CFormTestAppUi()
    // Destructor
    // Frees reserved resources
    // ----------------------------------------------------
    //
    CFormTestAppUi::~CFormTestAppUi()
        {
        if (iAppContainer)
            {
            RemoveFromStack( iAppContainer );
            delete iAppContainer;
            }
       }
     
    // ------------------------------------------------------------------------------
    // CFormTestAppUi::DynInitMenuPaneL(TInt aResourceId,CEikMenuPane* aMenuPane)
    // This function is called by the EIKON framework just before it displays
    // a menu pane. Its default implementation is empty, and by overriding it,
    // the application can set the state of menu items dynamically according
    // to the state of application data.
    // ------------------------------------------------------------------------------
    //
    void CFormTestAppUi::DynInitMenuPaneL(
        TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
        {
        }
     
    // ----------------------------------------------------
    // CFormTestAppUi::HandleKeyEventL(
    // const TKeyEvent& aKeyEvent,TEventCode /*aType*/)
    // takes care of key event handling
    // ----------------------------------------------------
    //
    TKeyResponse CFormTestAppUi::HandleKeyEventL(
        const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
        {
        return EKeyWasNotConsumed;
        }
     
    // ----------------------------------------------------
    // CFormTestAppUi::HandleCommandL(TInt aCommand)
    // takes care of command handling
    // ----------------------------------------------------
    //
    void CFormTestAppUi::HandleCommandL(TInt aCommand)
        {
        switch ( aCommand )
            {
            case EAknSoftkeyBack:
            case EEikCmdExit:
                {
                Exit();
                break;
                }
            case EFormTestCmdAppTest:
                {
                iEikonEnv->InfoMsg(_L("test"));
                break;
                }
            case 71:
                {
                    TBuf<20> buf;
                    CAknTextQueryDialog* dlg = CAknTextQueryDialog::NewL(buf);
                    if (dlg->ExecuteLD(R_TEXT_QUERY))
                        {
                        iEikonEnv->InfoMsg(buf);
     
                        }
                break;
                }
            case 72:
                {
                    TBuf<20> buf;
                    CAknTextQueryDialog* dlg = CAknTextQueryDialog::NewL(buf);
                    if (dlg->ExecuteLD(R_SECRET_QUERY))
                        {
                            iEikonEnv->InfoMsg(buf);
                        }
                    break;
                }
            case 73:
                {
                    TInt buf(0);
                    CAknNumberQueryDialog* dlg = CAknNumberQueryDialog::NewL(buf);
                    if (dlg->ExecuteLD(R_NUMBER_QUERY))
                        {
                            TBuf<20> b;
                            b.AppendNum(buf);
                            iEikonEnv->InfoMsg(b);
                        }
                    break;
                }
            case 74:
                {
                    TTime buf;
                    buf.UniversalTime();
                    CAknTimeQueryDialog* dlg = CAknTimeQueryDialog::NewL(buf);
     
                    if (dlg->ExecuteLD(R_TIME_QUERY))
                        {
                            TBuf<20> b;
                            buf.FormatL(b,_L("%H:%T:%S"));
                            //b.AppendNum(buf);
                            iEikonEnv->InfoMsg(b);
                        }
                    break;
                }
            case 75:
                {
     
                TTime buf;
                buf.HomeTime();
                CAknTimeQueryDialog* dlg = CAknTimeQueryDialog::NewL(buf);
     
                if (dlg->ExecuteLD(R_DATE_QUERY))
                    {
                        TBuf<20> b;
                        buf.FormatL(b,_L("%Y-%M-%D"));
                        //b.AppendNum(buf);
                        iEikonEnv->InfoMsg(b);
                    }
                break;
                }
            case 76:
                {
     
                TTimeIntervalSeconds buf;
     
                CAknDurationQueryDialog* dlg = CAknDurationQueryDialog::NewL(buf, CAknQueryDialog::ENoTone );
     
                if (dlg->ExecuteLD(R_DURATION_QUERY))
                    {
                        TBuf<20> b;
     
                        //buf.FormatL(b,_L("%Y-%M-%D"));
                        b.AppendNum(buf.Int());
                        iEikonEnv->InfoMsg(b);
                    }
                break;
                }
     
            case 77:
                {
                TReal value;
                CAknFloatingPointQueryDialog* dlg = CAknFloatingPointQueryDialog::NewL(value);
                if (dlg->ExecuteLD(R_FLOAT_QUERY))
                    {
                    TBuf<20> b;
                    TRealFormat rf(10,2);
                    b.AppendNum(value,rf);
                    iEikonEnv->InfoMsg(b);
                    }
                break;
                }
            case 78:
                {
                TInt i1(0);
                TInt i2(0);
                TBuf<20> d3;
                TBuf<20> d4;
                CAknMultiLineDataQueryDialog* dlg = CAknMultiLineDataQueryDialog::NewL(d3,d4);
                if (dlg->ExecuteLD(R_MULTI_QUERY))
                    {
                      _LIT(Kmsg,"i1=%d i2=%d");
                      TBuf<20> buf;
                      buf.Format(Kmsg,i1,i2);
                      buf.Append(d3);
                      iEikonEnv->InfoMsg(buf);
                    }
                }
            case 79:
                {
     
                CAknQueryDialog* dlg = CAknQueryDialog::NewL();
                if (dlg->ExecuteLD(R_CONFIRM_QUERY))
                    {
                        iEikonEnv->InfoMsg(_L("ok"));
                    } 
                else
                    {
                        iEikonEnv->InfoMsg(_L("cancel"));
                    }
                break;
                }
            case 41:
                {
                TInt index(0);
                CAknListQueryDialog* dlg = new(ELeave)CAknListQueryDialog(&index);
                if (dlg->ExecuteLD(R_SINGLE_LIST))
                    {
                    _LIT(Kmsg,"index = %d");
                      TBuf<20> buf;
                      buf.Format(Kmsg,index);
                      iEikonEnv->InfoMsg(buf);
                    }
                break;
                }
            case 42:
                {
                    CArrayFixFlat<TInt>* array = new (ELeave)CArrayFixFlat<TInt>(6);
                    CleanupStack::PushL(array);
                    CAknListQueryDialog* dlg = new(ELeave)CAknListQueryDialog(array);
                    if (dlg->ExecuteLD(R_MULTI_LIST))
                        {
                            TInt len = array->Length();
                            TBuf<40> buf;
                            TBuf<10> tmpbuf;
                            _LIT(Kmsg,"index=%d");
     
                            for (int i=0;i<len;i++)
                                {
                                    tmpbuf.Zero();
                                    TInt tmpvalue= array->At(i);
                                    if (tmpvalue=NULL) break;
                                    tmpbuf.Format(Kmsg,array->At(i));
                                    buf.Append(tmpbuf);
                                }
                            iEikonEnv->InfoMsg(buf);
                        }
                    CleanupStack::PopAndDestroy();
                }
     
     
            // TODO: Add Your command handling code here
     
            default:
                break;     
            }
        }
     
     
     
    // End of File 

  • 相关阅读:
    js监听对象属性的改变
    js中的垃圾回收机制
    防抖和节流
    Ajax的浏览器缓存问题及解决方法
    Java多线程系列---“基础篇”07之 线程休眠
    Java多线程系列---“基础篇”06之 线程让步
    Java多线程系列---“基础篇”05之 线程等待与唤醒
    Java多线程系列---“基础篇”04之 synchronized关键字
    Java多线程系列---“基础篇”03之 Thread中start()和run()的区别
    Java多线程系列---“基础篇”02之 常用的实现多线程的两种方式
  • 原文地址:https://www.cnblogs.com/zziss/p/1740206.html
Copyright © 2020-2023  润新知