|
help me please, I am stucked here.
It's a very simple SDI application. I got it from MFC appWizard.
In the view class, I started a worker thread, which will be running until a flag is cleared. I made sure that the worker thread is ended before the program terminate, because I put a TRACE line before its return statement, and the line is outputed. But still, I got such info:
Detected memory leaks!
Dumping objects ->
thrdcore.cpp(166) : {97} client block at 0x00305BB0, subtype 0, 112 bytes long.
a CWinThread object at $00305BB0, 112 bytes long
Object dump complete.
To make it more annoying, this doesn't happen all the time. What can go wrong?
Any clue is appreciated!
|
|
|
|
|
As its a CWinThread object thats been leaked, you can either store the pointer when you create the thread or set the m_bAutoDelete member var to true so it deletes itself when the thread ends.
Roger Allen
Sonork 100.10016
In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!
|
|
|
|
|
Thank you for your quick help.
I set it, but it didn't solve the problem. anything else?
|
|
|
|
|
I noticed that after I rebuild the project then run it for the first time, this memory leak will occur for sure. The subsequent running doesn't have this problem. Why this inconsistence?
|
|
|
|
|
It seemed that after I add #include "StdAfx.h" to my generic cpp file, this problem is solved.
But in my generic cpp file, all I did is some mathematical computation. No input or output involved, except for the argument passing to the function.
What does StdAfx.h do here? Why I have to include it? It makes no sense to me.
|
|
|
|
|
Hi.
I read an interesting thread at a MSDN newgroup on MFC and thread safety. Its author asks about why a thread causes the process to hang when you pass to the thread points to MFC control objects (CListrCtrl, CEdit, CTreeCtrl, etc).
I remember something similar to what the author of thread asks from a application I just finished. I found that you can make changes to MFC controls from threads via pointers to the controls. Everything works well until you call WaitForSingleObject(), or WaitForMultipleObject(), etc. In other words, the process hangs if you call WaitForSingleObject() when the thread is updating an MFC control.
Ivan Lalis posted an interesting solution involving MFC controls handles. He writes that one solution is to pass in the worker threads handles to MFC controls instead of pointers.
-----
UINT theWorkerThread(LPVOID pParam)
{
CListCtrl theList;
theList.attach(handleToRealListbox);
...
theList.detach();
return 0;
}
-----
I would like to know what is the safest solution to this problem? Secondly, in terms of Lalis' solution, do you create and attach, for example, one CListCtrland for the entire life-time of the thread?
Thanks,
Kuphryn
|
|
|
|
|
Does anyone know how to print the German characters öäü to a line printer (Epson LX-300). I suppose I need to select a character set to do this, but somehow I can not manage to get it workin.
Thanks,
Richard
|
|
|
|
|
:-DI want to get the data from video card and store them as Bmp.Please tell me how to do? Thanks a lot!
thanks to every one!
|
|
|
|
|
Do you have the data from the video card?
How did you get it?
How you got the information and the format that it is currently stored in determines how you will save it.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
no, i have't the data ,i want to know how to get the data in it.which function in Visual c++ can get the data?
thanks!
|
|
|
|
|
The next question is do you want to save an image that is on the screen or in a window?
You will need to create a device context for either the desktop window or the window that you want to save.
AFter you have the DC look at this article:
http://www.codeproject.com/bitmap/dibsection.asp[^]
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
i want to screen capture to Bmp format.
|
|
|
|
|
Use avphone3 control:
'connect to driver
vidcap1.device = -1;
Sub Timer1_Timer()
SavePicture vidcap1.Picture, filename
End Sub
|
|
|
|
|
I get past one problem, and bump into another... Steep learning curve
I created a dialog with among other controls, a static control expanded to a size I can use to draw small plots in. I created my own plotting class derived from CStatic, and attached it to the static control in the dialog with ClassWizard. I built the functionality in my derived class to draw the plots, and now I'd like to handle some mouse move and click messages. For some reason, my CStatic derived class won't handle any of these messages. If I add a handler in the dialog, it does handle them. I've looked through the articles on subclassing controls, and I don't see where I'm missing anything. Can you give me some suggestions on where to look?
Thanks.
|
|
|
|
|
In your OnDialogInit handler have you attached your derived CStatic control to the actual window? Do you get any sort of notification or response in your special class?
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
You have to set the NOTIFY style of the CStatic in the resource editor for your class to pick up the mouse messages.
Roger Allen
Sonork 100.10016
In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!
|
|
|
|
|
That did the trick! mumble...mumble...
Thanks
|
|
|
|
|
Maybe there's a simple answer for this too...
I can handle mouse messages now, but not popup menu messages!
I created a popup menu, and display it when I right click my derived CStatic object. I added message handlers for the menu items in my derived class, but for some reason, none of the menu items are enabled. The menu is displayed, but all items are greyed out.
I'll poke around for the cause of this, but if you have a suggestion, I'd appreciate it.
Thanks.
|
|
|
|
|
Never mind, simple mistake on my part...
|
|
|
|
|
You have to map the WM_INITMENUPOPUP message and enable the items on a command by command basis in this as your not using the standard MFC CCmdUI method in your own controls. After doing that, the items should be enabled as required, but instead of using a ON_COMMAND() handler for each I would recommend using the TPM_RETURNCMD option in your popup menu so that the selected item ID is returned by the call to TrackPopupMenu(). Then you can handle all the commands in the same place or farm them out to member functions as required.
Roger Allen
Sonork 100.10016
In case you're worried about what's going to become of the younger generation, it's going to grow up and start worrying about the younger generation. - Roger Allen, but not me!
|
|
|
|
|
I am trying to find a way to determine which application or instance thereof is connected to the internet and to where (IP).
Netstat and IPHlpAPI (I think I got the name right) will let you see the status of ports on your machine and see where they are connected.
For example, how do firewalls like ZoneAlarm and McAfee know which application is trying to connect and where to?
I need this for Windows.
Thanks...
|
|
|
|
|
It is done by IPhlpAPI, for some source you can look to great site - sysinternals.com There is an application which does probably exactly what you wants to achieve:
TCP View[^]
Hope this helps & enjoy
|
|
|
|
|
Thanks for the information. I actually looked up the code in SysInternals.com.
IPHlpAPI seems to have undocumented functions that can be used to obtain the ProcessIDs of the applications accessing ports. However, it also appears that these undocumented functions come only with XP.
So how did people find the same information prior to using XP? Any ideas?
Thanks.
|
|
|
|
|
Hi!
I want to implement a "dialog box" inside a "menu" application. And both the applications should interact with each other.
How can I do that?
Thanks
sumod
|
|
|
|
|
Huh ? What do you mean by both should interact with each other ? are the two applications independant ( 2 exe files ) or something else ?
If I understand correctly , you need to create a modeless dialog, using Create and ShowWindow on the dialog instead of DoModal.
Max.
|
|
|
|