CAknTextQueryDialog -- Simple question
Login to reply to this topic.
Thu, 2005-10-13 20:51
Joined: 2005-10-03
Forum posts: 32
Why does this crash upon execution?

Code:
TBuf<KMaxNotesLength> notes;
CAknTextQueryDialog* notesQuery = CAknTextQueryDialog::NewL(notes);
notesQuery->MakeLeftSoftkeyVisible(ETrue);  //Crashes here

I need to make that left softkey visible even if they have not typed in any info.

Thanks in advance  Cheezy

A.Arnott

Fri, 2005-10-14 07:15
Joined: 2004-07-09
Forum posts: 111

Hi aarnott,

  You need to implement your own class ,
  derive from CAknTextQueryDialog and override UpdateLeftSoftKeyL - then from inside UpdateLeftSoftKeyL  call  MakeLeftSoftkeyVisible.

   e.g.
  /** CCustomeDialog is Derived From CAknTextQueryDialog */

  void CCustomeDialog:: UpdateLeftSoftKeyL  ()
  {
   MakeLeftSoftkeyVisible (ETrue);
  }

All the best.

DipakBaviskar

Fri, 2005-10-14 17:59
Joined: 2005-10-03
Forum posts: 32
Okay, I've tried implementing it, but I can't figure out how to get it so that CAknTextQueryDialog gets my TBuf (notes).

Here is my code (more like a template attempt):

Code:
// custdbQueryDialog.cpp

#include <AknQueryDialog.h>
#include "custdbQueryDialog.h"

CCustDBQueryDialog* CCustDBQueryDialog::NewL(TDes& aText) {
//CCustDBQueryDialog* self = new CCustDBQueryDialog(aText);
CCustDBQueryDialog* self = (CCustDBQueryDialog*) CAknTextQueryDialog::NewL(aText);
self->MakeLeftSoftkeyVisible(ETrue);
CleanupStack::PushL(self);
return self;
}

void  CCustDBQueryDialog::UpdateLeftSoftKeyL () {
MakeLeftSoftkeyVisible (ETrue);
}


//custDBQueryDialog.h

#ifndef CUSTDBQUERYDIALOG_H
#define CUSTDBQUERYDIALOG_H

#include <AknQueryDialog.h>

class CCustDBQueryDialog : public CAknTextQueryDialog {

public: // Constructor

static CCustDBQueryDialog* NewL(TDes& aText);

public: // from CAknTextQueryDialog

void  UpdateLeftSoftKeyL ();

};

#endif

Sigh, if only Symbian were in java programming would be so much easier (I'm pretty bad with c++ as you can see...)

A.Arnott
Fri, 2005-10-14 20:22
Joined: 2005-10-03
Forum posts: 32
Okay I got it working (kinda).  Now onto a new dillema -- when I press okay when there is no text in the box, instead of just having the TBUF (notes) set to "", it also likes to crash (no panics or anything, just a plain ol' "program closed" message box).  Do I have to override another function to handle the event of an empty String?  I'm going to try that, but if there is a different/better way to do this, I'd be most appreciative Smiley.

Edit:  I've discovered the cause of the crash by commenting out code, I think it is either the line that executes my custom CAknTextQueryDialog, or the construction line.
Here is my source commented out:

Code:

/** Function that creates the dialog*/
TBuf<KMaxNotesLength> notes;
CCustDBQueryDialog* notesQuery = CCustDBQueryDialog::NewL(notes);

if( notesQuery->ExecuteLD(R_CUSTDB_NOTES_BOX) ) {
//Commented out stuff
}

/**CCustDBQueryDialog.h*/

#ifndef CUSTDBQUERYDIALOG_H
#define CUSTDBQUERYDIALOG_H

#include <AknQueryDialog.h>

class CCustDBQueryDialog : public CAknTextQueryDialog {

public: // Constructor
static CCustDBQueryDialog* NewL(TDes& aText);

private: // Constructor
CCustDBQueryDialog(TDes& aText) : CAknTextQueryDialog(aText) {};

public: // from CAknTextQueryDialog
void  UpdateLeftSoftKeyL ();
};

#endif

/**CCustDBQueryDialog.cpp*/

#include <AknQueryDialog.h>
#include "custdbQueryDialog.h"

CCustDBQueryDialog* CCustDBQueryDialog::NewL(TDes& aText) {
CCustDBQueryDialog* self = new CCustDBQueryDialog(aText);
CleanupStack::PushL(self);
return self;
}

void  CCustDBQueryDialog::UpdateLeftSoftKeyL () {
MakeLeftSoftkeyVisible (ETrue);
}




Thanks!

A.Arnott

copyright 2003-2009 NewLC SARL