|
It is actually the case that malloc can allocate a larger block. This is a common technique used to increase memory allocation speed. You have a quick allocation lists for specific memory ranges. Such as 0-32 bytes uses one queue, 33-64 uses another queue, etc...
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Ahhh hah!...Thanks for your reply...as I was formulating a response to this it dawned on me that I never tried to allocate the memory to its prefered size, and check the headers and footers then...in fact you are correct that it does allocate the reported size. This also brought an interesting quirk with calloc to my attention...it will write 0s to the requested size, not the allocated size...very confusing. Thanks for your help...I think I have a good grip on this stuff now.
-Jesse Rosalia
|
|
|
|
|
Can you please help me out on the below problem.I am in short of time and sorry if this type of question has been posted previously.
I want to display a message box when the windows XP system is about to shutdown and the user must respond to it.I am displaying the message box[with flags MB_TOPMOST|MB_SETFOREGROUND|MB_SERVICE_NOTIFICATION|MB_OKCANCEL] from service.I can do this successfully but what is happening is say after 5 seconds if the user doesnot respond then OS is displaying a message box like "Could not terminate or kill the program,user has to respond to the application".
1.How can i avoid the above message box coming from the system.
2.I see some of the applications in the system tray getting closed in the meanwhile, i mean how can my application[service] be the first to trap WM_QUERYENDSESSION.Is there any other simple approach other than HOOKS.Basically if the user does a cancel from the message box, i have to make sure system is in normal state like before shutdown.
Sincerely,
Suren
|
|
|
|
|
1. To avoid the message, close the message box. You will probably need a second thread to kill the app after a time out. You may want to consider using a custom dialog rather than a message box. Then you can control its duration from inside.
2. I don't know of any way to effect the order in which the apps receive messages. There is no way to re-instate other apps that have already shut down, unless you're program knows what they are and how to restart them.
|
|
|
|
|
Cancel the shutdown programatically. If OK is hit then tell XP to shutdown, otherwise do nothing.
Joel Lucsy (jjlucsy@ameritech.net)
|
|
|
|
|
Hi guys,
I've been messing around with the Hello World example program and what I'm wanting is that when the user goes to the "about" screen the main window is closed or made invisible. Sorry if it such a vague qeustion, I've only been on VC++ for 5 hours now and I'm a bit strapped for cash for books at the moment Any help would be great
Thanks for your time
Aaron
|
|
|
|
|
Check ShowWindow(() ,use SW_HIDE
for it.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
In the "About" handler (where the about dialog is created and shown with DoModal issue a ShowWindow(SW_HIDE) before producing the about dialog and ShowWindow(SW_SHOW) after
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
when you say 'main window' do you mean the whole application, or a dialog which says 'Hello World'.. if you are displaying a dialog using DoModal() then it will have focus and not allow you to go to help/about until you close the box that has focus.. please elaborate on exactly what you want closed or made invisible.
-dz
|
|
|
|
|
But he can hide the window before the DoModal and show it when DoModal returns
Nish
My miniputt high is now 29
I do not think I can improve on that
My temperament won't hold
www.busterboy.org
|
|
|
|
|
THANKS GUYS!!!!
Aaron
|
|
|
|
|
I swear MS taking out the class wizard was like a big 'F-U' to me.
Can someone please tell me if there is an automated way to add an event to a new toolbar button? i tried double clicking it in hopes that would help.. but of course not, i tried right clicking it hoping for add event handler.. no such luck either.. im so ticked.. is there no way to add an event handler to a toolbar button without manually writing out the event handler?!
.. i know i must be missing something.. microsoft has to know how lazy i am .. there is no lightning bolt to click on to add the handler for the toolbar.. please someone help, i would much appreciate it.
-dz
|
|
|
|
|
several times I tried to get a Handle to a window or dialog and i received this error code with GetLastError. M
|
|
|
|
|
try
errno = GetLastError();
Otherwise you are getting the address of the GetLastError function.
One other thing to realize is that not all calls set last error. Your 183 may be an artifact from a previous error.
|
|
|
|
|
Say I have a string:
string MyString;
And I want to remove all punctuation characters from it say, !@#$%^&*(,.?) etc . . .
what is the best way to do this?
NewString = MyString.replace("!@# . . .", "")
Any Thoughts,
Tim
---------------------------------------
Tim Booher
|
|
|
|
|
Replace() is the thing you want,but I think you have to use it for each punctuation characters sepratly.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
This is just a simple sample of how you could do it with C-strings.
This code doesn't work for DBCS. But it would be easy to modify for that. (I am being lazy)
void RemoveChars (LPTSTR pszSource, LPCTSTR pszCharacters)
{
LPTSTR pszIn = pszSource;
LPTSTR pszOut = pszSource;
TCHAR c;
while ((c = *pszIn++) != 0)
{
if (_tcschr (pszCharacters, c) == NULL)
*pszOut++ = c;
}
*pszOut = 0;
}
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Wow Tim.
Good solid pointer usage...
I am impressed.
Nish
My miniputt high is now 29
I do not think I can improve on that
My temperament won't hold
www.busterboy.org
|
|
|
|
|
When you get to be an old fart like me, you learn a lot of tricks.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Sorry, but this makes no sense to me, like what datatype is LPTSTR? is this STL stuff or microsoft stuff?
I implemented something like:
void wordcounter::CleanUpWord()
{
string::iterator i = remove_if( word.begin(), word.end(), ispunct ); // compact the string
word.erase(i,word.end()); // trims the characters identified from the string
transform( word.begin(), word.end(), word.begin(), tolower ); // convert all to lower
}
What do y'all think of this?
Tim
---------------------------------------
Tim Booher
|
|
|
|
|
LPTSTR is basically a "char *" in ANSI/MBCS mode and "wchar_t *" in UNICODE mode.
My code is basically exactly the same thing remove_if does. At the end of my loop, "pszOut" would be the same as your "i". My terminating the string with a 0 does what your erase does.
Mine is for C style strings and yours is for STL strings. Since your version doesn't do a lot of extra string copies they both perform very well. The only thing in the C string version is that you could roll the tolower into the loop.
This STL version looks good IMHO.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Just for an FYI, here is how your routine would look for C strings.
void CleanUpWord (char *pszWord)
{
char *pszIn = pszWord;
char *pszOut = pszWord;
char c;
while ((c = *pszIn++) != 0)
{
if (!ispunct (c))
*pszOut++ = tolower (c);
}
*pszOut++;
}
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Sorry,I misunderstood your question,you have to use Remove() .This is from MSDN:
CString str("This is a test.");
int n = str.Remove('t');
ASSERT(n == 2);
ASSERT(str == "This is a es.");
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
CString strTest("What the *@(%!?");
CString Holder = "-?`~!@#$%";
for (int i = 0; i < strTest.GetSize(); i++)
if(Holder.Find(strTest.GetAt(i))!=-1))
{
AfxMessageBox("Found bad character");
}
:P im a newbie so flame away if there is an easier way.. oh ya.. i stole this code from someone somewhere at somepoint..
-dz
|
|
|
|
|
If you're using std::string s, this should do (warning, I haven't tested it so some off-by-one errors might have been overlooked.)
string remove(const string& src,const string& chars)
{
string dst;
for(string::size_type off=0,off2=0;(off=src.find_first_of(chars,off2))!=string::npos; ){
off2=src.find_first_not_of(src,off);
dst+=src.substr(off,off2==string::npos?string::npos:off2-off);
}
return dst;
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|