|
thank u for your reply. i changed the codes like this:
delete ptStrArry;
-->delete [] ptStrArry;
this can resolve the question.
but when i test the codes, for example, run the function OnBtnLoop like this:
void CListboxstrDlg::OnBtnLoop()
{
TRACE("-------------start loop! \n");
for (int i = 0; i < 10000; i++)
{
OnBtnAddlistitem();
}
for (i--; i >= 0; i--)
{
OnBtnDellistitem();
}
TRACE("-------------finish loop! \n");
}
i found the memory used from 4668k to 4876k, and when i run the funcion again, the memory used form 4876k to 5384k. so i think the program must be something wrong...
but until now, i havenot found it.....
but another question
modified on Friday, December 26, 2008 7:24 AM
|
|
|
|
|
btw:
if i donot run the codes in the debug mode(Ctrl + F5), the memory used is normal...
so, why in debug mode(F5), the memory used from 4668k to 4876k,or from 4876k to 5384k?
i really donot know the reason...
anybody can explain this for me? thank u!
|
|
|
|
|
In the debug version of the C++ runtime it allocates memory differently from the release version.
In the debug version, when you allocate new memory, the runtime also allocates a full page of extra memory before and after the buffer you have called for.
It fills these extra pages with the value CD. These are called guard pages. They are used for checking to see if your program has written outside the bounds of the memory you allocated.
This is why your debug version uses more memory than the release version.
|
|
|
|
|
thank u for your reply.
but i think what i said is not clear.
my meaning is that the two ways are both in debug version:Ctrl+F5(not debug mode) and F5(debug mode), but not in release version.
|
|
|
|
|
I want to create a window in a thread. Instead of deriving a class from CWinThread and setting the m_pMainWnd variable, can I just create a worker thread and create the window in the controlling function. Then could I post messages to the window, and the resulting functions calls would occur in the new thread?
|
|
|
|
|
That's the way I've always done it. Unless there is something I'm unaware of, that seems to be the way to go.
|
|
|
|
|
Hi, I went to project properties, linker input and added the following library: "winmm.lib", then I clicked on resouces in the solution explorer and clicked on add existing resource and added a .wav file.. Then I manually created a resource script that I will show you here:
#include "Resource.h"
IDI_FISHL ICON "Res\\fishicon.ico"
IDI_FISHS ICON "Res\\fishiconsm.ico"
IDB_BACKGROUND BITMAP "Res\\background.bmp"
IDB_FISH BITMAP "Res\\fish.bmp"
IDB_BUBBLE BITMAP "Res\\bubble.bmp"
IDW_BUBBLES WAVE "Res\\bubbles.wav"
and here is the resource.h file
#define IDI_FISHL 1000
#define IDI_FISHS 1001
#define IDB_FISH 2000
#define IDB_BACKGROUND 2001
#define IDB_BUBBLE 2002
#define IDW_BUBBLES 3000
Okay and this is the error the compiler gives me: 1>.\Resource.h(21) : fatal error RC1004: unexpected end of file found
PLEASE PLEASE HELP ME!!!
|
|
|
|
|
This is what MSDN says about that error:
This error can be caused by missing linefeed and carriage return characters on the last line of a text file.
Try adding a few blank lines at the end of the resource.h file, making sure that each line has a CRLF.
|
|
|
|
|
I added some blank lines and that didn't work.. But I did take that last line and put in the front of the file and it worked okay.
|
|
|
|
|
Glad to hear it worked out.
Happy Holidays!
|
|
|
|
|
Hey guys...
I got a string from a web page. I wanted to match a string if it exists. Actually my search string doesnot include any reg-ex characters. (Pls do not advise me to use search string methods...)
Anyway.... When I call rgx.Match method it returns TRUE and marks start and end string (I saw it in debug mode) BUT m_uNumGroups variable is set to 0. So I could not get matched piece.. I got error......
So why this happens? Regex says there's a match but there are no match groups....
Thank you all...
|
|
|
|
|
|
The m_uNumGroups shows how many captures you have from using grouping characters (i.e. brackets) in the regexp.
e.g. If I match "abc" with the regexp "([a-z])(.+)" it'll match and I'll get two groups, the first containing "a" and the second containing "bc". If I match "abc" with the regexp "[a-z].+" (i.e. same as the first but without the brackets) it'll still match, but I'll get no groups.
So - I suspect your regexp has no brackets? Difficult to say without seeing it...
|
|
|
|
|
we have one dedicate m/c to do logging stuff only.The process which is doing logging get hanged for 5-15 min. By analyzing the problem,I have found that it hanged on closing the file.it hangs on API "fclose".It happens when we have file large log file(in between of 500MB to 1.3GB).
I have already tried following things:
1) just doing fflush before flose(fflush has been done successfully and very quickly)
2) to make sure this file has not been used by any other process,I tried to rename the file when fclose is in hanging state.I am able to do this.
3) After 500MB,I tried to close and open file again after each 50MB.Still hangs every time.
This problem is happening only on live system.It is not getting on my local m/c.I am not finding any reason now.
Do anyone have some suggestion or idea related to this problem?
Regards,
Vishal Soni
modified on Thursday, December 25, 2008 1:00 PM
|
|
|
|
|
How to use CAsyncSocket objects in CWinThread object Safely?!
(the tread should use ActiveX controls - a CListCtrl in the main CDialog dialogbox- to show notifications and events)
- i dint use threads in a first version, instead i used a RoundRobin Algo to answer the clients! but the server was slow
so now i need to get the threads work!
thank's in advance...
|
|
|
|
|
Mind Machine wrote: How to use CAsyncSocket objects in CWinThread object Safely?
The same way you'd use any other objects in a thread safely.
Do you have a specific question? If you don't know how to write
multi-threaded code, that would probably be a great place to start.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
well Mark, my problem exactly is;
when is, in my thread, when i use th listening socket wich is a member of my main dialog to accept connections; this last calls the runtime to terminate it, which is an unusual way to end a dialog! and also my thread cant call any ActiveX control! (assertion fails!!)
|
|
|
|
|
You're probably getting failed assertions because you are calling functions of your UI controls on a secondary thread.
Remember that you must only manipulate the UI with the thread that created the UI and its controls.
If you want a secondary thread to be able to affect the UI, you should have the secondary thread post window messages that are acted upon by the UI thread.
|
|
|
|
|
i want to connect my SQL server 2005 data base through c++ code.. please some one help me..
more precisely, when ever there is a update in the data base i have to pass the values of the field to another application thru c++ code..
|
|
|
|
|
Have you checked out one of these [^]?
i.e. a polite way of saying: "RTFM".
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
I create a process on another desktop using CreateProcess by providing another desktop information.
All the things go well. Then, i want to send some message to it.
But the problem is, if i send quit message to it, it get the message successfully, but if i use GetMenu to get its meneu and then get submenu, and send menu message to it, it gets nothing. But if i just send a WM_QUIT message to it, it gets it because the process will quit as excepted. I mean, GetMenu function would fail if the process runs on another virtual desktop
Im sure i got the window handle successfully and had called SetThreadDesktop to make my program can post messages to the process runs on another desktop.why?
Merry Christmas.
modified on Thursday, December 25, 2008 1:25 AM
|
|
|
|
|
There are security issues involved with sending window messages between desktops.
It would probably solve all your problems if you made the processes communicate with named pipes instead.
|
|
|
|
|
Yes, i agree with you. Named pipe can solve all the problems, but the final problem is that, the app witch i want send messages to is not my app.
Thanks for your reply. Maybe i should find another way, hook for example.
Regards.
|
|
|
|
|
Here's a wild idea:
Inject a DLL into the target app, and have the DLL send the messages.
Then communicate with the dll by named pipe.
Just a thought.
|
|
|
|