|
Could do that, but:
1. They are still used in other programs too
2. Some of these programs have also already been built in Studio 2010 and they all work.....
William
|
|
|
|
|
Hi William,
Try linking your exe with Data Execution Prevention off: Project->Properties->Linker->Advanced->Data Execution Prevention (DEP)->No.
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
Hello everyone!
I am trying to alternate an SDI application which is used to operate a spectral camera as part of my diploma thesis. Since it's not my code entirely I tried to simulate a bit of the functionality I want add in a simpler example. So I created an MFC SDI application using Creation Wizard of Visual Studio 2005 (it's a bit old I know but what can you do...). The code I added implements a new class derived from CDialog which creates an invisible message-only, and posts/sends two user-defined messages. These two messages are supposed to be handled by an object of my class CInvisibleWnd. Everything seems to work fine (no errors and no warnings during building) and all my objects are successfully created but the code inside the event handlers is not reached! Do you have any suggestions?
Here's a code snippet of my added classes:
#define WM_MITSOS (WM_APP + 14)
#define WM_TAKIS (WM_APP + 15)
class CDialogMsg : public CDialog
{ DECLARE_DYNAMIC(CDialogMsg)
public:
CDialogMsg(CWnd* pParent = NULL);
virtual ~CDialogMsg();
enum { IDD = IDD_DIALOG_MSG };
CInvisibleWnd* pWnd;
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedOk();
afx_msg void OnBnClickedCancel();
afx_msg void OnBnClickedButtonCreate();
BEGIN_MESSAGE_MAP(CDialogMsg, CDialog)
ON_BN_CLICKED(IDOK, &CDialogMsg::OnBnClickedOk)
ON_BN_CLICKED(IDCANCEL, &CDialogMsg::OnBnClickedCancel)
ON_BN_CLICKED(IDC_BUTTON_CREATE, &CDialogMsg::OnBnClickedButtonCreate)
END_MESSAGE_MAP()
void CDialogMsg::OnBnClickedOk()
{
SendMessage(WM_MITSOS, (WPARAM)1, (LPARAM)3);
}
void CDialogMsg::OnBnClickedCancel()
{
SendMessage(WM_TAKIS, (WPARAM)2, (LPARAM)4);
}
void CDialogMsg::OnBnClickedButtonCreate()
{
pWnd = new CInvisibleWnd;
}
class CInvisibleWnd : public CWnd
{ DECLARE_DYNAMIC(CInvisibleWnd)
public:
CInvisibleWnd();
virtual ~CInvisibleWnd();
protected:
DECLARE_MESSAGE_MAP()
afx_msg LRESULT OnMitsos(WPARAM w, LPARAM l);
afx_msg LRESULT OnTakis(WPARAM w, LPARAM l);
};
IMPLEMENT_DYNAMIC(CInvisibleWnd, CWnd)
CInvisibleWnd::CInvisibleWnd()
{
CString wnd_class_name = ::AfxRegisterWndClass(NULL);
this->CreateEx(0,wnd_class_name,_T("CMyMessageOnlyWindowClass"),0 ,0 ,0 ,0 ,0 ,HWND_MESSAGE,0);
AfxMessageBox(_T("Invisible Window created!"));
}
BEGIN_MESSAGE_MAP(CInvisibleWnd, CWnd)
ON_MESSAGE(WM_MITSOS, &CInvisibleWnd::OnMitsos)
ON_MESSAGE(WM_TAKIS, &CInvisibleWnd::OnTakis)
END_MESSAGE_MAP()
LRESULT CInvisibleWnd::OnMitsos(WPARAM w, LPARAM l)
{
AfxMessageBox(_T("Hi Mitsos"));
return LRESULT(true);
}
LRESULT CInvisibleWnd::OnTakis(WPARAM w, LPARAM l)
{
AfxMessageBox(_T("Hi Takis"));
return LRESULT(true);
}
The CDialogMsg object is created by C"MyProjectName"Doc object...
I could not incorporate message-only CWnd to C"MyProjectName"Doc due to multiple inheritance which is, as I found out, very difficult to implement. The best source I found for message-only CWnd in MFC is here: How to make a Message Only Window
Any ideas?
Thank you very much!
Best Regards!
Ody -- Always look on the bright side of life --
modified on Thursday, June 23, 2011 11:40 AM
|
|
|
|
|
Possibly try something like, pWnd->SendMessage(...)?
|
|
|
|
|
Thank you very much! it worked and I just couldn't see that....
|
|
|
|
|
See my answer if you have some question as to why his code wasn't working. 
|
|
|
|
|
There's two ways to send messages in windows (not including PostMessage() ):
Using the WinAPI[^]
OR
Using MFC[^]
Each one can do pretty much the same thing. In your posted code, you're using the MFC version, but since you're calling the method internal to CDialogMsg , you're posting the message to that specific CDialogMsg object (you have him sending that message to himself), not to any CInvisibleWnd object.
How can you specify to send it elsewhere?
pWnd->SendMessage(...);
SendMessage( pWnd->GetSafeHwnd(), ...);
On a related note, you probably shouldn't name your messages with the "WM_" preffix, as that's there to indicate its an internal windows framework message.
|
|
|
|
|
Hi Developers,
Can anybody help me for a sample application of list control( Report View ) in MFC.
Actually I was handling a employee table. I want to show it's records in list control.
Thanks in Advance
|
|
|
|
|
|
Amrit Agr wrote: Can anybody help me for a sample application of list control( Report View ) in MFC.
See here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Hi Developers,
Suppose there is one text file in which I have stored database of Employee table like this:
EmpID EmpName Age Designation
101; Amrit; 23; Software Developer;
102; Ganesh; 25; Software Developer;
I want to take these record ( field by field ) based on these delimeter which is ;
Pls help me out to do that.
Thanks in advance.
|
|
|
|
|
Use string::getline to read the file line by line in a loop.
For each line read use the tokenize functions like strtok_s or wcstok_s with ; as the separator.
|
|
|
|
|
«_Superman_» wrote: For each line read use the tokenize functions like strtok_s or wcstok_s with ; as the separator.
Why not string::find_first_not_of ?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Well, why not?
In this case that will work since it is a single separator.
|
|
|
|
|
Yeap Thanks,
CString::Tokenize works better if we are getting the text in CSTring object, as I was using CStdioFile::readString().
|
|
|
|
|
This is a good answer, but I think it's interesting to mention that when dealing with large files, reading line-by-line will make this a very slow process.
Reading the file or a large part of it into memory and then scanning that would speed it up.
modified 13-Sep-18 21:01pm.
|
|
|
|
|
That is true, but Windows also does this for you by pre-fetching from disk to memory.
So even if you do this, the performance improvement may not be so great.
But you never know.
|
|
|
|
|
See the section titled "A string tokenizer" here.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
i have a project depend on converting mathematical C formula to mathematical formula used in calcualtors
for example
pow(x , 2 ) .....>x^2
the same as roots and all expreesions
which topics i must search ? must i search for tex and latex and MathML ?
help please
thnx in advance
|
|
|
|
|
You may try yourself to build a parser for.
What has it to do with TeX (i.e. formula used in calculators are pretty different by formula produced by TeX)?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
i cannot understand from where i must begin and what topics exactly i must know 
|
|
|
|
|
Is that homework (I mean do you need to write yourself the 'expression parser' or you may use a tool)?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
it's part of project i need write expreesion parser
|
|
|
|
|
The you may use a tool, like, for instance, Boost Spirit[^] or ANTLR[^] or the oldie-goldie bison[^]-flex[^] pair.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|