|
BTW, my kids have spent many hours playing your 'Alchemy' game so thanks for that
|
|
|
|
|
Hi,
I want to make only one file as /clr supported instead of whole project. But if i do the same i'm getting compilation error as -
Command line error D8016: '/ZI' and '/clr' command-line options are incompatible
My intention is to invoke managed API from unmanaged code.
I googled but not good result i found till now.
So kindly guide me how to avoid above error or any substitute Project-setting i need to do .
If possible please suggest(sample code)if any for my requirement.
Thanks
|
|
|
|
|
There is no sample code for your problem. The message is quite clear you cannot mix managed and unmanaged code in the same project this way. You need to split it into two projects, one which is normal unmanaged C++ and one which is managed and uses the /clr option. Calling Managed Code from Unmanaged Code and vice-versa[^] is a CodeProject article that will help you.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Hi Richard,
I got error when i tried as below -
- I created a COM Dll. Then i made it as CLR supported (whole project). But requirement is to make only required file as CLR supported.
It can be possible.
Because i observed,one of our existing COM dll contains only one file as CLR supported. And there is know issue with that COM Dll.
I think there is some project-setting or in code, we need to do for achieving the same.
That i'm trying to find out by comparing my project with that existing COM DLL. Unfortunately i didn't get any new thing till now.
Hence if any area i'm skipping while comparing ,Kindly advice .
Or any other way to achieve the same ,please guide
|
|
|
|
|
You may need to create a mixed mode wrapper dll. Create a new CLR class library. Inside that create a new unmanaged class (without the ref keyword) containing static functions. Expose it to your COM dll with the usual unmanaged __declspec macro declaration. Add a Framework reference to the managed dll you want to use.
Make sure the wrapper cpp file uses clr (should be default for managed dll, but check via right-click on cpp file, Properties, C/C++, General, Common Language Runtime support).
You could try to set the same option for one of the cpp files in your COM dll, if it's built in one of the newer VS versions. But chances are it won't work that way because of the incompatibilities you initially mentioned.
|
|
|
|
|
Hi, this is my first post.
Work flow is like this:
i open child dialog from a dialog( which is launched from a toolbar of a window) after editing i close the child dialog, after closing child dialog shadow is retained on window but not on the parent dialog. Later when i close the parent dialog the child dialog shadow disappears.
(issue exist only when i edit in child dialog)
Thanks a lot,
Shivaraj
|
|
|
|
|
That's because your main window does not receive a WM_PAINT message until the main dialog terminates. Cascading dialogs in this way is not the best design pattern.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Hi, I tried to use GetAncestor() method to get main window handle & REPAINT with RedrawWindow() or UpdateWindow(). Neither of which is working.
|
|
|
|
|
That's because, as I said before, your main window will not be able to action a WM_PAINT , or any other, message, until the dialog returns from DoModal() . You need to consider whether your design is the right way of doing things.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Thanks for reply, I have seen same design patterns(using child dialog)in the same application but there is no issue there. I compared the code, am not finding any difference in RePainting aspects.
here i have sample code..
Below used OnModifyview dialog is child dialog of a dialog.
void CSelectColumnViewDlg::OnModifyview()
{
int iIndex = m_ctrlColumnViewList.GetCurSel();
if (iIndex < 0)
return;
double dViewId = m_ctrlColumnViewList.GetItemDataDouble(iIndex);
if (dViewId == 0.0)
return;
CWaitCursor wait;
CComPtr<idispatch> pDispColumnView;
CComPtr<itrackingdatamanager> pManager;
pManager.CoCreateInstance(CLSID_TrackingDataManager);
if (pManager)
pManager->GetColumnView(dViewId, &pDispColumnView);
CComQIPtr<itrackingcolumnview> pColumnView(pDispColumnView);
if (pColumnView == NULL)
return;
CModifyColumnViewDlg dlg;
dlg.SetColumnView(pColumnView);
dlg.SetType(m_lSolution, m_lListType);
dlg.SetTrackGroupCd(m_dTrackGroupCd);
std::set<cstring>* pExistingNames = GetExistingNames(iIndex);
dlg.SetExistingNames(pExistingNames);
if (dlg.DoModal() == IDOK)
{
HWND hWndAncestor = ::GetAncestor(GetSafeHwnd(), GA_ROOT);
m_ctrlColumnViewList.DeleteString(iIndex);
CComBSTR bstrName;
pColumnView->get_Name(&bstrName);
int iIndex = m_ctrlColumnViewList.AddString(CString(bstrName));
m_ctrlColumnViewList.SetItemDataDouble(iIndex, dViewId);
m_ctrlColumnViewList.SetCurSel(iIndex);
}
if (pExistingNames)
delete pExistingNames;
Invalidate();
//OnPaint(); //not working
//RedrawWindow();// not working
}
modified 7-Oct-12 0:04am.
|
|
|
|
|
I don't know what more I can say except to repeat my earlier comment: as long as you have a dialog open (called via DoModal() ) the main window cannot respond to messages and thus will not repaint itself.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Hi,
I have a C++ application & I know the assembly which contains the managed API. But i unable to access from my un-managed code.
Kindly help me using a simple program.
Please note only .net dll (assemblies)has been provided but not any .tlb file.
So we want, with out using .tlb file we need to invoke .net API.
Thanks
modified 4-Oct-12 10:05am.
|
|
|
|
|
|
Hi Andrew,
Thanks for your suggestion(link) .
Actually i had gone through the same link before you sent. Its a good link but it seems a very lengthy way. That's why i ignored that time.
And i need to add code without disturbing my existing unmanaged & managed code as well.
Like creating '/clr' supported files.
Hence if you have any good suggestion as compared to this ,then kindly let us know.
Thanks
|
|
|
|
|
litu kumar wrote: Hence if you have any good suggestion as compared to this ,then kindly let us
know.
The way described in the article is the only way.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Hi,
I have created a win32 dll. And I know the appropriate .net assembly file which contains the required methods.
I want to access those methods from my DLL.
I came to know , it can possible through C++/CLI interface.
But i'm very new to C++/CLI . So kindly help me to create such interface in C++ which can access those methods using certain assembly/any way.
If have any any sample example (running),then please share me soon. I tried a lot in google , but till now i didn't get any helpful samples .
Thanks in advance
modified 4-Oct-12 9:14am.
|
|
|
|
|
Hi developers,
I am interested to so solve this chunk of code
void main()
{
int Var = 90;
if(Var += Var == ++Var == 89)
printf(" %d ",Var);
}
After executing the code i m getting the answer "91"
I am really surprised with the answer. Infact, I am not clear with operator precedence in this problem. Please give some help for it.
Thanks.
Amrit Agrawal, Mumbai
|
|
|
|
|
The rules are that expressions such as this may lead to incorrect results. You need to split it into constituent parts.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Amrit Agr wrote: Please give some help for it.
Rewrite it so it is more maintainable.
|
|
|
|
|
void main()
{
int Var = 90;
if(Var += (((Var == (++Var)) == 89)))
printf(" %d ",Var);
}
Operator precedence:
1. Increment operator (++)
2. Relational operator (==), and its Associativity is Left to Right
3. Assignment operator (+=)
Hope it helps...
|
|
|
|
|
Hi my professor gave my class this homework to do without giving us any notes or hints on how to do it. Im so lost and dont know where to start. I've put together some of the member function declarations and one constructor but highly doubt if they're correct.
An array can be used to store large integers one digit at a time. For example, the integer 1234 could bestoredinthearrayabysettinga[0]to1,a[1]to2,a[2]to3,anda[3]to4. However,for this project, you might find it more useful to store the digits backward, that is, place the least significant digit 4 in a[0], 3 in a[1], 2 in a[2], and the most significant digit 1 in a[3].
Design, implement, and test a class in which each object is a large integer with each digit stored in a separate element of a character array. You’ll also need a private member variable to keep track of the sign of the integer (perhaps a Boolean variable), and another private member variable to keep the size (or length) of the integer. The number of digits may grow as the program runs, so the class must use a character pointer (dynamic character array) as a member variable, which stores its value on the dynamic memory freestore (heap). You should also implement other appropriate operators for this class. More specifically, your class should provide default constructor, deep-copy copy constructor, overloaded constructor(s), destructor, deep-copy assignment operator, overloaded arithmetic operators, comparison operators, input and output operators. You should also have a nice driver code to test all implemented member functions and overloaded operators.
#include <iostream>
using namespace std;
class BigInteger
{
private:
bool sign;
char * arr;
int size;
public:
BigInteger(int size=0);
BigInteger( const char* arr);
BigInteger( BigInteger& arr);
~BigInteger();
void swap(BigInteger&);
void count( int );
BigInteger& operator=(const BigInteger& arr);
BigInteger& operator+(const BigInteger& arr);
BigInteger& operator-(const BigInteger& arr);
bool operator==(const BigInteger & arr) const;
bool operator!=(const BigInteger & arr) const;
bool operator<(const BigInteger & arr) const;
bool operator>(const BigInteger & arr) const;
bool operator>=(const BigInteger & arr) const;
bool operator<=(const BigInteger & arr) const;
friend ostream& operator<<(ostream & output, const BigInteger& arr);
friend istream& operator>>(istream & input, const BigInteger& arr);
};
int main()
{
}
BigInteger::BigInteger(int size) : arr(){
arr= new char[size+1];
for(int i=0;i<size;i++)
{
arr[i]=' ';
}
arr[ size ] = '\0';
}
BigInteger::BigInteger(const char* arr){
}
any help with this program to even get it started would be very appreciated thank you, i'm not asking for just the answer i actually want to know what i'm doing in my class.
|
|
|
|
|
Msemler93 wrote: i actually want to know what i'm doing in my class. If you don't know then it's a sure bet that we don't.
If you have specific technical questions then people will try to answer them, but no one is going to do your assignment for you. If you really do not understand the assignment then go and talk to your professor, or find some books or online materials to help you.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
You don't need the null at the end
Your constructor looks ok except that you did not take into account that the first byte might be a sign character.
I am not sure why your teacher thinks it would be better to store it backwards.
I suggest you try to create the following method next.
bool operator==(const BigInteger & arr) const;
To code it THINK (don't code) about the following cases
- The number is exactly the same.
- One number is zero, the other isn't.
- One number have more digits than the other.
- AFTER you do the above then consider what happens if the 'sign' value is set to represent a negative value.
AFTER you think about the above then attempt to code the method.
|
|
|
|
|
ok me and my friend have been working on the program and are having trouble getting the arrays to pass to the functions and dont know where the issue is.
#include <iostream>
using namespace std;
class Integer{
public:
Integer();
Integer(Integer& a);
Integer operator +(const Integer &);
Integer operator -(const Integer &);
bool operator<(Integer)const;
void SetArr();
void print();
void addNumbers();
void subNumbers();
private:
bool sign;
int size;
int size2;
int size3;
char * arr1;
char * arr2;
char * arr3;
};
int main()
{
Integer sum,diff, in1,in2;
in1.SetArr();
/*in2.SetArr();
in1.addNumbers();
in1.print();
in1.subNumbers();
in1.print();*/
}
Integer::Integer()
{
size=0;
arr1=NULL;
}
Integer::Integer(Integer& a)
{
a.size=0;
a.arr1=NULL;
}
void Integer::SetArr()
{
cout<<"How many digits is the number?"<<endl;
cin="">>size;
int* arr1=new int[size];
cout<<"Enter the sequence of the "<<size<<" integers"<<endl;=""
="" for(int="" i="(size-1);i">=0;i--)
cin>>arr1[i];
cout<<endl;
for(int="" i="0;i<size;i++)
" cout<<arr1[i];
="" cout<<endl<<"how="" many="" digits="" is="" the="" second="" number?"<<endl;
="" cin="">>size2;
int* arr2=new int[size2];
cout<<"Enter the sequence of the "<<size2<<" integers"<<endl;=""
="" for(int="" i="(size2-1);i">=0;i--)
cin>>arr2[i];
cout<<endl;
for(int="" i="0;i<size2;i++)
" cout<<arr2[i];
="" if(size="">=size2)
size3=size+1;
else
size3=size2+1;
int* arr3=new int[size3];
int carry=0;
for(int i=0;i<size3;i++){
arr3[i]="48+(arr1[i]+arr2[i]-2*48+carry)%10;
" carry="(arr1[i]+arr2[i]-2*48+carry)/10;
" }
="" cout<<endl<<"addition:"<<endl;
="" for(int="" i="(size3-1);i">=0;i--)
cout<<arr3[i];
="" cout<<endl<<endl;
=""
="" for(int="" i="0;i<size3;i++){
" if(arr1[i]="">arr2[i])
arr3[i]=arr1[i]-arr2[i];
else{
arr1[i+1]=(arr1[i+1]-1);
arr1[i]=arr1[i]+10;
arr3[i]=arr1[i]-arr2[i];
}
}
cout<<endl;
for(int="" i="0;i<size3;i++)
" cout<<arr3[i];
="" cout<<endl<<"subtraction:"<<endl;
="">=0;i--)
cout<<arr3[i];
}
void integer::print()
{
="" for(int="" i="0;i<size;i++)
" cout<<arr1[i];
}
void="" integer::addnumbers()
{
="" int="" carry="0;
" arr3[i]="48+(arr1[i]+arr2[i]-2*48+carry)%10;
" }
}
void="" integer::subnumbers()
{
="" if(arr1[i]="">arr2[i])
arr3[i]=arr1[i]-arr2[i];
else{
arr1[i+1]=(arr1[i+1]-1);
arr1[i]=arr1[i]+10;
arr3[i]=arr1[i]-arr2[i];
}
}
}
|
|
|
|
|
Use code tags when you post code.
Focus on the class - not the input/output. For testing you can hard code some values right now.
|
|
|
|