|
Hi,
For book recommendations, see here[^]. I am assuming that you have working knowledge of Win32 and a good understanding of the object oriented programming paradigm. Those two will help you in learning MFC faster.
Happy learning.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I'm using VS 2008 with the new MFC framework and ribbon UI. I'm working on a hobby project, and am trying to add a combobox to one of the ribbon tab/panels. It appears - and shows the first item of text added, but it is not "enabled". It's light grey as though it's not enabled and clicking does nothing, although when I mouse over the rest of the panel, the panel itself lights up correctly.
bNameValid = strTemp.LoadString(IDS_RIBBON_PORT_SELECT_BOX);
ASSERT(bNameValid);
CMFCRibbonComboBox* pSerialPortSelectBox = new CMFCRibbonComboBox(ID_RIBBON_PORT_SELECT_BOX, TRUE, 80, strTemp, 1);
pSerialPortSelectBox->AddItem(_T("Test"));
pSerialPortSelectBox->AddItem(_T("Test2"));
pSerialPortSelectBox->AddItem(_T("Test3"));
pSerialPortSelectBox->AddItem(_T("Test4"));
pSerialPortSelectBox->SelectItem(1);
pSerialPortSelectBox->EnableDropDownListResize(TRUE);
pPanelSerialConfig->Add(pSerialPortSelectBox);
This shows "Test2" sitting in the box, but the whole thing is greyed out.
Any thoughts?
|
|
|
|
|
You should add a message handler for it.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Thanks, stupid oversight for a HW guy like myself. That did the trick...
|
|
|
|
|
Hi All,
Microsoft XP, 2003 OS comes with default compression utility. Anynody knows the way to configure it with follows parameters
- temp file locations
- time out value
- Vikram S
|
|
|
|
|
vikrams wrote: temp file locations
Probably as defined by the TMP or TEMP environment variable?
vikrams wrote: time out value
What time-out? A compression operation won't time-out. The underlying file access operations might, if they're (for example) network operations, but not the compression operation.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
My TMP env vars points to system32\temp and localsettings\temp
Actually it creates the temp file at the same location of the requested file for compression
|
|
|
|
|
SO, what's the problem? And does it actually have anything to do with C, C++ or MFC?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi I asked this before, but didn't get a clear answer. How can I build an array of CObArray arrays? In other words, I need it to work like a stack, so I can add CObArrays to the stack, and retrieve an Array based on an index?
Thanks
"Failing to prepare is preparing to fail"
|
|
|
|
|
Software2007 wrote: How can I build an array of CObArray arrays?
Even though you asked this same question three minutes ago, have you tried:
CArray<CObArray, CObArray&> arr;
|
|
|
|
|
Isn't this where I would run into Copy assignment problems?
|
|
|
|
|
Doesn't this work:
CObArray my_array;
my_array.Add(new CObArray);
my_array.Add(new CObArray);
...
((CObArray *)my_array.GetAt(0))->Add(...);
... ?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
I think I had something similar which didn't work;
CObArray array1;
CObArray array2;
.....
array2.Add(&array1);
......
CObArray RetrieveArray;
RetrieveArray.Copy( *(CObArray *)array2.GetAt(2));
pre>
|
|
|
|
|
How did it fail?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
For instance,
for(int i=0; i< 3; i++){
if(i==0)
array2.add(&a);
if(i==1)
array2.add(&b)
if(i==2)
array2.add(&c)
}
RetrieveArray.Copy( *(CObArray*)array2.GetAt(0)); RetrieveArray.Copy( *(CObArray*)array2.GetAt(1));
it seems to always come back with the last array no matter what I do! arra2.GetSize() = 3, which is right.
|
|
|
|
|
I did a very simple experiment and it worked fine for me:
CString as("as"), bs("bs"), cs("cs");
CObArray array2, a, b, c;
a.Add((CObject*)&as);
b.Add((CObject*)&bs);
c.Add((CObject*)&cs);
for(int i=0; i< 3; i++)
{
if(i==0)
array2.Add(&a);
if(i==1)
array2.Add(&b);
if(i==2)
array2.Add(&c);
}
CObArray aRetrieveArray, bRetrieveArray, cRetrieveArray;
aRetrieveArray.Copy( *(CObArray*)array2.GetAt(0));
bRetrieveArray.Copy( *(CObArray*)array2.GetAt(1));
cRetrieveArray.Copy( *(CObArray*)array2.GetAt(2));
CString *astr = (CString *)aRetrieveArray.GetAt(0);
CString *bstr = (CString *)bRetrieveArray.GetAt(0);
CString *cstr = (CString *)cRetrieveArray.GetAt(0);
AfxMessageBox((*astr) + _T("\n") + (*bstr) + _T("\n") + (*cstr));
Maybe i am not getting your point.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
I appreciate taking yout time. I am testing your sample code and comparing it to my code to realize the differences. The only thing that stands out is I have data of Type Class objects to fill out the arrays, as opposed to the Strings you put in, but this should be irrelevant.
I will let you know in few.
Thanks
|
|
|
|
|
Ok, I swapped your code a bit to get it more like what I need it to do:
CString as("as"), bs("bs"), cs("cs");
CObArray array2, a, b, c;
for(int i=0; i< 3; i++){
if(i==0){
a.Add((CObject*)&as);
array2.Add(&a);
}
if(i==1){
a.Add((CObject*)&bs);
array2.Add(&a);
}
if(i==2){
a.Add((CObject*)&cs);
array2.Add(&a);
}
}
CObArray aRetrieveArray, bRetrieveArray, cRetrieveArray;
aRetrieveArray.Copy( *(CObArray*)array2.GetAt(0));
bRetrieveArray.Copy( *(CObArray*)array2.GetAt(1));
cRetrieveArray.Copy( *(CObArray*)array2.GetAt(2));
CString *astr = (CString *)aRetrieveArray.GetAt(0);
CString *bstr = (CString *)bRetrieveArray.GetAt(0);
CString *cstr = (CString *)cRetrieveArray.GetAt(0);
AfxMessageBox((*astr) + _T("\n") + (*bstr) + _T("\n") + (*cstr));
What I am trying to say is, When I am doing array2.Add(&a), array a could be different everytime...but When I do the retrieveArray, it comes back with the last array a...in this case aRetrieveArray, bRetrieveArray, bRetrieveArray all = "as"... Not sure what am doing wrong
|
|
|
|
|
Here:
Software2007 wrote: if(i==0){
a.Add((CObject*)&as);
array2.Add(&a);
}
you add as to the array a and then add a to array2, right? So the first item of a is as and the first item of array2 is a.
Now here:
Software2007 wrote: if(i==1){
a.Add((CObject*)&bs);
array2.Add(&a);
}
you add bs to the array a, so the first item of a is as and the seond item of a isbs, then you add a again to array2 so both the first and second item of array2 is a, right?
Here:
Software2007 wrote: if(i==2){
a.Add((CObject*)&cs);
array2.Add(&a);
}
you add cs to the array a, so the first item of a is as, the second item is bs and the third item is now cs. Then you add a again to array2, so now array2 has 3 items and all 3 items is a, right?
When you do this:
Software2007 wrote: aRetrieveArray.Copy( *(CObArray*)array2.GetAt(0));
bRetrieveArray.Copy( *(CObArray*)array2.GetAt(1));
cRetrieveArray.Copy( *(CObArray*)array2.GetAt(2));
you actually copying the array a into aRetrieveArray, bRetrieveArray and cRetrieveArray, since all 3 items of array2 is a. Later here:
Software2007 wrote: CString *astr = (CString *)aRetrieveArray.GetAt(0);
CString *bstr = (CString *)bRetrieveArray.GetAt(0);
CString *cstr = (CString *)cRetrieveArray.GetAt(0);
, since all 3 arrays contain a copy of a you will put the first element of a, which is a pointer to as, into astr, bstr and cstr and then get the string in the message box "as\nas\nas".
Please note that CObjArray contains pointers to objects, not copies of objects, so if you add a pointer to a 3 times to the same array, it will contain 3 pointers to the original a, not 3 copies of a which then live separate lifes.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Thanks of the explanation. But, not sure how I would be growing the same array (a) in this case and copying it over to array2...Or, there any other way to do this, may be some kind of a Stack?
|
|
|
|
|
I'm afraid i don't understand what you actually want to achieve...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
All I want to do is this,
CobArray A = as
CobArray A = bs after an update of some type
CobArray A = cs after another update
I want to create an Array that holds the CobArray A every time it changes, so when I ask for the update that happened at #2 for example, I would get the array A = bs.
I am doing this to take snap shots of an array cuz I want to implement Undo and Redo logic, so I want to keep sanp shots of an array that I have so I can move forwards and backward in the list if you will.
modified on Friday, June 5, 2009 11:25 AM
|
|
|
|
|
You should then copy the original array and place the copy into your "undo-stack" array i guess...there are also smarter ways which are of course harder to implement that hold only the changes and not the whole array...
So to hold a snapshot of your original array you could do something like this (no success checking):
CObArray undo_array;
...
void AddToUndoArray(CObArray &array)
{
CObArray *CopyArray = new CObArray;
CopyArray->Copy(array);
undo_array.Add(CopyArray);
}
...
void GetFromUndoArray(CObArray &array, int index)
{
array.Copy(*undo_array.GetAt(index));
}
...
void DeleteUntoArray()
{
for (int i = 0, maxi = unto_array.GetCount(); i < maxi; i++)
delete undo_array.GetAt(i);
undo_array.RemoveAll();
}
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
I tried your Add method, and it worked like I wanted. I can go from there, I appreciate your help..Very good and insightful.
|
|
|
|
|
Great, i'm glad it worked out.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|