|
|
I can start a blank project, and have no problem using <complex> with anything I add. I can include it in the first source file I create, I can add a form to the project and use it in the form code file, I can link these things together, etc.
If I start a Net project I can add a generic C++ class and use <complex> therein, but any time I ntry to link this file to anything I get link errors. If I use <complex> in a form's code, or any other type of managed file, I get these same errors. I can copy code from another such project that I download, which works just fine, intop my own project, and it fails. These are typical.
delete3 fatal error LNK1120: 2 unresolved externals
delete3 error LNK2020: unresolved token (0A000016) delete
delete3 error LNK2020: unresolved token (0A000006) _CxxThrowException
Why?
I should mention that this is in VS 2003
Help please
|
|
|
|
|
If your are using static lib of you own (earlier version like VC 6 or 5) in VC.NET managed project. You will get some linker errors. Remedy is you need to rebuild your static lib with VC.NET.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Thank you for taking the time to respond.
Actually I have never had another version of VS installed on this computer.
|
|
|
|
|
Hi, I'm messing with some custom tooltips. Here's the situation:
In my application I'm showing certain items in a list ctrl. There's a note column and a (jpeg) preview column. Both should display tooltips. My idea was to override a CToolTipCtrl and the WM_PAINT message for that control. Then in OnToolHitTest I would test whether the mouse is hovering over a note or preview and it would fill the members (a jpeg image or string, depending on what I'm pointing at) and use either of these in the WM_PAINT handler.
Now, once I hovered over an existing note, the tooltip keeps displaying (I set it to trigger for the whole client rect), even though I keep returning -1 from OnToolHitTest. So I'm not really sure what I'm missing here, it does work for the first time though. But once a tooltip has been displayed, it's pretty much broken.
|
|
|
|
|
Why is it that I can't get this window to call OnSysCommand when the user clicks on the Close [X] button. Is there something wrong with my code that someone can point out or am I leaving something out? Thanks!
/*************************************/
CClass1.h
class CClass1: public CFormView
{
....code.....
protected:
// Generated message map functions
//{{AFX_MSG(Class1)
afx_msg void OnSysCommand(UINT nID,LPARAM lParam);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CClass1.cpp
BEGIN_MESSAGE_MAP(CClass1, CFormView)
//{{AFX_MSG_MAP(CClass1)
ON_WM_SYSCOMMAND()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CClass1::OnSysCommand(UINT nID, LPARAM lParam)
{
if(nID == SC_CLOSE) //Check If [X] Button
{
AfxMessageBox(_T("Hello"));
}
else
CFormView::OnSysCommand(nID, lParam);
}
|
|
|
|
|
From memory OnSysCommand() is called for items selected on the System Menu, not for the [x] Close button. Use WM_CLOSE (OnClose?) for that.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
I used Class Wizard to insert an On_WM_CLOSE OnClose() function but it doesn't call it at all when I click on [X]. Anything else I'm missing?
void CClass1::OnClose()
{
//perform actions before closing
CFormView::OnClose();
}
|
|
|
|
|
I have seen this type of problem.
If it is a Document.View app then look at CDocument::CanCloseFrame().
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
So I inserted the function into my code but nothing happens. It doesn't seem to call the function when [X] is clicked just like OnClose. What I am doing wrong?
BOOL CClass1::CanCloseFrame(CFrameWnd* pFrame)
{
...more code...
return TRUE;
}
|
|
|
|
|
Is CClass1 your CDocument class? ie. Is it derived from CDocument.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
|
And in your CClass1 it is virtual? ie.
virtual BOOL CanCloseFrame(CFrameWnd* pFrame);
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
|
Time to hop into the Debugger and look at the code for the FrameWindow's OnClose() which calls this function. All should become clear then.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Do you mean the CMainFrame::OnClose() calls the document view's OnClose function? How does that work?
|
|
|
|
|
Look at the MFC Source code for CFrameWnd::OnClose(). ED tells me this is in WINFRM.CPP
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
I created CanCloseFrame()in the document class. Within that function, how can I call the calling frame view's close function. For example, when I close CClass1 document view using [X], CanCloseFrame() from the document class is called. How do I know which frame or view called it so that I can call its corresponding OnClose function?
|
|
|
|
|
elephantstar wrote:
How do I know which frame or view called it so that I can call its corresponding OnClose function?
I don't think you can find this out. You need to go back and work out why the views OnClose() isn't being called. Again the MFC Source and VC++ Debugger are your friends here. Start by setting a breakpoint on CWnd::OnClose(), then CView::OnClose() etc.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
I have both OnSysCommand and CanCloseFrame but none of them work. When the window is closed, it calls CanCloseFrame, CFrameWnd::OnClose, and then CDocument::OnCloseDocument. I've been using the debugger but it's not helping at the moment. I'm back where I started.
|
|
|
|
|
You could try using CMyView::OnNcLButtonDown() to work out if the close button is pressed or code like:
BOOL
CMyView::IsMouseOnCloseButton()
{
BOOL bStat = FALSE;
if ( IsWindowVisible() )
{
CWnd* pFrameWnd;
POINT point;
GetCursorPos( &point );
if ( ( pFrameWnd = WindowFromPoint( point ) )->IsChild( this ) )
{
UINT nHitPos = pFrameWnd->SendMessage( WM_NCHITTEST, 0, MAKELPARAM( point.x, point.y ) );
bStat = nHitPos == HTCLOSE;
}
}
return bStat;
}
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
Handle WM_SYSCOMMAND for the FrameWindow(MainFrame or ChildFrame).
|
|
|
|
|
I tried that already when you had first suggested it but it doesn't work. I had the OnSysCommand() in both the CMainFrame and the document view class but it doesn't seem to call it.
By inserting CanCloseFrame() in the document class, the document view does call that function to determine if the view should be closed. My problem now lies in the many views that are attached to that document. How can I find out what the calling view was and from there, call its OnClose function that will perform some type of save before closing it.
|
|
|
|
|
One has to wonder why the "View" has data that needs to be saved. That's what the document is for.
If that is all you want to do then use CMyView::OnDestroy()
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
I used the View to transfer data to and from a struct. This is how I was told to do it but is it bad programming?
|
|
|
|