|
But don't forget that the data that the pointer points to needs to remain valid while you are processing it! i.e. don't do
void CMyWindow::OnSomeMessage()<br />
{<br />
CString strData = "Hello";<br />
m_pMyOtherWindow->PostMessage(WM_STRING, &strData);<br />
}
As the CString will have been destroyed by the time you come to use your pointer to it. In this instance, use SendMessage() instead.
|
|
|
|
|
My pointer is a member so its not local so I'll post and not send, but thanks so much for making me aware of the temporariness of the passed in variable...
Appreciate your help,
ns
|
|
|
|
|
Yes. Good Point! I was thinking about that. There will be a problem if the dialog goes out of scope.
John
|
|
|
|
|
I have SP5 installed for VS6.0. Now, when I build a project that I've been working on for 3 months, it blows up when it is launched outside the debugger. It blows up at lauch time - the debug version gives me a crash address of 0x00000009, which isn't even in my code yet!. If I compile it on a machine without SP5, it works fine.
Has anyone else seen this?
|
|
|
|
|
Have you tried rebuilding the whole project?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I just installed SP5 for VC++ 6, and everything *seems* to be working fine.
|
|
|
|
|
Indeed mine seemed fine for a while.
I just had to remove dev studio, and re-install it, and apply service pack 4. Everything is back to normal now.
|
|
|
|
|
My program is behaving differently when I link with MFC statically vs. when I link with MFC as a shared DLL. (In both cases I an using a debug build, so this is not a debug/release issue.)
The first issue I noticed is with the CRectTracker. When I use a RectTracker while linking with a shared DLL everythink works correctly. The cursor changes when over the rect to a cross and the user can move the rect around the screen. But, when linking with with static MFC the rect tracker does not behave correctly. After the rect tracket is displayed, moving the cursor over the rect makes the cursor disapear. It does not change to the cross, it just disappears when over the tracking rect.
Any ideas what I am doing wrong? Any ideas why this is and what I can do about it? Thanks!
Craig Smith
|
|
|
|
|
Try a service pack (or not, see my most recent thread...)
I know there were problems with sockets and statically linked MFC, which was supposedly fixed in SP5.
|
|
|
|
|
Sir i am setting the options of the ICMP Packet using the function below. As ttl=0 so packet should not be sent but it is not happening packet has reached its destination.
int ttl=0;
(setsockopt(sock,IPPROTO_IP, IP_TTL, (char *)&ttl, sizeof(ttl))
// Send the echo request
if (sendto(sock, (const char *) &echo_req, sizeof(ECHOREQUEST), 0, (SOCKADDR *) &sin, sizeof(sin)) == SOCKET_ERROR)
//plz help me
Reply me soon
|
|
|
|
|
Have you checked the error code returned by setsockopt? According to the MSDN, the TTL does not have to be supported. Also, if your destination is local then the packet may not have to go through any routing devices, and so the TTL wont have any effect (it is 'hop' based, not time based - with a hop being the passage through some routing device)
|
|
|
|
|
Hi there,
I have a problem with a global instance of a CArray based class (named CPlugInArray), my environnement is W2K / VC 6 / SDI application.
I define my variable in the application class (named CMyApp), then make it global.
In CMyApp::InitInstance, I add elements throught CArray::Add member function without any problem. Further in CMainFrame, I parse these elements without problems, but when I choose an item in my menu, the callback function (localized in CMainFrame) parse again elements but the first element address has slighly changed and I can't retrieve data, VC 6 even crash when I reach a break-point near elements calls !!
Does anybody has encounter the same problem ? Does CArray based global variables are not recommended or allowed ? Should I use a CPlugInArray * global symbol instead ?
Thank you for your answers ! I really need it !
Cheers,
Florian
|
|
|
|
|
pimOOsse wrote:
? Does CArray based global variables are not recommended or allowed ? Should I use a CPlugInArray * global symbol instead ?
First, you could use member variables of the Application. These can be accessed anywhere via <code>theApp.m_Member .
Second, you should really try to use the std::vector. After all, its the standard
Third, do you work with dangling pointers after having used CArray::Add() ?
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Thank you for your answer jhwurmbach,
I know I could use member variables of the application, but I cmust confess that it's easier to access global variables with CMyApp::m_MyVar than calling AfxGetApp(), casting the pointer into CMyApp * then accessing the variable
But, it I continue to have such problems, I'll follow your advices ! Overall I never tried std::vector, so it should be a good occasion to have a look at
|
|
|
|
|
You are trashing memory somewhere that is trashing the CArray data. You can use CArray with a global. There is no need to switch to std::vector, that wouldn't solve anything and is pointless in an MFC application if you aren't using STL's advanced features.
Somewhere, you just have a bug that is trashing memory. Chances are you are overrunning the end of an allocated array somewhere.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hi Tim,
Happy to read that there is no problem to use such object in a global manner
I'm also sure that someting wrong is occuring in my application but I don't know where yet The GetSize() mmeber function return the right amount of elements but it crashes as soon as I try to debug what happen.
I know that I'll spend some time in debug But it must work
Cheers.
|
|
|
|
|
Hi there,
I've found the solution, there was effectively a memory trash problem in addition of a bad use of the CArray object.
1) I was passing a personal object by reference to a DLL, whose job is to fill some CString members. I just can say that YOU MUSN'T do direct changes to variable members but YOU MUST use accessors instead. Now, all my memory problems are solved
2) I was using GetAt(n) in order to make changes in elements but I wasn't modifying the element anymore Using [] overloaded operator works fine
|
|
|
|
|
Does anyone know how to clear all text from the macro tab in the Output Window from a DevStudio Add-in?
|
|
|
|
|
Hi,
does sombody know how to change the font of the binary files editor ?
the default font is not a fixed font, and it is hard to view.
Thanks
|
|
|
|
|
Hi;
I want to check the Internet connection and upload few data at my program startup to ensure coopyright. I can do the job using "IsRasConnected" if my program is running on a computer which has modem and internetconnection itself. But if the computer is connected to internet via a LAN using internet connection sharing (MS ICS) or NAT, I can not handle the job. help please....
|
|
|
|
|
What do you mean you cannot handle the job? How did you establish TCP/IP connection via modem? Under a LAN setup, one solution is to simply establish a connection via WSASocket() and WSAConnect().
Kuphryn
|
|
|
|
|
Use InternetCheckConnection exported from WININET.DLL
to perform a "ping" of the address in question.
|
|
|
|
|
Hi everyone
I trying to map WM_CHAR message But when focus is on the Buttons or Check Boxs Dialog Will be close .
How can I do To Map This Message
(I'm Sorry For My English )
Iman Ghasrfakhri
|
|
|
|
|
Hi can anyone help me in creating and sending the ICMP packet. please refer helping material websites or code for the problem. Important thing is that I want to access the ttl(hop count) of the icmp packet created.
Plz help me.
Reply me soon
|
|
|
|
|
Hi,
I have derived my class from CPropertyPage, I have included a Groupbox control. Inside that Groupbox I have included three Edit controls. I mapped CString variables as well as CONTROL variables for those Edit controls. Now when I am going to enable or disable those Edit control based on some values I am getting errors.
Anybody have any idea.
The Phantom is Tracking Bullets.
|
|
|
|