|
I have written a simple, no frills managed C++ DLL, and am having trouble referencing it in a seperate C# project. Specifically, the C# compiler gives me an error, asking whether I have neglected to add a reference or using statement pointing to my library/namespace. However, I cannot insert a using statement in my C# code, even after properly referencing it in my project (right-click on the References icon in the Solution Explorer, click on Add Reference...).
ILDASM can traverse the C++ library, and in it I find my method (I have just one), so I suspect there is nothing wrong in the manner it compiled.
Also, the DLL I'm wanting to reference is in the same directory (bin/) as my C# project's DLL.
Is there anything special I have to account for when writing managed C++, and want to include it in a project of a different language?
~ Dr. Shim
|
|
|
|
|
I'm getting an error when I try to inherit a new view class for a MDI application, and I can't figure out why :/ .. First I created an OpenGL viewport inherited from CView, and packed it with all kinds of functionality. It works great. But now I'm trying to derive a new view class from it, and I'm getting the following error (using VC++ 6.0 professional):
C:\DEVELOPMENT\MotionX\MotionX.cpp(119) : error C2039: 'classCMotionXModelView' : is not a member of 'CMotionXModelView' c:\development\motionx\motionxmodelview.h(15) : see declaration of 'CMotionXModelView'
C:\DEVELOPMENT\MotionX\MotionX.cpp(119) : error C2065: 'classCMotionXModelView' : undeclared identifier
The thing is, I'm just deriving it from a class that is fully functional, and haven't added anything except a member variable to it.
This is the view class declaration that works:
<br />
#if !defined(AFX_MOTIONXGLVIEW_H__A90B4B55_D9F7_4DD4_A776_7EDC323D4724__INCLUDED_)<br />
#define AFX_MOTIONXGLVIEW_H__A90B4B55_D9F7_4DD4_A776_7EDC323D4724__INCLUDED_<br />
<br />
#if _MSC_VER > 1000<br />
#pragma once<br />
#endif // _MSC_VER > 1000<br />
<br />
#include "gl/gl.h"<br />
#include "gl/glu.h"<br />
#include "gl/glaux.h"<br />
<br />
#include "MotionXSceneDoc.h"<br />
#include "MotionXCamera.h"<br />
#include "MotionXModel.h"
<br />
<br />
<br />
#define PERSPECTIVE 0<br />
#define FRONT 1<br />
#define BACK 2<br />
#define LEFT 3<br />
#define RIGHT 4<br />
#define TOP 5<br />
#define BOTTOM 6<br />
<br />
class CMotionXGLView : public CView<br />
{<br />
protected:<br />
CMotionXGLView();
DECLARE_DYNCREATE(CMotionXGLView)<br />
<br />
public:<br />
<br />
public:<br />
CMotionXModel model;<br />
void DrawGrid();<br />
<br />
void SwitchViewportMode(unsigned int);<br />
void DollyViewport(const float speed);<br />
void PitchAroundPoint(const float speed);<br />
void RotateAroundPoint(const float speed);<br />
inline void PedistalViewport(float speed);<br />
inline void StrafeViewport(float speed);<br />
CMotionXCamera viewCam;<br />
BOOL SetupPixelFormat();<br />
<br />
public:<br />
virtual void OnInitialUpdate();<br />
protected:<br />
virtual void OnDraw(CDC* pDC);
virtual void OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint);<br />
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);<br />
virtual BOOL OnCommand(WPARAM wParam, LPARAM lParam);<br />
<br />
protected:<br />
virtual ~CMotionXGLView();<br />
#ifdef _DEBUG<br />
virtual void AssertValid() const;<br />
virtual void Dump(CDumpContext& dc) const;<br />
#endif<br />
<br />
protected:<br />
BOOL m_bCursor;<br />
double minClip, maxClip;<br />
double orthoWidth, orthoHeight, orthoZDistance;<br />
unsigned int m_viewportMode;<br />
CPoint m_pointMessage;<br />
CDC* GetDC();<br />
unsigned int height;<br />
unsigned int width;<br />
GLdouble aspectRatio;<br />
HGLRC m_hRC;
CDC* m_pDC;
<br />
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);<br />
afx_msg void OnDestroy();<br />
afx_msg void OnSize(UINT nType, int cx, int cy);<br />
afx_msg BOOL OnEraseBkgnd(CDC* pDC);<br />
afx_msg void OnMouseMove(UINT nFlags, CPoint point);<br />
afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);<br />
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);<br />
afx_msg void OnViewportColorchange();<br />
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);<br />
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);<br />
afx_msg void OnViewportScreenshot();<br />
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);<br />
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);<br />
DECLARE_MESSAGE_MAP()<br />
};<br />
<br />
<br />
<br />
#endif // !defined(AFX_MOTIONXGLVIEW_H__A90B4B55_D9F7_4DD4_A776_7EDC323D4724__INCLUDED_)<br />
<br />
This is the derived class.
<br />
<br />
#if !defined(AFX_MOTIONXMODELVIEW_H__AEBACD4C_059E_4D0D_8F56_6A4EFD2C25E9__INCLUDED_)<br />
#define AFX_MOTIONXMODELVIEW_H__AEBACD4C_059E_4D0D_8F56_6A4EFD2C25E9__INCLUDED_<br />
<br />
#if _MSC_VER > 1000<br />
#pragma once<br />
#endif // _MSC_VER > 1000<br />
<br />
#include "MotionXGLView.h"<br />
#include "MotionXModel.h"
<br />
class CMotionXModelView : public CMotionXGLView <br />
{<br />
public:<br />
CMotionXModel model;<br />
<br />
CMotionXModelView();<br />
virtual ~CMotionXModelView();<br />
<br />
};<br />
<br />
#endif // !defined(AFX_MOTIONXMODELVIEW_H__AEBACD4C_059E_4D0D_8F56_6A4EFD2C25E9__INCLUDED_)<br />
<br />
And this is my InitInstace code in my CMotionXApp class, that should tie the new class to the new document template:
<br />
m_pSceneTemplate = new CMultiDocTemplate(IDR_MOTIONTYPE,
RUNTIME_CLASS(CMotionXSceneDoc),
RUNTIME_CLASS(CChildFrame),<br />
RUNTIME_CLASS(CMotionXGLView) );
<br />
AddDocTemplate(m_pSceneTemplate);<br />
<br />
<br />
m_pModelTemplate = new CMultiDocTemplate(IDR_MOTIONTYPE,
RUNTIME_CLASS(CMotionXModelDoc),
RUNTIME_CLASS(CChildFrame),<br />
RUNTIME_CLASS(CMotionXModelView) );
<br />
Can anyone see what the problem is ??
|
|
|
|
|
NTense wrote:
//DECLARE_DYNCREATE(CMotionXModelView);
Uncomment this in your derived class, and add IMPLEMENT_DYNCREATE(CMotionXModelView, CMotionXGLView) in your .cpp file
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hi there!
Is there a way to obtain the parent process' handle using Win32 APIs?
One obvious way is to pipe the handle obtained by GetCurrentProcess() to the child process. But, I wanted to know if there's a direct way.
Thanks for your help!
Regards,
Sachin
|
|
|
|
|
Anonymous wrote:
Is there a way to obtain the parent process' handle using Win32 APIs?
Have you see the PROCESSENTRY32 structure, specifically the th32ParentProcessID member?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hello friends,
I had attend some interviews in recent time and faced one common question.
"When a database application can be developed using VB, then whats the advantage for using VC++ for that same application?"
Please tell me the advantage so that I can easily answer if the same question is asked
Thank you,
|
|
|
|
|
none.
except maybe if there's some sort of cross-platform compatibility needed on the front end.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
There's multi-threading of course.
VC++ clients can be made more UI responsive esp. if talking about large recordsets. Clever usage can help alleviate the annoying UI stalls.
Conversely, VC++ is much more costly to develop than VB (generally)
Cheers,
Andy
|
|
|
|
|
Neelesh K J Jain wrote:
"When a database application can be developed using VB, then whats the advantage for using VC++ for that same application?"
If the person doing the developing is more fluent in VC++, it will probably result in less cost, and quicker turn-around time.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Generally speaking, database access is far easier in VB than in VC++. Technologies such as ADO were built with ease-of-use for VB rather than C++.
Kevin
|
|
|
|
|
Neelesh K J Jain wrote:
whats the advantage for using VC++ for that same application?"
"whats THE advantage"?
There is no single advantage there are any number of them. Perhaps the most important would be that you were NOT developing in VB.
"for that same application"?
What are the rest of the requirements for the application?
I would seriously doubt the technical merit in that question and suspect a purely bias hidden agenda behind it. If that question is aimed at a technical issue that it is very poorly framed. It's as though the asker is expecting you to be thinking the same way he is. I find that to be an inappropriate question at best.
But, that's just my opinion... I could be wrong.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Hi,
i'm creating a jabber client (a chat tool, like icq or msn). In the app, i send info to a server, and i receive from it. I use MFC CSocket.
Is there any api function that checks if you are connected to internet?
thanks!!!
|
|
|
|
|
InternetGetConnectedState
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
thanks!
i looked it up in msdn ( http://msdn.microsoft.com/library/?url=/library/en-us/wininet/wininet/internetgetconnectedstate.asp) , and i don't understand the following:
lpdwFlags
[out] Pointer to a variable that receives the connection description. This parameter can be one or more of the following values.
Value Meaning
INTERNET_CONNECTION_CONFIGURED Local system has a valid connection to the Internet, but it might or might not be currently connected.
INTERNET_CONNECTION_LAN Local system uses a local area network to connect to the Internet.
INTERNET_CONNECTION_MODEM Local system uses a modem to connect to the Internet.
INTERNET_CONNECTION_MODEM_BUSY No longer used.
INTERNET_CONNECTION_OFFLINE Local system is in offline mode.
INTERNET_CONNECTION_PROXY Local system uses a proxy server to connect to the Internet.
INTERNET_RAS_INSTALLED Local system has RAS installed.
the following code always returns online.. any ideas?
unsigned long *a;
a=(unsigned long *)malloc(sizeof(unsigned long));
if (TRUE==InternetGetConnectedState(a,0))
AfxMessageBox("online");
else
AfxMessageBox("offline");
|
|
|
|
|
kfaday wrote:
I use MFC CSocket.
Over CAsyncSocket ? Why?
kfaday wrote:
Is there any api function that checks if you are connected to internet?
See here.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
|
And your point is? I'm aware of the downfalls of using CSocket , some of which aren't even mentioned in your article, but perhaps the OP is not.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
|
You know what would be great is if you could search for stuff on the internet instead of waiting for some nice person like you to provide a link to the page(s) of interest.
But, that's just my opinion... I could be wrong.
|
|
|
|
|
thanks for the link to the faq
#include <Wininet.h>
.
.
.
BOOL bConnected;
DWORD dwFlags;
bConnected = InternetGetConnectedState ( &dwFlags, 0 );
if ( bConnected )
if ( dwFlags & INTERNET_CONNECTION_OFFLINE )
bConnected = FALSE;
i get this error:
error C2065: 'INTERNET_CONNECTION_OFFLINE' : undeclared identifier
any ideas?
thanks!
|
|
|
|
|
I have an application that produces a calibrated tape. I am tying to impliment the ability to print this in mirror image as well. I call
<br />
void CTransformView::OnDraw(CDC* pDC)<br />
{<br />
pDC->SetMapMode(MM_LOENGLISH);<br />
SetGraphicsMode(pDC->GetSafeHdc(), GM_ADVANCED);<br />
SetWorldTransform(pDC->m_hDC, &XForm);<br />
...<br />
...<br />
}<br />
with XFORM structure filled out appropriately, and on screen everything is fine, however, with print and print previews, all text is simply rendered upsite down, not mirrored! In fact, simply creating a dummy application that does nothing but print a line of text to screen and draws a single line under it exhibits the same behavior if you make the call to SetGraphicsMode, (without any transform call). You will see your line of text as normal on screen with your line under it, but printing and print previews will show the line under your text printed upside-down. Has anybody come across this bug and found a work-around, or am I missing something? Sheesh, will these MS bugs never cease?
TIA Eric
|
|
|
|
|
hello, I'm interesting in delete the title bar of all windows (title, button minimice, button maximize,...,all thing). I`ve proven with diferent option, trying with case HCBT_CREATEWND OR HCBT_ACTIVATE but i can´t achive it. At the moment only I´ve achived that the hook CBT work´s.
Please can anyone help me?
Sorry for my english.
|
|
|
|
|
check my firewall done with the CBT function hope it will help you.
gabby
|
|
|
|
|
unsigned int GetOtherOffset( int index ) {<br />
byte array[8];<br />
unsigned long otherAddress;<br />
if ( ReadProcessMemory( g_hCurrentProcess, (void *) (g_uiOtherBaseOffset), (void *) array, 8, NULL ) ) {<br />
otherAddress = GetUnsignedLong( array );<br />
<br />
if ( ReadProcessMemory( g_hCurrentProcess, (void *) (otherAddress + 152416 + (index * 480)), (void *) array, 8, NULL ) ) {<br />
return GetUnsignedLong( array );<br />
}<br />
}<br />
return -1;<br />
}
I understand that in the first part, ReadProcessMemory gets the value from g_uiOtherBaseOffset and stores it as an Unsigned Long Labled "otheraddress".
What I have trouble understanding is the second part...this part.
if ( ReadProcessMemory( g_hCurrentProcess, (void *) (otherAddress + 152416 + (index * 480)), (void *) array, 8, NULL ) ) {<br />
return GetUnsignedLong( array );
So, it takes the value from 'otheraddress' and adds it to 152416.....then what? Where does the 'index' part come from? And why is it multiplied by 480?
|
|
|
|
|
'index' is the parameter passed into the GetOtherOffset function
unsigned int GetOtherOffset( int index )
I don't know why 152416 is being added to it, nor why index is multiplied by 480. That all seems very horribly hacky. What is the function used for? Maybe that will provide clues
|
|
|
|
|