|
This is the second time you have posted this question. There are many details involved in building mixed mode applications. Far more than can be imparted to you in a simple forum reply.
However you are in luck because there are many resources on MSDN web site and here on Code Project in the form of articles and example code on this subject. It also seems you do not yet understand basic constructs like how events work, spend some time on this as well.
I strongly suggest you stop typing messages into forums and start reading and researching the subject.
led mike
|
|
|
|
|
I am at an initial stage of converting a mixed class to make it COM class. (and eventually a complete project)
I googled a bit but have found information only for managed(C#) class.
Typically the mixed class would look like
namespace MyNameSpace
{
public __gc class CPoint
{
public:
CPoint();
~CPoint();
CPoint(float x, float y, float z);
__property void set_X(float x){ m_pPoint->m_x = x; }
__property float get_X() {return m_pPoint->m_x;}
public private:
};
I have to expose this class as a COM class. I need an interface too.
But not sure how to do this. Any link or information will be very helpful.
modified on Monday, May 19, 2008 5:59 AM
|
|
|
|
|
Looks like I have to implement CCW (COM Collable wrapper) for the mixed class.
Any examples or links in this regard wil be great.
|
|
|
|
|
Hai,
I just want to change the color of certain keyword, while typing itself, for that i am using the rtf format. For this which event handler shall i use. if i use textchange event it shows the error as follows.
An unhandled exception of type 'System.StackOverflowException' occurred in System.Windows.Forms.dll
My code is as follows.
private: System::Void lettertyped(System::Object^ sender, System::EventArgs^ e)
{
array<String^>^ keyword = gcnew array<String^>{"#include","#define","struct","int","char","void","float","double","longint","long","if","else","true","false","return"};
int length = keyword->Length;
String ^ strRTF = this->richTextBox1->Rtf;
int iCTableStart = strRTF->IndexOf("colortbl;");
if (iCTableStart != -1)
{
int iCTableEnd = strRTF->IndexOf('}', iCTableStart);
strRTF = strRTF->Remove(iCTableStart, iCTableEnd - iCTableStart);
strRTF = strRTF->Insert(iCTableStart,
"colortbl ;\\red255\\green0\\blue0;\\red0\\green128\\blue0;\\red0\\green0\\blue255;}");
}
else
{
int iRTFLoc = strRTF->IndexOf("\\rtf");
int iInsertLoc = strRTF->IndexOf('{', iRTFLoc);
if (iInsertLoc == -1) iInsertLoc = strRTF->IndexOf('}', iRTFLoc) - 1;
strRTF = strRTF->Insert(iInsertLoc,
"{\\colortbl ;\\red128\\green0\\blue0;\\red0\\green128\\blue0;\\red0\\green0\\blue255;}");
}
int len = strRTF->Length;
String^ tempst;
String^ result;
String ^key;
//String ^strReplace;
String ^slash = "/*";
String ^endslash = "*/";
String ^commentlinestr = "//";
char startquots = '"';
char endquots = '"';
int keylen;
int iRTFLoc;
int intslash;
int stquotes;
//int endquotes;
int commentline;
bool found = false;
bool spacefound = false;
bool starcomment = true;
bool slashcomment = false;
bool endquot = false;
int nlen = strRTF->Length;
for(int nchRTF = 0;nchRTF < nlen;nchRTF++)
{
if(strRTF[nchRTF] == ' ' || strRTF[nchRTF] == '\n' || strRTF[nchRTF] == '"' || strRTF[nchRTF] == ';' || strRTF[nchRTF] == '(' || strRTF[nchRTF] == ',' /*|| strRTF[nchRTF] == '*' */)
{
//Keyword
for(int nkeyword = 0;nkeyword<length;nkeyword++)
{
key = keyword[nkeyword];
keylen = key->Length;
iRTFLoc = tempst->IndexOf(keyword[nkeyword]);
if(/*iRTFLoc >= 0*/ tempst->Contains(key))
{
found = true;
break;
}
}
if(found)
{
if(starcomment)
{
int location = 4+iRTFLoc+keylen+1;
tempst = tempst->Insert( iRTFLoc,"\\cf3 ");
tempst = tempst->Insert( location,"\\cf0 ");
}
found = false;
}
tempst = String::Concat(tempst, strRTF[nchRTF]);
//Single Comment line
if(strRTF[nchRTF] == '\n')
{
if(slashcomment)
{
int newlen = tempst->Length;
tempst = tempst->Insert(newlen,"\\cf0");
slashcomment = false;
}
}
commentline = tempst->IndexOf(commentlinestr);
if(commentline >= 0)
{
tempst = tempst->Insert( commentline,"\\cf2 ");
slashcomment = true;
}
// Quotes
if(strRTF[nchRTF] == '"')
{
if(endquot)
{
int quoteslen = tempst->Length;
tempst = tempst->Insert(quoteslen,"\\cf0");
endquot = false;
}
else
stquotes = tempst->IndexOf(startquots);
if(stquotes >= 0)
{
tempst = tempst->Insert( stquotes,"\\cf1");
endquot = true;
}
}
//Group comment line
intslash = tempst->IndexOf(slash);
if(intslash >= 0)
{
starcomment = false;
tempst = tempst->Insert( intslash,"\\cf2 ");
}
int intslashend = tempst->IndexOf(endslash);
if(intslashend >= 0)
{
tempst = tempst->Insert( intslashend + 2 ,"\\cf0 ");
starcomment = true;
}
//Concat the string
result = String::Concat(result,tempst);
tempst = String::Empty;
}
else
{
tempst = String::Concat(tempst,strRTF[nchRTF] );
}
}
result = String::Concat(result,tempst);
tempst = String::Empty;
this->richTextBox1->Rtf = result;
this->richTextBox1->SelectionStart = this->richTextBox1->Text->Length;
}
in this code is working fine while opening the file.
Thanks
Mani,
|
|
|
|
|
I am using eclipse for C++ and powerpc-apple-darwin9-gcc-4.0.1 as my compiler.
I am trying to compile a code example, butI am running into the following problem with an include of a standard library.
here is the main program:
[code]
#include <iostream>
#include "d_search.h"
#include "d_sort.h"
#include "d_random.h"
#include "d_timer.h"
using namespace std;
int main()
{ const int ARRAY_SIZE = 100000, TARGET_SIZE = 50000;
int list1[ARRAY_SIZE], list2[ARRAY_SIZE], targetList[TARGET_SIZE];
int i;
timer t;
randomNumber rnd;
for (i = 0; i < ARRAY_SIZE; i++)
list1[i] = list2[i] = rnd.random(1000000);
for (i=0;i < TARGET_SIZE; i++)
targetList[i] = rnd.random(1000000);
cout << "Timing the Selection Sort" << endl;
t.start();
selectionSort(list2,ARRAY_SIZE);
t.stop();
cout << "Selection Sort takes " << t.time()
<< " seconds." << endl;
cout << endl << "Timing the Sequential Search" << endl;
t.start();
for (i = 0; i < TARGET_SIZE; i++)
seqSearch(list1,0,ARRAY_SIZE,targetList[i]);
t.stop();
cout << "Sequential Search takes " << t.time()
<< " seconds." << endl;
cout << endl << "Timing the Binary Search" << endl;
t.start();
for (i = 0; i < TARGET_SIZE; i++)
binSearch(list2,0,ARRAY_SIZE,targetList[i]);
t.stop();
cout << "Binary Search takes " << t.time()
<< " seconds." << endl;
return 0;
}
[/code] </iostream>
here is the included header file:
[code]
#ifndef SEARCH_FUNCTIONS
#define SEARCH_FUNCTIONS
#include <vector>
#include <list>
using namespace std;
int seqSearch(const int arr[], int first, int last, int target);
template <typename t="">
int seqSearch(const T arr[], int first, int last, const T& target);
int binSearch(const int arr[], int first, int last, int target);
template <typename t="">
int binSearch(const T arr[], int first, int last, const T& target);
template <typename t="">
int seqSearch(const vector<t>& v, int first, int last, const T& target);
template <typename t="">
int binSearch(const vector<t>& v, int first, int last, const T& target);
template <typename t="">
list<t>::iterator seqSearch(list<t>::iterator first,
list<t>::iterator last, const T& target);
template <typename iterator,="" typename="" t="">
Iterator find(Iterator first, Iterator last, const T& target);
int seqSearch(const int arr[], int first, int last, int target)
{
int i;
for(i=first; i < last; i++)
if (arr[i] == target)
return i;
return last;
}
template <typename t="">
int seqSearch(const T arr[], int first, int last, const T& target)
{
int i;
for(i=first; i < last; i++)
if (arr[i] == target)
return i;
return last;
}
int binSearch(const int arr[], int first, int last, int target)
{
int mid;
int midValue;
int origLast = last;
while (first < last)
{
mid = (first+last)/2;
midValue = arr[mid];
if (target == midValue)
return mid;
else if (target < midValue)
last = mid;
else
first = mid+1;
}
return origLast;
}
template <typename t="">
int binSearch(const T arr[], int first, int last, const T& target)
{
int mid;
T midValue;
int origLast = last;
while (first < last)
{
mid = (first+last)/2;
midValue = arr[mid];
if (target == midValue)
return mid;
else if (target < midValue)
last = mid;
else
first = mid+1;
}
return origLast;
}
template <typename t="">
int seqSearch(const vector<t>& v, int first, int last, const T& target)
{
int i;
for(i=first; i < last; i++)
if (v[i] == target)
return i;
return last;
}
template <typename t="">
int binSearch(const vector<t>& v, int first, int last, const T& target)
{
int mid;
T midvalue;
int origLast = last;
while (first < last)
{
mid = (first+last)/2;
midvalue = v[mid];
if (target == midvalue)
return mid;
else if (target < midvalue)
last = mid;
else
first = mid+1;
}
return origLast;
}
template <typename t="">
list<t>::iterator seqSearch(list<t>::iterator first,
list<t>::iterator last, const T& target)
{
list<t>::iterator iter = first;
while(iter != last && !(*iter == target))
iter++;
return iter;
}
template <typename iterator,="" typename="" t="">
Iterator find(Iterator first, Iterator last, const T& target)
{
Iterator iter = first;
while (iter != last && *iter != target)
iter++;
return iter;
}
#endif // SEARCH_FUNCTIONS
[/code]</typename></t></t></t></t></typename></t></typename></t></typename></typename></typename></typename></t></t></t></typename></t></typename></t></typename></typename></typename></list></vector>
the error seems to be when I call the list template. the syntax check in eclipse says
"expected constructor, destructor, or type conversion before 'seqSearch'
here is the error output of the build:
[code]
make all
Building file: ../source/prg3_1.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"source/prg3_1.d" -MT"source/prg3_1.d" -o"source/prg3_1.o" "../source/prg3_1.cpp"
"../source/d_search.h:43: error: expected constructor, destructor, or type conversion before 'seqSearch'
"../source/d_search.h:164: error: expected constructor, destructor, or type conversion before 'seqSearch'
"../source/d_sort.h: In function 'void distribute(const std::vector<int, std::allocator<int=""> >&, std::queue<int, std::deque<int,="" std::allocator<int=""> > >*, int)':
"../source/d_sort.h:234: warning: comparison between signed and unsigned integer expressions
make: *** [source/prg3_1.o] Error 1
[/code]</int,></int,>
any help is appreciated
thanks in advance.
|
|
|
|
|
C++/CLI is the .NET extensions to C++, which Eclipse does not support. I know it's not as clear as it could be, but the visual C++ forum is the place to ask this.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
In my Form application, I have created several object pointer using new operator. These objects are of Templated class and classed are exist in a separate lib (native c++ but compiled with /clr). I found my application is leaking momory. I tried to track all new and delete pair but still there is memery leak exist.
I search for memory leak detector but most free tools are for native c++.
How can I delect the memery leak in managed form which are due to new and delete pair.
Any idea or links to right tool will be highly appreciated.
Thank you
|
|
|
|
|
Hai
I am using .net windows form application, richtextbox control for creating a text editor. I don't know how to get caret position. Is there any command available to get the caret position. Can you tell me & give example.
Thanks in advance
Mani.
|
|
|
|
|
|
Hai
Thanks for reply,
Here i am using .Net Framework 2.0,Mc++. Is here any command like caretposition.
can you tell me.
Thanks
modified on Thursday, May 15, 2008 10:58 PM
|
|
|
|
|
Did you have a look at the link I suggested?
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Hai
Thanks for reply.
I saw that, actually what i want is i want to move the cursor position to the end of the file. while open the file. For that i want to know how to move the caret from one place to another place.
your attached document is very helpful for me.
Thanks again,
Mani,
|
|
|
|
|
Do you want to move caret to the end of the text in a textbox or do you want to move cursor position in the stream you are reading from?
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Hai
Thanks for reply
I want to move the caret position to end of the textbox.
Thanks,
Mani,
|
|
|
|
|
|
Hai
Thank you very much your answers are very helpful to me.
Thanks again,
Mani,
|
|
|
|
|
Glad to help you
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Hi, I am using Visual Studio 2005 C++/CLI. My application's Form1 begins as a maximized window. I am using GDI+ to draw graphics on Form1. I can zoom by setting the Matrix->Scale value and Matrix->Transform(OffsetX, OffsetY). As I zoom in on what I am drawing I never get any scroll bars even though I have the AutoScroll property set to true. I have read a few articles on this but still am having problems. Anyone have any insight on this?
Thanks,
Buck
|
|
|
|
|
i am working on a project which has two form.
i want to run the second form in a different thread.
and i declared my thread
private: System::Threading::Thread^ MyThread;
and
this->myThread = (gcnew System::Threading::Thread( <br />
gcnew System::Threading::ThreadStart( &MyClass::MyFunction)));
and i added" this->MyThread ->Start(); into button1_Click decleration
and i include the form2 into my form1 header file
and added my class codes under under the Form2's codes
so far everything is ok, but when i debug my project form2 can open once and after i close Form2, it doesnt open again, when i tried to click the button an error occours
"Thread is running or terminated"
How can i run my thread again after i close it?
--always comes daylight after night-----
|
|
|
|
|
Adnan Merter wrote: i want to run the second form in a different thread.
Why?
led mike
|
|
|
|
|
because,
the second form will start a process ,and the process can be stopped and the 2nd form will be closed if it is neccessary.
as far as i know, there is no way else to stop a process but using threads.
is there?
--always comes daylight after night-----
|
|
|
|
|
Adnan Merter wrote: as far as i know, there is no way else to stop a process but using threads.
is there?
yes you can use a message pump but threads are normally a better solution.
Adnan Merter wrote: i want to run the second form in a different thread.
Did you look at the BackgroundWorker class[^]?
led mike
|
|
|
|
|
Hello dear programmers
I need a sourcr code program in c++ that can add a 10 digit number
to another 10 digit number.This program must be written with link list and pointer.If anyone had thid.please send it 4 me because i'm in a terrible situation and extremly need it.Thanks
alirahimei@yahoo.com
|
|
|
|
|
Ali Rahimei wrote: because i'm in a terrible situation
Let me guess, you took a computer science course but you're just not suited to the field? If so I suggest you drop the course.
led mike
|
|
|
|
|
Hi,
I had develop some MFC calss and that program is working properly. Now I am decided to integrate my MFC class with .NET (C++/CLI).
My requirement is that, I want to use the same MFC class in my C++/CLI Program with out any changes. I can do it like this, I create a .dll file using the same MFC calss in load that .dll file into my C++/CLI ( CLR ) project and create an object using that .dll file and it is working. But I am not satisfied in this methord. Because, through this method, we want to keep a lot of .dll file ( for each class we need to create .dll file and load that .dll file in to my new project ). So I am trying for another method. So I made changes in my mfc project settings and inherit the mfc class in my native class and create an object using the new native calss and i can load the MFC class in my native class and I can call the functions from my native object. But in my MFC class there has a function OnCreate(LPCREATESTRUCT lpCreateStruct). in that function I had do some steps. I can't call that function through the native call. Can you help me to solve this problem?
My aim is using my existing MFC class, I want to create a create a native application ( C++/CLI )
my source code is like this,
MFC class
MyTreeView.h
class CFpiTreeView : public CView
{
protected:
/////CFpiTreeView(); // Dynamische Erstellung verwendet geschützten Konstruktor //Commented by sabeesh
DECLARE_DYNCREATE(CFpiTreeView)
// Attribute
public:
CFpiTreeView(); // Dynamische Erstellung verwendet geschützten Konstruktor
virtual ~CFpiTreeView(); //Added by sabeesh
CTreeCtrl m_Tree;
CStatic m_Logo;
HBITMAP m_hBtmLogo;
void SetTreeItemText(HTREEITEM ti, CString NewText);
//// CMainFrame *m_pParent; //Commented by sabeesh
// Operationen
public:
// Überschreibungen
// Vom Klassen-Assistenten generierte virtuelle Funktionsüberschreibungen
//{{AFX_VIRTUAL(CFpiTreeView)
protected:
virtual void OnDraw(CDC* pDC); // Überschrieben zum Zeichnen dieser Ansicht
virtual BOOL OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult);
//}}AFX_VIRTUAL
void Selchanged(NMHDR* pNMHDR, LRESULT* pResult);
// Implementierung
//protected: //Commented by sabeesh
// virtual ~CFpiTreeView(); //Commented by sabeesh
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
// Generierte Nachrichtenzuordnungsfunktionen
///protected:
public:
//{{AFX_MSG(CFpiTreeView)
void Test();
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSize(UINT nType, int cx, int cy);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
MyTreeView.cpp
#include "stdafx.h"
///#include "FpiTreeControl.h"
#include "FpiTreeView.h"
using namespace System;
using namespace System::Windows;
using namespace System::Windows::Forms;
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#define TREEID 1000
/////////////////////////////////////////////////////////////////////////////
// CFpiTreeView
IMPLEMENT_DYNCREATE(CFpiTreeView, CView)
/////CFpiTreeView::CFpiTreeView():m_pParent(NULL)
CFpiTreeView::CFpiTreeView()
{
MessageBox::Show(L"Create CFpiTreeView");
//IMPLEMENT_DYNCREATE(CFpiTreeView, CView) ;
//m_Tree.InsertItem("Grafische Darstellung");
// m_Tree.Create(WS_CHILD | WS_VISIBLE | TVS_SHOWSELALWAYS | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_DISABLEDRAGDROP | TVS_HASLINES, r, this, TREEID);
/* m_Tree.SetBkColor(RGB(0, 255, 0));
m_Tree.InsertItem("Grafische Darstellung");
ti = m_Tree.InsertItem("Projektstammdaten");
m_Tree.InsertItem("Eckdaten", ti);
m_Tree.InsertItem("Hinweise", ti);
ti = m_Tree.InsertItem("Kosten Bau");
m_Tree.InsertItem("Übersicht und Verteilung der Gesamtkosten", ti);
m_Tree.InsertItem("Zusammenstellung der Kosten", ti);
*/
/// m_hBtmLogo = (HBITMAP)LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BTM));
}
CFpiTreeView::~CFpiTreeView()
{
DeleteObject(m_hBtmLogo);
}
BEGIN_MESSAGE_MAP(CFpiTreeView, CView)
//{{AFX_MSG_MAP(CFpiTreeView)
ON_WM_CREATE()
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Zeichnung CFpiTreeView
void CFpiTreeView::OnDraw(CDC* pDC)
{
MessageBox::Show(L"OnDraw");
RECT r, r2;
CPen *pOldPen, pen;
CBrush *pOldBrush, brush;
pen.CreatePen(PS_SOLID, 0, RGB(255, 0, 0));
brush.CreateSolidBrush(RGB(255, 0, 0));
GetClientRect(&r);
m_Logo.GetClientRect(&r2);
r.bottom = r2.bottom + 10;
pOldPen = pDC->SelectObject(&pen);
pOldBrush = pDC->SelectObject(&brush);
pDC->Rectangle(r.left, r.top, r.right, r.bottom);
pDC->SelectObject(pOldPen);
pDC->SelectObject(pOldBrush);
}
/////////////////////////////////////////////////////////////////////////////
// Diagnose CFpiTreeView
#ifdef _DEBUG
void CFpiTreeView::AssertValid() const
{
CView::AssertValid();
}
void CFpiTreeView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// Behandlungsroutinen für Nachrichten CFpiTreeView
int CFpiTreeView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
MessageBox::Show(L"OnCreate");
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
RECT r;
HTREEITEM ti;
r.left = r.top = 0;
r.right = 100;
r.bottom = 100;
m_Logo.Create("", WS_CHILD | WS_VISIBLE | SS_BITMAP, r, this, 18);
m_Logo.SetBitmap(m_hBtmLogo);
r.right = 100;
r.bottom = 100;
m_Tree.Create(WS_CHILD | WS_VISIBLE | TVS_SHOWSELALWAYS | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_DISABLEDRAGDROP | TVS_HASLINES, r, this, TREEID);
m_Tree.SetBkColor(RGB(0, 255, 0));
m_Tree.InsertItem("Grafische Darstellung");
ti = m_Tree.InsertItem("Projektstammdaten");
m_Tree.InsertItem("Eckdaten", ti);
m_Tree.InsertItem("Hinweise", ti);
ti = m_Tree.InsertItem("Kosten Bau");
m_Tree.InsertItem("Übersicht und Verteilung der Gesamtkosten", ti);
m_Tree.InsertItem("Zusammenstellung der Kosten", ti);
return 0;
}
void CFpiTreeView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
RECT r;
int Diff;
m_Logo.GetClientRect(&r);
Diff = r.right - r.left;
r.left = (cx - r.right + r.left) / 2;
r.right = r.left + Diff;
m_Logo.MoveWindow(&r);
r.top = r.bottom = r.bottom + 10;
r.left = 0;
r.right = cx;
if (cy > r.bottom)
r.bottom = cy;
m_Tree.MoveWindow(&r);
}
BOOL CFpiTreeView::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
if (wParam == TREEID)
{
NMHDR *pNMHDR = (NMHDR*)lParam;
if (pNMHDR->code == TVN_SELCHANGED)
Selchanged(pNMHDR, pResult);
}
return CView::OnNotify(wParam, lParam, pResult);
}
void CFpiTreeView::Selchanged(NMHDR* pNMHDR, LRESULT* pResult)
{
// m_pParent->Selchanged(((NM_TREEVIEW*)pNMHDR)->itemNew.hItem, m_Tree.GetItemText(((NM_TREEVIEW*)pNMHDR)->itemNew.hItem)); //Commented by sabeesh
//*pResult = 0; //Commented by sabeesh
}
void CFpiTreeView::SetTreeItemText(HTREEITEM ti, CString NewText)
{
m_Tree.SetItemText(ti, NewText);
}
MainForm.h
// MainFrm.h : interface of the CMainFrame class
//
#pragma once
#include "ChildView.h"
#include "FpiTreeView.h"
//#include <msclr\marshal.h>
#include "Form1.h"
//class marshal_context;
#include <vcclr.h>
#include <windows.h>
#include <vcclr.h>
#using <system.dll>
using namespace System;
using namespace System::Windows;
using namespace System::Windows::Forms;
//TreeViewT::TreeViewT()
//{
// CFpiTreeView* treeview = new CFpiTreeView() ;
//}
public ref class MClass : public TreeView
{
public:
MClass() : m_Impl( new CFpiTreeView ) {}
public:
CFpiTreeView * m_Impl;
};
public ref class MyForm : public Form
{
private:
public:
MClass^ tree;
System::ComponentModel::Container ^components;
public:
MyForm(void)
{
tree = gcnew MClass();
tree->Width = 400;
tree->Height = 300;
this->Width=450;
this->Height=400;
this->Controls->Add(tree);
}
// ~MyForm();
private:
//void InitializeComponent1();
};
class CMainFrame : public CFrameWnd
{
public:
CMainFrame();
protected:
DECLARE_DYNAMIC(CMainFrame)
// Attributes
public:
//CWinFormsControl<project3::form1> pform1;
// Operations
public:
// Overrides
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
// Implementation
public:
virtual ~CMainFrame();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected: // control bar embedded members
CStatusBar m_wndStatusBar;
CToolBar m_wndToolBar;
CChildView m_wndView;
// Generated message map functions
protected:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnSetFocus(CWnd *pOldWnd);
DECLARE_MESSAGE_MAP()
};
MainForm.cpp
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
MyForm^ myfrm = gcnew MyForm();
myfrm->Show();
}
using this code, The tree view is created. But the node values, in
int CFpiTreeView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
MessageBox::Show(L"OnCreate");
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
RECT r;
HTREEITEM ti;
r.left = r.top = 0;
r.right = 100;
r.bottom = 100;
m_Logo.Create("", WS_CHILD | WS_VISIBLE | SS_BITMAP, r, this, 18);
m_Logo.SetBitmap(m_hBtmLogo);
r.right = 100;
r.bottom = 100;
m_Tree.Create(WS_CHILD | WS_VISIBLE | TVS_SHOWSELALWAYS | TVS_HASBUTTONS | TVS_LINESATROOT | TVS_DISABLEDRAGDROP | TVS_HASLINES, r, this, TREEID);
m_Tree.SetBkColor(RGB(0, 255, 0));
m_Tree.InsertItem("Grafische Darstellung");
ti = m_Tree.InsertItem("Projektstammdaten");
m_Tree.InsertItem("Eckdaten", ti);
m_Tree.InsertItem("Hinweise", ti);
ti = m_Tree.InsertItem("Kosten Bau");
m_Tree.InsertItem("Übersicht und Verteilung der Gesamtkosten", ti);
m_Tree.InsertItem("Zusammenstellung der Kosten", ti);
return 0;
}
is not created. How can I call this function?
Please help me
Thank you in Advance
Sabi
|
|
|
|
|