mfc >> Error on this line (Bad ptr for template name)

by Jacky Luk » Mon, 24 Jan 2005 17:06:57 GMT

if (!_AfxCheckDialogTemplate(m_lpszTemplateName, TRUE))
{
ASSERT(FALSE); <- goes off here // invalid dialog template name
PostNcDestroy(); // cleanup if Create fails too soon
return FALSE;
}






mfc >> Error on this line (Bad ptr for template name)

by Jacky Luk » Mon, 24 Jan 2005 17:32:51 GMT


template pointer was 0x83 <Bad Ptr>
What is a typical cause of this error?
Thanks
Jack

"Jacky Luk" < XXXX@XXXXX.COM >
: XXXX@XXXXX.COM ...





mfc >> Error on this line (Bad ptr for template name)

by Jacky Luk » Mon, 24 Jan 2005 17:45:31 GMT

I knew this was on my part. Someone told me before. But I couldn't remember
the answer. Thanks
Jack

"Jacky Luk" < XXXX@XXXXX.COM >
:# XXXX@XXXXX.COM ...
name




Similar Threads

1. Com+ debug issue: <Bad Ptr>, int overflow and unreasonable path

When I start to debug a Com+ project with VC8, I meet a lot of strange
issue.

For some CString variable:
When I watch them,  I can not see the correct value of them. sometimes
I could see <Bad Ptr>, ""(empty) or some garbage string like "p".

For some int variable:
I even got the value like 2016111848, in the watch window. But in fact,
the correct value should be in 0-10

But I could view the correct value of some other CString and int
variable.

And, when I go through some method step by step by click F10, I find
something more strange, for example:

1)	if (!m_bReadyForQuery)
2)	{// not ready to build query
3)		return false;
4)	}

5)    // this will add WHERE for the key field, if applicable
6)    if ( !ProcessKeyCriteria(rstWhere) )
7)    {
8)        return false;
9)    }
....

When it runs 1->3->6->8, so strange! It goes to the return line, but it
doen't not return after that line!


I think maybe my debugger has some problem, maybe some configration?
Could anyone give me any hint?

2. Permit "template" qualification to distinguish name-as-template from name-as-instantiated-class

3. what's the difference between delete ptr and ptr=0 -dont they accomplish the same

Hi,
I was going through this reference code and playing around with it.
The code (shown below) shows a class that represents a stack of string
pointers

In the code below in particular in the pop function, the code works
when I set stack[index]=0 but when I say delete stack[index] the code
compiles but does not execute -I am only trying to "delete
stack[index]"  after I have copied the relevant data pointed by it
into variable "rv", so why is this program not allowing me to free
stack[index] (which is nothing but a pointer to a string) ?.

Also, when I comment the stack[index] and the delete stack[index], the
code executes to completion but doesn't this actually create a memory
leak since stack[index] is never deallocated or freed and if so how is
the program executing to completion without any errors ?

I would greatly appreciate any feedback.



#include <string>
#include <iostream>
using namespace std;

class StringStack {
  static const int size = 100;
  const string* stack[size];
  int index;
public:
  StringStack();
  void push(const string* s);
  const string* pop();
};

StringStack::StringStack() : index(0) {
  memset(stack, 0, size * sizeof(string*));
}

void StringStack::push(const string* s) {
  if(index < size)
    stack[index++] = s;
}

const string* StringStack::pop() {
  if(index > 0) {
    const string* rv = stack[--index];
     stack[index] = 0;          // this works 
	//delete stack[index]; // doesn't work
    return rv;
  }
  return 0;
}

string iceCream[] = {
  "pralines & cream",
  "fudge ripple",
  "jamocha almond fudge",
  "wild mountain blackberry",
  "raspberry sorbet",
  "lemon swirl",
  "rocky road",
  "deep chocolate fudge"
};


const int iCsz = 
  sizeof iceCream / sizeof *iceCream;

int main() {
	cout << "size of iceCream="<< sizeof iceCream << endl;
	cout << "size of *iceCream="<< sizeof *iceCream << endl;

  StringStack ss;
  for(int i = 0; i < iCsz; i++)
    ss.push(&iceCream[i]);
  const string* cp;
  while((cp = ss.pop()) != 0)
    cout << *cp << endl;
} ///:~

4. Can smart ptr really encapsulate raw ptr?

5. REQ HowTo: Passing class specific char ptr through template declaration

How can you pass a string through a template parameter?  I am trying
to avoid using the stream objects and need to pass in class specific
information at creation.

Any information would be helpful.  Thanks,

dmille

i.e. 

template<class T, const char *FMT> 
class Foo
{
  private :
    T      _x ;

  public :
           foo() {}
    short  scan_it( const char *src )
    { 
      return sscanf( src, FMT, &_x ) ; 
    }
} ;

typedef Foo<long, "%ld">   LongFoo ;

...
LongFoo  tmp ;

tmp.scan_it( "192" ) ;

6. Function ptr to function templates

7. IDE confused (bad pragma & off by 3 lines problem)

Hi-
I've posted this in the past and never got a real answer. 
I think that my IDE is badly confused..
My project consists of 15 cpp files and 18 header files. About 8k lines altogether. When I put it in debug the line indicators in the gutter are off by 3 lines in some files. I was able to work around that until today. 

Today I added a timer and cannot get the timer to fire into its event handler. At least it never gets to the break points I set in the code (even in assembler). 

Also I moved one line: (before)
-------------------------------- 
#pragma package(smart_init)
#pragma link "hooks.lib"
#pragma resource "*.dfm"

static HtmlHelpFunc HHelp = NULL;

TForm1 *Form1;
-------------------------------- (after)
static HtmlHelpFunc HHelp = NULL;

#pragma package(smart_init)
#pragma link "hooks.lib"
#pragma resource "*.dfm"

TForm1 *Form1;
--------------------------------

And now all the pragmas are giving e2407 Bad pragma directive syntax errors. 

If I go back to the original order I get an unresolved external on the TForm1. 

THis is maddening.!!!

I think that the root cause is probably one thing. but I have no idea where to start. 

I went thru all the header files and their includes looking for anything out of the ordinary. Found nothing..

If anyone has an idea please let me know.
THanks.

8. COM+ returns Logon failu unknown user name or bad password - CSharp/C#