|
I would be grateful if anyone can help with this problem. I have an MFC Extension DLL called Base.DLL. It has a CFrameWnd derived class, CBaseFrameWnd. I next build a second MFC Extension DLL called Derived.DLL. In this DLL I add a class CDerivedFrameWnd, which is derived from CBaseFrameWnd. When I build Derived.DLL I get a problem at the linking stage...
DerivedFrameWnd.obj : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const CBaseFrameWnd::classCBaseFrameWnd" (?classCBaseFrameWnd@CBaseFrameWnd@@2UCRuntimeClass@@B)
DerivedFrameWnd.obj : error LNK2001: unresolved external symbol "protected: static struct AFX_MSGMAP const CBaseFrameWnd::messageMap" (?messageMap@CBaseFrameWnd@@1UAFX_MSGMAP@@B)
Can anyone explain what this is and how I can get round it? BTW, when I create a class derived from CBaseFrameWnd in an MFC AppWizard EXE project eveything works fine. I get no linker errors.
Thanks in advance.
|
|
|
|
|
The classXXX and messageMap symbols are the tip-off. I bet you forgot
DECLARE_DYNCREATE(CBaseFrameWnd)
in the class declaration, and
IMPLEMENT_DYNCREATE(CBaseFrameWnd, CFrameWnd)
in the .cpp file for the class. CDerivedFrameWnd will need similar lines (just change the class names).
|
|
|
|
|
Thanks for your reply. I used class wizard to add CBaseFrameWnd and CDerivedFrameWnd to BASE.DLL and DERIVED.DLL and so the DELCLARE_DYNCREATE and IMPLEMENT_DYNCREATE macros were added automatically.
When I first added CDerivedFrameWnd using class wizard, I specified the base class as CFrameWnd and then globablly replaced occurrences of CFrameWnd with CBaseFrameWnd. If I replace all occurrences of CFrameWnd except the two found in the IMPLEMENT_DYNCREATE and BEGIN_MESSAGE_MAP macros, then I get no linker errors. But this leads to problems like this...
I'm probably not understanding something quite fundamental here. I added a WM_CREATE handler in CBaseFrameWnd (OnCreate) which just does an AfxMessageBox. I would have thought that CDerivedFrameWnd should then show this message box when it is created. However, using the version that links (described above) - CDerivedFrameWnd does not display the message box (as expected, I suspect, as CFrameWnd is specified in the BEGIN_MESSAGE_MAP - not CBaseFrameWnd).
Thanks again for your help.
|
|
|
|
|
Mike, I searched the KB for "lnk2001 cruntimeclass derived" and found article Q128199 that might be of some help.
|
|
|
|
|
Many thanks, Mike. That KB article was exactly what I was looking for. The section "Limitations of _AFXEXT" solved my problems. Cheers!
|
|
|
|
|
I am trying to write a windows text editor that has a more attractive look (it looks a bit like sonique). But I am getting a memory leeks every time I redisplaying or resizing the app. I have separate functions to paint and resize the main window that I call when the appropriate message is sent to the app. And here seems to lie the problem because if I call them out side the msg look I don't get any memory leeks but it is very inefficient and untidy code. Here is the main gist of the message proc:
switch (uMsg)
{
case WM_PAINT:
DisplayWindow();
break;
case WM_MOUSEMOVE:
if (wParam == MK_LBUTTON)
{
SetWindowPos( hWnd,HWND_TOP,wdXPos,wdYPos,wdWidth,wdHeight,NULL);
} else {
CalcRGN(); // Calculate the windows new region
SetWindowPos( hWnd,HWND_TOP,wdXPos,wdYPos,wdWidth,wdHeight,NULL);
DisplayWindow();
}
}
Any help or a website that has got advanced windows programming tuts (ie stopping mem leeks) would be much appreciated
I am not using MFC because I want to learn as much about windows programming as possible.
|
|
|
|
|
From your code sniplet i can't see a leek, but the name of the function CalcRGN() suggest that you are using regions. A region is a resource which must be freed after using it, otherwise you get resource and memory leaks.
The leaks are caused by either of the function DisplayWindow() or CalcRGN() or both. Are you creating objects (regions or fonts ...)in those functions which are never released?
If you can't find anything then you better post the code of the two functions.
Hope this helps
|
|
|
|
|
Is it possible to make an item in a menu (CMenu ) visible/invisible at runtime (i.e. not just gray it out, but let it completely appear/disappear)?
|
|
|
|
|
It should be possible if you build your menu runtime (so, not with the resource editor).
Geert
|
|
|
|
|
When I add/remove it by code, I'm not really able to use the visual menu-resource editor and must do the creation of items by code.
So not the perfect solution. What I think about doing is deriving a class from CMenu and then add own functions to hide/show items. These can internally add/remove items but store them in member variables to make it transparent to the user.
|
|
|
|
|
Im having problems with recording sound using wavein functions in visual c++ 6.0 . Please help me if there is some
code in your pocession. I need to record the sound in buffers so that they can be sent to other computers
I'm not able to record the voice cause the callback (MM_WIM_DATA....) don't occur, Or I don't know
where to write them. Please give me information on how to play back without having breaks i the voice.
Thank you
|
|
|
|
|
You should review the web site of Reliable Software.
http://www.relisoft.com
They have many tutorials and discussions on writing 'reliable' software.
There are also C++ tutorial and C++ code sections.
Their page "Sampling Sound in Windows 32" will help you out.
http://www.relisoft.com/recorder.html
|
|
|
|
|
how is it with templates using?
then i use the same template in more source files it is expandend in every one of them (the same way) so final exe file is big(ger)?
do i understand it well?
is any optimalization/pragma what will say expand in this file only and all other files will take it a a extern?
thanks for reply
t!
|
|
|
|
|
How to easily but quickly rotate a DC or a bitmap by any angle ? Is there a ready made class somewhere ?
|
|
|
|
|
Hi,
I'm coding a Visual C++ Add-In, and I want to add a child
window, from my Add-In, to Visual C++. How can I do that?
How do I add docking control bar?
Thanks.
|
|
|
|
|
I am developing an application in which a user will edit some data which will later on be converted into a Microsoft Word document. The data will be stored in serializable classes. While I do use an edit control for simple text, how do I provide the interface of editing a table? shall I use a grid control? Or shall I how make my application OLE container into which the user edits the document using Word interface.........but if I take this approach, how can I serialize a Word object in my class.....My class which will hold the data (data which will be used to create a word document) is derived from CCmdObject and has many CString and CStringArrays. Right now I am just thinking of adding more CString and CStringArray which will hold some data and I will use automation to write the data in a Word document.
|
|
|
|
|
Hi,
when I print from my application, I always get 2 pages.
How do I resize the output so that it matches on one
page ?? (i.e. zooming to 75 % ??)
Thanks in advance,
Dennis Voss
|
|
|
|
|
hi!
i'm a newbie to win32 programming. :/
how do i use and translate accelerator keys?
i.e: pressing 'A' will bring up an open dialog, etc.
thanks.
|
|
|
|
|
I have (without success) been trying to use the SDK call GDIComment() (CDC::AddMetaFileComment()) to create groups in a drawing I put on the clipboard as a metafile. I'm sure I'm doing something stupid. Amazingly, there is little or no documentation of this in the Platform SDK.
Here is a simple example of what I'm trying to do (from OnDraw()), :
CPen pen(PS_SOLID, 2, RGB(0,0,0));
CPen* pOldPen = (CPen*)pDC->SelectObject(&pen);
#pragma pack(push, 1)
// byte array for begingroup
struct {
UINT ident;
DWORD iComment;
RECTL rclOutput;
DWORD nDescription;
} beginBuf;
// byte array for endgroup
struct {
UINT ident;
DWORD iComment;
} endBuf;
// if this is a metafile DC, create the first group
if (dynamic_cast<cmetafiledc*> (pDC))
{
beginBuf.ident = GDICOMMENT_IDENTIFIER;
beginBuf.iComment = GDICOMMENT_BEGINGROUP;
beginBuf.rclOutput.top = 0;
beginBuf.rclOutput.bottom = 200;
beginBuf.rclOutput.left = 0;
beginBuf.rclOutput.right = 200;
beginBuf.nDescription = 0;
BOOL bRet = ::GdiComment(pDC->GetSafeHdc(), sizeof(beginBuf), (const unsigned char *)&beginBuf);
if (!bRet)
{
ASSERT(0);
int iRet = GetLastError();
}
}
// draw an X
pDC->MoveTo(0,0);
pDC->LineTo(200,200);
pDC->MoveTo(200,0);
pDC->LineTo(0,200);
// end the first group
if (dynamic_cast<cmetafiledc*> (pDC))
{
endBuf.ident = GDICOMMENT_IDENTIFIER;
endBuf.iComment = GDICOMMENT_ENDGROUP;
BOOL bRet = ::GdiComment(pDC->GetSafeHdc(), sizeof(endBuf), (const unsigned char *)&endBuf);
if (!bRet)
{
ASSERT(0);
int iRet = GetLastError();
}
// begin the second group
beginBuf.ident = GDICOMMENT_IDENTIFIER;
beginBuf.iComment = GDICOMMENT_BEGINGROUP;
beginBuf.rclOutput.top = 205;
beginBuf.rclOutput.bottom = 415;
beginBuf.rclOutput.left = 0;
beginBuf.rclOutput.right = 200;
beginBuf.nDescription = 0;
bRet = ::GdiComment(pDC->GetSafeHdc(), sizeof(beginBuf), (const unsigned char *)&beginBuf);
if (!bRet)
{
ASSERT(0);
int iRet = GetLastError();
}
}
// draw an X further down the screen
pDC->MoveTo(0,210);
pDC->LineTo(200,410);
pDC->MoveTo(200,210);
pDC->LineTo(0,410);
// end the second group for a metafile DC
if (dynamic_cast<cmetafiledc*> (pDC))
{
endBuf.ident = GDICOMMENT_IDENTIFIER;
endBuf.iComment = GDICOMMENT_ENDGROUP;
BOOL bRet = ::GdiComment(pDC->GetSafeHdc(), sizeof(endBuf), (const unsigned char *)&endBuf);
if (!bRet)
{
ASSERT(0);
int iRet = GetLastError();
}
}
pDC->SelectObject(pOldPen);
|
|
|
|
|
Hi,
I'm writing an Add-In for Visual C++. I want to create a docking dialog bar of my own, that will dock the
Visual C++ window (similarly to the class/resource/file view dialog bar that's already there), but have
absolutely no idea how to idea. I've seen another Add-In that did it (it's commercial, so that there's no
source code).
There's an Add-In on this site (WinTabs) which implements a docking tab control. I tried to look for the
way it was done, but the code is rather complicated and big. I'm not even sure whether it would work for
a dialog bar.
Any help would be greatly appreciated
Thanks.
|
|
|
|
|
|
Thanks, but this doesn't help much, because what I'm trying
to do is create a child window (or a child dialog bar) to a
window from another process. Therefore, I have only a CWnd
object of that outer window but can't get its CFrameWnd.
|
|
|
|
|
We want to use some selfdefined ID's for the Toolbar Buttons.
Is there anything where I can look up the range of ID we are allowed to use?
We want to define them in a special header...
...like:
#define TOOLID_ZOOM 5666
Are there some ID's I am not allowed to use?
Is there anything about this in the MSDN (If...give me a keyword I can search for)
Thank you
|
|
|
|
|
TN020: ID Naming and Numbering Conventions
This note describes the ID naming and numbering conventions used by MFC 2.0 for resources, commands, strings, controls, and child windows.
Don't let the MFC 2.0 scare you, very little has changed...
|
|
|
|
|
Hello,
I need to write an MMC snapin in ATL. I've scanned the MSDN, but the samples are kind of tough. Does anybody know about a beginner tutorial? Or if anybody with experiences in writing MMC snapins can answer me some questions. Would be very helpfull.
Thanks a lot,
Matthias
|
|
|
|