|
I think I understand more clearly now. If you want to instantiate, possibly unknown, classes based on data then It's going to have to be COM or .NET I'm afraid. What you have at the moment is like a mini version of the way COM class factories work. There's an MSDN article in the ether somewhere called "From CPP to COM" which is what cracked COM for me. I'd take a look at that even if you eventually decide to go the .NET route.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
|
|
Hi,
after reading this thread I've maybe found a solution.
I think you could solve it with using templates.
The Base class:
class BaseClass
{
public:
BaseClass() {}
virtual void Show() = 0;
template<class T>
static BaseClass* Create()
{
return dynamic_cast<BaseClass*>(new T());
}
};
The derived class
class DeriveOne : public BaseClass
{
public:
DeriveOne() {}
virtual void Show()
{
std::cout << "DeriveOne.Show" << std::endl;
}
};
Then you could create a object like this
BaseClass* pBase = BaseClass::Create<DeriveOne>();
if(pBase != NULL) pBase->Show();
I don't know if this is what you need.
codito ergo sum
|
|
|
|
|
I'm using matlab 7.0.1 (R14 sp1)
I want to CONVERT my GUI to a stand alone application (.exe file) that dosent need Matlab to run.
I uesed the mcc function but I faild
I uesd this code
mcc -m mygui.m
it creates an .exe file and some other files
when I run the .exe file, a black window appears for seconds then nothing happen
plz I need ur help
-- modified at 15:51 Tuesday 19th June, 2007
|
|
|
|
|
I have a listview control and i would like to change the background colour of it.. How would i implement this in pure C/C++ using the Win32 API?
Thanks for your help!
--PerspX
|
|
|
|
|
BOOL bSystemColor = FALSE;
COLORREF clrNew = RGB(0,0,0);
COLORREF clrOld = (COLORREF)SendMessage(m_hWnd, EM_SETBKGNDCOLOR, bSystemColor, clrNew);
Best Wishes,
-Randor (David Delaune)
|
|
|
|
|
Randor wrote: ...EM_SETBKGNDCOLOR...
Do listview controls respond to messages meant for edit controls?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
heh,
Actually I responded to the question thinking he was asking about a RichEdit control.
|
|
|
|
|
Ignore my previous post, I responded while multi-tasking and forgot the original question.
Try:
SendMessage(hWndList,LVM_SETBKCOLOR,0,(LPARAM)RGB(0,0,0));
Best Wishes,
-Randor (David Delaune)
|
|
|
|
|
How about using the LVM_SETBKCOLOR message (ListView_SetBkColor macro)?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Thanks guys maybe i should have looked at the MSDN documentation more closely..
Thanks for your help!
--PerspX
|
|
|
|
|
|
OK, I've had to learn on the job doing this and that, done some Win32, some MFC, C++ but without a background in proper design and usage, and I'd like to step back and learn properly. The issues I have are that I'm often confused by things that I don't even know are different, like when someone says "VS 2005 complies C++ better than VC++6". My experience of VS6 is that it did everything fine and I got used to where most things are (though I am still not very clued up on it, at least I have the MS book for it - could not find an equivalent for VS2005). I also get mixed up between when I'm using C++, when I'm using STL, when MFC/raw Win32 etc. I've got quite a few books, some unread, and some read but wondered if anyone who was an expert could give a clear path (or a link to sites that would give this info) to step back, find out about what the current C++ standard is, what's changed from what I may know now (and not even realise), generic info about the development environment and Visual Studio in particular (in Vista, still not happy with it!), going on to C++ learning (more formally with more depth of knowledge), good things to do to try and get practice, perhaps online courses or tutorials or workbooks?, then info on the different things like STL, MFC etc, how they fit in with the bare bones, all the way through to developing good quality apps and code. When I read software design articles (eg some of the ones at flounder) I am inspired to be able to do this properly but have fallen into the trap (not my own fault really) of having to learn 'just enough' without understanding it all and fixing things by brute force or by asking for help or digging through the help files/docs (by the way in places the MSDN help from F1 in VC6 is woeful!)
anyway, I hope someone can take a few minutes to help me. I know these kind of questions often get a generic one line answer, and I can understand that to some extent, but I'd really like to get some help with a more structured plan for building a proper skillset up, perhaps some bad habits will be harder to break but on the other side, some concepts won't be so alien to me having done some fiddling
many thanks,
Lee
|
|
|
|
|
I found Easiest way and reliable way to learn . net by this video series
Though I have not purchased but getting free video's and they are quite useful,LearnVisualStudio. NET
|| ART OF LIVING ||
|
|
|
|
|
To answer a few of your questions, you're using STL when you have to use include any of the STL container headers, such as vector, deque, map, queue, etc. I believe you're using MFC if you have to use anything that requires afxwin.h. As for when you're using C++, well, you're either using C, C++, or Managed C++ unless you're doing some kind of crazy interop work. If you use templates or make use of a C++ compiler, then you're using C++, if you have to use any handles, then you're using Managed C++ (^ vs. *).
|
|
|
|
|
ldsdbomber wrote: having done some fiddling
Some people would say that I learned almost everything I know by fiddling. The key is knowing what to fiddle with.
If you want the full works on C++ Mr Stroustrup is your man. It's his baby.
http://www.amazon.com/s?ie=UTF8&keywords=History&rh=n%3A565718%2Ck%3AHistory&page=1[^]
If this is the latest one it's got lots of STL goodness as well. For advanved STL usage and scary template stuff see www.boost.org[^]
For Microsoft technologies like Win32 and MFC then MSDN is really the definitive source.
It took me a few years to get all the technologies separated out in my head and get a grip on what's what. I guess it's pretty normal.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Hi,
I'm trying to solve a problem I have, when I run my program in debug mode is works without a problem, but when I run it in without debug it gives me a Unhandled win32 exception. When I go into the debug from there in the output Unhandled exception at 0x7c911e58 in program.exe: 0xC0000005: Access violation reading location 0x00000000. Any idea of how I can track down what is causing this problem?
Thanks
Simon
|
|
|
|
|
simoncoul wrote: when I run my program in debug mode...
Are you using F5 or Ctrl+F5?
Have you read this article?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi I'm using VS2k5 and using Ctrl+F5, I'm taking a look at those things in the website you gave me but I have no idea where to start looking, like I'm assuming that this is probably a allocationg error right?
Simon
|
|
|
|
|
A debug run tends to give your uninitialized pointers a garbage memory address, so if you check the value of these pointers, be careful.
|
|
|
|
|
Could you explain this a bit more? Like it doesn't make sense taht the error is occuring in the release mode of when I run the debug without debugging, I thought the whole point of bugging was to find errors so they won't be in the final product
thanks again
Simon
|
|
|
|
|
simoncoul wrote: ...the error is occuring in the release mode of when I run the debug without debugging...
This makes no sense. What exactly are you trying to say?
simoncoul wrote: ...I thought the whole point of bugging was to find errors so they won't be in the final product
You thought wrong. "Bugging" is the act of actually putting bugs in the code. Identifying and eradicating those bugs is called "debugging."
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
So...to run an app in the bugger...is that Alt-F5?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
yeah that is fine for now, but when I need to make a final product it will not work.
|
|
|
|