|
How to change menu background color in VC++
|
|
|
|
|
Dont need to ask again.
|
|
|
|
|
Rect rt(0,10,100,20);
TextureBrush br(&bm);
g.FillRectangle(&br,rt);
|
|
|
|
|
Hi,
try using
CBrush::CreatePatternBrush.
then use
void FillRect(
LPCRECT lpRect,
CBrush* pBrush
)
tio Fill the Rectangle.
thanks
Nitheesh
|
|
|
|
|
I'm using SYSTEMTIME to get the current time, but I'm unable to get Hour because it always returns 0. Do anybody know why?
<br />
SYSTEMTIME st;<br />
GetSystemTime(&st);<br />
DWORD hours = st.wHour;<br />
DWORD minutes = st.wMinute;<br />
For example if my time now is 5:14, and it only says 0:14
|
|
|
|
|
The first thing I'd suggest is setting a breakpoint and inspecting st in the debugger. I suspect you'll find that the hour data in the SYSTEMTIME struct is correct.
My gut instinct is that you have a bug in your string formatting statement. If you'll show me the full snippet, perhaps I'll notice something that you might have overlooked.
|
|
|
|
|
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
|
|
|
|