|
Hello, everyone.
I'm hoping this is the right place to post my question. I've been looking around on the net for the last couple of hours and haven't found a solution to my problem. (I did learned some new stuff for use in the future). So this is my situation. I have a program that lets the user create a response test using a movie. When I tried to draw on the movie the activeX controller always pushed its way to the front. So I've created a separate form that floats on top of the main form to draw on. The program also has three threads running, the main thread, a timing thread, and a thread that updates the floating form.
My problem is when I try and send a message to the floating form I trip a NullReferenceException. I've checked both the callback and my class, and both look properly initialized. The floating form is also correctly intialized. I've tried everything I could find, but nothing helps. I've included the method and the callback declaration. The floating form is called 'TestViewer' and the 'HOTSPOT' class is one I've created.
Thanks everyone for your help
(Sorry my code is in C++, but I know most people us C# or VB when programming in .net, and a lot more people frequent this form than the managed C++ one. If needed I can translate it into C#. Feel free to give me an answer in C#. Over the years I've gotten pretty good a translating C# to C++. Thanks.)
delegate System::Void SetDrawActivePanelCallback(HOTSPOT^ hSpot);
private: System::Void SetTestViewDrawActivePanel(HOTSPOT^ hSpot)
{
if(this->TestViewer->InvokeRequired)
{
SetDrawActivePanelCallback^ cb = (gcnew SetDrawActivePanelCallback(this,
&Edit::SetTestViewDrawActivePanel));
try
{
this->Invoke(cb, hSpot);
} // End try
catch(System::NullReferenceException^ e)
{
String^ s = e->ToString();
::MessageBox::Show(s);
} // End catch
} // End if
else
{
System::Windows::Forms::Panel^ panel = hSpot->GetPanel();
this->TestViewer->DrawActivePanel(panel, this->hotspotVisible);
} // End else
} // End SetTestViewDrawActivelPanel
|
|
|
|
|
This may not be your problem but shouldn't:
Member 3848269 wrote: SetDrawActivePanelCallback^ cb = (gcnew SetDrawActivePanelCallback(this,
&Edit::SetTestViewDrawActivePanel));
be coded with a "+=" rather than a "="!
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
In the following example 1 I added rows to the DataSet
And I did not have any problem. However when I tried to add rows to a DataSet with more than one dimension I get the following error message at row 1 “Object reference not set to an instance of an object.”. I am unable to add the word new after equal sign. Does anyone know how to solve this problem.
Example 1
DataRow dr = dsI.EVar.NewRow();
dr["nRecordID"] = x;
dsI.EVar.Rows.Add(dr);
Example 2
DataRow dr = dsMI[x][1].EVar.NewRow();
dr["nRecordID"] = x;
dsMI[x][1].EVar.Rows.Add(dr);
Thanks in advance,
Michael
|
|
|
|
|
Hello, everyone.
I'm hoping this is the right place to post my question. I've been looking around on the net for the last couple of hours and haven't found a solution to my problem. (I did learned some new stuff for use in the future). So this is my situation. I have a program that lets the user create a response test using a movie. When I tried to draw on the movie the activeX controller always pushed its way to the front. So I've created a seperate form that floats on top of the main form to draw on. The program also has three threads running, the main thread, a timing thread, and a thread that updates the floating form.
My problem is when I try and send a message to the floating form I trip a NullReferenceException. I've checked both the callback and my class, and both look properly initialized. The floating form is also correctly intialized. I've tried everything I could find, but nothing helps. I've included the method and the callback decleration. The floating form is called 'TestViewer' and the 'HOTSPOT' class is one I've created.
Thanks everyone for your help
delegate System::Void SetDrawActivePanelCallback(HOTSPOT^ hSpot);
private: System::Void SetTestViewDrawActivePanel(HOTSPOT^ hSpot)
{
if(this->TestViewer->InvokeRequired)
{
SetDrawActivePanelCallback^ cb = (gcnew SetDrawActivePanelCallback(this,
&Edit::SetTestViewDrawActivePanel));
try
{
this->Invoke(cb, hSpot);
} // End try
catch(System::NullReferenceException^ e)
{
String^ s = e->ToString();
::MessageBox::Show(s);
} // End catch
} // End if
else
{
System::Windows::Forms::Panel^ panel = hSpot->GetPanel();
this->TestViewer->DrawActivePanel(panel, this->hotspotVisible);
} // End else
} // End SetTestViewDrawActivelPanel
|
|
|
|
|
hi ,
i am trying to copy file in a new file and search a name in newfile , see the code below, but not able to find method, what could be the code in place of ???????.
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
void main()
{
FILE *in, *out;
int i;
char str[100];
clrscr();
in=fopen("B.txt","r+");
if(!in)
{
printf("can not open input file");
exit(0);
}
out=fopen("newB.txt","w");
if(!out)
{
printf("can not open output file");
exit(0);
}
while (!feof(in))
{
fgets(str,100,in);
//for(i=0;str[i]!=null;i++)
fputs(str,out);
fclose(out);
fclose(in);
}
|
|
|
|
|
Turbo C does not support C++/CLI, so you're in the wrong forum. Try the Visual C++ forum
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
This is a Managed C++ Forum.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
|
|
|
|
|
Hi ,
Can any body help me in using MFC Extension UI dll in .NET Winform
Kamal
|
|
|
|
|
kushu wrote: Can any body help me in using MFC Extension UI dll in .NET Winform
Maybe, but it's not possible unless you can provide specific information so someone can understand what you need.
|
|
|
|
|
Hi Mike,
Thanks for your early response.I am sending you the code for my class that needs to be used in .NET .I need to use this control CSizingControlBar in my Winform. CSizingControlBar is derived from MFC class CControlBar.I am migrating an application from MFC to .NET, there are few controls which require a lot of rewrite effort.Hence we wish to reuse the in .NET.It would be a grest help if you could provide with some feasible solution.
You could see one of my classe below.
Thanks
#ifndef baseCSizingControlBar
#define baseCSizingControlBar CControlBar
#endif
class CSizingControlBar;
typedef CTypedPtrArray <CPtrArray, CSizingControlBar*> CSCBArray;
#include "DsGUIExtClass.h"
class DSGUI_EXT_CLASS CSizingControlBar : public baseCSizingControlBar
{
DECLARE_DYNAMIC(CSizingControlBar);
// Construction
protected:
CSizingControlBar();
public:
virtual BOOL Create(LPCTSTR lpszWindowName, CWnd* pParentWnd,
CSize sizeDefault, BOOL bHasGripper, UINT nID,
DWORD dwStyle = WS_CHILD | WS_VISIBLE | CBRS_TOP);
// Attributes
public:
CSize m_szHorz;
CSize m_szVert;
CSize m_szFloat;
const BOOL IsFloating() const;
const BOOL IsHorzDocked() const;
const BOOL IsVertDocked() const;
const BOOL IsSideTracking() const;
// Operations
public:
virtual void LoadState(LPCTSTR lpszProfileName);
virtual void SaveState(LPCTSTR lpszProfileName);
static void GlobalLoadState(LPCTSTR lpszProfileName);
static void GlobalSaveState(LPCTSTR lpszProfileName);
// Overridables
virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
// Overrides
public:
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSizingControlBar)
public:
virtual CSize CalcFixedLayout(BOOL bStretch, BOOL bHorz);
virtual CSize CalcDynamicLayout(int nLength, DWORD dwMode);
virtual BOOL DestroyWindow();
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CSizingControlBar();
protected:
// implementation helpers
UINT GetEdgeHTCode(int nEdge);
BOOL GetEdgeRect(CRect rcWnd, UINT nHitTest, CRect& rcEdge);
virtual void StartTracking(UINT nHitTest);
virtual void StopTracking();
virtual void OnTrackUpdateSize(CPoint& point);
virtual void OnTrackInvertTracker();
virtual void NcPaintGripper(CDC* pDC, CRect rcClient);
virtual void AlignControlBars();
const int FindSizingBar(CControlBar* pBar) const;
void GetRowInfo(int& nFirst, int& nLast, int& nThis);
void GetRowSizingBars(CSCBArray& arrSCBars);
BOOL NegociateSpace(int nLengthAvail, BOOL bHorz);
protected:
static CSCBArray m_arrBars;
DWORD m_dwSCBStyle;
UINT m_htEdge;
CSize m_szMin;
CSize m_szMinT;
CSize m_szMaxT;
CSize m_szOld;
CPoint m_ptOld;
BOOL m_bTracking;
BOOL m_bKeepSize;
BOOL m_bParentSizing;
BOOL m_bDragShowContent;
UINT m_nDockBarID;
int m_cxEdge;
int m_cyGripper;
CSCBButton m_biHide;
// Generated message map functions
protected:
//{{AFX_MSG(CSizingControlBar)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg void OnNcPaint();
afx_msg void OnNcCalcSize(BOOL bCalcValidRects, NCCALCSIZE_PARAMS FAR* lpncsp);
afx_msg LRESULT OnNcHitTest(CPoint point);
afx_msg void OnCaptureChanged(CWnd *pWnd);
afx_msg void OnSettingChange(UINT uFlags, LPCTSTR lpszSection);
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point);
afx_msg void OnWindowPosChanging(WINDOWPOS FAR* lpwndpos);
afx_msg void OnPaint();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
|
|
|
|
|
How to Convert Binary File to Hex File Format without using any tool?
|
|
|
|
|
The ToString method will allow you to specify a format. Assuming you're not in the wrong forum and are using .NET
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
hi ,
i am trying to get the object name, see the code below, but not able to find method, what could be the code in place of ???????.
#include "iostream"
using namespace std;
class A{
public:
int i;
void printObjectname(){
cout << ????????;//<--what could be here, to print the object name as 'objectA'
}
};
int _tmain(int argc, _TCHAR* argv[])
{
A *objectA = new A();
objectA->printObjectname();
return 0;
}
santosh
|
|
|
|
|
Hi,
this can not be done.
new A() is an object, it could have a name.
objectA is not an object, it is a variable, it holds a reference to the
class A object. There could be many more references to the same object, it suffices
to do A* objectB=objectA; , now how would the class A object have to know
the name of all the variables pointing to it, and in particular the one you want??
Suggestion: give your objects a name by providing a Name property and/or a name argument
in their constructor, so new A("aha"); would create a new class A object and
give it the name "aha". Now you can ask that object for its name, and/or you can override
its ToString() method so it identifies itself. Remark: this works independently of the
variable(s) that may refer to that object!
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hello. I have to parse an HTML file and extract data from it. Currently I load it into Excel and then save as a .csv file. Then I load the .csv file and parse that. I now have to get the data directly from a web page into .csv format. Has anyone out there attempted something similar. Thank you.
Tom Paronis
|
|
|
|
|
Are you using C++ and .NET ?
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
I'm using VC++ 6.00 and Visual Studio 2005. I think IHTMLDocument will help me but I can't figure out how to implement it. I'm scouring the web for an example.
Tom Paronis
|
|
|
|
|
OK, so VC6 doesn't use .NET. VS2005 does. If you're not using .NET then you're in the wrong forum. Try the Visual C++ forum.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
Hi Friends,
In socket programming I want to connect double byte charcters.
Earlier we used recv() function for single byte charcter.
If we use double byte chracter in below recv function, its coming as a question mark symbol.
If anybody knows how can I handle double byte charcter in Scoket programing(recv function),Please let me know.
My codesnippet:
while( bytesRecv == SOCKET_ERROR ) {
bytesRecv = recv( ConnectSocket, recvbuf, 64, 0 );
if ( bytesRecv == 0 || bytesRecv == WSAECONNRESET || CheckTimeOut()) {
return CloseListen();
}
}
Note:Here recvbuf works for singel byte not for doublebyte charcters.
Thanks in advance.
|
|
|
|
|
Looks like you're in the wrong forum. C++/CLI is C++ with .NET. You want the visual C++ forum.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
Hi all,
Is there something in boost that I can use to check if a file is existing and if the file is working.
for example string file = "c://sample.doc", is there something from boost that can see if the sample.doc exists in c: directory?
Thanks,
Jj
|
|
|
|
|
AS you're using .NET, use File.Exists. If you're not using .NET, try using the right forum.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
Hi Christian,
I am just using regular c++ at visual c++.
Thanks
|
|
|
|
|
OK, so then you're in the wrong forum. The Visual C++ forum is the one you want
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|