|
Polymorphism only kicks in if you are accessing your C++ object through a pointer. This is what you need to do:
{
derived myDerived, *pDerived;
int nData = 5;
pDerived = &myDerived;
pDerived->fn(nData);
}
==================
The original message was:
I was wondering if somebody can explain why the following doesn't work:
class base { public: virtual void fn(int nData) ( /* Do Something */ }; virtual void fn(char * pszData) { /* Do Something */ }; }
class derived : public base { public: virtual void fn(char * pszData) { /* Do Something */ }; }
void MyFunction { derived myderived; int nData = 5;
myderived.fn(nData); }
The compiler complains about myderived.fn(nData). It says.... "error C2664: 'fn' : cannot convert parameter 1 from 'int' to 'char *'. ...."
Why doesn't it just use the base class fn(int nData)???? Am I doing something wrong or is this C++ behaviour?
Thanks in Advance Chris Mancini
|
|
|
|
|
You have actually overrided the function 'fn' and using it as a overloaded function. Check it out.
Regards,
Prabhat
==================
The original message was:
I was wondering if somebody can explain why the following doesn't work:
class base { public: virtual void fn(int nData) ( /* Do Something */ }; virtual void fn(char * pszData) { /* Do Something */ }; }
class derived : public base { public: virtual void fn(char * pszData) { /* Do Something */ }; }
void MyFunction { derived myderived; int nData = 5;
myderived.fn(nData); }
The compiler complains about myderived.fn(nData). It says.... "error C2664: 'fn' : cannot convert parameter 1 from 'int' to 'char *'. ...."
Why doesn't it just use the base class fn(int nData)???? Am I doing something wrong or is this C++ behaviour?
Thanks in Advance Chris Mancini
|
|
|
|
|
Hi there,
I have the following problem with exception handling in my ATL-COM object:
The following works fine in debug mode
try
{
throw //..etc.
}
catch(...)
{
return Error("Unkown Error: SaveDots");
}
but in release mode: I get an unhandled-exception error message.
Do you have a sollution?
tnx in advance,
Kai.
|
|
|
|
|
Hi,
I've been able to create an activeX control and to change its background color and font using OnDrawItem.
Now my problem is that everytime I put this activeX in a composite control and then use this composite control as an ActiveX over the Internet, I can see everything being drawn and disappear...
First I just implemented the OnPaint function in the composite control with just 'return 0' in it
-> my activeX control shows up, the onSize function works great, but of course, if I switch from a window to another one, the activeX control disappears and is not refreshed...
Here is some code:
From the activeX:
BEGIN_MSG_MAP(CSRAxControl)
MESSAGE_HANDLER(WM_CREATE, OnCreate)
MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
MESSAGE_HANDLER(WM_DRAWITEM, OnDrawItem)
CHAIN_MSG_MAP(CComControl<csraxcontrol>)
ALT_MSG_MAP(1)
END_MSG_MAP()
From the composite control:
LRESULT OnPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) {
_axViewControl.SetFocus();
return 0;
}
LRESULT CIdefixView::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled){
HRESULT hresult=0;
CLSID clsid;
CWindow hwndParent = NULL;
hwndParent = GetParent();
CComPtr<idispatch> myIDispatchView;
CComBSTR progID = OLESTR("Ctrls.SRAxControl");
hresult = CLSIDFromProgID(progID, &clsid) ;
if (SUCCEEDED(hresult)){
hresult = CoCreateInstance(clsid, 0, CLSCTX_ALL, IID_IDispatch, (void**)&myIDispatchView);
if(SUCCEEDED(hresult)) {
_axViewControl.Attach(GetDlgItem(IDC_VIEW));
_axViewControl.ModifyStyle( NULL, WS_CLIPSIBLINGS, SWP_SHOWWINDOW );
hresult=_axViewControl.AttachControl(myIDispatchView, NULL);
_pViewControl = myIDispatchView;
RECT rc;
hwndParent.GetClientRect(&rc);
_axViewControl.MoveWindow( 0, 0, rc.right - rc.left, 26, TRUE );
}
}
return S_OK;
}
Please Help !!
Thanks,
Catherine.
|
|
|
|
|
Hi!
I needed a two column combo box that autocompletes. I used Chris Maunders excellent autocomplete example as a starting point and have a perfectly working control.
However I have a problem: I normally would override ONSELENDOK in my app to update a view when a user selects a new item from the drop down list, with this new control a user can type a partial string, hit a match and tab out of the control. So there are two ways of selecting an item. I have tried several methods to do this but none very successfull, they would be too complex in most cases. The ideal solution I'm guessing would be to post an ONSELENDOK message either way but I can't seem to get it to work.
Any recommendations would be greatly appreciated.
|
|
|
|
|
Hi,
Please check SHAutoComplete( ) if you are using latest version of IE... It helped me...
==================
The original message was:
Hi! I needed a two column combo box that autocompletes. I used Chris Maunders excellent autocomplete example as a starting point and have a perfectly working control.
However I have a problem: I normally would override ONSELENDOK in my app to update a view when a user selects a new item from the drop down list, with this new control a user can type a partial string, hit a match and tab out of the control. So there are two ways of selecting an item. I have tried several methods to do this but none very successfull, they would be too complex in most cases. The ideal solution I'm guessing would be to post an ONSELENDOK message either way but I can't seem to get it to work.
Any recommendations would be greatly appreciated.
|
|
|
|
|
is someone there using crystal report with mfc (visual c++)
i need help
thank you very much
|
|
|
|
|
==================
The original message was:
is someone there using crystal report with mfc (visual c++) i need help thank you very much
-=-=-=-=-=-=-=-=-=-=
I am! I only use it with ADO datasources in C++ apps using the crpengine not the ActiveX control.
Email me and I can try to help.
|
|
|
|
|
Post the question and someone will answer
==================
The original message was:
is someone there using crystal report with mfc (visual c++) i need help thank you very much
|
|
|
|
|
yes! But what do you want?
==================
The original message was:
is someone there using crystal report with mfc (visual c++) i need help thank you very much
|
|
|
|
|
Even I have used it, What is the problem ??????
==================
The original message was:
|
|
|
|
|
Hi!
I want to paste some text into an input-box of another application running. I think I have to use SendMessage(WM_PASTE,0,0), but first I must get a handle to the active input-box. The pasting is to be triggered by the user of my program, so probably the handle must be to the previously active window. Any suggestions? I'm using VC++ 5.0.
Thanks!
Pär
|
|
|
|
|
Hi,
Using VC++ 6.0, is it possible to create an MFC based Ax control using a static build with MFC. This would eliminate any runtimes with the finished control. I have read this can't be done in previous versions of VC++?
Thanks, Scott
slewis@bigfoot.com
|
|
|
|
|
How can I determine if this is empty/full and have the ability to empty it? I already know that there are shell extension APIs for version 4.71 of Shell32.dll, but this requires that you use the IE extended desktop environment. Normally NT and its rug rats 95 and 98 use version 4 of this DLL. These procaddrs are not in the older DLL. There must have been an "old way" to do this that I can use for existing users and non-IE folks. Anyone know?
Thanks! Bob
|
|
|
|
|
Try looking at SHFileOperation
|
|
|
|
|
==================
The original message was:
Try looking at SHFileOperation
|
|
|
|
|
==================
The original message was:
Try looking at SHFileOperation
Whoops! Thanks for your reply, but SHFileOperation is
used to remove a file *into* the recycle bin, not query
the state of the recycle bin. Thanks for your trouble anyway!
|
|
|
|
|
Hi,
I've built an irregular shaped dialog app using MFC VC+6.0,
Anyone got any tips on how to use the regions to build a frame for it.
I've tried various things in my NC areas to know success.
Regardz
Colin Davies
|
|
|
|
|
what is the bets way to erialise Chris' grid control?
if it is embedded in a view, using his method for doing this?
|
|
|
|
|
I am trying to make a composite control so that I can use it in my grid. In the control, I have several check boxes. I want them to act like radio buttons. However, I couldn't figure out how to make them talk to each other. Any suggestions? I have gone through a lot of ATL samples, but I couldn't find any composite example.
Thanks
JC
|
|
|
|
|
Hi all,
does anybody have a Visual C++ solution for schedule problems and visualisation by Gantt-Diagrams.
|
|
|
|
|
Hi all,
does anybody have a Visual C++ solution for schedule problems and visualisation by Gantt-Diagrams.
|
|
|
|
|
Hi, everybody!
Do somebody know whether is it possible to emulate a system modal dialog (I mean a 'system modal' style) using MFC CPropertySheet class?
Thanks in advance.
|
|
|
|
|
Hi All --
I'm probably overlooking a simple API or class, but:
Does anyone have sample code for converting a double value to a formatted string using the currency format defined by the system? For example:
double dValue = 1234567.89;
CString sValue = FormatAsCurrency(dValue);
// If we're in the USA,
// sValue should be "$1,234,567.89".
// If we're in the UK,
// sValue should be "£1,234,567.89"
I'd be grateful for any suggestions.
|
|
|
|
|
Use wsprintf() to convert your value to a string, then call GetCurrencyFormat(). Simple!
--Mike--
==================
The original message was:
Hi All --
I'm probably overlooking a simple API or class, but:
Does anyone have sample code for converting a double value to a formatted string using the currency format defined by the system? For example:
double dValue = 1234567.89; CString sValue = FormatAsCurrency(dValue);
// If we're in the USA, // sValue should be "$1,234,567.89". // If we're in the UK, // sValue should be "£1,234,567.89"
I'd be grateful for any suggestions.
|
|
|
|