Join Now
Quality Rating:
  • Currently 1.0 / 5
(1.0 / 5 - 1 vote cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 21:37, 13 December 2007.

Create Modal dialog and add controls dynamically

From Forum Nokia Wiki

Create an empty modal dialog :

Define a Dialog resource in RSS file with out any items. Instead of defining the items in the resource file, you can also construct them dynamically. Below is a sample code to create an empty dialog.

RESOURCE DIALOG r_modal_dialog
  {
  flags=EEikDialogFlagWait |EEikDialogFlagFillAppClientRect
        |EEikDialogFlagNoTitleBar | EEikDialogFlagNoDrag |
        EEikDialogFlagCbaButtons;
  buttons = R_AVKON_SOFTKEYS_OK_EMPTY;
  // Do not add any items
  }

Add Edwin control to the modal dialog :

Header files:

#include <eikedwin.h> 
#include <eikdialg.h>

Link against:

LIBRARY avkon.lib eikcoctl.lib eikctl.lib form.lib uiklaf.lib eikdlg.lib

PreLayoutDynInitL() is called by the EIKON dialog framework before the dialog is sized and laid out.The default implementation is empty and it should be overloaded to initialize the control values that should influence sizing and layout.

Now in PreLayoutDynInitL() controls can be created and added to the dialog dynamically using CreateLineByTypeL().

void CModalDialog::PreLayoutDynInitL()
  {
  _LIT(KMyText, "The mobile phone market will flourish 
when software for phones flourishes");
  const TInt KMyId = 1;
  // To Create Edwin control
  CCoeControl* control = CreateLineByTypeL(KNullDesC, KMyId, EEikCtEdwin, NULL);
  iEdwin = static_cast<CEikEdwin*>(control);
  iEdwin->ConstructL( EEikEdwinNoHorizScrolling |EEikEdwinNoAutoSelection
               |EEikEdwinResizable, 20, 100, 10 );
  iEdwin->CreateTextViewL();
  iEdwin->SetTextL(&KMyText);
  }

PostLayoutDynInitL() is called by the EIKON dialog framework just before the dialog is activated, after it has called PreLayoutDynInitL() and the dialog has been sized.

void CModalDialog::PostLayoutDynInitL()
  {
  TRect rect = Rect();
  iEdwin->SetRect(rect);
  }

Launching the dialog :

The following code snippet launches the dialog using the specified resource (RESOURCE DIALOG):

CModalDialog* dlg = new (ELeave) CModalDialog;
dlg->ExecuteLD(R_MODAL_DIALOG);

Code Example :

ModalDialogWithEdwinControl_ExApp

Add custom control to the modal dialog :

A control of type aControlType specified in CreateLineByTypeL() is created by the control factory. Built-in control types are recognized by the framework.If the value of aControlType is not known to the control factory then the construction of the control must be handled by CreateCustomControlL().

const TInt KMyId = 1;
const TInt EMyCotrol = 2300; // any arbitary value
CCoeControl* control = CreateLineByTypeL(KNullDesC, KMyId, EMyCotrol, NULL);
 
// CreateCustomControlL() called by framework
SEikControlInfo CMyDialog::CreateCustomControlL( TInt aControlType )
    {
    SEikControlInfo controlInfo;
    ontrolInfo.iControl = NULL;
    controlInfo.iTrailerTextId = 0;
    controlInfo.iFlags = 0;
    switch ( aControlType )
        {
        case EMyControl:
	    // Instantiate your own custom control here
            controlInfo.iControl = new (ELeave) CMyControl;
            break;
 
        default:
            break;
        }
    return controlInfo;
    }
Related Discussions
Thread Thread Starter Forum Replies Last Post
Dialog like as "Message Information" in SMS yavolinsky General Symbian C++ 24 2007-01-10 14:17
embedded video itziks Browsing and Mark-ups 6 2008-01-14 19:37
changes the text on dialog cindul Symbian User Interface 1 2005-05-19 13:21
How to create a multiple recordstore for multiple users dynamically ? ritu Mobile Java General 5 2007-04-09 19:08
Need help:How to add icons in a form dynamically? dc-huang Symbian User Interface 1 2005-09-20 06:58
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX