|
Member 8109560 wrote: Is it the one in the title bar
Not necessarily; you can find it out using Spy++, or programmatically with, for instance:Get a handle on your window and use GetWindowText().
|
|
|
|
|
Same behavior when specifying my window as target.
|
|
|
|
|
1) how about Navigate2("http://www.xxx.com"...)?
2) try OnNewWindow3 please.
|
|
|
|
|
Thanks for your help, but still no luck.
Implemented a handler for the NewWindow3 event but it seems that the event is not fired.
Tried with Navigate2("http://www.codeproject.com") but same behaviour (source code shown in notepad).
When trying to open local file it is downloaded to temporary internet files and then opened in IE.
|
|
|
|
|
The behavior sounds like that the Win7 default shell operation not correctly set.
Can you check the registry for the default value of HKEY_CLASSES_ROOT\htmlfile\shell
[HKEY_CLASSES_ROOT\htmlfile\shell]
@="opennew"
or you can try on another Win7 machine?
|
|
|
|
|
Thanks again.
Checked the registry value: was OK. Checked on another Win7 system: same behaviour.
Created a new blank SDI-App with a CHtmlView derived View. Same code like in my original app:
CHtmlViewTest::OnInitialUpdate()
{
CHtmlView::OnInitialUpdate();
Navigate2(_T("http://www.codeproject.com"));
}
The source code of the page is opened in notepad.
If I use a local html file, it is displayed correctly.
|
|
|
|
|
It's really very strange...
Because CHtmlView::Navigate2 just a wrapper of IWebBrowser2::Navigate2
Maybe you need to step into the Navigate2 call.
or just call IWebBrowser2::Navigate2 directly and see what will happened.
Unfortunately I does not have Win7 on hand. So, can not help you more.
|
|
|
|
|
I've just tried to call Navigate2 in the CHtmlView and the IWebBrowser2 with all the same behavior.
I come to think that it might be some user permissions thing on Windows 7. Maybe my app is not allowed to open websites? Does anyone know which permissions have to be granted? I've checked the I[Internet Explorer\Main\FEATURE_...] stuff but did not find something appropriate.
I had a look on the process creation and following happened:
After my Navigate2 call an iexplore process was created and this one created another iexplore process that then showed my page.
modified on Thursday, August 25, 2011 3:16 AM
|
|
|
|
|
Wild guess:
CHtmlView::Navigate2(fileName);
Just in case there is another Navigate2 around.
|
|
|
|
|
I have an MDI project, that obvioulsy can open more then one document open ... but the request is to could be open only one ... how can I do that ?
Let say that we have open a first document file, and if the user want to create a new document or open an existing document file, should close all documents and let the user to create or open another document ...
I override OnFileNew() and OnFileOpen() from CMyDocument class, but I can't create or open documents then ... there is another solution ?
Thank you.
|
|
|
|
|
Flaviu2 wrote: another solution ?
Please check the behavior of notepad.exe .
It is concepted as SDI application
They sought it with thimbles, they sought it with care;
They pursued it with forks and hope;
They threatened its life with a railway-share;
They charmed it with smiles and soap.
|
|
|
|
|
Though, I need a MDI application that should open a single document at time ...
|
|
|
|
|
Then please post your overwritings here
They sought it with thimbles, they sought it with care;
They pursued it with forks and hope;
They threatened its life with a railway-share;
They charmed it with smiles and soap.
|
|
|
|
|
Well, if I map OnFileOpen like this (trying to close all documents first) :
protected:
afx_msg void OnFileOpen();
DECLARE_MESSAGE_MAP()
and
BEGIN_MESSAGE_MAP(CMyDoc, CDocument)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
END_MESSAGE_MAP()
void CMyDoc::OnFileOpen()
{
theApp.CloseAllDocuments(TRUE);
}
I can not open any files ...
|
|
|
|
|
Try it now :
void CMyDoc::OnFileOpen()
{
theApp.CloseAllDocuments(TRUE);
CDocument::OnFileOpen();
}
They sought it with thimbles, they sought it with care;
They pursued it with forks and hope;
They threatened its life with a railway-share;
They charmed it with smiles and soap.
|
|
|
|
|
I try this too but I get follow error :
void CMyDoc::OnFileOpen()
{
theApp.CloseAllDocuments(TRUE);
CDocument::OnFileOpen();
}
...
|
|
|
|
|
... and so ? :
void CMyDoc::OnFileOpen()
{
theApp.CloseAllDocuments(TRUE);
theApp.OnCmdMsg(ID_FILE_OPEN, 0, NULL, NULL);
}
They sought it with thimbles, they sought it with care;
They pursued it with forks and hope;
They threatened its life with a railway-share;
They charmed it with smiles and soap.
|
|
|
|
|
All I try to do is to close all documents open on file new and file open handler ... and after that, of course, let user to create or open an existing document ...
|
|
|
|
|
If you never want to open more than one document then why are you using an MDI application? The logical (and sensible) answer is to change your app to be SDI. Alternatively you can make it more complex than necessary by adding some global flags to prevent opening more than one document at a time.
|
|
|
|
|
Because the application must have more then one kind of document ...
|
|
|
|
|
Hi,
Since I knew The Code Project, it has been helpful a lot.
Now I think I have a small misunderstanding about pointer to member function in a struct and I need your help, which will be priceless to me.
I am simply trying to see how pointer to member function works and it seems a little tricky.
The code I am having a problem with is below.
#include <iostream>
#include <conio.h>
#define KEY_ESC 27
using std::cout;
using std::endl;
class CAccount;
struct StateMap
{
int input;
void (CAccount::*mfp)();
};
class CAccount
{
public:
enum
{
STATE_IDLE,
STATE_INPUT,
STATE_WAIT_ACK
};
public:
StateMap map[3];
int m_iState;
CAccount();
void OnIdle();
void OnInput();
void OnWaitAck();
};//class CAccount
CAccount::CAccount(){
map[0].input = 1;
map[0].mfp = &CAccount::OnIdle;
map[1].input = 2;
map[1].mfp = &CAccount::OnInput;
map[2].input = 3;
map[2].mfp = &CAccount::OnWaitAck;
m_iState = STATE_IDLE;
}
void CAccount::OnIdle()
{
cout << "OnIdle()" << endl;
}
void CAccount::OnInput()
{
cout << "OnInput()" << endl;
}
void CAccount::OnWaitAck()
{
cout << "OnWaitAck()" << endl;
}
int main()
{
int ch = 0;
int i;
CAccount account;
while ( ch != KEY_ESC )
{
ch = _getch();
i = 0;
while ( account.map[i].input != 0 )
{
if ( ch == account.map[i].input )
{
(account.(map[i].*mfp))(); // compile error
}//if
i++;
}//while
}//while
return 0;
}//main()
I just don't know the right syntax for that part.
How should I change that error line to make it work?
Thanks in advance.
|
|
|
|
|
Try the following :
typedef void (*LPSTATEPROC) (void);
struct StateMap
{
int input;
LPSTATEPROC mfp;
};
They sought it with thimbles, they sought it with care;
They pursued it with forks and hope;
They threatened its life with a railway-share;
They charmed it with smiles and soap.
|
|
|
|
|
Thanks.
Eugen Podsypalnikov wrote: typedef void (*LPSTATEPROC) (void);
You meant this, right?
typedef void (CAccount::*LPSTATEPROC) (void);
But it seems like it doesn't still work and the error occurs at the same line.
#include
#include
#define KEY_ESC 27
using std::cout;
using std::endl;
class CAccount;
typedef void (CAccount::*LPSTATEPROC) (void);
struct StateMap
{
int input;
LPSTATEPROC mfp;
};
class CAccount
{
public:
enum
{
STATE_IDLE,
STATE_INPUT,
STATE_WAIT_ACK
};
public:
StateMap map[3];
int m_iState;
CAccount();
void OnIdle();
void OnInput();
void OnWaitAck();
};//class CAccount
CAccount::CAccount(){
map[0].input = 1;
map[0].mfp = &CAccount::OnIdle;
map[1].input = 2;
map[1].mfp = &CAccount::OnInput;
map[2].input = 3;
map[2].mfp = &CAccount::OnWaitAck;
m_iState = STATE_IDLE;
}
void CAccount::OnIdle()
{
cout << "OnIdle()" << endl;
}
void CAccount::OnInput()
{
cout << "OnInput()" << endl;
}
void CAccount::OnWaitAck()
{
cout << "OnWaitAck()" << endl;
}
int main()
{
int ch = 0;
int i;
CAccount account;
while ( ch != KEY_ESC )
{
ch = _getch();
i = 0;
while ( account.map[i].input != 0 )
{
if ( ch == account.map[i].input )
{
(account.(map[i].*mfp))(); // compile error
}//if
i++;
}//while
}//while
return 0;
}//main()
How can I change that error line to make it work?
Thanks!
|
|
|
|
|
I think the line:
(account.(map[i].*mfp))();
should not use indirection, and should read:
(account.(map[i].mfp))();
|
|
|
|
|