|
The sample might be fragmentary, but it has continuity. I'm sorry if you lost out on it.
With regards to one variable being local to one class, and seemingly used in another, again I believed you missed seeing where the pointer from the first class was assigned to a pointer of similar declaration in the second class, and the array was accessed (in the second class) by the pointer declared in the second class. There is no contention nor misrepresentation of pointers occurring. If I said I was able to access the data while working in the second class, that ought to have cleared up any notion of pointer misrepresentation.
About the design being weird, do you have the patent to "Only These Designs Are Acceptable" type designs?
William
Fortes in fide et opere!
|
|
|
|
|
There is no contention nor misrepresentation of pointers occurring. If I said I was able to access the data while working in the second class, that ought to have cleared up any notion of pointer misrepresention.
Most likely, some misrepresentation is going on, as the program crashes after all. I mean, if the program was correct it wouldn't fail. So questioning every assumption is IMHO the way to find the bug. Do not take any naive question I might make in a defensive manner. A simple "no, it's not that" does suffice.
About the design being weird, do you have the patent to "Only These Designs Are Acceptable" type designs?
I haven't said the design is unacceptable, I've said it's weird. Surely you'll have a valid reason for having chosen this design --that's why I asked.
And then again, I'm not doing paid support or anything, I just hang round here at CP trying to help some other folks. If you feel I'm not your kind of helper, I'll be glad to move on to some other question in this forum.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
>> nbrOfNodes = (*(*pNd+i))->nodeCnt;
pNd is a pointer to an array, *pNd+i will point to 'next array' i'm guessing you actually want 'next node in array pNd' in which case try :
nbrOfNodes = (*pNd)[i]->nodeCnt;
(i could be wrong, the code you give is fairly incomplete ... and it's 5:20am here - time for bed)
...cmk
Save the whales - collect the whole set
|
|
|
|
|
My error! My error! My typographical error! I meant the following:
nbrOfNodes = (*(*(pNd+i)))->nodeCnt;
It's one of those things I constantly have to deal with, "the omitting of a pair of parentheses". You have very sharp eyes!! Thanks.
=================================
However, since the program has the correct number of parentheses (and it was my error the way I showed the expression), the original problem remains the same.
William
Fortes in fide et opere!
|
|
|
|
|
I'd say that
nbrOfNodes = (*(*(pNd+i)))->nodeCnt; gets out of bounds, and that the correct expression is
nbrOfNodes = (*(*pNd+i))->nodeCnt; For instance, the following complete program works OK (memory leaks aside)
#include <stdlib.h>
struct Node
{
short nodeCnt;
} *(*pNode)[7];
int main()
{
pNode = (Node*(*)[7])calloc(7, sizeof(Node*));
for(int i=0;i<7;++i)
{
(*(*pNode+i))=0;
}
return 0;
} while the following crashes
#include <stdlib.h>
struct Node
{
short nodeCnt;
} *(*pNode)[7];
int main()
{
pNode = (Node*(*)[7])calloc(7, sizeof(Node*));
for(int i=0;i<7;++i)
{
(*(*(pNode+i)))=0;
}
return 0;
} Could your problem be there?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Found a solution!
Admittedly, it was my own fault! (Tunnel vision struck again. It's amazing what fresh air and a half hour break will do in clearing one's mind.)
I hate myself when I make these VERY STUPID MISTAKES!! I HATE IT!! I HATE IT!! I HATE IT!!
If I can only remember to assign NULL to a pointer after I have deleted it, I could avoid a lot of other problems.
William
Fortes in fide et opere!
|
|
|
|
|
To clear up a lot of the confusion about when memory ought to be allocated and deallocated, I moved the allocation statement to the 'ctor' of the first class, and likewise deallocated the memory in its 'dtor'.
Astonishingly, when I run the program, I get a message about "Damaged block" just before the program terminates.
The program still runs fine, but it's never settling to your mind when you receive a message such as that.
I've tried using, "free(pNode);" to deallocate the memory, but when that didn't change a thing, I tried, "delete pNode;" and when that didn't make it better, I tried using a "for" statement in which I individually deleted the memory by using, "delete[] (*pNode)[7];", and that's where I am, because the message is still occurring.
Might you have any idea what would set matters right?
Thanks.
William
Fortes in fide et opere!
|
|
|
|
|
WREY wrote:
Might you have any idea what would set matters right?
Using STL containers that do memory allocation / deallocation for you! It will also save you a sh*tload of time and headaches...
|
|
|
|
|
I have an SDI application, which crashes when running on win98. It uses some resources when running that are not really required but I don't know how I can limit the used resources.
Actually, when I run more than one instance of this application it crashes with error message: "This program has performed an illegal operation and will be shut down."
I'm debugging it and monitoring the used resources (some dialogs are displayed as in use in resource symbol dialog of VC++ while debugging) and see that it uses some unnecessary resources; It indicates that some dialogs are in use, which are not involved with part of the action I'm performing by the application.
any idea will be appreciated
|
|
|
|
|
i write a voice chat program it ok when run in local network(good banwidth) but when i public in internet for my friend test it hang out because i send to much data and the modem are to slow
(i send every thing what my Recorder class recored when start voice chat 2KB each packet)
but if i don't do that i can hear what i say the voice is miss . So some body have good solution for this problem pls help me out
PS: or demo code is very goood
Thank so muchhhhhhhhhhhhhhhhhhhh
|
|
|
|
|
Hi,
Pls help anyone.
i linked menu and main dialog.
How to link submenu and another dialog?
i've created menu and dialog using resource in dialog based applications.
pls help me soon.
mithila
|
|
|
|
|
I can disable device in xp/2k by using the setup** functions.However, the same functions can not be used in 98/ME. Anybody can tell me how to realize the disabling device in 98/me?
please contact:
xiayi@ustc.edu
|
|
|
|
|
I can disable device in xp/2k by using the setup** functions.However, the same functions can not be used in 98/ME. Anybody can tell me how to realize the disabling device in 98/me?
please contact:
max_xiayi@hotmail.com
|
|
|
|
|
I am trying to create an app that, among other things, uses an MFC Doc/View architecture to display RTF files. I have the editing and display and all the standard stuff from a library (LED) that does an excellent job. Now I have to have a second window open, that shows a portion of the text from another view (lets for argument say the top two lines) blown up (or zoomed in) large. However, I have to have the resolution higher, not just StretchBlt the smaller image up and get a pixelated image. I have a mechanizm to open a separate Frame Window and View, and to transfer the selected text to it.
I thought I could manimpulate the Mapping Mode along with the Viewport and Window Extents to in effect change the DPI of a memory mapped DC. Then, just like when you print, in my OnDraw routine, I pass the DC to my view, let it render to the DC, and then Blit it over to my window.
When I set up my DC, and change it's mapping mode to MM_ANISOTROPIC, and then modify the Extents, everything seems fine when I create a font and call GetOutputTextExtent(), I get a value, and when I double the ratio of the Window to the Viewport Extents, GetOutputTextExtent() reports a value that is double. HOWEVER, when I then use TextOut, the text is the same size, unaffected by the extents. How can GetOutputTextExtent()report a different value than TextOut produces?
Below is some sample code, note the second and third lines from the bottom get the size and create the text, but they do not match:
CDC cdcScreen;<br />
cdcScreen.CreateDC("DISPLAY", NULL, NULL, NULL); <br />
ResizeableDC = new CDC;<br />
ResizeableDC->CreateCompatibleDC(&cdcScreen);<br />
<br />
int mode = ResizeableDC->SetMapMode(MM_ANISOTROPIC);<br />
ASSERT(mode == MM_TEXT);<br />
ResizeableDC->SetWindowExt(1024*20, 768*20);<br />
ResizeableDC->SetViewportExt(1024, 768);<br />
<br />
CFont font;<br />
{<br />
LOGFONT lf;<br />
memset(&lf, 0, sizeof(LOGFONT));
lf.lfHeight = -MulDiv(12, ResizeableDC->GetDeviceCaps(LOGPIXELSY), 72);<br />
strcpy(lf.lfFaceName, "Arial");
VERIFY(font.CreateFontIndirect(&lf));
}<br />
<br />
CFont* def_font = ResizeableDC->SelectObject(&font);<br />
CSize Size = ResizeableDC->GetOutputTextExtent("Now is the time for all good men");<br />
<br />
ResizeableDC->TextOut(Size.cx, Size.cy, "Now is the time for all good men");<br />
ResizeableDC->SelectObject(def_font);
Any other ideas on how to get the results I need? The View class will render to a printer at a high DPI quite well, so I don't think I need to re-write the View code, I just have to figure out how to change the DPI of a DC!
Corey Cooper
|
|
|
|
|
I need to implement a listCtrl where one list (Master) is used to highlight and select items on this list for display on another list.
Are they any good examples. I have seen it used in many applications, but not found an example where you filter what you want to be displayed on the main ListCtrl.
grahamfff
|
|
|
|
|
One solution is SetItemState(). Pass in LVIS_SELECTED.
Kuphryn
|
|
|
|
|
Hi,
There's some problem in MFC's documentation about CTreeCtrl::SortChildrenCB method. The parameters in the callback function are not handles to the tree items but the datas of the items..
My problem is my tree can have subfolders and when i sort i want subfolders reside on the top ( alphabetically sorted within themselves ) and the leafs under them ( again alphabetically sorted ). I distinguish the subfolder and leafs with their data ( leafs being 0 and subfolders being some positive values ). So i can use the parameters of the callback function to separate subfolder from leaf but i couldn't figure out how i could get the item's text so that i can sort them...
Any help is appreciated. Thanks in advance.
|
|
|
|
|
Are you using the data values for anything other than parent/leaf determination? If not, you can set the item's data to be its HTREEITEM, so you have full access to the item's properties in the callback. If you do use the data for something else, create a data structure containing the data you need, and set the item data to be a pointer to an instance of this structure.
Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi Ryan,
I use the data to figure out which item item is leaf and which item is subfolder. Your first proposal came to my mind too but i used the data values too often in the project that replacing them HTREEITEMs will require quite an effort to modify the whole project. And the subfolders under a parent folder have all the same data so i guess the only unique value left for me is the HTREEITEM.
I think i'll have to implement my own sorting function if i can't come up with a better idea on reaching to HTREEITEM using callback function.
Thanks for your reply.
|
|
|
|
|
Can anyonme help me on finding info oin defragmenting a hard drive programatically. Are there any projects on CodeProjects?
gabby
|
|
|
|
|
Gabby,
You could always try www.sysinternals.com
http://www.sysinternals.com/ntw2k/info/defrag.shtml
This information is regarding the built in native support for disk defragmentation on NT and later.
The pointer also includes source code and examples.
Hope it helps
Regards
Darren
|
|
|
|
|
Thank you very much for your help.
I will check up the site right now
gabby
|
|
|
|
|
I've been working on a Phone Book program for a few days and have hit a snag on the graphical part.
I wanted 5 buttons with bitmaps (for home, mobile, work, ect) with text, to do that I would have to make them ownerdrawn, I did'nt want to go through the hastle of that.
I decided to make the buttons bitmaps, then when the mouse is over them change the styles to text to show the text.
I got that working fine but when you click the buttons (actually check buttons) they stay in there current state! When you mouse over the other buttons then come back to the one you just checked it works fine!
Here is the link to a zip with the source+workspace/exe http://www.kruncherinc.com/PhBk.zip
Please, any ideas?
wWw.KruncherInc.cOm
|
|
|
|
|
Are you Invalidate()ing the window of the button who's state changes? The window will only redraw itself in response to a WM_PAINT message- perhaps the action of moving the mouse is triggering this.
There are loads of graphic/bitmap button classes here on codeproject that would probably suit your needs. Yes, you'll need to apply BS_OWNERDRAW to a button for it to appear properly, but these classes will handle all of the details for you.
jon
using System.Beer;
|
|
|
|
|
Hi
I'm facing the following problem using AddFontResource function.
I've got Type1 fonts' files embedded in my programs resources. And I want make them(fonts) automatically install on programm startup and remove on programs shutdown. I'm doing the following:
1) extracting binary data from resources and saving them in temporary files
2) trying to add them by calling
AddFontResource("c:\\windows\\temp\\DIN-Bold.pfm | c:\\windows\\temp\\DIN-Bold.pfb");
But this function always returns 0.
The same procedure works well for single-file ttf fonts.
Could anybody help me to find out why it doesnt install pfm+pfb fonts.
I'll be glad to get any help from you.
|
|
|
|