×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Jun 2004
    Location
    Helsinki, Finland
    Posts
    38

    frustrations in using dialogs and controls

    I'm reposting here, in perhaps a more suitable location, a rant I published two days ago in "Developer's Feedback to Nokia / Series 40 & S60 Platform Feedback", under the title "dialogs in SymbianOS/S60 a complete crock":


    Of all the frustrations in programming for Symbian/S60 devices, I have, in the last few working days, come to discover dialogs as the worst of the worst.

    I've been attempting to create a fairly simple dialog with two input fields: an integer number, called an extension in my app, and a numeric password, or a PIN. All I need to display to the user in the dialog is (a) a couple of lines of instructions, (b) a label telling what to enter in the first field, (c) a field for entering the extension number, (d) a label telling what to enter in the second field, and (e) a field for entering a secret PIN. Not a tall order, one would think, and perusing the available documentation, one would indeed think that this would be a snap. Just define a dialog resource in an .rss file, then instantiate a dialog class with the resource's ID.

    That turned out to be a vain hope. Almost nothing works as documented, and while the resoure compiler catches some errors, there are others that are only evident when the OS throws up some cryptic panic code when the program tries to instantiate the dialog: KERN-EXEC 3, of BAFL 4, or what have you. The documentation for these panic codes is usually not that useful in telling one what the actual problem is. At other times, the dialog's instantiation will not crash, but on the emulator's screen, all that can be seen is the title bar, an empty background, and the softkey indicator -- plus, sometimes, a scroll-bar floating on the edge of the empty background. At other times, other weird errors appear.

    Let's start with what works. After lots of trial and error, I have arrived at the following resource. Keep in mind that I have not yet actually tried to use the dialog in the program; so far, I have only ascertained that the following definition results in a dialog that I can instantiate and that doesn't look obviously broken. (The identifiers, such as "EAuthQueryDlgExtensionEntry" here and later, are defined in an app-specific .hrh file.)

    Code:
    RESOURCE DIALOG r_authorisation_query_dialog
        {
        flags   = EGeneralQueryFlags; 
        buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
        items =
            {
            DLG_LINE
                {
                type      = EAknCtQuery;
                id        = EAuthQueryDlgExtensionEntry;
                itemflags = EAknEditorFlagNoT9;
                control   = AVKON_DATA_QUERY
                    {
                    layout = ENumberLayout;
                    // class CAknIntegerEdwin can be instantiated based on a
                    // AVKON_INTEGER_EDWIN control:
                    control = AVKON_INTEGER_EDWIN
                        {
                        min         = 0;
                        max         = 9999;
                        unset_value = 0;
                        maxlength   = 4;
                        };
                    };
                }
            };
        }
    When constructed with the following code:

    Code:
    void CMobUiAuthorisationViewContainer::ConstructL(
            const TRect&         aRect,
            const CCoeControl*   aParent,
            MEikCommandObserver* aCommandObserver,
            CMobUiBaseView*      aView )
        {
        // Construct base container and create window
        BaseConstructL( aRect, aParent, aCommandObserver, aView );
        ActivateL(); // must be called before control can be drawn
    
        HBufC* noteText = StringLoader::LoadLC( R_STRING_AUTHORISATION );
        iAuthQueryDlg = new ( ELeave ) CMobUiAuthorisationQueryDialog( *noteText );
        CleanupStack::PopAndDestroy( noteText );
        iAuthQueryDlg->SetMopParent( this );
        iAuthQueryDlg->ExecuteLD( R_AUTHORISATION_QUERY_DIALOG );
        AppUi()->AddToStackL( iAuthQueryDlg );
        //!!! continue...
        }
    a dialog does appear on the screen. Its title is "Authorisation", because that's what the definition of R_STRING_AUTHORISATION is. Below the line of text "Authorisation" is a box where one can enter up to numbers. Above the right-hand corner of the box is the symbol that tells that numbers only can be entered. Four digits can be typed in, and if a fifth digit key is pressed, a little box appears on the screen saying that the maximum number of characters has been reached. The left-hand softkey is labeled "OK" and the right-hand one as "Cancel". All of this is as expected.

    Now, to the things that go wrong.

    BUG 1: If I replace the line flags = EGeneralQueryFlags; by flags = EEikDialogFlagNoDrag | EEikDialogFlagCbaButtons | EEikDialogFlagFillAppClientRect | EEikDialogFlagWait;, then, at dialog instantiation, the app crashes with a message App. closed: Application Name KERN-EXEC 3. And what does KERN-EXEC 3 mean? According to http://www.symbian.com/developer/tec.../SystemPanics/, it means: "This panic is raised when an unhandled exception occurs. Exceptions have many causes, but the most common are access violations caused, for example, by dreferencing NULL. Among other possible causes are: general protection faults, executing an invalid instruction, alignment checks, etc."

    Very useful. Through trial and error, I traced the cause of the panic to the flag EEikDialogFlagFillAppClientRect. Why it should have this effect, I don't know; according to the .chm-form documentation that comes with the SDK, one should be able to use it so that "The dialog will be sized to fill the client rect." But henceforth I'll know to avoid it.

    There is no warning about this problem at compile time, it is not mentioned in the documentation, and the run-time error is useless.

    BUG 2: Let's say I want to add a prompt before the entry box, to show the user a text such as "extension number:". The DLG_LINE structure, defined in eikon.rh, has just the field for this, called "prompt":

    Code:
    STRUCT DLG_LINE
        {
        WORD type;
        LTEXT prompt;
        WORD id=0;
        LONG itemflags=0;
        STRUCT control;
        LTEXT trailer="";
        LTEXT bmpfile = "" ;   // NEW AVKON bitmap filename 
        WORD bmpid = 0xffff ;  // NEW AVKON icon image ID
        WORD bmpmask ;         // NEW AVKON icon mask ID
        LTEXT tooltip = "" ;   // NEW AVKON hint text for form line
        }
    The documentation tells that its meaning is "The text that appears in front of the control in this dialog line." So, if I change the dialog line's definition thus:

    Code:
        ...
        DLG_LINE
            {
            type      = EAknCtQuery;
            id        = EAuthQueryDlgExtensionEntry;
            itemflags = EAknEditorFlagNoT9;
            prompt    = "extension number:";
            control   = AVKON_DATA_QUERY
        ...
    you'd think the text "extension number:" would appear above the box. Instead, the dialog now looks like it was shifted to the right by about half the width of the screen, with the rest having fallen off. On its left side appears a black bar the width of the evacuated area, the height from the top of the dialog to about one-fifth of the way down. Not very good.

    I then thought that maybe the fields have to be given in exactly the order they are defined in STRUCT DLG_LINE in eikon.rh. I shifted the "prompt" field to right after the type field, but this produced no difference to the previous result.


    BUG 3: So, if the "prompt" field of DLG_LINE cannot be used, some workaround will have to do. One can have a label as a dialog line. So, I added the following to my dialog structure definition:

    Code:
    RESOURCE DIALOG r_authorisation_query_dialog
        {
        flags   = EGeneralQueryFlags; 
        buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
        items =
            {
            DLG_LINE
                {
                type      = EEikCtLabel; // corresponds to LABEL
                id        = EAuthQueryDlgExtensionLabel;
                control   = LABEL { txt = "extension number:"; };
                },
            DLG_LINE
                {
                type      = EAknCtQuery;
    ...
    The result, in this case, is the text "extension number:" floating above the dialog, and above the dialog's label, "Authorisation". So obviously, I cannot use a label, either.


    (continued in follow-up post, due to size limitation on entries)

  2. #2
    Registered User
    Join Date
    Jun 2004
    Location
    Helsinki, Finland
    Posts
    38

    Re: frustrations in using dialogs and controls

    continued from the first post


    BUG 4: OK, fine, perhaps I'll just have to use the dialog's label text -- the text that currently says "Authorisation" -- to explain to the user that he should enter the extension number and the PIN in the two boxes below. I delete the DLG_LINE for the label, and change the definition of the R_STRING_AUTHORISATION resource. However, now that the text is longer, I discover that it does not wrap.

    Update added to this repost: That was a mistake; the text does wrap. This is a relief, as it means I can use at least have sufficiently long instruction to the user in a single-control dialog.


    BUG 5: To get the other edit box, for the PIN, to appear, I add another the following DLG_LINE to the dialog's definition:

    Code:
                ...(first edit box)...
                },
            DLG_LINE
                {
                type    = EAknCtQuery;
                id      = EAuthQueryDlgPasswordEntry;
                control = AVKON_DATA_QUERY
                    {
                    layout = ENumberLayout;
                    // classes CEikSecretEditor and CAknNumericSecretEditor
                    // can be instantiated based on a NUMSECRETED control:
                    control = NUMSECRETED
                        {
                        num_code_chars = KMaxPasswordDigits;
                        };
                    };
                }
            };
        }
    What now happens at dialog instantiation is that the app crashes, with the following immensely useful error code displayed: App. closed: Application Name BAFL 4. And what does BAFL 4 mean? According to the web page referred to above, it means that "This panic is raised by the Read...() member functions and the Advance() member function of TResourceReader, when the current position in the resource buffer is moved beyond the end of the buffer." Well, that makes it all clear.

    After a lot of trial and error and googling, I find out that I have to replace the line layout = ENumberLayout; in the DLG_LINE's definition by layout = EPinLayout;. Is the fact that EPinLayout has to be used with a NUMSECRETED mentioned anywhere in the documentation that comes with S60? Of course not. Is it mentioned in file avkon.hr, where STRUCT NUMSECRETED is defined in? Of course not. The different layout constants, including EPinLayout, are defined in an anonymous enum in avkon.hrh. Are they commented in any way to tell which structures each constant is to be used for? No, of course not.

    BUG 6: So, after the change to the "layout" field just mentioned, the dialog's instantiation doesn't crash. But, neither is a second edit box shown, only the one that was there earlier.

    However, If I delete the first DLG_LINE, leaving only the one encapsulating the NUMSECRETED control, the control does appear. (It looks the same as the original one, but when digits are entered, stars appear in the edit box.) So it seems that only one edit box can be displayed in one dialog.

    OTHER BUGS: I've left out many other errors I encountered and no longer remember. I think I tried using an AVKON_INTEGER_EDWIN control directly in a DLG_LINE, without encapsulating it in an AVKON_DATA_QUERY, and that resulted in an empty screen background, but I'm no longer sure. I also tried to use a multi-page dialog with only one page, in the forlorn hope that something would work better there, but no joy there, either.


    Conclusion: By now I'm ready to give up. I'll just use two separate dialogs for entering the two fields. Though it's hard to believe it would be impossible to do so within a single dialog in the world's most popular smartphone operating system, so it would appear.

    (I'm using the S60 3.0 MR 2 SDK, and Carbide.c++ v1.2.2.)

    My advice to Symbian and Nokia would be, if it's impossible to throw out this almost completely broken UI component framework in favour of something more sensible, is to (a) make it work as it's documented; (b) if that's impossible, change the documentation to reflect how things actually work; (c) and in general, document things much better than currently.


    I'd also be interested to hear any tips on how one should go about doing what I'm attempting to do.

  3. #3
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644

    Re: frustrations in using dialogs and controls

    Have you read through the workbook?
    (http://www.forum.nokia.com/info/sw.n..._1_en.pdf.html)

    Next look at the examples
    (e.g. Registration example)

    Next look at the supplied documentation in the S60Doc folder
    s60_platform_avkon_ui_resources_forms_v1_1_en.pdf
    s60_platform_avkon_ui_resources_dialogs_v1_1_en.pdf
    s60_platform_avkon_ui_resources_editors_v1_1_en.pdf

    Of course you can use the UI designer to build the front end if you have the developer version of Carbide

  4. #4
    Registered User
    Join Date
    Jun 2004
    Location
    Helsinki, Finland
    Posts
    38

    Re: frustrations in using dialogs and controls

    Reading the documentation (in file S60Doc\s60_cpp_sdk_3rd_mr.chm that comes with the SDK) further I did find out that there's a special "Multiline query dialog", where "multiline" means "two-line". One has to tell the DLG_LINE that the type is EAknCtMultilineQuery. Based on the resource example given in the documentation, I ended up with the following resource definition:

    Code:
    RESOURCE DIALOG r_authorisation_query_dialog
        {
        flags   = EGeneralQueryFlags;
        buttons = R_AVKON_SOFTKEYS_OK_CANCEL;
        items =
            {
            DLG_LINE
                {
                type      = EAknCtMultilineQuery;
                id        = EAuthQueryDlgExtensionEntryId;
                itemflags = EAknEditorFlagNoT9;
                control   = AVKON_DATA_QUERY
                    {
                    layout = EMultiDataFirstNumEd;
                    // class CAknIntegerEdwin can be instantiated based on a
                    // AVKON_INTEGER_EDWIN control:
                    control = AVKON_INTEGER_EDWIN
                        {
                        min         = 0;
                        unset_value = 0;
                        maxlength   = KMaxExtensionDigits;
                        };
                    };
                },
            DLG_LINE
                {
                type    = EAknCtMultilineQuery;
                id      = EAuthQueryDlgPasswordEntryId;
                control = AVKON_DATA_QUERY
                    {
                    layout = EMultiDataSecondPinEd;
                    // classes CEikSecretEditor and CAknNumericSecretEditor can be
                    // instantiated based on a NUMSECRETED control:
                    control = NUMSECRETED
                        {
                        num_code_chars = KMaxPasswordDigits;
                        };
                    };
                }
            };
        }
    I had to guess what exactly should go in the AVKON_DATA_QUERY controls' layout field. Before I got to the resource above, I first used my original layout definitions, that is, ENumberLayout and EPinLayout. That caused the app to crash with a panic code of BAFL 15 when it tried to instantiate the dialog. I then replaced the layout definitions by EMultiDataFirstEdwin and EMultiDataSecondPinEd (from enum EAknMultilineDataLayout in file avkon.hrh), which resulted in the same thing. I then hit upon the right layout IDs: EMultiDataFirstNumEd and EMultiDataSecondPinEd. (There's naturally no documentation on these constants in the code, nor any mention of them in the SDK's documentation.)

    Now, the app doesn't crash when it's launched and the dialog instantiated. Instead, what I see in the emulator is a screen that is otherwise empty, except for the softkey labels OK and Cancel on the bottom, and the the dark blue band of the title bar that has the battery and network icons. Not even the application title is displayed.

    To tell the truth, by this point, I'd be shocked if the dialog had actually worked as expected.

    On edit, adding the following:

    If I type in digits, then at the ninth digit, the warning "Maximum number of characters reached" is displayed on the screen. So apparently the dialog has been instantiated, even if it is invisible, and I am entering digits into the first control.

    When I now press the left softkey, marked OK, the execution moves to the following function:

    Code:
    TBool CMobUiAuthorisationQueryDialog::OkToExitL( TInt aKeycode )
        {
        switch ( aKeycode )
            {
            case EAknSoftkeyOk:
                {
                // Get the extension number editor control:
                CAknIntegerEdwin* extensionEditor =
                    static_cast< CAknIntegerEdwin* >(
                        ControlOrNull( EAuthQueryDlgExtensionEntryId ) );
                if ( extensionEditor == NULL )
                    {
                    // something is very wrong if the control can't be accessed
                    User::Leave( EMobilityUi );
                    }
                TInt enteredExtension;
    
                CAknNumericEdwin::TValidationStatus validationStatus =
                    extensionEditor->GetTextAsInteger( enteredExtension ); // CRASH HERE
    And as before, the execution goes fine until the last line included above, then the app crashes with the panic code EIKON-EDWIN 8 displayed on the screen. This means, I think, TEikEdwinPanic::EEikPanicEdwinNoText, which I already saw in earlier experiments: see thread http://discussion.forum.nokia.com/fo...d.php?t=124422, which no one has commented on yet.
    Last edited by leisti; 2008-01-10 at 22:53. Reason: used the invisible dialog, and it crashed

  5. #5
    Registered User
    Join Date
    Jun 2004
    Location
    Helsinki, Finland
    Posts
    38

    Re: frustrations in using dialogs and controls

    Quote Originally Posted by Paul.Todd View Post
    Have you read through the workbook?
    (http://www.forum.nokia.com/info/sw.n..._1_en.pdf.html)
    No, but I downloaded it. It seems to be a basic introduction to S60 programming. Having already worked on S60 for over five years, I do know the basics. I have not had to deal with data-entry dialogs till now, but I have read the chapter on dialogs in the book Developing Series 60 Applications, and perused the documentation that comes with the SDK.

    Next look at the examples
    (e.g. Registration example)
    I don't understand which example you're referring to. Do you mean the workbook? There is no "registration example" there.

    Next look at the supplied documentation in the S60Doc folder
    s60_platform_avkon_ui_resources_forms_v1_1_en.pdf
    s60_platform_avkon_ui_resources_dialogs_v1_1_en.pdf
    s60_platform_avkon_ui_resources_editors_v1_1_en.pdf
    I opened the file on dialogs. Its contents have been included in the documentation file s60_cpp_sdk_3rd_mr.chm I have been using when writing the resource and code, which I have posted here in this thread.

    Please, if you know of some code somewhere that successfully launches a data-query dialog, preferrably one that uses the AVKON_INTEGER_EDWIN control, and successfully reads what the user has entered into the dialog before pressing OK, can you post the resource definition and the code here? I am completely stumped as to how to get this to work.

Similar Threads

  1. Using dialogs in EPOCEXE
    By dbrukakis in forum Symbian User Interface
    Replies: 0
    Last Post: 2005-12-04, 17:43
  2. dynamic controls in containers
    By entell in forum Symbian
    Replies: 5
    Last Post: 2005-02-18, 18:11
  3. Dialogs & Forms
    By heuven in forum Symbian User Interface
    Replies: 0
    Last Post: 2005-01-13, 15:04
  4. Multiple views with dialogs
    By djgtram in forum Symbian User Interface
    Replies: 0
    Last Post: 2005-01-01, 20:33
  5. CEikMfne based controls on SERIES60
    By gregroach in forum Symbian User Interface
    Replies: 1
    Last Post: 2003-07-14, 13:21

Posting Permissions

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