|
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
|
|
|
|
|
That's way too much code for pretty much anyone here to look through
Are you using MFC for your app's UI? If so, you shouldn't need to change anything
to build the app for CLR.
None of that MFC UI code is going to work if the MFC message loop isn't running or
messages are not being forwarded to MFC from another message loop.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hello,
Its ok, But I want to reuse the MFC class in my CLR project.
ie, I have an MFC class for create a CTreeView. I want to use this same class for create a tree view in CLR. That is my problem. I create a form using CLR and I want to add the MFC treeview in to that form. How can I do it?
|
|
|
|
|
Hi, I'm using Visual Studio 2005 C++/CLI. I have setup a zoom function that uses a Matrix class. Changing the Scale of the matrix will cause the image on the screen to zoom in or zoom out. On the zoom in function the upper left corner of the screen (0,0) is anchored so it appears that you are zooming in on the upper left corner. I can't seem to find the correct way to change the bounds of the screen because all of the Screen class properties seem to be read only. Is a screen class the right approach? Ideally I want the zoom functions to zoom relative to where the mouse is clicked on the screen.
Thanks,
Buck Brown
|
|
|
|
|
|
Hi,
I'm wrapping a native DLL with a managed wrapper(DLL) and I'm mimicking some inheritance like follows:
public ref class ManagedBaseClass abstract {
...
internal:
UnmanagedBaseClass *GetBase(void);
...
};
public ref class ManagedDerived : public ManagedBaseClass {
...
internal:
UnmanagedDerived *mWrappedObject;
UnmanagedBaseClass *GetBase(void) { return mWrappedObject; }
...
};
In the C++ DLL, UnmanagedDerived inherits from UnmanagedBase. When I hit the GetBase() method in ManagedDerived, I get a System.AccessViolationException at the return. I add a test before I return to call mWrapperObject->SomeFunc() and I still get the exception. mWrappedObject is non NULL and I'm calling other methods. Any idea what might be wrong?
Thanks,
-Mike
|
|
|
|
|
Sorry, I figured this out. There was an error somewhere else in my code
|
|
|
|
|
i am trying to create an application whis has one more forms and i have problem,
how can i declare a variable, which can be reached and changed by different form
controls(not the same time)?
i mean one of forms change the value of variale and the other form reach it create a process dependent this variable.
--always comes daylight after night-----
|
|
|
|
|
create a public property in a form and by setting its property you can change the value
//declaring property in CForm1
private: int abc;
public :
property int ABC
{
int get()
{
return abc;
}
void set(int value)
{
abc = value;
}
}
// using property in CForm2
#include "Form1.h"
CForm1^ frm = gcnew CForm1();
frm->ABC = 123;
Nigah M Manzoor
|
|
|
|
|
hai
I am using window form application.
Using richtextbox i am going to create a text editor.
when i am typing something in the text editor i want to change the font style, for that which eventhandler shall i use(Textchange or keypress).
thanks,
|
|
|
|
|
you have to use both event handler
in OnKeyPress you know which key has been pressed
and in OnTextChanged you can set the font and other things.
Nigah M Manzoor
|
|
|
|
|
Hi,
I want to have a StatusStripLabel in the StatusStrip display a bubble formatted ToolTip. The problem I'm having is that the SetToolTip function takes a Control, and the StatusStripLabel is not a control; StatusStrip is, but then the ballon will not appear at the label, it'll just appear where ever.
One answer I've heard to this is in an 'OnHover' event for the label to add the StatusStrip to the Tooltip, making it only appear when the mouse is hovering over the label. The problem I have with this is that I want the Tooltip to appear when an error occurs in the application, and not when a cursor hover is taking place.
Does anyone have any suggestions?
|
|
|
|
|