|
Hello.
I'm writing an ActiveX control which was created by MFC ActiveX ControlWizard. I run the ActiveX control in Internet Explorer. I'm trying to obtain a pointer to the container to be able to change the html-page from the ActiveX control.
In the control class which is derived from COleControl I have to following code:
LPOLECLIENTSITE lpSite = GetClientSite();<br />
LPOLECONTAINER lpContainer; <br />
if(lpSite == NULL) AfxMessageBox("Click OK to crash..."); <br />
lpSite->GetContainer(&lpContainer);
The problem is that GetClientSite() returns NULL so the application crashes.
Any help is greatly appriciated. Thanks in advance.
/Charlie.
|
|
|
|
|
Hi,
I've got a code which is adding 2 non-printable characters at the end of the string, which is causing a lot of problem.
Can anyone help me in removing these 2 "funny" characters.
Here is the code
[CODE]
========================================
#include <winsock.h>
#include <windows.h>
#include <iostream.h>
#include <string>
#include <conio.h>
using std::string;
const char *yy;
int u,i;
string final = "<req><loginid>8888<reqtype>08<broadcast><messagetype>M<no>5359846<message>\n";
void main()
{
final.append("<date>02/10/2002 14:30:10\n");
yy=final.c_str();
u=strlen(yy);
for(i=0;i<=u;i++)
{
printf("%c %d\n",yy[i],yy[i]);
}
}
===========================================
[CODE]
Kindly help!!
Many Thanks,
John
|
|
|
|
|
Hello,
simply replace
for(i=0;i<=u;i++)
by
for(i=0;i<u;i++)
So, remove the =.
Then the 2 "funny" characters should not occur.
-Dominik
|
|
|
|
|
Hi Domnik,
I did that and its not removed the second character.
What comes towards the end is 10 and 0.
When I do a for(i=0;i
|
|
|
|
|
You mean the number representation of the linefeed-character?
Well, you could count two less than the string-length (CR/LF), or you could introduce a filtering line, that does skip any LF characters. That way you would even skip internal CR/LF sequences.
"My opinions may have changed, but not the fact that I am right."
Found in the sig of Herbert Kaminski
|
|
|
|
|
By the way: C++ like would be doing that with iterators. Its just as easy and less error prone. (see your index error dominic has shown)
"My opinions may have changed, but not the fact that I am right."
Found in the sig of Herbert Kaminski
|
|
|
|
|
As jh pointed out, you have to change the u to
u=strlen(yy) - 2; when using CR/LF (\r\n)
and u=strlen(yy) - 1; when using LF only (only \n).
|
|
|
|
|
Hi Dominik and Jh,
Yes, your suggestions worked out.
Apparently the problem still persists and I've got no clue why its happening..
What I am doing is just sending in some data to another server using a sendto(). The server program is written in Java.
But when I send it, the server gets it with some non-printing character (ASCII '0') in the begining and it's causing a problem.
Any suggestions, what could be going wrong?
Here's the sendto() code
[CODE]
========================================
e = sendto(sd,final.c_str(),final.length(),0,(struct sockaddr *)&saServer,sizeof(saServer));
========================================
[CODE]
Many Thanks,
John
|
|
|
|
|
Hi Dominik and Jh,
Just out of curiosity, can we do something like concatenating 2 strings? Something like this in sendto()?
========================
e = sendto(sd,"string1"+"string2",lenght(),0,(struct sockaddr *)&saServer,sizeof(saServer));
========================
Many Thanks,
John
|
|
|
|
|
Hi!
I've two identical machines (NT4.0, same IE, SP6a). I got a program that works in one machine, but the other one gives a messagebox "Microsoft Visual C++ Runtime Library", "Runtime Error!", the name of the program crashing and "abnormal program termination.
The machines are supposed to be totally identical basic installation (except the other one has more programs installed on it).
What files should I check to have the same versions?? What is causing that? Comctl32 is the same, so is MSVCRT.DLL.
|
|
|
|
|
This can be a very tricky problem. Look with the dependency Walker which dlls you are using and compare the versions.
IMHO it looks like a initialization error. A value out of the registry is missing or a file can´t be opened because the path doesn´t exist.
I would start a debug build on the crashing machine.
Try this @ home. (B&B)
|
|
|
|
|
at run time i want to known a fuction's caller ,how can?
for example:
void a(int i)
{
CString szCaller = GetTheCaller();
MessageBox(szCaller);
}
void b(int j)
{
a(j);
}
I'd like to get a message :"void b(int j)"
How to implement method "GetTheCaller()"
Scratch
|
|
|
|
|
How 'bout just passing the caller as a string argument?
Getting the calling function's name as a string is way beyond my knowledge
|
|
|
|
|
It's a good idea,but didn't fit my application.
Scratch
|
|
|
|
|
You want a stack trace, huh?
I did it once and regreted it. It was a great bunch of work.
Some starting points:
1. Look at the StackWalk Win32 API function. Walk the stack until you find the calling function.
2. Once with the address of the calling function, you'll need the SymFromAddr Win32 API function.
3. You'll need to ship the PDB file together with your application, because the Symbol functions will need this file.
If you only need this info for debugging purposes, you could try looking, IIRC, the address (&i)[1] (the address of the first parameter + 4 bytes. In your case, the parameter is an int), which will give you the return address on the stack. This is a hack and can fail for a hundred reasons, including the automatic inline made by the optimizer. The right way of doing it is the StackWalk way.
I see dumb people
|
|
|
|
|
How about creating a global array of some appropriate size, adding a call in every function in your code to add its own name to the array, and then at any point, just get the last so-many elements to know where you came from?
It's not really a call "stack" as much as a call "trace." The caller of any function would be the last element in the array.
The function to add to the array would have to do all the proper subscript incrementing and roll-around, making it a circular list of the last some-number of functions called.
This may not be appropriate, because you do have to add something to every function.
Dave
"You can say that again." -- Dept. of Redundancy Dept.
|
|
|
|
|
i am new user of vc++.How do i start it.Actually i am thinking of making own operating system.please give me suggestion.
|
|
|
|
|
I hope this is a joke
What about reading books?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Rajes wrote:
Actually i am thinking of making own operating system
ROTFLMAO!
That was a good one!
Buy a goog book, do you have ANY C++ knowledge?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
nice joke
|
|
|
|
|
Rajes wrote:
Actually i am thinking of making own operating system.
It's good to meet a man who is not scared of a challenge. But I'm afraid that's not gonna happen. Buy some books on C++ ( NOT Visual C++, just the C++ language ) and do the exercises in them, and ask lots of questions here. If you find it hard going, consider learning C# first.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
|
I have to write a program to calculate a user's year of birth, given their age. I want to use the year from the system clock, but I have no idea how to do this. Could someone show me some code that would accomplish this??
As simple as: cout<<"systemtime"-age; is what I need.
I'm not real good with C++ yet, so please try and make it simple.
|
|
|
|
|
sorry....not cout<<"systemtime"-age; I meant systemyear. All I need is the current year.
|
|
|
|
|