|
Hi,
Class 'B' is overloading the operator '<<'. In quick mockup test I managed to get the following to work:
class A<br />
{<br />
public:<br />
A& operator << (double arg)<br />
{<br />
return *this;<br />
}<br />
};<br />
<br />
class B : public A<br />
{<br />
public:<br />
B& operator << (int arg)<br />
{<br />
return *this;<br />
}<br />
<br />
using A::operator <<;
};
I ran into difficulties when using the reference operator '&' for the two arguments.
I hope this is of use!
Lea Hayes
|
|
|
|
|
It appears that when I remove the reference operator, I don't have to specify "using". It's a shame though as I was hoping to subclass an existing implementation and just add a few of my own << operators to write my own types. Looks like I'll have to try defining the operators outside of the class.
|
|
|
|
|
Hi,
Whilst not necessarily the perfect solution, you could inline the operators.
class B : public A<br />
{<br />
...<br />
<br />
public:<br />
inline A& operator << (double & atr)<br />
{<br />
return A::operator << (atr);<br />
}<br />
};
This might be a useful workaround for your scenario.
Lea Hayes
|
|
|
|
|
|
Simon1 wrote: I am programming in c++ and need to ask the user information.
Does somebody has a solution for this problem?
Your question is a bit vague. If you need to prompt the user for information, you can do so regardless of their credentials. If I've misunderstood you, please elaborate.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
I am using the ID3LIB and sucsesfuly writing all of the TAG except for the image. I had this working, but I must have messed something up and have spent ages trying to see the bug, but can't. Any help would be much apreciated...
<br />
ID3_Tag myTag("test.mp3");<br />
myTag.Clear();<br />
ID3_Frame* myFrame;<br />
myTag.AddFrame(ID3FID_PICTURE);<br />
myFrame = myTag.Find(ID3FID_PICTURE);<br />
if (NULL != myFrame)<br />
{<br />
ID3_Field* myField;<br />
myField = myFrame->GetField(ID3FN_MIMETYPE);<br />
if (NULL != myField)<br />
{<br />
myField->Set("image/jpeg");<br />
}<br />
myField = myFrame->GetField(ID3FN_PICTURETYPE);<br />
if (NULL != myField)<br />
{<br />
myField->Set(ID3PT_COVERFRONT);<br />
}<br />
myField = myFrame->GetField(ID3FN_DATA);<br />
if (NULL != myField)<br />
{<br />
myField->FromFile("cover.jpg");<br />
}<br />
}<br />
myTag.Update();<br />
An Expert is somone who has previously made ALL the Mistakes, I dream of this day. - Lucky
www.mpic3.com - My PIC based MP3 player project
|
|
|
|
|
Hi,
I have the following code, which is adding an OLE object to a word document, linking the OLE file to the document so that the document can be moved to another machine without the linked file, and the linked file can still be seen/activated.
When the code executes on a machine with Office XP, the code functions as desired and the resulting .doc file is ~1.5mb (expected). However, when the code is executed on a machine with Office 2007, the code returns no error, but the resulting file is much smaller (~20kb), and when I double click the OLE object to activate it (having removed the linked object to test it's linked correctly), nothing happens. When I right click on the OLE object and select 'Object', I get a message saying "The object is corrupt or is no longer available". It's as though the LinkToFile = true has been ignored by Word 2007 - is that the case? Or is there a problem with my code?
MicrosoftWord :: _Application lApp;
if (!lApp.CreateDispatch(_T("Word.Application")))
{
AfxMessageBox(_T("sorry old chap, winword's not playing ball"));
return;
}
COleVariant lTrue((short) TRUE);
COleVariant lFalse((short) FALSE);
COleVariant lMissing((long) DISP_E_PARAMNOTFOUND, VT_ERROR);
MicrosoftWord :: Documents lDocsMgr(lApp.GetDocuments());
MicrosoftWord :: _Document lDoc;
lDoc.AttachDispatch(lDocsMgr.Add(lMissing, lFalse));
MicrosoftWord :: Selection lContent(lApp.GetSelection());
CString aFileName = _T("c:\\temp\\my.avi");
MicrosoftWord :: InlineShapes lShapeCollection(lContent.GetInlineShapes());
lShapeCollection.AddOLEObject(lMissing, COleVariant(aFileName), lTrue, lFalse, lMissing, lMissing, lMissing, lMissing);
lDoc.SaveAs(COleVariant(_T("c:\\temp\\abc.doc")), lMissing, lMissing, lMissing, lMissing, lMissing, lMissing, lMissing, lMissing, lMissing, lMissing);
lDoc.Close(lMissing, lMissing, lMissing);
lApp.Quit(lMissing, lMissing, lMissing);
Many thanks,
- Dylan
- Dy
|
|
|
|
|
prerequiste information:
VC++ windows application (Dialog based)
On dialog, List control is added. I have embedded edit control in List control.
A Cancel button on dialog.
Problem:
When cursor (focus) is on edit control (that is in list control), if i click Cancel button, the event is not handled unless i click it again. I mean, i need to click Cancel button again to cancel the dialog.
In code, When i click Cancel button, only (user defined) OnLostFocus() function of edit control is called.
|
|
|
|
|
With thanks to earlier help, I now know how to read and write JPG and GIF and some other graphics files; there is an example on http://msdn2.microsoft.com/en-us/library/ms533844.aspx .
But, behind the class function calls Image:Image(WCHAR* filename) and Image:Save(WCHAR*filename,...), please what are the names of the basic bottom-level Windows functions that read and write graphics files without going though classes?
|
|
|
|
|
There isn't Win32 API to do that stuff.
You have to use either GDI+ (hence classes) or third party (free?) libraries.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Does Visual C++ 2008 (either the free download or the paid-for version) have an option to run in the old form with the Windows functions expecting old-type 8-bit character arrays?
For example, I get the impression that the old MessageBox() function with char* arguments, may still exist, but that there is also a new library routine MessageBoxW() with WCHAR* arguments, and then #define MessageBox MessageBoxW somewhere in the library blocks access to the old MessageBox() function; and similarly with many other Windows functions.
I know that this is to handle 16-bit Unicode characters; but my current program is a graphics program, and I am not interested in handling Devanagari or Arabic or Chinese etc characters and I am content with the old ascii set; and going through a biggish program adapting for so many Windows function calls being masked by new forms which need WCHAR* instead of char* arguments, is getting to be a total nightmare, and the more I have to change, the more risk is of mistakes getting in.
|
|
|
|
|
In VS2005 and up, projects default to Unicode. Change the project setting for Character Set to Not Set (this is what they're called in 2005) and you'll be back to ANSI.
Judy
|
|
|
|
|
Thanks. In Visual C++ 2008 mouse the menu Project -> (prog_name) Property Pages -> Configuration Properties -> General, and Character Set is 3rd from the bottom in the list of properties inside the box.
|
|
|
|
|
Anthony Appleyard wrote: Does Visual C++ 2008 (either the free download or the paid-for version) have an option to run in the old form with the Windows functions expecting old-type 8-bit character arrays?
By default Visual Studio 2008 generates UNICODE builds, but you can disable it:
Select Project Properties menu item then (in the appeared window), select Configuration Properties->General node and change the Character Set option.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Your impression is right.
All the 'old' functions have an A at the end (ANSI char).
All the 'new' functions have a W at the end (wide char).
e.g. MessageBoxA() (defined in winuser.h)
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
I would like to remote debug a dll that I made as a plig-in of a 3rd party application. I have set up the VS2005 debugger so that I can see processes from the remote computer, but I only see .exe, and not my dll. And choosing the exe that uses my dll does not help.
Any idea ?
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
Do not feed the troll ! - Common proverb
|
|
|
|
|
Hallo ,
i want to code an SDI-ExplorerStyle application.
Are there tuts, code snippets or samples on how to fill the tree (as in the orig. Explorer) and how to show the Datas in the ListView out there ?
I really searched for it, but the only things i found are treectrls on dlgs !!!
Many, many thx for your Help
best regards
Croc
|
|
|
|
|
CrocodileBuck wrote: samples on how to fill the tree
CrocodileBuck wrote: but the only things i found are treectrls on dlgs
For filling the tree control it doesn't matter how it is hosted in the application because a tree control is a tree control, period. The same is true for ListViews and yes I don't remember there being a shortage of ListView and TreeView samples and articles on the internet. Mainly here on CodeProject and on MSDN.
|
|
|
|
|
Thx Led Mike for qour quick answer !
No Tuts or samples ;(( !
I will try it anyway
Best regards
Croc
|
|
|
|
|
CrocodileBuck wrote: No Tuts or samples
What? There are loads of them both here in CodeProject Articles and on MSDN.
For the articles on CodeProject in the left column under "Chapters" click "Desktop Development". In that list you will see both List Controls and Tree Controls.
|
|
|
|
|
FWIW - when the new MFC classes are released in the next month or two,
there's new controls for both the tree and the list in the shell (Windows)
explorer.
You can roll your own, of course
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
What are you doing in my thread!
Merry Christmas Mark
|
|
|
|
|
|
How to insert a hotkey (Eg. Ctrl+U)in a menu item (through code) in vc++.
|
|
|
|
|