|
An SDI project without doc-view support.
MFC doesn't call OnKeyDown either in CChildView or CMainFrame.
|
|
|
|
|
Add a WM_SYSKEYDOWN handler to your CChildView or CMainFrame and you will be able to process the down event of VK_F10.
|
|
|
|
|
I'll try.
But now I process VK_F1 VK_F2 VK_UP etc. in OnKeyDown,
if it works, they would be in differents places, OnSysKeyDown and OnkeyDown.
|
|
|
|
|
Yes, it's ok, but amazing,
the function
<br />
void OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)<br />
makes no flags, then how mfc knows not to process as before
|
|
|
|
|
I am not sure what you mean by "then how mfc knows not to process as before". MFC doesnt do anything here, Windows does it. I cant find the documentation of it, but I think it has something to with Accessibilty Features. Pressing F10 switches the focus to the Menu, thus its a SYSKEY event.
|
|
|
|
|
After adding OnSysKeyDown in CChildview, it is local, except the the message map is changed, I think MFC detect the message map to determine whether to pop up the menu when F10 is pressed, becasue there no other info tell the program not to pop up the menu when F10 is pressed.
|
|
|
|
|
I had the same problem. When more than one view are used, the typical OnKeyDown / Up work only in the MainView, thats the one connected with the Document from the beggining.
If you want to use keydowns in other places, you should code the PreTranslateMessage and send the message to the place you want to execute by yourself.
Or use a trick (not very elegant, but it works): If you just need "some" few keys to execute something across the views. You can add a HotKey to the programm, that will ensure that ALL views get a message when that key is pressed.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Hello. I want to clear the command console in my C++ programs, and my research shows that I need to use the statements "using namespace System" during the include section and in the function, to clear the console, I use "System.Console.Clear();". I am using Visual C++ 8 express beta orcas edition, and I am getting a compiler error: cannot find System. Is there somewhere I can download the System namespace? Or is there another way to clear the command console? Any help is appriciated.
|
|
|
|
|
Hi,
either you are creating a managed .NET application (C++/CLI) in which case "using System"
is automatically present and included (and you are asking in the wrong forum),
or you want an unmanaged app (C++/MFC) in which case there is no "using System" involved,
you are in the right forum, and I don't know the answer, except maybe this will help[^].
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
If it is already present, shouldn't I be able to do something like System.Console.Clear, or System::Console.Clear, etc. to clear the command console? Both of those give me no such thing as System.
|
|
|
|
|
first decide and tell whether your app is unmanaged or managed code!
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
This is a C++/CLI question, please post in the correct forum.
Anyways:
using namespace System;
int main(array<System::String ^> ^args)
{
Console::WriteLine(L"Hello World");
Console::Clear();
return 0;
}
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
I have an SDI and want to get a pointer to class SDIDoc .
If I was creating a new class instance from within SDIDoc , I would do the following:
SomeClass* pSC = new SomeClass;
Then I would have a pointer pSC to the new instance of SomeClass .
But, since SDIDoc already exists, and I am within SDIDoc , how do I get a pointer to SDIDoc ?
In SDIDoc.h I have the following:
SDIDoc* pSDIDoc;
In SDIDoc.cpp , I am looking for the following:
pSDIDOC = ???????
Thanks
|
|
|
|
|
pSDIDoc=this;
(or I don’t understand the question )
|
|
|
|
|
From MSDN,
All nonstatic member functions can use the this keyword, which is a const (nonmodifiable) pointer to the object for which the function was called.
...
Occasionally, the this pointer is used directly — for example, to manipulate self-referential data structures, where the address of the current object is required.
|
|
|
|
|
Hi,
I did it within the stdafx.cpp , the #include MyDocument.h should be in stdafx to do this
CMyDoc* pMyDoc;
In your CMyView::OnInitialUpdate () just make
extern CMyDoc* pMyDoc;
pMyDoc = GetDocument ();
ASSERT (pMyDoc);
if it is made correctly, you have Doc access from every class using it.
I.E.
class CMyObject : public CObject
{
public:
void MyMethode ();
}
void CMyObject::MyMethode ()
{
extern CMyDoc* pMyDoc;
any_local_variable = pMyDoc->a_document_variable;
return;
}
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Hi
am developing an application with MFC and i need to know how can i run the registered web browser and pass a url to naviagate to it.
thanks a lot
|
|
|
|
|
why not using this :
::ShellExecute(null, _T("open"), t("http://www.codeproject.com"), null, null, SW_SHOWNORMAL);
|
|
|
|
|
Hi
thanks a lot, that worked well
thanks again
|
|
|
|
|
Tarek Jabri wrote: ...i need to know how can i run the registered web browser...
See here.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I create a windows form application named p2pport.
and I want to use the Message Map of MFC.
so I use MFC with shared DLL and include afxwin.h.
But When I compile it, it says that
Debug Assertion Failed
File : dbgheap.c
line 144
Expression : _CrtIsValidHeapPointer(pUserData)
I find it is because of the afxwin.h.
I google it and found that it is a bug that was reported to MSDN.
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=99715[^]
I use that method to replace the main function and put #include <afxwin.h> in stdfax.h file.
My original code is
#include "stdafx.h"<br />
#include "Dlg.h"<br />
<br />
using namespace p2pport;<br />
[STAThreadAttribute]<br />
<br />
int main(void)
{<br />
Application::EnableVisualStyles();<br />
Application::SetCompatibleTextRenderingDefault(false); <br />
<br />
Application::Run(gcnew Dlg());<br />
CMFCApp k;<br />
return 0;<br />
}
And I modify it.
#include "stdafx.h"<br />
#include "Dlg.h"<br />
<br />
using namespace p2pport;<br />
<br />
[STAThreadAttribute]<br />
class CMFCApp : public CWinApp<br />
{<br />
public:<br />
virtual BOOL InitInstance()<br />
{<br />
Application::EnableVisualStyles();<br />
Application::SetCompatibleTextRenderingDefault(false);<br />
return FALSE;<br />
}<br />
}theApp;
But it comes the error.
error C3115: 'System::STAThreadAttribute': this attribute is not allowed on 'theApp'
I delete the [STAThreadAttribute] .
It comes another two errors.
error LNK2001: unresolved external symbol _main
fatal error LNK1120: 1 unresolved externals
I dont know how to solve it. I stuck it all day.
Can anybody help me to solve the problem.
Appreciate for ur reply
Thx.
Jane
|
|
|
|
|
|
Hello everyone,
Could dumpbin be used to check whether an executable or a DLL (written in Visual Studio C/C++ native unmanaged) is debug version or release version? I use /headers option but can not see any differences.
If dumpbin can not be used to check debug or release, any other tool could be used?
thanks in advance,
George
|
|
|
|
|
Hi Luc,
Here is my test result, and debug version/release version are of different size.
1. I have dumped debug and release version, the both of them has only one existence of word *debug*, here it is
24000 [ 1C] RVA [size] of Debug Directory
2. See (1);
3. What do you mean *the presence of the PDB file name at the end of the exe*, could you show more information please?
regards,
George
|
|
|
|
|
Hi George,
my hex viewer shows this as the very last few bytes in a debug exe:
01EFF0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 "................"
01F000 4E 42 31 30 00 00 00 00 53 3D A9 3F 03 00 00 00 "NB10....S=.?...."
01F010 48 3A 5C 4C 50 5F 70 72 6F 6A 65 63 74 73 5C 5F "H:\LP_projects\_"
01F020 70 75 7A 7A 6C 65 73 5C 62 65 65 6C 64 7A 6F 65 "puzzles\beeldzoe"
01F030 6B 65 72 5C 44 65 62 75 67 5C 62 65 65 6C 64 7A "ker\Debug\beeldz"
01F040 6F 65 6B 65 72 2E 70 64 62 00 "oeker.pdb. "
so what I am suggesting is you either use such tool to look, or you programmatically
verify the file ends on "2E 70 64 62 00"
BTW: I am not sure this ".PDB == debug build" relation always holds true
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|