|
|
Hi
I have a number of rich edit classes in my project. Defined basically as such
class Myrich : public CrichEditCtrl they all have a default constructor with no parameters
I now wanted to extend their functionality with paging (up or down) cursor selection etc.
So I wrote a class KeyStroke. I declared KyStroke(s) in each of my classes as such
KeyStroke mykeys; in my .h class definitions. My constructer for KeyStroke takes 2
parameters the number of lines in the rich edit and a pointer to a rich edit class
So that meant I would have to modify my rich edit constructor as such
MyRich::MyRich() ---> MyRich::MyRich(int numlines, CRichEditCtrl* myrichptr) : KeyStroke(int numlines, CRichEditCtrl* myrichptr)
I am getting all sorts of errors with this such as "int" unexpected and KeyStroke no default contsructor
|
|
|
|
|
If you create a parameterised constructor for a class you must also provide a default parameterless one.
class KeyStroke
{
public KeyStroke(int numlines, CRichEditCtrl* myrichptr)
{
}
public KeyStroke()
{
}
|
|
|
|
|
I did that I am still getting errors as stated below
\progedit.cpp(13): error C2062: type 'int' unexpected
1> progdialog.cpp
while intellsense says class KeyStroke
"KeyStroke" is a nonstatic data member or base class of class Cprogedit
I have KeyStroke in Cprogedit.h as KeyStroke mystroke; in the public section of the class
I have defined a constructor for Cprogedit which will provide the paramters for Keystroke
as such
CProgedit::CProgedit(int numlines, CProgedit* editptr) : KeyStroke(int numlines, CProgedit* editptr)
KeyStroke::KeyStroke()
{
}
KeyStroke::KeyStroke(int numlines, CRichEditCtrl* editptr)
{
max_line = numlines;
edit_ptr = editptr;
}
|
|
|
|
|
Sorry, I cannot make head or tail of that. Can you show the class definition for Keystroke and indicate exactly where the error message occurs?
|
|
|
|
|
Not home now Dr appt but I'll paste the entire output in about 1 and 1/2 thanks so so so much
|
|
|
|
|
Richard, Richard Andrew X64 got me pointed in the right direction
For the Class Declaration
KeyStroke mykeys;
inside
class Cprogedit : public CrichEditctrl
this was the necessary constructer
CProgedit::CProgedit(int numlines, CProgedit* editptr) : mykeys(numlines, editptr)
|
|
|
|
|
ForNow wrote: CProgedit::CProgedit(int numlines, CProgedit* editptr) : KeyStroke(int numlines, CProgedit* editptr)
This is a problem. While you're declaring the CProgedit constructor on the left-hand side, the part on the right-hand side is actually a call, so you wouldn't put the data types of the aguments. In other words, try the following:
CProgedit::CProgedit(int numlines, CProgedit* editptr) : KeyStroke(numlines, editptr)
Let me know if this helps.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Richard
Thanks almost I got a compiler error saying KeyStroke not a member ... and that's right KeyStroke was a type as I declared KeyStroke mykey. However when I declared I got a clean build
CProgedit::CProgedit(int numlines, CProgedit* editptr) : mykey(numlines, editptr)
|
|
|
|
|
I'm glad you got it fixed.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
KeyStroke mykey; defined in Cprogedit.h
CProgedit::CProgedit(int numlines, CProgedit* editptr) : mykey(numlines, editptr)
KeyStroke::KeyStroke(int numlines, CRichEditCtrl* editptr)
Cprogedit* myrich = new Cprogedit((int) 30, myrich);
DO you think this will work. What I mean is the two parameters are being passed to KeyStroke
but will myrich have a vaule before KeyStroke constructor is called
|
|
|
|
|
I think that will definitely not work. Because it passes an uninitialized value into the constructor before it returns the new pointer.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Is there any way this is do-able
What I mean by that is I am sure you know MFC internals better than me does get the storage
for the Object class BEFORE it calls one or all of the member classes/object in the class
For some reason I thought that it did
|
|
|
|
|
I don't know what to tell you because you need to explain what you are trying to accomplish.
If we can talk about what you want to accomplish, then we can probably find a solution.
Why do you think you need to do it this way?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I wrote a number of rich edit classes after finishing I realized they would all have common functionality
1) processing KeyStrokes
2) cursor select
3) Finding data
I decided to encompass all of this in a class called KeyStroke which would expand functioality on a EditCtrl object
so I declared KeyStroke mykey1; etc; 2 3 ...
The constructor of KeyStroke takes a RicheditObject it was my understanding that when "new" build a class/object the First thing it does is allocate storage for the class/object and then
call member classes which is why I thought this was doable
Thanks
|
|
|
|
|
If you do,
CObject* ptr = new CObject();
It performs that in two steps:
1. Calls the CObject constructor
2. Then it assigns the instance to the ptr
ptr is uninititalized when the CObject constructor is called. It's not initialized until after the constructor returns.
It might allocate the memory for ptr before it calls the constructor, but it does not contain a useful value. It's uninitialized until the assignment occurs.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Thanks I think the only other way I Might ? be able to do what I want is use the "this" pointer
Assuming that KeyStroke is a Abstract Object used within the context of Cricheditctrl
The this pointer would be that of the CRicheditctrl
I can set a breakpoint inside the KeyStroke constructer check the "this" value
and check "myrich =" pointer afterwards to see if they are the same value
otherwise I guess I would set the richedit ptr after I allocate the object
thanks
|
|
|
|
|
In the KeyStroke Contructor
I cast a "this" pointer to CRicheditctrl * and I wrote down the address
I then observed Cricheditctrl pointer assigned after the new and it was the same address
i'll cut and paste the code for more clarity
KeyStroke::KeyStroke(int numlines, CRichEditCtrl* editptr)
{
max_line = numlines;
edit_ptr = editptr;
edit_ptr = (CRichEditCtrl*)this;
}
myedit = new CProgedit((int)30,myedit);
|
|
|
|
|
A common solution to add such functionality is adding a KeyStroke member to your Rich Edit derived class and pass the this pointer to the member:
class MyRich public CRichEditCtrl
{
public:
MyRichyRich(int numlines);
KeyStroke m_KeyStroke;
};
MyRich::MyRich(int numlines) :
m_KeyStroke(numlines, this)
{
} But this will generate a C4355 warning. To avoid that, you can make the KeyStroke member a pointer and allocate it in the constructor:
MyRich::MyRich(int numlines)
{
m_pKeyStroke = new KeyStroke(numlines, this);
} or provide an initialisation function:
MyRich::MyRich(int numlines)
{
m_KeyStroke.Init(numlines, this);
}
Your problem is not the error message from the subject but that you want to access your Rich Edit object before it is created (and did not use this instead).
|
|
|
|
|
Thanks upon entry to the constructer the "this" pointer is valid
Thanks
|
|
|
|
|
I created an xll excel add-in with Visual C++ 2013 and Excel 2007/2010/2013 XLL SDK package. In the application I have to load a third party dll which depends on MSVCR90.dll for release version and MSVCR90D.dll for debug version. But I don't know how to load the MSVCR90D.dll in the project. What I tried is to create an additional manifest file or use a pragma comment instead in the code like
#pragma comment(linker, "/manifestdependency:\"name='Microsoft.VC90.DebugCRT' processorArchitecture='x86' version='9.0.30729.1' type='win32' publicKeyToken='1fc8b3b9a1e18e3b' \"")
It works in win32 console application but not in xll application.
Also I wonder why in the xll application all the release version of msvcr dll including MSVCR90.dll, MSVCR100.dll and MSVCR120.dll are automatically loaded if they are installed in windows system. Since I am working in vc++ 2013, msvcr120d.dll is loaded as well.
Can anyone tell me how msvcr90d.dll can be loaded as well?
visual c++ 2008/2010/2013 redistributable packages are installed.
|
|
|
|
|
There is no need to load these DLLs in your project. They must be only present on your system so that they can be found and loaded by the 3rd party DLL when your application is executed. The only problem might be getting the debug version (MSVCR90D) because it is not publicly available (not allowed to be distributed).
If you have it, just copy it to your project's Debug folder where it can be found when executing the debug executable.
There might be also problems when using different runtime library versions from a single application, but I have no experiences with that. The best solution would be to ask the supplier of the 3rd party DLL if he can provide a version build with VS 2013 or a version that has the runtime statically linked.
|
|
|
|
|
When I copied the DLLs in the project debug folder, the problem still exists.
When I copied the DLLs in the folder where the 3rd party DLL is, I got a R6034 Debug error "An application has made an attempt to load the C runtime library without using manifest".
|
|
|
|
|
Dropping the exact error text into google didn't help you like it helped me?
The very first result was the following: C Run-Time Error R6034
|
|
|
|
|
I need some hint how to identify / troubleshoot this syntax error.
/home/vaclav/TEMPLATE_Cross_GCC_RPI: 1: /home/vaclav/TEMPLATE_Cross_GCC_RPI: Syntax error: "(" unexpected
I get it when I specify
"/home/vaclav/TEMPLATE_Cross_GCC_RPI"
as "file path". The path is valid.
Mrs Google suggested "linux bash error".
I am lost.
Amy help would be greatly appreciated.
Cheers.
Vaclav
|
|
|
|