|
Folks,
Does anyone know who to disable the accelerator keys temporarily in a MFC application? I would like to disable the functionality of the entire menu bar when doing lengthy operation. Currently, I call the following function to disable the menu bar.
CMainFrame::EnableWindow ( FALSE );
Apparently, it works ok. The menu bar is grayed out and does not response to mouse clicks. However, when as user press "Alt", the menu bar turn ON again and start to operate. It seems like the "Alt" button enable the menu bar.
Anyway, to disable accelerator keys feature temporarily?
Thank you.
bluntagain
|
|
|
|
|
MSDN:
If the accelerator command corresponds to a menu item, the application is sent WM_INITMENU and WM_INITMENUPOPUP messages, as if the user were trying to display the menu. However, these messages are not sent if any of the following conditions exist:
The window is disabled.
The menu item is disabled.
The accelerator key combination does not correspond to an item on the window menu and the window is minimized.
A mouse capture is in effect. For information about mouse capture, see the SetCapture function.
So chose wisely!
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hi,
I have a VC++ project; I’m exporting a class with static public data members, declared in the .h file and initialized in it’s .cpp file. (OK)
When I see the dll’s depends it’s all ok; I can see the class and its attributes, but when I try to use it from another dll (like className::attributeName ), at I linking time, I got an ‘unresolved external symbol’ error, but it compiles well.
Can someone help me to resolve this?
Thanks
|
|
|
|
|
you need to create an import list for the linker to know what symbols you are linking from your DLL.
You can either report the symbols that you want to import in the import section of your .def file,
Or you can create a header file for you DLL that declares the symbols that you would like to import.
If you create a default DLL that exports some symbols in VC++, it creates a basic framework that will allow the same header file to be used in both the exported DLL and the imported EXE. This is done by changing the declspec(export) command to a declspec(import) with preprocessor defines
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I already tried that;
The situation is this:
I have a dll with several classes that I export (one of them is this one, with static members), and I’m using them from another dll. For the other classes I had no troubles (I included the header files and used them normally) but I don’t know what happens with this one.
I’ve tried:
- Include the class header file with __declspec(dllimport) in the dll that uses it
At linking time returns ‘error LNK2001: unresolved external symbol’
- Make a header file with extern sentence ( extern string className::attributeName; );
At compiling time returns: file.h(53) : error C2720: [attributeName] : 'extern ' storage-class specifier illegal on members
- The same header file, but with extern “C” sentence
( extern “C” string className::attributeName )
At linking time return:
file.obj : warning LNK4006: "public: static class string className::attributeName already defined in file2.obj; second definition ignored
I don’t know what else to do or try.
Paranoico? yo???
|
|
|
|
|
Hello!
I have an app which until recently have worked very well, but now I get an Unhandled Exception when I run the program in Release mode. It works in Debug mode. Since the error is in MFC and I can't find any of my code in the calling stack I'm stuck!
I get this error messages:
"Unhandled exception in COMSmartist.exe (MFC42.DLL): 0xC0000005: Access Error"
When I press OK I wind up in Wincore.cpp (line: 231).
The calling stack look like this:
AfxCallWndProc(CWnd * 0x00000000 {CWnd hWnd=???}, HWND__ * 0x046a0cc0, unsigned int 20, unsigned int 3422620807, long 0) line 231 + 10 bytes
AfxWndProc(HWND__ * 0x046a0cc0, unsigned int 20, unsigned int 3422620807, long 0) line 368
AfxWndProcBase(HWND__ * 0x046a0cc0, unsigned int 20, unsigned int 3422620807, long 0) line 220 + 21 bytes
USER32! 77e71303()
USER32! 77e71962()
NTDLL! 77f763ef()
CView::OnPaint(CView * const 0x00000007 {CView hWnd=???}) line 183
MFC42! 6c371fb5()
CWnd::WindowProc(CWnd * const 0x00000007 {CWnd hWnd=???}, unsigned int 15, unsigned int 0, long 0) line 1585 + 27 bytes
AfxCallWndProc(CWnd * 0x00000000 {CWnd hWnd=???}, HWND__ * 0x046a0cc0, unsigned int 15, unsigned int 0, long 0) line 218
AfxWndProc(HWND__ * 0x046a0cc0, unsigned int 15, unsigned int 0, long 0) line 368
AfxWndProcBase(HWND__ * 0x046a0cc0, unsigned int 15, unsigned int 0, long 0) line 220 + 21 bytes
USER32! 77e71303()
USER32! 77e71962()
NTDLL! 77f763ef()
AfxCallWndProc(CWnd * 0x00000000 {CWnd hWnd=???}, HWND__ * 0x046a0cc0, unsigned int 20, unsigned int 3422620807, long 0) line 231 + 10 bytes
AfxWndProc(HWND__ * 0x046a0cc0, unsigned int 20, unsigned int 3422620807, long 0) line 368
AfxWndProcBase(HWND__ * 0x046a0cc0, unsigned int 20, unsigned int 3422620807, long 0) line 220 + 21 bytes
USER32! 77e71303()
USER32! 77e71962()
NTDLL! 77f763ef()
CView::OnPaint(CView * const 0x00000007 {CView hWnd=???}) line 183
MFC42! 6c371fb5()
CWnd::WindowProc(CWnd * const 0x00000007 {CWnd hWnd=???}, unsigned int 15, unsigned int 0, long 0) line 1585 + 27 bytes
AfxCallWndProc(CWnd * 0x00000000 {CWnd hWnd=???}, HWND__ * 0x046a0cc0, unsigned int 15, unsigned int 0, long 0) line 218
AfxWndProc(HWND__ * 0x046a0cc0, unsigned int 15, unsigned int 0, long 0) line 368
AfxWndProcBase(HWND__ * 0x046a0cc0, unsigned int 15, unsigned int 0, long 0) line 220 + 21 bytes
USER32! 77e71303()
USER32! 77e71962()
NTDLL! 77f763ef()
If anyone can light some light about this I would be very greatful!
// Mike
Mike Eriksson
Sonork 100.21825
|
|
|
|
|
Just some first thoughts...
1. Had you noticed there seems to be some recursion here? Why does CView::OnPaint end up calling CView::OnPaint ??
2. Why is the CWnd * parameter to AfxCallWndProc = zero?
3. Why is the CWnd * parameter (this pointer) to CView::OnPaint = 7
Perhaps a breakpoint at line 183 of CView::OnPaint would help you to lever your way in.
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
Thank You!
This was just the help I needed to find the error! Which by the way was due to an attempt to do resizable windows and not understanding what I was doing I copied some code from CodeProject and now I can't find this article anymore. So maybe the author got the same error and revoked the article.
Anyway, thanks to your pointers I manage to make my application bug-free(.???.) AND resizable!
Mike Eriksson
Sonork 100.21825
|
|
|
|
|
Pleased to be able to help, and pleased to get your grateful reply.
Cheers!
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
It looks like an invalid window handle. Are you trying to draw something on the View before it has been properly created?
Michael
"Time and tide melts the snowman."
-- The Doctor (Doctor Who: Time and the Rani
|
|
|
|
|
In the following:
char* tempBuffer = NULL;
std::vector <char*> nBuffer;
int nRetNewDB;
CFileDialog fileDlg1(TRUE, ".*", NULL, OFN_EXPLORER|OFN_ALLOWMULTISELECT, "All Files(*.*)|*.*||",NULL);
nRetNewDB = fileDlg1.DoModal();
if (nRetNewDB == IDOK)
{
POSITION Pos;
Pos = fileDlg1.GetStartPosition();
while (Pos != NULL)
{
CString sPathName = fileDlg1.GetNextPathName(Pos);
int nSize = ReadPMAFile(sPathName, tempBuffer);
if(nSize !=0)
{
tempBuffer = new char[nSize+1];
ReadPMAFile(sPathName, tempBuffer);
nBuffer.push_back(tempBuffer);
}
}
}
I am getting compile errors regarding 'new':
c:\program files\microsoft visual studio\vc98\include\new(35) : error C2061: syntax error : identifier 'THIS_FILE'
c:\program files\microsoft visual studio\vc98\include\new(35) : error C2091: function returns function
c:\program files\microsoft visual studio\vc98\include\new(35) : error C2809: 'operator new' has no formal parameters
help! I've used 'new' a thousand times but somethings gone wrong here.....
Thanks,
ns
|
|
|
|
|
Are u using namespace std??
And i see that ur vector isnt given a type, why??
Deal with the first error first:
identifier 'THIS_FILE'
And generaly u gotta move some header include before or after
#define THIS_FILE
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
the vector does have a type: char* but CP did something to the angled brackets...
I dont have anything fancy in my includes:
#include "stdafx.h"
#include "FreadTest.h"
#include "FreadTestDoc.h"
#include "FreadTestView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
#include <vector>
Oh gosh! I had to move the #include vector to above the #ifdef stuff. Now its compiling. Thanks for the juggling hint. Its bizarre!
Thanks,
ns
|
|
|
|
|
Had that and fixed it that way, i guess its mainly that vector needs to see THIS_FILE [] = __FILE__; so better let him have it!
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hello!
I'm overriding OnActivateView function in my CFormView derived class, and it is in that function that i'm creating and displaying some objects, the number of objects depends on a database query. In order to resize my form, i must have its CRect parameters.
Inside OnActivateView i do : GetClientRect(&myRect);, but all the size parameters (left, top, right, bottom) are equal to 0.
Maybe i'm wrong but i understand that these values should only be available when OnActivateView is finished.
My question: Is there an onverride for CFormView that is called after OnActivateView and where CRect parameters are available?
Thank you in advance
|
|
|
|
|
Why dont u do all this work in OnDraw??
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Well, i'm a beginner and, I want to execute the following piece of code just after OnActivateView. I am not sure about OnDraw(). I tried placing the code in OnDraw() but I got a flickering screen.
CRect myRect;
CSize mySize;
GetClientRect(&myRect);
if (myRect.bottom<=y) //y is the vertical position of my last object
{
myRect.bottom+=200;
MoveWindow(&myRect, TRUE);
mySize=myRect.Size();
SetScrollSizes(MM_TEXT, mySize);
GetParentFrame()->RecalcLayout();
}
What am I doing wrong?
Thanks for your trouble.
|
|
|
|
|
u are flickering i guess cos
MoveWindow( LPCRECT lpRect, BOOL bRepaint = TRUE );
This means that ur sending a WM_PAINT message froom within the OnDraw, try changing it to FALSE
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
I tried that, with and without GetParentFrame()->RecalcLayout();
And in none of those ways i got satisfactory results.
I'm doing like :
void CStocks::OnDraw(CDC* /*pDC*/)
{
CRect myRect;
CSize mySize;
GetClientRect(&myRect);
if (myRect.bottom<=m_iLastY)
{
myRect.bottom+=500;
MoveWindow(&myRect, FALSE);
mySize=myRect.Size();
SetScrollSizes(MM_TEXT, mySize);
//GetParentFrame()->RecalcLayout();
}
}
After OnActivateView is finished, i have the final value for m_iLastY, and then iwant to use it to resize, is there an alternative to OnDraw?
Am i doing something wrong?
Thank again
|
|
|
|
|
Check void ResizeParentToFit( BOOL bShrinkOnly = TRUE ); guess it could help u
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Thanks again Papa!
But i don't think i must use OnDraw, i just want to find a way of calling some code after OnActivateView is finished.
Is that possivel?...I even thougth on using timers...
Thanks
|
|
|
|
|
First I dont see a flag or anything telling CFile::Read that its reading binary data, and not text. I read a binary file into a char*a: I need to know, knowing the length of the cFile object thats been opened, what size to make a:
say nSize (from GetLength) is n. Then do I say
a = new char[n+1];
or
a = new char[n];
When I read text data in, I have to put a[n] = 0 ; to null terminate it. DO i do the same in case of a binary file?
Thanks,
ns
|
|
|
|
|
ur binary file already contains NULL chars in it, so why add one??
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
From the SDK: 'FILECORE.CPP'
BOOL CFile::Open(LPCTSTR lpszFileName, UINT nOpenFlags,
CFileException* pException)
{
ASSERT_VALID(this);
ASSERT(AfxIsValidString(lpszFileName));
ASSERT(pException == NULL ||
AfxIsValidAddress(pException, sizeof(CFileException)));
ASSERT((nOpenFlags & typeText) == 0); // text mode not supported
// CFile objects are always binary and CreateFile does not need flag
nOpenFlags &= ~(UINT)typeBinary;
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Okay. That helps a lot.
Thanks,
ns
|
|
|
|
|