|
This keeps your code readable and safe at the same time. And while the pragma is not portable, the resulting safe, readable code is.
Misunderstanding. My bad. Please forgive me this one transgression.
Just out of curiosity, why don't you consider if (NULL == m_pPointer) readable? I admit it looked strange to me at first, but it's such a simple coding trick that you can use to save debugging time without having to remember some obscure pragma directive.
Jon Sagara
"We assume you already know not to consider something like Windows as a firewall platform. Does the name "Windows" evoke images of security? Silly rabbit, Windows is for desktops." -- Unix System Administration Handbook
|
|
|
|
|
Yeah, I agree. It is all about just getting use to it.
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
Why not use:
if (!m_pPointer)
instead of
if (NULL == m_pPointer)
|
|
|
|
|
Because the second is instantly readable, whereas with the first one you have to remember that "!pointer" means "pointer is not zero".
--Mike--
http://home.inreach.com/mdunn/
#include "witty_sig.h"
your with and
|
|
|
|
|
I agree with Mike, but I would make it
if (m_pPointer == NULL)
instead.
It just looks better to me because it flows more like the way you speak the same phrase. I've never heard anyone say "If NULL is the pointer...", but instead, people say "If the pointer is NULL...".
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
void NewPointer()
{
if (m_pPointer == NULL)
{
m_pPointer = new(MyCPointClass);
if (NULL != pPointer && m_pPointer->NewPoint()) // NewPoint is a function, right?
{
return;
}
else
{
delete(m_pPointer);
m_pPointer = NULL; // avoid deleting the memory twice! deleting a NULL pointer is safe, but has a performance penalty since a call to the C-runtime library is done.
}
}
}
void DeletePointer()
{
if (NULL != m_pPointer)
{
delete m_pPointer;
m_pPointer = NULL;
}
}
if you insert
m_pPointer = NULL
somewhere in your code between NewPointer() and DeletePointer(), then yes you have a memory leak.
--------------------------------------------------
If my messages appear curt, I apologize.
I try to be brief to save your time as well as mine.
--------------------------------------------------
|
|
|
|
|
I would just like to say thanks to everybody for their response, all the answers were superb. I just didn`t think to delete the pointer first and then assign it NULL, but everything fits perfectly in my head now. I wondered how the application could delete those pointers in my program that were unused, without any trouble and it was because I had assigned them all to NULL in the constructor! For some reason I thought delete, deleted the memory AND set it to NULL, thats why I couldn`t grasp how it was actually working. But thanks to everyone who wrote in, I am very grateful,
Cheers,
Alan.
P.S. I liked the tips too. Just when I think I seem to be mastering this language, someone comes along and goes "Here's a better way of going about it...", that always amazes me. Thanks for those too guys.
"When I left you I was but the learner, now I am the Master" - Darth Vader
|
|
|
|
|
pls
==============
www.design.kg
|
|
|
|
|
use this
ShellExecute(this->m_hWnd,"open","mailto:","","",SW_SHOW);
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
Nish is a BIG fan of Goran Ivanisevic
|
|
|
|
|
?
==============
www.design.kg
|
|
|
|
|
you need to open the following registry key
HKEY_CLASSES_ROOT\mailto\shell\open\command
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
Nish is a BIG fan of Goran Ivanisevic
|
|
|
|
|
|
(1) open the key HKEY_CLASSES_ROOT\mailto\shell\open\command
(2) read it default value. I got this when I did that here
"%ProgramFiles%\Outlook Express\msimn.exe" /mailurl:%1
(3) you need to replace %ProgramFiles% with the actual path
for that use SHGetSpecialFolderLocation and SHGetSpecialFolderPath [you'll find samples in CP]
(4) forget the /mailurl:%1 part
(5) shellexecute the rest of it
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
Nish is a BIG fan of Goran Ivanisevic
|
|
|
|
|
Hello, the codegurus around the world.;)
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
Do you need a DLL's source code to generate .tbl or in there some tool that will extract a .tbl file from a .dll ?
I was importing (declaring) functions from a .dll (you may know it RAPI.dll, it comes with MS ActiveSync) into VB software, the functions didn't work and kept returning wierd error values. I tracked down a web site, which offered a copy of a .tbl which described the .dll I was attempting to use. Once registered I had no problem using the .dll . Can someone tell me what was going on ?
Regards
Ray
"Je Suis Mort De Rire"
|
|
|
|
|
Did you try registering the dll?
regsvr32 xxx.dll
Glad you found a solution, its nice to be talking hypothetically instead of urgently.
Bill
|
|
|
|
|
It seems to be a Com component, its Export Table has all the apropriate functions etc. But I can't registry it ... What is a .tbl file, where does it come from ?
Regards
Ray
"Je Suis Mort De Rire"
|
|
|
|
|
.tbl files are type libraries. They are created when an activeX control is built. They contain all the information regarding an objects interfaces. ActiveX controls are somewhat different than ordinary dlls, in that there is a lot more control excercised over the calling of exported functions.
If you look at your project, you will see some additional files created when you build it using the .tbl. It should create a .c file containing helper functions. Your program calls the helpers, which in turn call Invoke in the control, telling it which method (exported function) to invoke.
|
|
|
|
|
I want to recognize a word under mouse position.
How to this problem..
|
|
|
|
|
Do you want to do it in your app, or system wide ? I've seen this question asked often and never seen a solution, apart from maybe rolling your own OCR software.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
This approach is not bullet-proof, and it's sentence- rather than word-oriented, but it might suit your needs.
- Enumerate all top-level windows on the screen with
EnumWindows() .
- Stick with the first top-level windows lying under the mouse position (
GetCursorPos() , you sure knew that one).
- Repeat the trick with the child windows of this top-level window --
EnumChildWindows() is the API to use now.
- Stick with the first child window under the mouse position, or the top-level window if none of the childs passes the test.
- Retrieve the text of the window with
GetWindowText() .
Problems with z-order seem to be handled OK as the enumeration routines do their job in a top-to-bottom way.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
In my case anywhere on the screen
Hope this helps
|
|
|
|
|
If you found any solution, please contact me.
I need it much in one of my programs. I saw this facility in Webster Dictionary CD before. It works properly, and returns all words under mouse pointer in every window in all applications, That's a great job.
As I thought, it runs two application agtexe16.exe and agtserv.exe from Accent Software. these two executable files are running when u run the main .exe file of dictionary, because they are in task manager. if I shut down these programs, the application doesn't work anymore and we can not see word returns.
I hope these information were useful, but if you found any solution, please give it to me.
Thank you.
|
|
|
|
|
I try to make HTML-Editor using MSHTML.
I downloaded sample program,"CTriEditControl Sample" on microsoft site.
But.... for Example,
When you Press "Enter",Inserting .
I insert " " when "Enter".
I insert HTML-tag " ",pressing "Enter key".
I tried to send message "IDM_?????".
please tell me!!
and if you know good site about MSHTML,please tell me.
|
|
|
|
|
I want my app to search after a EXE to run.
How can my app do that when pressing a button?
------------------------------
CodeCracker - That's me!
------------------------------
|
|
|
|