|
How about overlaying the view with a 50% gray, 50% opaque window (see WS_EX_LAYERED[^] and SetLayeredWindowAttributes[^])? That's kind of what Safari (the web browser) does when you click on a bookmarked site that it has a preview for - looks kind of cool.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Stuart,
That's interesting. How could this overlaying effect be achieved? calls to CWnd::SetLayeredWindowAttributes() don't seem to be affect my CView in anyway:
SetLayeredWindowAttributes(RGB(50,50,50), 100, WS_EX_LAYERED);
Equally, calling the Win32 API equivalents doesn't have any discernable effect:
HWND hwnd = GetSafeHwnd();
::SetWindowLong(hwnd, GWL_EXSTYLE,
::GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_LAYERED);
::SetLayeredWindowAttributes(hwnd, 0, (255 * 70) / 100, LWA_ALPHA);
Regards,
Sternocera
|
|
|
|
|
Sorry - wasn't quite clear enough. Create another window. Make it the same size and position as your view, but put it on top of it. Make it layered, 50% gray, 50% opaque.
The reason your trials didn't work is (I think) because you can't apply WS_EX_LAYERED to a child window - my own experiments (with a trial SDI app) indicate that. So, you'd need to set that style on your CMainFrame.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Sorry Stuart, but I'm going to need you to be clearer still. What sort of window class would I create, and how? What about resizing of my CMainFrame, wouldn't I have to resize my overlaying windows as my underlying view changed shape?
Regards,
Sternocera
|
|
|
|
|
Sternocera wrote: Sorry Stuart, but I'm going to need you to be clearer still. What sort of window class would I create, and how?
This (Win32 code) seems to work nicely enough and shows how to register the window class and create the window:
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == WM_CLOSE) return 0;
return DefWindowProc(hWnd, message, wParam, lParam);
}
BOOL CreateLayeredWindow(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = &WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = 0;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_BTNTEXT+1);
wcex.lpszMenuName = 0;
wcex.lpszClassName = _T("layered");
wcex.hIconSm = 0;
RegisterClassEx(&wcex);
const DWORD screenWidth = GetSystemMetrics(SM_CXSCREEN);
const DWORD screenHeight = GetSystemMetrics(SM_CYSCREEN);
hWnd = CreateWindowEx(WS_EX_LAYERED|WS_EX_TOOLWINDOW, _T("layered"), _T("layered"), WS_POPUPWINDOW,
screenWidth/4, screenHeight/4, screenWidth/2, screenHeight/2, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
SetLayeredWindowAttributes(hWnd, 0, 0xc0, LWA_ALPHA);
ShowWindow(hWnd, nCmdShow);
return TRUE;
}
You will probably need to replace hInstance by AfxGetModuleState()->m_hCurrentInstanceHandle and there're probably advantages to making the layered windows parent be one of your application's windows (mainly ensuring the window z-order is sane).
Sternocera wrote: What about resizing of my CMainFrame, wouldn't I have to resize my overlaying windows as my underlying view changed shape?
Yes - that's not too much of a problem - in your view's OnSize handler, just get the view's window rect (GetWindowRect) and tell the overlay to move itself there. You also need to handle the main frame's OnMove handler similarly - here's what I've got in a sample app:
void CMainFrame::OnMove(int x, int y)
{
CFrameWndEx::OnMove(x, y);
if (const MSG* msg = GetCurrentMessage())
{
if (CView* activeView = GetActiveView())
{
activeView->SendMessage(msg->message, msg->wParam, msg->lParam);
}
}
}
void CsdihiderView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
OverlayHider();
}
void CsdihiderView::OnMove(int x, int y)
{
CView::OnMove(x, y);
OverlayHider();
}
void CsdihiderView::OverlayHider()
{
if (hider_)
{
CRect windRect;
GetWindowRect(&windRect);
::SetWindowPos(hider_, HWND_TOP, windRect.left, windRect.top, windRect.Width(), windRect.Height(), SWP_NOACTIVATE);
}
}
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks a lot for that Stuart. I'll see what I can come up with,
Regards,
Sternocera
|
|
|
|
|
The problem: big bad legacy application with code written from 1996 onward.
Application starts another process (utility app written on .Net), original idea was to start utility app in background during loading time and to close it when main application is closing.
Now someone wants ability to close it whenever one wants.
All that is rather simple to comprehend, but what worries me how to inform main application that utility app is closed?
Main app has utility's process handle and it made me to believe everything will be easy...
This is code for utility start:
void CFireAdder::StartService(void)
{
CString planBrowserPath;
#ifdef DEBUG
planBrowserPath = CUtils::AddPathToWorkingPath("Debug\\FireAdder");
#else
planBrowserPath = CUtils::AddPathToWorkingPath("FireAdder");
#endif
planBrowserPath = CUtils::AddFilenameToPath(planBrowserPath,"FireAdder.exe");
TRACE("starting planbrowser... ");
_process=(HANDLE)_spawnl(_P_NOWAIT,planBrowserPath,"FireAdder",NULL);
WaitForInputIdle(_process,INFINITE);
TRACE("... started\n");
}
And this is little piece of code I've written for getting utility's window handle:
HWND CFireAdder::getWindowHandle()
{
if(_process == (HANDLE) -1) return NULL;
DWORD procID = GetProcessId(_process);
if(procID > 0){
HWND hw = FindWindow("WindowsForms10.Window.8.app.0.378734a","FireAdder - pregled reklama");
return hw;
}
_process = (HANDLE) -1;
return NULL;
}
I though I could use same recipe for checking if utility app is closed, but above mentioned code does not return NULL, I thought GetProcessID will return 0!
Can someone tell me how to check whether utility process is still active in more inteligent way?
I am .Net brat with limited C++ Windows programming experience.
Excuse me for bad grammar or spelling, I am in a hurry.
|
|
|
|
|
You've got a process handle - you can use GetExitCodeProcess[^] to see if the process has termnated or not - GetExitCodeProcess returns TRUE and the output status is STILL_ACTIVE if the process is still there.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thank you! It works as expected.
|
|
|
|
|
try using IsWindow api
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
I'll try it later, so far above mentioned solution satisfies me.
|
|
|
|
|
Hello,
i search for a CEdit control that have a image suport, mean, i need to set image and text in that!
Is there any known project on server?
Thanks for any help!
termal
|
|
|
|
|
termal wrote: i search for a CEdit control that have a image suport, mean, i need to set image and text in that!
Perhaps you need a rich edit control.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
|
Folks,
I have a VERY OLD legacy app that I'm trying to compile under VS 2008 (I am NOT an MFC developer at all).
I am running into build errors on things like:
<br />
template <> void AFXAPI ConstructElements <SubjectUsage> (SubjectUsage * pSubName, int nCount)<br /> NOTE: Edited this to correct the line
ERRORS for this is:
C2143 Syntax error: missing ";" before "<"
C2182: "ConstructElements: illegal use of type 'void'
C2988: unrecognizable template declaration/definition
I know NOTHING about the AFXAPI, but the file does have an
<code>#include <afxtempl.h> </code>
Any help greatly appreciated, and in general, any words of wisdom from moving from VC++6 to VS2008?
modified on Wednesday, May 20, 2009 2:06 PM
|
|
|
|
|
gartnerj wrote: template <> void AFXAPI ConstructElements (SubjectUsage * pSubName, int nCount)
There appears to be something missing from this statement. Try clicking the "Do not interpret HTML..." checkbox, and use the Verify button.
gartnerj wrote: C2143 Syntax error: missing ";" before "<"
It looks as though the compiler does not know what SubjectUsage is.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Well, I didn't include all of the code, but the SubjectUsage class is defined right above this line in the file, so that shouldn't be an issue.
This code DOES compile in Visual C++ 6.0. I'm sure there must be differences with C++ and with the MFC supplied with VS 2008 that is causing this -- not sure if there are any project switches to set for compatibility?
Also, the CORRECT statement that has the errors is:
template <> void AFXAPI ConstructElement <SubjectUsage> (SubjectUsage * pSubUsage, int nCount)
Sorry about that!
|
|
|
|
|
|
Thanks -- I did read those pages, but not a lot of info on using old MFC with VS 2008.
|
|
|
|
|
gartnerj wrote: but not a lot of info on using old MFC with VS 2008.
Yes but old MFC is just C++. Stuart has provided the pinpoint documentation for you so you can move on. If you find other problems they will be similar because VC6 did not fully implement the C++ Standards. I don't believe 2008 does either but it implements much more which can produce compiler errors in old code due to the compiler enforcing more standards. Each version of VC since 6 has been more compliant so as in this example the documentation might be version specific since it was changed in a specific version.
|
|
|
|
|
Thanks -- yeah that link really helped!
I guess I was hoping that there would be some sort of compatibility mode setting for the compiler/project to allow this to work with minimal change, but I don't think that's possible!
|
|
|
|
|
This page[^] tells you what to do - basically, don't use ConstructElements any more!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks -- VERY helpful!!!
|
|
|
|
|
hi there,
I have compiled a string table and some of the strings I need to assign to a char* variable, how can I do it?
Thanks
Jim
|
|
|
|
|
What about LoadString [^] function?
(LPTSTR resolves to char * for a ANSI build)
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
[My articles]
|
|
|
|
|