|
Where do I find a full reference (and possible Tutorial) on the Writing of an Installation Script, acceptable to Windows Installer.
Bram van Kampen
|
|
|
|
|
|
Functions exist, MoveTo(x,y) or LineTo(x,y) to draw or move to coordinate points in MFC. Are there also functions to MoveTo or LineTo in 3D? I.E. MoveTo(x,y,z) or LineTo(x,y,z)? Please let me know.
Sid
|
|
|
|
|
Nope, you've to use a 3D library, like, for instance OpenGL or Direct3D .
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi
I found a macro "MAKEINTRESOURCE" to convert resource id to resource name. Is there any way to convert resource name to resource id?
Thanks,
|
|
|
|
|
transoft wrote: MAKEINTRESOURCE
Doesn't really convert anything...IIRC, Windows treats any resource name (i.e. character pointer) with a zero high-order word as an integer rather than a string. That's all.
Basically, a resource can be specified with a name OR an integer id. The only difference (as I said) is whether the high-order word is zero or not.
So conversion of resource name to id is completely meaningless, really.
I suppose something like the code below is the closest you could get
int IsResourceNameInt(LPCTSTR resourceName)
{
return ((int)resourceName&0xffff) == ((int)resourceName)?(int)resourceName:-1;
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hello,
In my application I have buttons over a static control used to display a background image. The problem is when the window needs to be resized, the controls are not drawn simultaneously, so the controls are flickering. For instance the background image is drawn, and only after controls and it's quite annoying, resulting in a sort of flashing app when resizing.
I tried to use SetRedraw(0) and SetRedraw at the beggining and the end of the function but it doesn't work either.
LockWindowUpdate doesn't work too.
Have you got any solution for that ?
Thanks in advance.
|
|
|
|
|
Did you try "CMemDC" class?
|
|
|
|
|
I use a library for the gui that I can't modify, so I can't use CmemDC. (dskinlite)
|
|
|
|
|
Hi Netc. How about making the buttons child controls of your static and give the static control the style WS_CLIPCHILDREN , would that work? For more background see KB79981[^].
/M
|
|
|
|
|
I have my application run with gflags with Pageheap enabled to track down the page heap corruption.
Now the application has crashed and it shows this error, i could not interpret these lines (other than having a feeel of resource inavailablity)
Can anyone throw a light on what exactly is the reason that has caused the carsh of the app.
[info : Application is a multithreaded one about 500 threads running,in a multi - processor machine)
kernel32!RaiseException+53
msvcrt!_CxxThrowException+36
mfc42u!AfxThrowResourceException+19
mfc42u!AfxRegisterWndClass+ab
mfc42u!CAsyncSocket::AttachHandle+5c
mfc42u!CAsyncSocket::Socket+25
mfc42u!CAsyncSocket::Create+14
Pls help
|
|
|
|
|
Elsie wrote: Application is a multithreaded one about 500 threads running
Do not use CSocket, consider using CAsyncSocket if it has to be MFC based. Also see CSocket considered harmful[^] in the Winsock Programmer's FAQ.
/M
|
|
|
|
|
Hi Guys,
This same problem has driven me nuts but finally i fixed it and it is working. This is bug with MFC socket library that when inside a thread [other than main application thread], If we try to do something like
CSocket socket;<br />
socket.Create();
It will throws an unhandled exception. I found an article on it See What Microsoft says about this
that said something from Microsoft but that did not help me either. So here is a workaround i have found and i hope it can help some frustrated fellow like me.
Inside thread, do this
CSocket mySock;<br />
SOCKET sockethandle = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);<br />
mySock.m_hSocket= sockethandle;
After that DO NOT call mySock.Create as it has been created already through assignment of socket handle. I am not sure if we can use mySock.Attach(sockethandle) as i did not try it yet.
After that you can call Connect etc directly.
When you are done using the socket, DO NOT call
<code></code>mySock.Close() - rather call
closesocket(mySock.m_hSocket); And that will free the socket object. If Attach works in above case then i guess we need to do Detach here when to free the socket.
Good Luck
Nauman Khan
|
|
|
|
|
#include<iostream.h>
class abc
{
int a;
public:
abc(){a=5;}
~abc(){}
};
void my_func()
{
abc obj;
}
void main()
{
my_func();
getch();
}
Question: Whenever an object is created, memory will be allocated for the data "int a;".
Will a destructor, with an empty body, deallocate the memory taken for the object when the object goes out of scope??
Is it our job to include the memory deallocation functions inside the destructor body?
|
|
|
|
|
Gjm wrote: Will a destructor, with an empty body, deallocate the memory taken for the object when the object goes out of scope??
Any destructor will call the destructor of any child object when it completes.
It will not (and cannot) deallocate the memory taken by the object. What if the object's on the stack? No deallocation needed!
If you want to automatically handle object memory management, use smart[^] pointers[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
The Destructor Mechanism is an Opportunity for you, the programmer, to do some cleanup when an object falls out of scope. By default, thre Default Destructor does nothing!! (a Misses Opportunity if you did not use it when you needed it!). The Main use of the destructor is to release memory pointers first allocated to class members. (But, you HAVE to write the Code to do thids!) Typical of the way I use this would be, Set the Pointer to NULL in the Constructor, Set it to a Value n a method that Allocates to the member pointer, and use 'free' on All pointers in the Destructors. If the pointer was not used, it would still be NULL. You can free a NULL pointer benignly!
Bram van Kampen
|
|
|
|
|
As has been sortof explained, the destructor is your chance to tidy up. But the memory taken by your object is tidied AFTER the destructor is finished.
That's because your object could have been created with new , or on the stack. Either way, the freeing of memory taken by a is done for you.
main ()
{
abc blah;
;
;
}
main ()
{
abc *pBlah = new abc;
;
;
delete pBlah;
}
So far, there's no point in a destructor. The constructor could at set a to 0.
Where it is useful, is if (eg) a is a pointer. The memory taken by the pointer is auto-freed, but not the memory /object *it* pointed to.
Now, go back to the book!
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/[ ^]
|
|
|
|
|
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/[ ^]
|
|
|
|