Kelvin said:
Hi all,
I am trying to create a new window (without border, title bar..etc) for
using brush to make the whole screen become red.
So, anyone knows how to create a new window after pressing a buttom in a
diglog??
Thanks,
I don't know if this helps, but here's a copy of my reply to your previous
thread:
Kelvin said:
Hi Marks,
Thanks a lot. I can use the code to display red color on the entire
screen.
But, how to create a window, make the size of the screen and retrieves the
device context (DC) for that window?
Hi Tim,
Sorry for the delayed reply. I was out of town all last week.
If you still need an example of creating a full screen colored window,
here's some code...
//-----------------------------------------------------
// FullScreenColorWnd.h
//-----------------------------------------------------
#pragma once
#include "afxwin.h"
// CFullScreenColorWnd
class CFullScreenColorWnd : public CFrameWnd
{
DECLARE_DYNAMIC(CFullScreenColorWnd)
public:
CFullScreenColorWnd();
virtual ~CFullScreenColorWnd();
protected:
DECLARE_MESSAGE_MAP()
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
public:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
CBrush m_BkgndBrush;
};
//-----------------------------------------------------
// FullScreenColorWnd.cpp
//-----------------------------------------------------
#include "stdafx.h"
#include "FullScreenColorWnd.h"
// CFullScreenColorWnd
IMPLEMENT_DYNAMIC(CFullScreenColorWnd, CFrameWnd)
CFullScreenColorWnd::CFullScreenColorWnd()
{
m_BkgndBrush.CreateSolidBrush(RGB(0xFF,0x00,0x00));
}
CFullScreenColorWnd::~CFullScreenColorWnd()
{
}
BEGIN_MESSAGE_MAP(CFullScreenColorWnd, CFrameWnd)
ON_WM_ERASEBKGND()
ON_WM_LBUTTONDOWN()
ON_WM_CREATE()
END_MESSAGE_MAP()
// CFullScreenColorWnd message handlers
BOOL CFullScreenColorWnd:
reCreateWindow(CREATESTRUCT& cs)
{
BOOL ret = CFrameWnd:
reCreateWindow(cs);
cs.style = WS_VISIBLE | WS_POPUP;
cs.dwExStyle = 0;
return ret;
}
int CFullScreenColorWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
HDC ScreenDC = ::GetDC(NULL);
MoveWindow(0, 0, ::GetDeviceCaps(ScreenDC, HORZRES),
::GetDeviceCaps(ScreenDC, VERTRES));
::ReleaseDC(NULL, ScreenDC);
return 0;
}
BOOL CFullScreenColorWnd::OnEraseBkgnd(CDC* pDC)
{
CRect CliRect;
GetClientRect(&CliRect);
pDC->FillRect(&CliRect, &m_BkgndBrush);
return TRUE;
}
void CFullScreenColorWnd::OnLButtonDown(UINT nFlags, CPoint point)
{
DestroyWindow();
}
//-----------------------------------------------------
// Example creating the window - click on the window to destroy it
//-----------------------------------------------------
CFullScreenColorWnd *pFullScreenColorWnd = new CFullScreenColorWnd();
pFullScreenColorWnd->Create(NULL, _T(""));
Mark