|
Why don't you use an existing cross-platform GUI library instead of doing it all yourself. Take a look at wxWidgets[^] for instance, it will save you a lot (but really a lot) of pain...
For your problem, I don't understand why you are passing a DWORD to the function . Read the function documentation: the second argument is a string that is used for the search, so I really don't understand why you pass the DWORD. What did you have in mind, what are you trying to do ?
|
|
|
|
|
yes,wxWidgets is well good,but for us,there are some other problems, so we decided to do it ourselves.
why use DWORD? there are some other causes...
and i think this is not the key of this question now, is it?
thk u again!
|
|
|
|
|
kaviniswell wrote: and i think this is not the key of this question now, is it?
Of course it is. That's the core of your problem: you are using the FindString function in a complete erroneous way because of that. And that is the reason why it crashes. You already got a reply that could fix your problem: pass a string and not a DWORD (and try to avoid casts at all costs, because they let you do wrong things like you just did).
kaviniswell wrote: yes,wxWidgets is well good,but for us,there are some other problems, so we decided to do it ourselves.
I think it was a bad choice. Making cross-platform GUI is something extremly complex. Much more complex than trying to fix a problem you had with it. Why didn't you focus on that instead ?
|
|
|
|
|
yes, maybe u are right.
ok, the codes:
int CComboBox::FindString( int nStartAfter, DWORD dwItemData )
{
CListBox *pcListBox = GetListCtrl();
int nIndex = pcListBox->FindString( nStartAfter, dwItemData );
return nIndex;
}
int CListBox::FindString( int nStartAfter, DWORD dwItemData )
{
int nCount = GetCount();
if ( nCount <= nStartAfter )
return LB_ERR;
int nIndex;
for( nIndex=0; nIndex <= nCount; nIndex++ )
{
if ( GetItemData( nIndex ) == dwItemData )
break;
}
return ( nIndex == nCount ? LB_ERR : nIndex );
}
then what is the problem? i will be crazy now...
|
|
|
|
|
Wait a minute, I have a serious doubt: in fact you are not using MFC at all ? I thought that you were using MFC (because CComboBox is an MFC class with a FindString method).
If that is the case, I think you will have to debug a bit more in details because it will be difficult to help you without more concrete information. Use your debugger and just before the point of the crash, try to inspect all the variables to see if something is wrong or not...
|
|
|
|
|
Hi Cedric,
I still feel that he is using MFC. if not control should go to his implementation of CSkinComboBox::FindString and not the CComboBox. I tried using MFC and passing DWORD i get exactly same stack trace.
Regards,
Sandip.
|
|
|
|
|
Did you write a cross platform GUI library? Congratulations!
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]
|
|
|
|
|
not me but "us", and i just a freshman.
thk u again!
|
|
|
|
|
Well 'you' meant 'your group'.
Since in Italy we distinguish between 'tu' (i.e. 'you' as 'kaviniswell the freshman') and 'voi' , (i.e. you as 'the team wherein kaviniswell is a freshman'), I would say "Congratulations to voi!"
BTW: since your team looks very skilled, why don't you ask them too?
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]
|
|
|
|
|
|
|
i was confused! the skincombobox is used in winOS and actually is a mfc class ...
|
|
|
|
|
Hello I have no problem declaring a CArray variable inside a class definition but as I have a separate file that I place all my typedefs inside it have tried to define a struct that has a CArray member but compiler says:
Error 1 error C2248: 'CObject::CObject' : cannot access private member declared in class 'CObject' c:\program files\microsoft visual studio 8\vc\atlmfc\include\afxtempl.h 272
this was my code inside TypeDefs.H
typedef struct tag_compliance_info
{
LONG lModuleCode;
LONG lModuleVersion;
CString sModuleName;
CArray<POINT> aCompliance; //Oh I forgot this board filters <> signs
} STRUCT_COMPLIANCE_INFO;
How can I solve this?
modified on Friday, October 24, 2008 3:12 AM
|
|
|
|
|
use a Poiner CArray * or another object to substitute the CArray. is it really essential?
Greetings from Germany
|
|
|
|
|
Hi KarstenK ,
You mean there is no way? but why? there should be a reason. what other objects you mean?
Thanks
|
|
|
|
|
You got me wrong.
I think the constructor of the CArray dont like it that way. Do you really need the CArray? What will be in it?
Greetings from Germany
|
|
|
|
|
I'm not sure I still clear but do you mean CArray constructor has written in away that can't be declared in a struct and other objects do not have this problem. I want to store an array of 2 long int so either CArray<LONG,LONG>aMyarray or CArray<POINT>aMyArray Danke
|
|
|
|
|
Some constructors of the CArray aren't public (with good reason).
or try
typedef CArray<long,> CMyArray;
struct
{
CMyArray m_array;
}
Greetings from Germany
|
|
|
|
|
dose not work. I even tried to inherit my struct from CObject but since the problem is accessing private members not protected couldn't solve the problem!
typedef struct tag_compliance_info: CObject
{
LONG lModuleCode;
LONG lModuleVersion;
CString sModuleName;
CArray<POINT> aCompliance;
} STRUCT_COMPLIANCE_INFO;
|
|
|
|
|
why havent you tried it like i posted it you?
And you NEED a Array because the is a lot and different count of points
Greetings from Germany
|
|
|
|
|
KarstenK wrote: why havent you tried it like i posted it you? Unsure
Hello I did but as I said it dose not work.
you typed
ypedef CArray<long,> CMyArray;
struct
{
CMyArray m_array;
}
but I think there are many typos in it so I typed
typedef CArray<POINT> CMyArray;
typedef struct tag_compliance_info
{
LONG lModuleCode;
LONG lModuleVersion;
CString sModuleName;
CMyArray aCompliance;
} STRUCT_COMPLIANCE_INFO;
still I get
Error 1 error C2248: 'CObject::CObject' : cannot access private member declared in class 'CObject' c:\program files\microsoft visual studio 8\vc\atlmfc\include\afxtempl.h 272
KarstenK wrote: And you NEED a Array because the is a lot and different count of pointsConfused
Exactly
|
|
|
|
|
in VS2008 i could compile and link:
typedef CArray<point> CMyArray;
typedef struct tag_compliance_info
{
LONG lModuleCode;
LONG lModuleVersion;
CString sModuleName;
CMyArray aCompliance;
} STRUCT_COMPLIANCE_INFO;
or must use a pointer CMyArray* paCompliance;
Greetings from Germany
|
|
|
|
|
Well I use visual studio 2005
danke anyway
|
|
|
|
|
Hey everybody
I have a weird scenario that requires that 2 header file will include each other, and I'm not sure how should I do that.
I'll explain...
I have 2 Form: mainForm (mainForm.h) and subForm (subForm.h).
The mainForm opens a non-modal subForm -> meaning mainForm must include subForm.h in order to show it.
Now, the subForm, which is non-modal, can change things on the mainForm (for example, a button that displays text on the mainForm), meaning that subForm must have access to mainForms public functions -> in other words, I must include mainForm.h in subForm.
How can I perform something like that in C++ without getting into that problem?!
Thanks!
|
|
|
|
|
Green Fuze wrote: The mainForm opens a non-modal subForm -> meaning mainForm must include subForm.h in order to show it.
You can always use a pointer to the dialog class instead of an instance of the dialog class. This way, you only need to put a forward declaration in your header file.
See here[^] for instance.
|
|
|
|