|
> Do you want the property page to actually grow vertically together with the > list control if the data in the list control overruns the initial size?
Yes. Sort of make the listctrl grow dynamically with the property page.
|
|
|
|
|
DanYELL wrote: Sort of make the listctrl grow dynamically with the property page.
So the property page is sizable?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
DanYELL wrote: I have a propertypage and the first page...
Do you mean the first page of a property sheet has a list control?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I was looking at the WinSpy artical (http://www.codeproject.com/threads/winspy.asp), which describes how to extract text from any control (I think it uses WM_GETTEXT).
But this doesn't work on windows that display rich text. Does anyone know how to get to extract the text in this case?
By the way, I'm not sure that the window in question is the rich edit control. It says that it is a "AfxFrameOrView" class, but that could just be the parent window.
|
|
|
|
|
Richtext is not added to a control with a simple sendmessage, it is streamed in and streamed out a little at a time. If you wanted to use a similar method to winspy, you would need to write the whole streaming functions and inject a callback.
|
|
|
|
|
Thanks for the answer!
Do you know any working example that does that?
|
|
|
|
|
Now, I found some code to extract the text using EM_STREAMOUT, but it doesn't work. It could be that the window is not a rich edit control. It there anyway to test if the window is a rich edit?
|
|
|
|
|
when u get a handle of window. Use GetClassName to get class of window. Compare it with "RICHEDIT".
nave
|
|
|
|
|
Nevermind, I figured another way to do it.
|
|
|
|
|
Hi !!!
Did somebody know some really good Refactoring tool for C++?
Thanks.
Bye.
-:KNOX:-
|
|
|
|
|
|
I'm using a parent class that holds pointers to child classes (parent-child is the application's terminology, not indicating heirarchy in c++).
The parent class has an array of pointers to children named "children"
To save space (and I need all I can get), I want to dynamically allocate this array. I have been using malloc/realloc with success in the past, but recently it's been reporting heap corruption:
"Heap block at 01720DD8 modified at 01720DE4 past requested size of 4"
before stopping at this line in memcpy_s.c:
"memcpy(dst, src, count);"
The realloc command in the code that is initiating the problem is indicated below. This array is initially malloc'd in the constructor of the class with a size of one child pointer.
bool parent::addchild(child *childToAdd){
//////////////////////////////
// Add child to children
//////////////////////////////
numchildren++;
children = (child**)realloc(children,(numchildren * sizeof(child*))); //<--Error occurs here
children[(numchildren-1)] = childToAdd;
return TRUE;
}
Thanks for any help
|
|
|
|
|
Slightly different error in Debug (original post was for Release):
Heap corruption:
"Heap block at 01F13EA0 modified at 01F13ED0 past requested size of 28"
Stops at the end brace of this function in mlock.c:
void __cdecl _unlock (
int locknum
)
{
/*
* leave the critical section.
*/
LeaveCriticalSection( _locktable[locknum].lock );
}
|
|
|
|
|
Read your error, the answer is there.
nadiric wrote: "Heap block at 01F13EA0 modified at 01F13ED0 past requested size of 28"
You requested a block of memory of size 28 bytes, it was given to you at address 01F13EA0, but you tried writing to it at address 01F13ED0 which is over the 28 byte limit. Basicly you are writing past the end of the array somewhere in your code.
|
|
|
|
|
my code effectively stops at the realloc indicated, it never makes it past this line...?
|
|
|
|
|
Run your code in the debugger, open the call stack window, and watch. When your code calls that function, there will be something like _invalid_pointer shown in the window. realloc() will check the memory for problems before doing what it should. Somewhere before calling the function, you have written past the end of the array. Just step through your code and look out for the address in the error message, thats when you will find your problem.
|
|
|
|
|
nadiric wrote: children = (child**)realloc(children,(numchildren * sizeof(child*))); //<--Error occurs here
So you only allocate memory for an array of child* pointers (which is 4 bytes on 32-bit Windows), not an array of children?
Best,
Jun
|
|
|
|
|
the array "children" holds pointers to "child" objects. Maybe the below will clarify.
child **children; //declaration in parent class
children = (child**)malloc(sizeof(child*)); //done in parent constructor
parent *parent1 = new parent;
child *child1 = new child; //creating a child somewhere in code
parent1.addchild(child1); //adding the child to a parent (the code in question)
|
|
|
|
|
Actually, this is something... Since you use the heap, why not just save child objects (instead of child* pointers). Theoretically it's OK, but it could cause implications to the memcpy() call, if the memory size not calculated correctly.
Best,
Jun
|
|
|
|
|
nadiric wrote: child *child1 = new child; //creating a child somewhere in code
parent1.addchild(child1); //adding the child to a parent (the code in question)
You may have issues here as well. new and malloc/calloc/realloc use different heaps. You are using new to allocate your objects and realloc to allocate your pointers. Mixing heaps like this can cause some interesting and hard to debug issues.
As a side note, you would probably get better performance by using a deque or a vector (with a pre-allocated buffer). Since each time you are adding a child, you are basically forcing a new memory allocation (actually 2, since you had to allocate the child object and then a pointer to it). You might find it easier, and more efficient to do something like the following:
class Child
{
public:
Child() : m_Data(0)
{
}
private:
int m_Data;
};
class Parent
{
public:
Parent()
{
}
void addChild(Child* pChild)
{
m_Children.push_back(pChild);
}
private:
std::deque<Child*> m_Children;
};
const unsigned long DEFAULT_SIZE = 100;
class Parent
{
public:
Parent()
{
m_Children.reserve(DEFAULT_SIZE);
}
void addChild(Child* pChild)
{
m_Children.push_back(pChild);
}
private:
std::vector<Child*> m_Children;
};
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
When you get heap corruption the actual cause need not be near where the problem manifests itself; often there is no obvious connection. He's what I'd try first:
- If you haven't already got it, down and install WinDBG[^]. This is an absolute essential and every C/C++ developer should have the latest version installed at all times.
- Select "Start->All Programs->Debugging Tools for Windows->Global Flags".
- Select the "Image File" tab.
- Type the name your application in the "Image: (TAB to refresh)" edit box then press TAB. The name should be the whole file name and extension but not the full path.
- Tick "Enable page heap", "Enable heap tail checking", "Enable heap free checking", "Enable heap parameter checking", "Enable heap validation on call" & "Create user mode stack trace database".
- Press "OK".
Now run your application. It will run many, many times slower then normal and consume huge amounts of memory but most heap errors will cause a break point to be generated as soon as the heap error occurs. If you use WinDBG as your debugger you can also get access to stack traces for each allocation. For example for a double free you can get a stack trace to the first free and a break point is generated for the second. It's good to have a machine with the fastest possible CPU and as much RAM as you can afford for debugging processes with the page heap.
After you've finished you'll want to turn the page heap off again for your process. Follow the steps above but uncheck all the tick boxes.
Steve
|
|
|
|
|
Lets say I have a class with quite a few public members, each time one of these functions is called I need to check a variable (by calling another function) before I can allow the code to proceed. Obviously I could insert the function call into each public function, but is there an alternative? What I'm worried about is somebody subclassing and forgetting to add the call into their extended function.
|
|
|
|
|
Private functions
A cynic is a man who, when he smells flowers, looks around for a coffin. -H.L. Mencken
|
|
|
|
|
hey thats a great idea, I will declare all of the class functions as private, that will stop those hackers from subclassing my class. One small drawback though, it won't work.
|
|
|
|
|
waldermort wrote: hey thats a great idea, I will declare all of the class functions as private, that will stop those hackers from subclassing my class. One small drawback though, it won't work.
JWood's answer was too short. He probably meant something like:
class Base {
public:
void doSomething() {
checkVar();
doSomethingImp();
}
private:
virtual void doSomethingImp() {
}
};
class Derived : public Base {
public:
private:
virtual void doSomethingImp() {
}
}
-- modified at 17:43 Thursday 7th September, 2006
see also: http://www.gotw.ca/publications/mill18.htm[^]
|
|
|
|