|
Is there such a function or property?
|
|
|
|
|
*** WRONG FORUM. Sorry. C++ and C# look the same at first... ***
|
|
|
|
|
What do you want to know?
|
|
|
|
|
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.
![Sigh | :sigh:](https://www.codeproject.com/script/Forums/Images/smiley_sigh.gif)
|
|
|
|
|
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
|
|
|
|
|