Click here to Skip to main content
15,886,137 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Getting a disabled CView to give a strong visual cue of being disabled, so that the user understands that it isn't a bug that it's disabled. Pin
Michael Dunn20-May-09 10:43
sitebuilderMichael Dunn20-May-09 10:43 
GeneralRe: Getting a disabled CView to give a strong visual cue of being disabled, so that the user understands that it isn't a bug that it's disabled. Pin
Sternocera20-May-09 11:32
Sternocera20-May-09 11:32 
GeneralRe: Getting a disabled CView to give a strong visual cue of being disabled, so that the user understands that it isn't a bug that it's disabled. Pin
Sternocera20-May-09 11:56
Sternocera20-May-09 11:56 
AnswerRe: Getting a disabled CView to give a strong visual cue of being disabled, so that the user understands that it isn't a bug that it's disabled. Pin
Stuart Dootson20-May-09 11:39
professionalStuart Dootson20-May-09 11:39 
GeneralRe: Getting a disabled CView to give a strong visual cue of being disabled, so that the user understands that it isn't a bug that it's disabled. Pin
Sternocera20-May-09 12:10
Sternocera20-May-09 12:10 
GeneralRe: Getting a disabled CView to give a strong visual cue of being disabled, so that the user understands that it isn't a bug that it's disabled. Pin
Stuart Dootson20-May-09 13:22
professionalStuart Dootson20-May-09 13:22 
GeneralRe: Getting a disabled CView to give a strong visual cue of being disabled, so that the user understands that it isn't a bug that it's disabled. Pin
Sternocera20-May-09 22:58
Sternocera20-May-09 22:58 
GeneralRe: Getting a disabled CView to give a strong visual cue of being disabled, so that the user understands that it isn't a bug that it's disabled. Pin
Stuart Dootson21-May-09 0:56
professionalStuart Dootson21-May-09 0:56 
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)
{
   // Don't let the window close - might want to modify slightly...
   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:

// Main-frame OnMove handler
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);
      }
   }
}

// View's OnMove and OnSize handlers
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

GeneralRe: Getting a disabled CView to give a strong visual cue of being disabled, so that the user understands that it isn't a bug that it's disabled. Pin
Sternocera21-May-09 3:35
Sternocera21-May-09 3:35 
QuestionHow to manipulate with processes from your app? Any help is appreciated Pin
Oshtri Deka20-May-09 7:55
professionalOshtri Deka20-May-09 7:55 
AnswerRe: How to manipulate with processes from your app? Any help is appreciated Pin
Stuart Dootson20-May-09 8:16
professionalStuart Dootson20-May-09 8:16 
GeneralRe: How to manipulate with processes from your app? Any help is appreciated Pin
Oshtri Deka20-May-09 22:38
professionalOshtri Deka20-May-09 22:38 
AnswerRe: How to manipulate with processes from your app? Any help is appreciated Pin
ThatsAlok20-May-09 21:42
ThatsAlok20-May-09 21:42 
GeneralRe: How to manipulate with processes from your app? Any help is appreciated Pin
Oshtri Deka20-May-09 22:41
professionalOshtri Deka20-May-09 22:41 
QuestionCEdit with image suport? Pin
bosfan20-May-09 7:24
bosfan20-May-09 7:24 
AnswerRe: CEdit with image suport? Pin
David Crow20-May-09 7:43
David Crow20-May-09 7:43 
AnswerRe: CEdit with image suport? Pin
Nuri Ismail20-May-09 7:50
Nuri Ismail20-May-09 7:50 
QuestionConvert C++ from VisC++ 6 to VS 2008 [modified] Pin
gartnerj20-May-09 6:49
gartnerj20-May-09 6:49 
AnswerRe: Convert C++ from VisC++ 6 to VS 2008 Pin
David Crow20-May-09 7:42
David Crow20-May-09 7:42 
GeneralRe: Convert C++ from VisC++ 6 to VS 2008 Pin
gartnerj20-May-09 8:02
gartnerj20-May-09 8:02 
AnswerRe: Convert C++ from VisC++ 6 to VS 2008 Pin
led mike20-May-09 7:53
led mike20-May-09 7:53 
GeneralRe: Convert C++ from VisC++ 6 to VS 2008 Pin
gartnerj20-May-09 8:00
gartnerj20-May-09 8:00 
GeneralRe: Convert C++ from VisC++ 6 to VS 2008 Pin
led mike20-May-09 8:48
led mike20-May-09 8:48 
GeneralRe: Convert C++ from VisC++ 6 to VS 2008 Pin
gartnerj20-May-09 8:55
gartnerj20-May-09 8:55 
AnswerRe: Convert C++ from VisC++ 6 to VS 2008 Pin
Stuart Dootson20-May-09 8:24
professionalStuart Dootson20-May-09 8:24 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.