static_cast to a custom control...

Login to reply to this topic.
Fri, 2006-04-07 17:26
Joined: 2003-11-28
Forum posts: 35
Hello,

I have a custom control into a dialog box , like this:

SEikControlInfo CAccountDlg::CreateCustomControlL(TInt aControlType)
{
   SEikControlInfo controlInfo;
   controlInfo.iControl = NULL;
   controlInfo.iTrailerTextId = 0;
   controlInfo.iFlags = 0;

    switch (aControlType)
    {
      case ESmileyControl:
         controlInfo.iControl = new(ELeave) CSmileyContainer(iMainPlugin);
      break;

      default:
      break;
   }
    return controlInfo;
}

void CAccountDlg::PreLayoutDynInitL()
{
   iListBox = static_cast<CSmileyContainer*>(Control(ESmileyControl));
}


and in the PreLayoutDynInitL method I want to get a pointer to this control, but my application crashes.

Why ? When I do static_cast to other non custom controls , it works.

thanks.

Fri, 2006-04-07 20:38
Joined: 2005-11-20
Forum posts: 1242
Re: static_cast to a custom control...
I am not sure about the error, but isn't the argument of the 'Control' method the id of the control (regardless whether it is a custom control or a normal control) and not your new "control type"?

René Brunner

  • Login to reply to this topic.