|
|
Hi, i would like to know hot to implement an operator to cast a class to void*.
I thought of overloading operator (), but i don't know how to proceed (as i didn't find anything on the web). Any ideas?
thanks!!
|
|
|
|
|
The following example overloads the + operator to add two complex numbers and returns the result.
// operator_overloading.cpp
// compile with: /EHsc
#include <iostream>
using namespace std;
class Complex
{
public:
Complex( double r, double i ) : re(r), im(i) {}
Complex operator+( Complex &other );
void Display( ) { cout << re << ", " << im << endl; }
private:
double re, im;
};
// Operator overloaded using a member function
Complex Complex::operator+( Complex &other )
{
return Complex( re + other.re, im + other.im );
}
int main()
{
Complex a = Complex( 1.2, 3.4 );
Complex b = Complex( 5.6, 7.8 );
Complex c = Complex( 0.0, 0.0 );
c = a + b;
c.Display();
}
|
|
|
|
|
Something like:
class MyClass
{
public:
operator LPVOID() const
{
return ???;
}
};
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
what do you mean with ???
thanks!
|
|
|
|
|
Since you did not tell us anything about your class, I obviously don't know what that method needs to return.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
hi ,
I want to change the toolbar at click of a button .I am new to vc++ and i dont know how to solve this task.Any help would be much appreciated . thanks in advance .
regards,
vinod
|
|
|
|
|
Here is a partial clip for switching toolbars, from "The MFC Answer Book":
UINT nIDFrom = ::GetWindowLong( pBarFrom->GetSafeHwnd(), GWL_ID );
UINT nIDTo = ::GetWindowLong( pBarTo->GetSafeHwnd(), GWL_ID );
::SetWindowLong( pBarFrom->GetSafeHwnd(), GWL_ID, nIDTo );
::SetWindowLong( pBarTo->GetSafeHwnd(), GWL_ID, nIDFrom );
pFrame->ShowControlBar( pBarFrom, FALSE, bDelay );
pFrame->ShowControlBar( pBarTo, bVisible, bDelay );
This example is used to switch between toolbars that only differ in the size of the buttons. It could also be used to switch between a toolbar that contains image buttons and one that uses test buttons instead.
I hope that helps!
INTP
|
|
|
|
|
i use IMsTscAx control to connect to the TS Server.
setting valid server name and so on i finnaly call connect method. he return s_ok. but exploring other property's values i find that startconnected property is false - thats mean that control is not trying to connect. as a sequel connected property is false too.
what do i do wrong?
regards
|
|
|
|
|
Can anyone tell me how to obtain the screen dimensions in an MFC app?
Thanks
|
|
|
|
|
it doesnt seems to be mfc. but its simply call api functions:
GetSystemMetrics(SM_CXSCREEN);
GetSystemMetrics(SM_CYSCREEN);
|
|
|
|
|
|
Get SystemMetrics will do the trick, if you'd like to substract the taskbar of other toolbars => use SystemParametersInfo.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
|
CWnd::GetDesktopWindow()->GetWindowRect (...);
Although this will return the same screen size regardless of the presence of app bars. You probably want the size of the workspace.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
i would like to paste some word text with special characters, őúűöí. my problem is, that they are always converted to simple chars at paste operation, oúuöi.
Is there anyone who can help me out?
Thanks.
Leo.
|
|
|
|
|
Have you used CF_UNICODETEXT as the format when you copied the data into the clipboard?
Jaime
|
|
|
|
|
I paste the text from the MS Word document. The CEdit supports only the CF_TEXT format.
Leo.
|
|
|
|
|
Do somebody know where i can find a word automation example to write a .doc file?
Thanks a lot
tiziacaia
|
|
|
|
|
find your office "compiled help" file. This file has the .chm extension.
Here you can read up about the objects ...
It will not really get you started though.
Search on MSDN and google and idd hope that somebody has a sample code.
good luck.
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
MSDN article Q178749 has an Excel example. Step 9 is the important one as you'll use Word's type library instead of Excel's. Creating an instance of the (Word) _Application object and using its methods will be the same, though.
_Application app;
app.CreateDispatch(_T("Word.Application"));
Documents docs = app.GetDocuments();
CString strFilename(_T("A letter to home.doc"));
_Document doc = docs.Open(COleVariant(strFileName), ...);
...
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thanks a lot for the answers but now i get a new problem:
error C2065: '_Application' : undeclared identifier
I added word's type library, with classes _Application, _Document and Documents. I tryied to import the .h files but don't work.
I don't understand.
Thanks
|
|
|
|
|
tiziacaia wrote:
I tryied to import the .h files but don't work.
You should have include d, not import ed, msword9.h , preferably in the project's stdafx.h file.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I write "import" but i used correctly the "include". I don't have msword9.h but only CApplication.h, CDocuemnts.h and CDocuments0.h
I added the .h files like you say in the stdafx.h but don't work.
|
|
|
|
|
When you added Word's type library, it would have created a .h and a .cpp file and added those to the project. Can you confirm this?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|