|
Thanks John
The Rotate function goes off and calls SetWorldTransform which needs to be called before the metafile is played. I'd started to look at pallets and it looks like it's possible to get hold of pallet info for a metafile but I couldn't find any easy way to reset the data to give new colours. I'll have a look at the CodeProject stuff today
___________________________
Jeremy Preston
|
|
|
|
|
Hi @ all.
I have an biiig problem! I want to convert a PDF file to a simple txt file.
Does anybody know how it works? Maybe you can help me.
best regards
J.J.
|
|
|
|
|
An entertaining possibility is this and there are various tools about to do it at some cost. Or you could try the free tools available here. Google for 'pdf text' for many options.
Bear in mind that if the coding of the PDF is for an embedded font then you may be into some low level hacking to get any text out at all. In that case it may be fastest to print it, scan it and OCR it....
Paul
|
|
|
|
|
Hi,
I´m trying to add an new button to my outlook application.
I´m doing this:
_Explorer exp;
_OutlookBarGroups obgs;
exp = app.ActiveExplorer();
obgs = exp.GetCommandBars();
obgs.Add("MyButton",COleVariant((short)1));
But for the last command I´m getting an error.
Can someone help me ?
Maybe there´s another way to do this ?
Please send help !
JohnX
|
|
|
|
|
Anonymous wrote:
But for the last command I´m getting an error.
And that error would be what?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Hi i wonder if anybody can answer this (simple?) question, i have a buffer returned from a library call declared as:
const UCHAR* pkt_data
and i want to fill a CString object from a certain postion from that buffer, say 14 charachers in, I have looked at all the CString articles here and for the life of me cannot figure out how to do it. Can anybody be so kind as to post a code snippet?
Cheers
Andy
|
|
|
|
|
I'm assuming the data returned is standard text, you can do something like:
CString strMyString = reinterpret_cast<const char*="">(&pkt_data[14]);
|
|
|
|
|
CString str;
int iOffset=2;
str = _T(pkt_data+iOffset);
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
How about:
CString str;
strcpy(str.GetBuffer(###), ...);
str.ReleaseBuffer(); You might also be able to use CString 's assignment operator, but I've not tried it so I can't say for sure.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
The type UCHAR* and the name pkt_data sugest this is probubly a pointer to binary data, in which case you should be using a CByteArray.
If you know the data you wish to copy has no bytes equal to zero and you still want to copy it to a CString then the sipilest way is as follows:
CString str;
for( int i=0; i<14; ++i )
{
str += (char)pkt_data[i];
}
INTP
|
|
|
|
|
When I run my program I get an error message box saying:
An invalid argument was encountered.
I tracked the error down to the following function in CWinApp:
ProcessShellCommand(cmdInfo)
Does anyone know why this is happening
Thanks
|
|
|
|
|
What arguments are being passed to your application? Have you looked at the data members of the cmdInfo object?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
The thing is I don't know what it is/ what it does as visual c++ writes it for you.
Thanks
|
|
|
|
|
Just set a breakpoint on the call to ProcessShellCommand() . At that point, examine the app's m_lpCmdLine member, and cmdInfo 's members.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
This response has nothing to do with this thread except that I found this thread when searching for the cause of this error message. In my case, I had serialized a CStringArray object to a file using a CArchive. Somehow the file became corrupted, overwritten/filled with zeros, when my machine was shut down. When I restarted my machine and my application attempted to load this file, I got the "An invalid argument was encountered" message box. The solution was to use some easily testable numeric values that had already been written in the file prior to the CStringArray as a means to determine if the file was corrupt. At that point my logic treats a corrupt file in the same manner as a non-existent one and simply re-creates it. I've posted this here in the hope my experience might help someone else.
|
|
|
|
|
I have a thread that listens the serial port in a while(1) loop. I am using PCOmm library for serial port access. When I run the program I see CPU Usage is %100. I think I should create a new event handler. But I don't know where to start from. What should I search about? I could not find anything on the web. Thanks in advance.
|
|
|
|
|
I am not familiar with the PComm library. User defined events can be created using the ::CreateEvent() Windows API. Check the documentation on the other Synchronization functions as well.
Again I apologize for my unfamiliarity with PComm, but the ::WaitCommEvent() API can be used when opening Serial ports with the ::OpenFile() API. Hope this gives you somewhere to start.
Happy Hunting...
|
|
|
|
|
Hi
My system has an employee hierarchy with CEmployee at the top. I have several child classes - CSalesman, CStaff, CWorkers.
I can use polymorphism to calculate for example salaries so I have array of CEmployee pointers. I can call the calcSalary() function on these pointers and the right function for the child class gets called. One of my employee types has a member function getCommission(). Using my array of base class pointers, I want to call this function on all the CSalesman objects and not the others. I also want to ennumerate each type so I can find how many CWorkers I have for instance.
Can someone suggest a best practice for this?
Thanks
|
|
|
|
|
Add a mamber variable in your base class: it will be an ID that will identify the object type. Something like this:
class CBaseClass<br />
{<br />
.....<br />
....<br />
....<br />
<br />
private:<br />
int m_ClassID;<br />
enum<br />
{<br />
Worker,<br />
Salesman,<br />
Staff<br />
};<br />
}
In the constructor of all your child classes, initalize this ID with the correct value.
CWorker::CWorker()<br />
{<br />
m_ClassID = CBaseClass::Worker;<br />
}<br />
You can add a function to get this Id and so, using a pointer to CBaseClass, you can know the type of Employee it is.
Hope this helps.
|
|
|
|
|
That would work, but it means that you couldn't then add derived classes without having to change your base class.
An alternative is to use the IsKindOf() member function of CObject , which means of course, that you would have to derive your base class from CObject , but that may add useful features such as serialisation and dynamic creation.
More here:
MSDN - Accessing run-time info[^]
"Oh, I'm sick of doing Japanese stuff! In jail we had to be in this dumb kabuki play about the 47 Ronin, and I wanted to be Oshi, but they made me Ori!"
|
|
|
|
|
Yes, you just have to add new enum types for each new child class you want to create.. But what is the problem ? You have to recompile your project in both cases. The only difference is that in this case all the child classes will be recompiled...
Can you explain a little bit more here ? Thanks
|
|
|
|
|
Yes, every time you add a new derived class using your suggestion you have to make a change to the base class. I'd respectfully suggest that this isn't "best practice", as it breaks the concept of encapsulation and effectively prevents the use of late/dynamic binding. However, in the context of a single project, your method would work, which is why I suggested mine as an alternative and not a correction
"Oh, I'm sick of doing Japanese stuff! In jail we had to be in this dumb kabuki play about the 47 Ronin, and I wanted to be Oshi, but they made me Ori!"
|
|
|
|
|
also, have a look at RTTI ( runtime type information ).
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
It depends on how you think. Some people like RTTI, some people like home grown (enums and typecodes), other people don't use it at all. To prevent casting, and to get the cleanest possible OO design use the 'Visitor' pattern from the gang of four book.
The general idea is you use double-dispatch to sort out the type information
#include <iostream>
#include <vector>
using namespace std;
class Visitor;
class CEmployee
{
public:
virtual void accept(Visitor& v);
virtual void foo()
{
cout << "employee" << endl;
}
};
class CSalesman : public CEmployee
{
public:
virtual void accept(Visitor& v);
virtual void getCommision()
{
cout << "commision" << endl;
}
virtual void foo()
{
cout << "salesman" << endl;
}
};
class CStaff : public CEmployee
{
public:
virtual void accept(Visitor& v);
virtual void foo()
{
cout << "staff" << endl;
}
};
class Visitor
{
public:
virtual void visit(CEmployee* pA) = 0;
virtual void visit(CSalesman* pB) = 0;
virtual void visit(CStaff* pC) = 0;
};
void CEmployee::accept(Visitor& v)
{
v.visit(this);
}
void CStaff::accept(Visitor& v)
{
v.visit(this);
}
void CSalesman::accept(Visitor& v)
{
v.visit(this);
}
class CommisionVis : public Visitor
{
public:
virtual void visit(CEmployee* pEmp)
{
}
virtual void visit(CSalesman* pEmp)
{
pEmp->getCommision();
}
virtual void visit(CStaff* pEmp)
{
}
};
int main()
{
std::vector<CEmployee*> empList;
empList.push_back(new CEmployee());
empList.push_back(new CSalesman());
empList.push_back(new CStaff());
for(size_t i = 0; i < empList.size(); i++)
{
empList.at(i)->foo();
}
cout << "**************************" << endl;
CommisionVis vis;
for(size_t i = 0; i < empList.size(); i++)
{
empList.at(i)->accept(vis);
}
}
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|