|
Thanks for your reply. I checked the GetSystemTime description again and it doesn't return the time values according to local time so it's my fault to use that function over the GetLocalTime(). It's working now.
thanks.
|
|
|
|
|
You should use the GetLocalTime () function to get the local time. The GetSystemTime() function returns the time in UTC(Coordinated Universal Time )
|
|
|
|
|
Not sure that I was any help, but I'm glad you got it worked out. Always an adventure, ain't it?
|
|
|
|
|
nintendoWii wrote: For example if my time now is 5:14, and it only says 0:14
What timezone are you in?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Since IE7 provides tabs and yet, curiously, no tab API, I'm back in the all too familiar land of hacks and workarounds. Here's the current little jewel I'm grappling with. I navigate to a new page via IWebBrowser2::Navigate, specifying the flag to open in a new tab. This is a toolbar project, and IE actually creates a new instance for each tab.
Here's the problem. Normally, you'd check DISPID_DOCUMENTCOMPLETE and get the current url to know where you are. However, in this scenario, the url I've called with Navigate in tab 1 gets domain level redirected to a different domain / url in the destination tab 2.
What I need to know in the context of the new tab is the original url that was specified in the first tab. Unfortunately, none of the DISPID_... events I've tested allow me to determine what the original intent was before the redirect. At any point where I can get the current doc for this tab, it's already showing the domain redirect, not the original request. Given that there can be multiple tabs open, I haven't figured out any way for tab 2 to communicate with tab 1.
Any ideas on how to suss this out?
Thanks,
|
|
|
|
|
DISPID_BEFORENAVIGATE2 event is fired before navigating to a URL, It will be called several time before the final page due to redirect. The first event should be that of the url set in the Navigate() and then events for redirected urls. The advantage of DISPID_BEFORENAVIGATE2 is that you can cancel the redirection. please check whether the first event of DISPID_BEFORENAVIGATE2 has the original url.
|
|
|
|
|
Hi, Rajkumar.
Thanks for the idea. I'd actually checked this one, and the results are inconsistent. If I launch a new tab by calling Navigate(), this event is only fired once and a call to m_pBrowser->get_LocationURL(&bstrUrl); yields an empty string.
On the other hand, if I set the breakpoint and click on the link to CP from your email, it's called numerous times as you predicted.
In a third scenario, if I click the empty tab to create a new one, it's called with an empty string (not "about:Tabs"); When next navigating to a new page via the address bar UI, e.g. practicalusa.com, it is again only called once and yields not the practicalusa.com site, but rather the previously expected "about:Tabs."
And of course, this is all without even getting into the issue of domain level redirects. Consequently, I've not found a dependable way of determining what the original url was that I passed into Navigate().
Heaven forbid this should be easy.
|
|
|
|
|
Hi,
m_pBrowser->get_LocationURL(&bstrUrl); return the url the Webbrowser control is currently displaying, BeforeNavigate is the stage at which no url is Completed its Navigation or displayed (I think it updated after Navigate complete or Document complete). And that is the reason you got "about:Tabs." when you expected "practicalusa.com" since "about:Tabs." is the previous navigated url.
you need to check the parameter of the event, (second parameter url of BeforeNavigate2)
void DWebBrowserEvents2::BeforeNavigate2(
IDispatch *pDisp,
VARIANT *&url,
VARIANT *&Flags,
VARIANT *&TargetFrameName,
VARIANT *&PostData,
VARIANT *&Headers,
VARIANT_BOOL *&Cancel
);
I checked it in MFC classes, that get_LocationURL() returns empty string as you said.
the number of time event fired is inconsistent depends upon the number of redirects.
modified on Friday, May 9, 2008 12:55 AM
|
|
|
|
|
That was the silver bullet. Thanks, man - you rock!
|
|
|
|
|
how can I programmatically enable "File & Printer sharing for Microsoft Networks" ?
Are here any solution which works under XP and Vista ?
|
|
|
|
|
I have similiar question/problem about chars and LPTSTR.
I have some C++ code that copiles in Studio 6.0:
CWinApp *app = AfxGetApp();<br />
<br />
char m_commandLine[40];<br />
strcpy(m_commandLine, app->m_lpCmdLine);
but doesn't do so in Studio 2005:
error C2664: 'strcpy' : cannot convert parameter 2 from 'LPTSTR' to 'const char *'<br />
<br />
1> Types pointed to are unrelated;<br />
conversion requires reinterpret_cast, C-style cast or function-style cast
Rather than doing the "reinterpret_cast", is there some setting in compiler that I need regarding the workings with char *s, CStrings?
(I am running into char/CString problems porting to Studio 2005.)
Thanks in advance,
Johnny
|
|
|
|
|
How a LPTSTR maps to a character type is dependent on the definition of the macro _UNICODE.
With _UNICODE defined, the character type is wchar_t.
With _UNICODE not defined, the character type is char.
Your project has _UNICODE defined, so you're trying to copy a wchar_t array to
a char array. Not good (and a cast would mask the problem!).
See Generic-Text Mappings[^]
You could do something like this:
TCHAR commandLine[40];
strcpy(commandLine, app->m_lpCmdLine); // 2nd is LPTSTR and 1st is char [max]
or better yet:
CString commandLine(app->m_lpCmdLine);
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks! I will look through my settings (.vcproj and .sln) to see what is going on.
Best regards,
John
|
|
|
|
|
App which would work on every Windows system.
Will setting "include MFC as a static library" do the trick?
I had programs compiled with Debug and not Release and they didn't work on certain machines (without vs08 of course). I realize that they should be compiled in Release configuration, however now i want to be SURE, before I go and check it out (if won't work, it will be to late...).
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
gajatko wrote: I had programs compiled with Debug and not Release
Don't tell it toxcct or you'll be flamed.
Anyway you should never deploy debug builds of your applications.
Have a look at http://msdn.microsoft.com/en-us/library/ms235299.aspx[^]
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
|
|
|
|
|
gajatko wrote: App which would work on every Windows system.
Will setting "include MFC as a static library" do the trick?
Not necessarily. What if you are using an API or a function that is not supported on a particular platform? It wouldn't matter how you linked to the MFC libraries at that point.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I am looking for a way to override the maximize button for the main window in an MDI application. I have found several articles telling me how to override the maximize button for the child window, but not the main window. What I need is when the User clicks on the maximize button the application maximizes itself to two monitors instead of just one monitor. I hope that somebody can help me.
|
|
|
|
|
You need to handle the WM_SYSCOMMAND message.
void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
switch(nID)
{
case SC_MAXIMIZE:
break;
case SC_MINIMIZE:
break;
case SC_CLOSE:
break;
}
CFrameWnd::OnSysCommand(nID, lParam);
}
Best Wishes,
-David Delaune
|
|
|
|
|
Thank you that was extremely helpful
|
|
|
|
|
I need someone to please help me figure out how to get a TCHAR into a CString; when I will NOT know in advance what the TCHAR will be. Here's my code:
// SysData.h : header file
//
#pragma once
// CSysData
// Class that contains the System File Data
class CSysData
{
public:
// Functions:
CSysData(); // Default Constructor
~CSysData(); // Default Destructor
void CreateDirectoryName(CSysData cData);
void CleanUp(void);
// Copy Constructor:
CSysData(const CSysData& cSource);
// Assignment operator:
CSysData& operator= (const CSysData& cSource);
CString SetPathName(CString str);
//Varables:
CString m_csOperatorName;
CString m_csWellName;
CString m_csPath;
CString m_IsFileName;
CString m_csDirections;
CString m_csTanks;
};
Here's how I obtain the path:
CString CSystemDB::SetPath(CSysData cSysData)
{
CString str, str1, str2, str3;
str1 = _T("c:\\Wells\\Program\\DataBases\\Operators\\");
// Make path for SystemDB.bku file for each Operator:
str3 = "c:\\Wells\\Program\\DataBases\\SystemDB\\SystemDB.bku";
m_csSystemDB_BKU = str3;
// Make path for SystemDB.sdb file for each Operator:
str2 = "c:\\Wells\\Program\\DataBases\\Operator\\";
str2 += cSysData.m_csOperatorName;
str2 += _T("\\");
str2 += "SystemDB.sdb";
m_csSysNameTMP = str2;
str = str1;
str += cSysData.m_csOperatorName + _T("\\");
str += cSysData.m_csWellName;
str += _T("\\");
m_vSys.m_cSysData.m_csPath = str;
DoDirectory(m_vSys.m_cSysData);
// Now get the file filename:
cSysData.m_IsFileName = cSysData.m_csWellName;
cSysData.m_IsFileName += ".wdb";
m_csFileName = str;
}
The cSysData data was collected from dialog editbox input from the User.
now I must open a CStdioFile using a TCHAR filename. m_csFileName has that filename at this point, BUT it is not a TCHAR. How do I make it into a TCHAR? I simply don't know how. Mark showed me how to do it using the CString Constructor, but this is not possible after the CString has already been constructed.
Can someone please help me?
A C++ programming language novice, but striving to learn
|
|
|
|
|
sorry, i don't really get your question.
if you want to get a char (TCHAR) at a certain position, use CString::operator[]() or CString::GetAt()
if you want to retrieve a certain character (TCHAR), use CString::Find()
and please, please, PLEASE, format your code samples using <pre></pre> tags
|
|
|
|
|
Probably you need a const TCHAR * : just pass the CString itself.
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
|
|
|
|
|
Larry Mills Sr wrote: now I must open a CStdioFile using a TCHAR filename.
Why? What's wrong with:
CStdioFile file(m_csFileName, CFile::modeRead);
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Larry Mills Sr wrote: BUT it is not a TCHAR. How do I make it into a TCHAR?
Hello Larry,
You seem to reiterate the same questions regarding TCHAR which implies that you may be confused about the subject. First thing you should know is that technically there is no such thing as a TCHAR. TCHAR simply means "Template Character" and is simply a wrapper definition for both wchar_t and char based on whether or not UNICODE is defined. In other words if UNICODE is defined then TCHAR=wchar_t otherwise its a char.
All you need to do is enable unicode support in your project and CString will default to CStringW and TCHAR will default to wchar_t. Thats all you need to do. There are some functions which may require you to convert the wchar_t to multi-byte and if you run into these types of functions you can use my previous answer to convert the wchar_t to char[^].
Best Wishes,
-David Delaune
|
|
|
|
|
More here...[^]
Larry Mills Sr wrote: m_csFileName has that filename at this point, BUT it is not a TCHAR. How do I make it into a TCHAR?
Actually the character type of the string IS the same as TCHAR.
As David mentioned, a TCHAR is just a conditional macro whose resulting type is based
on whether the _UNICODE macro is defined or not. CString is the same - its
internal string character type is determined by the same Unicode macro being defined
or not defined.
I'm still not sure where in your code you think you need this "TCHAR"...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|