|
You can use one of several Win32 APIs to check the validity of a pointer: IsBadCodePtr() , IsBadReadPtr() , IsBadStringPtr() and IsBadWritePtr() as well as the Huge analogs.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Unfortunately, AfxIsValidAddress() and related functions like IsBadReadPtr() don't tell you if the pointer has been freed or not. They know if the address can be read from and/or written to. You'll just need to get into the habit of assigning NULL to the pointer after delete has been called.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
class CTest<br />
{ <br />
public: <br />
CTest** m_ptr;<br />
CTest(CTest** ptr = NULL)<br />
{<br />
m_ptr = ptr;<br />
}<br />
~CTest();<br />
{<br />
if(m_ptr)<br />
*m_ptr = NULL;<br />
}<br />
void Release() <br />
{ <br />
delete this; <br />
}<br />
};<br />
<br />
<br />
CTest *pTest = NULL<br />
pTest = new CTest(&pTest);<br />
pTest->Release();
"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
|
|
|
|
|
Shah Shehpori wrote:
How can i determine that the pointer is pointing to a valid memory address??
There is a big difference between "valid memory" and "memory that contains valid data". Unfortunately the computer can only tell you about the former. Even after you delete a pointer, the memory is not usually removed from your app's process space, so you could go on dereferencing the pointer and not cause a GPF.
As someone else said, get in the habit of setting pointers to NULL after a delete or Release() call and you'll avoid such bugs.
--Mike--
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
CP SearchBar v2.0.2 released
|
|
|
|
|
Please help me to find some Assembler IDE which work on Win32.
(Kind of VASM).
I spend much time for surfing all over WWW but links I found was broken
Code Red
|
|
|
|
|
Hi guys,
I am just starting to use DirectShow. I've managed to make it play a video in a CStatic in my dialog box. But now I want to draw something else there, like, put something on top of the video that is playing. I've tried using the device context from the CStatic but that doesn't seem to work - I guess I "gave" it to DirectShow and don't have control over it anymore. Another possibility would be to put another CStatic in front of the video playing, but that doesn't seem to work either, the video just plays over everything! Any suggestions?
|
|
|
|
|
|
am trying to load JPEG2000 (J2k) image and make use of the scalability features provided by J2k
by showing the image while loading. The tutorials clearly show that there are two possible “modes”:
- Progressive by resolution (You load the picture and it becomes sharper while loading, something
like interlaced GIF)
- Progressive by accuracy (ROI – region of interest)
I am interested in the first: “Progressive by resolution”. So I want to show the image while loading
for example if you download a 2 MB image through Modem connection.
I am looking for a exemplary implementation - does not matter in which language or platform it is running.
I would be grateful for any help.
Regards,
gicio
|
|
|
|
|
There any good beginner tutorials on making a context menu plug-in for Internet Explorer. I have come across a few articles here but none of them have the source code or the point you to MSDN to read about it. Trying to find something thats easy to follow.
Thanks!
|
|
|
|
|
If you just want to add items to the IE context menu that is easy. I imagine there is a way to replace it, but don't know how. What are you trying to do?
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
|
Thanks for the relpys. I kinda know how do add an item to the context menu (This is done through the registery) but what I would like info on is creating the DLL to grab the text thats selected and all that good stuff. Just something to get me started would be great. As an example (Not exactly but close) is just have an extra selection come up when I have selected text that says like Search for on goole then have my DLL get the text and post to google or wherever.
|
|
|
|
|
Hi. I have created a dialog called LOADS. This uses 8 radio buttons to allow the user to select the load (Hi / Low) on one of four instances of a wheelspeed transducer(WST). I therefore create an instance of LOADS in my main dialog:
LOADS WST
A second type of transducer is an Anti Skid Valve (ASV), but this has 6 instances of which I wish to set the load. The way I've implemented this is to have all six instances (12 radio buttons) on the LOADS dialog, and I pass a switch to DoModal() to tell it wether or not to disable the other two sets of radio buttons:
LOADS WST;
LOADS ASV;
if(WST.DoModal(1)!=IDOK)
return;
if(ASV.DoModal(0)!=IDOK)
return;
Then, in the LOADS functionality I can disable the unwanted radio buttons if the parameter to DoModal=1, and enable them if parameter =0;
Question: Instead of doing the above, how can I inherit a LOADS dialog so that I create a new dialog (eg LOADSASV) which I can then add the extra radio buttons to, thus replACING THE ABOVE CODE WITH:
LOADS WST;
LOADSASV ASV;
Can you help or point me to a suitable article? Thanks in advance.
Paul
|
|
|
|
|
Hi,
Im doing a project in Labview/IMAQ, but C/C++ can also be. I need to know how can it be done most effectively. I mean, It works in IMAQ in LabView, just by detecting particles, and measuring their max intercept and elongation.But there is a problem of right thresholding the original(grayscale) image. I also looked into hough transform - the demos are impressive. But there seems to be no implementation of it in Labview/IMAQ. Can you help somehow? Maybe you know where in WWW I can find some good and relatively simple Hough Transform implementation in C/Labview? Or some other way to do it. The calculation should take under a second for 2.4GHz computer - and image is big.
Thanks in advance.
Andru (CZ)
|
|
|
|
|
I have an app that is finished except for the aesthetics associated with my window resizing.
I need the windows size to be no smaller than a certain dimension and I need the height and width to always be a certain ratio.
I have built an OnSize handler, but it doesn't stop the window from resizing.
I have also tried using the WINDOWPLACEMENT structure and manually changing the values in that structure in response to the cx and cy passed to my OnSize handler, but it doesn't prevent all of my controls from resizing as the user continues to drag the window border.
How do I intercept the Window's resizing before the resize actually occurs so I can prevent the window from being resized?
|
|
|
|
|
See if something like this works:
void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
lpMMI->ptMaxSize.x = 640;
lpMMI->ptMaxSize.y = 480;
lpMMI->ptMinTrackSize.x = 640;
lpMMI->ptMinTrackSize.y = 480;
CFrameWnd::OnGetMinMaxInfo(lpMMI);
}
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
(Montgomery Burns, rubbing hands together) Excellent.........
Thanks DavidCrow! That nipped those pesky, resizing windows in the bud.
I wonder why WM_GETMINMAXINFO doesn't show up in class wizard?
Is there a way to tell VisualStudio to show all of the windows messages?
|
|
|
|
|
Terry O`Nolley wrote:
I wonder why WM_GETMINMAXINFO doesn't show up in class wizard?
Um, it does for me. Did you select the right class in the Class name: combobox?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
DavidCrow wrote:
Did you select the right class in the Class name: combobox?
Yes - the listing of WM_ did not include WM_SIZING or WM_GETMINMAXINFO. My entire list of WMs is only 37 messages. I have had to manually write many of my handlers because they don't show up in class wizard.
I'm using VC++ 6.0 and the app is dialog based.
|
|
|
|
|
Click the Class Info tab. In the Message filter: combobox, select something other than Dialog.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Cool - I changed it to Window and now all of the messages are there. Thanks again!
|
|
|
|
|
Terry O`Nolley wrote:
Is there a way to tell VisualStudio to show all of the windows messages?
There is a filter within the class wizard, that based upon the MFC class that your class inherits from, the wizard will filter what messages it will build for you. Fortunately you can change the filter. I can't remember the tab, but within the wizard dialog somewhere you change the setting from CDialog to CWnd, the wizard will allow to pick from other messages like WM_GETMINMAXINFO.
Chris Meech
If you spin a Chinese person around, do they become dis-oriented?
Why do people in this time period worry so much about time traveler's destroying their worldline when they have no problem doing it themselves every day? John Titor.
|
|
|
|
|
|
Is it a form view class?
If so then you need to do it within the ChildFrame (not FormView)
|
|
|
|
|
No, it is a dialog-based app.
|
|
|
|