|
I have a project on InstallShield 12. The project includes standard redistributable module Visual C++ 8.0 ATL (x86) WinSXS MSM (Microsoft_VC80_ATL_x86.msm) – it contains file ATL80.dll and others.
I have seen the following problem: uninstallation of my project works too slow – up to 10 minutes. This is uninstallation of the “Visual C++ 8.0 ATL (x86) WinSXS MSM” who takes all the time (custom action SxsUninstallCA).
I tried to use the following solution to avoid such long uninstallation – I have added flag msidbComponentAttributesPermanent into Attributes column of Component Table of the Microsoft_VC80_ATL_x86.msm. But this did not help – its uninstallation happens anyway.
What else I can do?
|
|
|
|
|
Hello,
I would like to ask, if it is possible to create a new object of some type when i only have the object type_info.
I need to have a map that stores a pair<int,some class="" info=""> and than a function that returns new object (all the objects are derived from one base class) according to the the id in the map.
map<int,type_info> myMap;
base_class* GetObject(int id)
{
map<int,type_info>::iterator iter = myMap.find(id);
if( iter != myMap.end() )
{
return new object according to iter.second
}
}
I know I could just check for the id and return the object of specific type, but the problem is that i don't know yet what types of object will be stored. That would mean that every time I create a new class I should add it manually in this code.
So if there any way to create a new object from some information such as type_info?
Thank you for your help.
|
|
|
|
|
Tomas(cz) wrote: if it is possible to create a new object of some type when i only have the object type_info
No, don't think so.
Tomas(cz) wrote: I need to have a map that stores a pair and than a function that returns new object (all the objects are derived from one base class) according to the the id in the map.
You could store function pointers in the map:
#include <map>
#include <iostream>
#include <typeinfo>
struct base_class { virtual int GetID() = 0; };
struct A : public base_class { int GetID() { return 1; } };
struct B : public base_class { int GetID() { return 2; } };
typedef base_class* BasePtr;
typedef std::map<int, BasePtr (*)()> ObjectCreationMap;
template<class ObjectType>
base_class* CreateObject() { return new ObjectType(); }
base_class* GetObject(int id)
{
static ObjectCreationMap myMap;
if (myMap.empty())
{
#define INSERT(ID, TYPE) myMap.insert(std::make_pair(ID, &CreateObject<TYPE>));
INSERT(1, A)
INSERT(2, B)
#undef INSERT
}
ObjectCreationMap::iterator iter = myMap.find(id);
if( iter != myMap.end() )
{
return iter->second();
}
}
int main()
{
BasePtr x = GetObject(1);
std::cout << x->GetID() << " " << typeid(*x).name() << std::endl;
x = GetObject(2);
std::cout << x->GetID() << " " << typeid(*x).name() << std::endl;
}
Compiles, links and runs correctly with g++ 4.0.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thank you for your reply, I tried to implement it to my code, but I am probably missing something.
Here is a piece of my code:
class SerializationMap
{
public:
typedef Base_Object* objectPtr;
static std::map <int,objectPtr (*)()> map;
};
template<class OBJECT_TYPE>;
Base_Object* CreateObject()
{
return new OBJECT_TYPE();
}
#define REGISTER_CLASS(ID,TYPE) SerializationMap::map.insert(std::make_pair(ID, &CreateObject<TYPE>));
base_object class
#include "SerializationMap.h"
class Base_Object
{
public:
REGISTER_CLASS(1,Base_Object)
Base_Object(void);
~Base_Object(void);
Base_Object(const Base_Object& obj);
void operator =(const Base_Object& obj);
int archive_version;
private:
int serializationClassId;
};
but when I try to compile I get these errors:
error C2143: syntax error: missing ';' before '.'
error C2238: unexpected token(s) preceding ';'
error C2602: 'SerializationMap::map' is not a member of a base class of 'Base_Object'
error C3210: 'SerializationMap' : access declaration can only be applied to a base class member.
What am I doing wrong?
Thanks
|
|
|
|
|
Tomas(cz) wrote: // don't know why it doesn't show <> - it is declared the same way like in the previous post
When you paste code in, make sure the 'Encode HTML tags when pasting' checkbox is ticked - otherwise, it sees angle brackets as an HTML tag.
Tomas(cz) wrote: template;
That's wrong - should be template<class OBJECT_TYPE> I think.
Tomas(cz) wrote: REGISTER_CLASS(1,Base_Object)
You can't put functional code into a class definition like that - has to be in a function body. Try putting it into the class constructor?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Yes you can!
But, it is not simple to do this in a general way. Microsoft tried to do this and ended up with the COM (Common Object Module) architecture. The general idea in that was to generate Globally Unique Identifiers (GUID's)which were (are) essentially 128 bit Numbers stored in your record of the object, and, associate those numbers with DLL's classes and Methods,( via the registry)to call constructors, methods, and destructors. It is this mechanism that allows you to paste a few spreadsheet cells into a Word Document etc.
Bram van Kampen
|
|
|
|
|
Hi Sakthi here....
Could any one tell me the steps :
How to save a bitmap in Visual C++ (mfc)..
|
|
|
|
|
The steps....
The good way is to learn how to load them first, reading all about BITMAPINFOHEADER. The information starts from there.
That's if you want a learning experience, and wish to become a better programmer.
Once you've done that, the lazy (and still good) way is to read articles like: CxImage[^] here on codeproject, in the graphics section.
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
HBITMAP hBmp;
CBitmap bmp;
CBitmap *pOldbmp;
BITMAP bi;
CDC bmDC;
hBmp = (HBITMAP)::LoadImage(NULL,"E:\\Deharadun.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
if(hBmp==NULL)
MessageBox("Bitmap Failed");
bmp.Attach(hBmp);
CClientDC dc(this);
bmDC.CreateCompatibleDC(&dc);
pOldbmp = bmDC.SelectObject(&bmp);
bmp.GetBitmap(&bi);
dc.BitBlt(0,0,bi.bmWidth,bi.bmHeight,&bmDC,0,0,SRCCOPY);
bmDC.SelectObject(pOldbmp);
copy same code u can open bitmap file to save bitmap file u have to look for same function as shoown in baove code
|
|
|
|
|
Hi,
May i know how can i reduce the height of CREct....ie rect should be just around the text inside the rect...
|
|
|
|
|
if you pass the outer rectangle to DrawText() function with the DT_CALCRECT flag specified, that function will modify the rectangle and returns you the correct bounding rectangle of the input text.
|
|
|
|
|
GetClientRect(clientRect);
DrawText(_T"testing"), clientRect, DT_SINGLELINE|DT_CALCRECT| DT_END_ELLIPSIS);
when i use the above code the text inside rect became invisible and when i remove the
DT_CALCRECT then it worked fine....
|
|
|
|
|
Try reading the documentation for DrawText / DT_CALCRECT a bit more carefully.
With this flag, you are asking the function to calculate the rectangle it would have used, not to draw the text.
If this was not the case, then you could not do the calculation without leaving graffiti all over the place.
You are allowed to call this function twice, once to calculate your rectangle, and once to actually draw. It is not rationed. Quite a few windows functions work in this way - once to get how bit a chunk of memory you need, and then to use that memory, and so on.
Good luck,
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
we got a pre-written C project and there's a need to make a small addition.
we would like to open a text document (not necessarily ms word) add an image (a company logo) to each document and
add some statistical text after the image.
at the end there will be several documents which have a logo at the beginning and some data.
programmer does not want to deal with COM and OLE since he has C code. Is there an easy way to solve this problem with C?
Thanks.
aysan ethem narman
|
|
|
|
|
alashara wrote: not necessarily ms word
I'll take "not necessarily" as "not".
There is no way to add a logo to any document...
A text file is a document, and notepad can't show pictures.
I could have made a .iain document type, for loading in IainWrite(tm) - you wouldn't have a clue how to add a logo to it without knowing the file format.
So, the answer to your question really depends on what the doc format is.
If it's word, then you're probably stuck telling your programmer to learn COM. You can put screws in with a hammer, but it's not efficient.
Speaking of efficiency... why are *you* asking this question, rather than the programmer?
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
With "not necessarily" I meant it can be some other document types like (open office word etc) which can be converted to ms word later.
I know that we can not add logo to any document and txt files can not show images. And the doc in the subject title was
actually .doc extension which is ms word 97-2003 file (my mistake).
So I am repeating the question in a different way. There is a need to add an image (jpg,gif or sth else) to a document (which can be converted to .doc file in an easy way) and add some text after the image in C. Is this possible?
As I understood he was working with .txt files before and just adding some text data into them. But then they decided to add the company logo to these documents.
>Speaking of efficiency... why are *you* asking this question, rather than the programmer?
I am sure he would if he could.
aysan ethem narman
|
|
|
|
|
alashara wrote: >Speaking of efficiency... why are *you* asking this question, rather than the programmer?
I am sure he would if he could.
???
Interesting Remark!
Why Could he not? do you have him imprisoned, or can he not type on a computer. In case of the latter, I know a few programmers like that too, but I tend to steer clear of those when looking for people to code!
Bram van Kampen
|
|
|
|
|
Yes it is possible in C.
He will have to insert in your text file some RTF tags and (as text) the binary data of your logo (see http://www.snake.net/software/RTF/RTF-Spec-1.7.pdf[^] page 90) , and save the file as .rtf which can be read by MS-Office, OpenOffice, Windows WordPad and many other.
However I would not recommand such costly approach
cheers,
AR
|
|
|
|
|
|
i want to convert a char * to LPWSTR can any body help me out
const char *lpszPSTPath="C:\\rahul";
SPropValue PropVal;
PropVal.Value.lpszW =(LPWSTR)lpszPSTPath;
I tried with above type cast but iam getting square brackets...any help
|
|
|
|
|
You can use MultiByteToWideChar() function to convert a char* to wchar*.
However in the above case, you can directly assign the string to PropVal.Value.lpszW by adding a "L" before the string. like
SPropValue PropVal;<br />
PropVal.Value.lpszW = L"C:\\rahul";
|
|
|
|
|
you can also try mbstowcs api
|
|
|
|
|
i have to list control in a mfc dialog application.
first one is ipList. i want to search an item in the list.
int i = 0;
TCHAR ss[50] = {0};
ipAdd.GetAddress(m_M1, m_M2, m_M3, m_M4);
_stprintf_s(ss, _T("%d : %d : %d : %d"), m_M1, m_M2, m_M3, m_M4);
for(int j=0; j < ipList.GetItemCount(); j++)
{
if(ipList.GetItem(j) != ss)
i=0;
else
i = 1;
}
it gives the error ---
error C2664: 'CListCtrl::GetItem' : cannot convert parameter 1 from 'int' to 'LVITEMW *'
what i should do now ?
btw thanks
|
|
|
|
|
Hi,
GetItem has the declaration like this:BOOL GetItem(LVITEM* pItem) const;
So it can't accept a int type parameter. besides, it return a BOOL value;
I think you must misunderstand the function.
|
|
|
|
|
thanks for the reply.
please tell me how to search an item in list control.
|
|
|
|