|
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?
|
|
|
|
|
I was able to solve this problem by implementing the ToolTip.Show function and putting in the coordinates manually. But I've run into an issue with the "stem" of the bubble pointing in the wrong direction, (pointing up when the bubble is above the point) and I cannot move the bubble down to manually line up the stem with the point of intrest as it is at the bottom of the application, and the window is maxamized (like an icon in a tray). Any thoughts?
|
|
|
|
|
hi everybody,
i've been trying to display one of my flash animation on a windows form, but i havent succeed so far.
can someone help me?
--always comes daylight after night-----
|
|
|
|
|
Adnan Merter wrote: i've been trying to display one of my flash animation on a windows form
How? Using the Flash ocx? Using a web browser control?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
(OCX)i added a shockwawe flash object to my form but still i cant display my animation.
how i can use this object?
--always comes daylight after night-----
|
|
|
|
|
|
hello
I want to know whether NTL package works in the VC++.NET 2005 enviroment . and how ?
|
|
|
|
|
Member 4125584 wrote: I want to know whether NTL package works in the VC++.NET 2005 enviroment . and how ?
It doesn't, according to this[^]
led mike
|
|
|
|
|
I am using Visual c++ NET 2005 Version.
I have this:
double salary ;
double^ salarym;
My problem is to convert for example double^ type to double. According to above lines, i need to do salary = salarym.
The second problem, I read from a file, how to convert for example
double salary = adapt->GetDouble(1);
|
|
|
|
|
mikobi wrote: My problem is to convert for example double^ type to double. According to above lines, i need to do salary = salarym.
You can use the same syntax used to dereference a C++ pointer:
salary = *salarym;
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I've got a problem using managed c++ and opengl.
The thing is that i'd like to have an opengl instance inside a form, i've tried tutorials like "OpenGL on a windows form" posted in this webpage, but when i compile it it doesn't work, many null references are found... googleing for hours and i haven't found what i'm looking for, help would be really apreciated!!!!!!!
So the first problem is that when I call wglCreateContext for the first time it returns a NULL value,calling GetLastWin32Error it returns 2000. Calling it twice returns a graphics context, i don't know if its the correct context even...
There's the code (GLwin is a Picturebox, it returns a valid Handle as you see it's forced to create it's Handle with CreateControl() ).
PIXELFORMATDESCRIPTOR pfd = {<br />
sizeof(PIXELFORMATDESCRIPTOR),
<br />
1,
<br />
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER, <br />
<br />
PFD_TYPE_RGBA,
<br />
32,
<br />
0, 0, 0, 0, 0, 0, 0, 0,
<br />
0,
<br />
0, 0, 0, 0,
<br />
32,
<br />
24,
<br />
0,
<br />
PFD_MAIN_PLANE,
<br />
0,
<br />
0, 0, 0
<br />
};<br />
<br />
<br />
this->Glwin->CreateControl();<br />
HDC mhDC = GetDC((HWND)this->Glwin->Handle.ToPointer());<br />
<br />
<br />
int iPixelFormat = ChoosePixelFormat(mhDC, &pfd);<br />
SetPixelFormat(mhDC, iPixelFormat, &pfd);<br />
<br />
HGLRC mhGLRC=0;<br />
mhGLRC= wglCreateContext(mhDC);<br />
<br />
if (!mhGLRC)<br />
{<br />
int err=System::Runtime::InteropServices::Marshal::GetLastWin32Error();<br />
System::Windows::Forms::MessageBox::Show(err.ToString(),"Error",Windows::Forms::MessageBoxButtons::OK,Windows::Forms::MessageBoxIcon::Error); <br />
}<br />
else<br />
{<br />
System::Windows::Forms::MessageBox::Show("Ok","Ok!",Windows::Forms::MessageBoxButtons::OK,Windows::Forms::MessageBoxIcon::Information); <br />
wglMakeCurrent(mhDC, mhGLRC);<br />
}<br />
<br />
So if the code ends up with a correct context created, when i try to call
glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE );
i get a "System Violation Exception".
|
|
|
|
|