|
Okay. Thanks.
I understand the concept more and why I my design will not work.
I want to create random objects that derive from other objects, but I do not know what.
Object -> A or B or C
A -> D or E or F
B -> G or H or I
C -> J or K or L
Basically, I am implementing an object, but I do not know what classes it and its ancestors are derived from.
Kuphryn
|
|
|
|
|
?? Pardon? I really do not get your point. If you explain it with some pseudocode or something maybe I can try to be of help (the thing seems promising, though ).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I will try a quick example.
-----
- Generate a random number
1 = object 1A
2 = object 2A
...
Given: object xA derives from xB
- Generate a random number
1 = object 1B
2 = object 2B
...
..
..
- Use an object factory to create the object based on the results of the random number.
-----
In general, I am trying to stay away from implement many lines of switch and if/else statements in order to create a single object.
Kuphryn
|
|
|
|
|
Well, you'd have to write some sort of class factory, as you point out. Here's a sketch of what could be done:
class A
{
typedef A* (creator *)();
typedef map<int,creator> creators_map;
static creators_map m;
protected:
static void register(int n,creator c)
{
m[n]=c;
}
public:
A* create(int n)
{
creators_map::iterator it=m.find(n);
if(it==m.end())return 0;
return it->second();
}
};
class A1: public A
{
static A* create(){return new A1;}
public:
static void register()
{
A::register(1,create);
}
...
};
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
i'm trying to cut some size off a DLL. i removed 3000+ lines of code and saved a total of 4K. if i remove a few hundred lines of code using std::vector, i save 50K.
so, i'm wondering if there's anything else out there that acts like a dynamic array but without the horrible overhead of std::vector? i don't use any of the algorithm stuff on the vectors, no sorting, no foreach, i rarely even use an iterator (usually just .at, .push_back, .size and .clear).
i could write my own, but i don't want to.
no MFC, please.
-c
A conclusion is simply the place where someone got tired of thinking.
|
|
|
|
|
Alexandrescu provides something of the sort in his article Generic<Programming>: Typed Buffers (I)[^]. Haven't used it myself, so I don't really know if it can be of help.
Besides, are you exporting (through declspec ) the vector ? This could be the cause of the code bloat you're experiencing.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Nope, i don't export them. they are all internal.
thanks for the link.
-c
A conclusion is simply the place where someone got tired of thinking.
|
|
|
|
|
you mean you didn't ever write your own Array class?
n/p with the universal balance, though. I got three of them
skulls don't kiss for an explanation - wait for the vacation photos! [sighist]
|
|
|
|
|
i did write my own array class, and i even posted it here. but i'm looking for something slightly different and am a little short on time.
-c
A conclusion is simply the place where someone got tired of thinking.
|
|
|
|
|
CAtlArray in VC7 is very good. I used it in my no-STL tests and it saved tons of memory.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hi,
I have developed an application where I want to chk whether a dialog instance is alredy open or not if its already there I dont want to initiate new instance if not then only it should open new dialog instance how can I chk this...please somebody help me.
Thanks
Prateeti
|
|
|
|
|
there are 2 menus in MDI mfc app, one is for main-frame, another one for child-window.
if no child window opened, the menu used is main-fram menu, otherwise is child-window menu.
GetMenu() only gets current menu. I want to get these 2 menus in one function - or at same time (child-window may be opened or not while the function is called), how to do that?
thx.
includeh10
|
|
|
|
|
I don't understand what you want to do ? you want to always see the menu visible when a "child window" is openned ?
|
|
|
|
|
I am trying to set the cleint window background color from a menu selection. I am looking for the member fuctions needed to set the color from my menu
|
|
|
|
|
You will have to do the drawing yourself. The easiest way is probably to store the color in a COLORREF variable in the window which you want to change the background of. Update this variable with the new color and tell the window to redraw itself. Then intercept the WM_ERASEBKGND message and fill the background using this color value. There is a handy function in CDC that does exactly that -> FillSolidRect( ).
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
I think this is simple enough though the solution seems to be eluding me for almost a day now
i have a standard listctrl with checkbox ,say
m_list.SetExtendedStyle(LVS_EX_CHECKBOXES|LVS_EX_FULLROWSELECT);
what i want is to lock some of the list rows,say row 2
so that the check box value cannot be modified by the user
so i wrote the following in NM_CLICK
{
// TODO: Add your control notification handler code here
NMITEMACTIVATE* pLVCD = reinterpret_cast<NMITEMACTIVATE*>(pNMHDR);
LVITEM rItem;
int nItem = pLVCD->iItem;
ZeroMemory ( &rItem, sizeof(LVITEM) );
LVITEM rItem;
rItem.mask = LVIF_STATE;
rItem.iItem = nItem;
rItem.stateMask = LVIS_SELECTED|ODS_DISABLED;
m_list.GetItem ( &rItem );
if ( nItem ==2)
{
BOOL bSel=m_list.GetCheck(nItem);
m_list.SetItem(nItem,bSel);
m_list.Update(nItem);
}
*pResult = 0;
}
here if a checkbox is unselected and i click it
the control comes to the above code and bSel is FALSE and eventhough i say to update the list row 2 with that itself ...it doesnt work.
the rows check box gets selected invariable
i tried the same in LV_ITEMCHANGED and a couple of others as well...
but to no avail...
please put me out of my misery
what am i doing wrong??
|
|
|
|
|
1) an item does NOT have to be selected for the check to be checked/unchecked.
2) if you want to prevent the check from being checked... or unchecked... or prevent an item from being modified in any other way, just handle LVN_ITEMCHANGING and watch the status of the modified item (which, need i remind you, is not necessarily selected). If the state image changes (item state & LVIS_STATEIMAGEMASK ), then the check has been modified. If you don't agree with the modification, then just return FALSE , and the change will not occur. Otherwise, return TRUE.
Shog9
------
Rather hammer futiley at the locked door than just sit and ignore it. Obviously finding a way to get through the locked door would be even better though. - Paul Watson, My Ignorance
|
|
|
|
|
Its second time
I hope you all've used MSN messenger. The window/GUI of MSN messenger is customizable and there are many custom add-ons present. I mean that we can customize the window of MSN messenger without having the access to the original source code.
I also want to make my window based application that i can customize later without accessing the original source code, just like MSN messenger. Can any one tell me how such applications are created ???
|
|
|
|
|
By exposing an interface, so that the code to *generate* these changes is present, and so is code to parse the add-ons. At least that is what WinAmp does.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
|
Subj (I need properties window like in Explorer).
|
|
|
|
|
I'm not on my Dev machine right now, so you might have to change some of the names of the members of the SHELLEXECUTEINFO struct.
SHELLEXECUTEINFO a_stInfo;
memset( &a_stInfo, 0, sizeof( a_stInfo ) );
a_stInfo.cbSize = sizeof( a_stInfo );
a_stInfo.lpVerb = _T("properties");
a_stInfo.lpFile = _T("C:\\YourFile.ext");
a_stInfo.fMask = SEE_MASK_INVOKEIDLIST;
ShellExecuteEx( &a_stInfo );
Chris Richardson
Programmers find all sorts of ingenious ways to screw ourselves over. - Tim Smith
|
|
|
|
|
I'm supporting multiple platforms and want to make sure that the person who creates our CE installation package doesn't put a DLL for a MIPS device on an ARM device.....yeah I know I shouldn't have to do this, but I found that none of the correct files were on the device after a couple hours of trouble shooting.
Ideally I could read part of the DLL from the device and determine which platform it is supposed to run on.
Ideas??
Thanks,
Paul
|
|
|
|
|
Hi,
I want to change the font of code in my VC++6.0 IDE, but the font I wanted not listed in VC++6.0 IDE, how to realize my dream??????
Thanks a lot
Extreme programming. Do the No.1
|
|
|
|