"Kelvin" <Ke****@discuss ions.microsoft. comwrote in message
news:87******** *************** ***********@mic rosoft.com...
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" <Ke****@discuss ions.microsoft. comwrote in message
news:82******** *************** ***********@mic rosoft.com...
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...
//-----------------------------------------------------
// FullScreenColor Wnd.h
//-----------------------------------------------------
#pragma once
#include "afxwin.h"
// CFullScreenColo rWnd
class CFullScreenColo rWnd : public CFrameWnd
{
DECLARE_DYNAMIC (CFullScreenCol orWnd)
public:
CFullScreenColo rWnd();
virtual ~CFullScreenCol orWnd();
protected:
DECLARE_MESSAGE _MAP()
virtual BOOL PreCreateWindow (CREATESTRUCT& cs);
public:
afx_msg int OnCreate(LPCREA TESTRUCT lpCreateStruct) ;
afx_msg BOOL OnEraseBkgnd(CD C* pDC);
afx_msg void OnLButtonDown(U INT nFlags, CPoint point);
CBrush m_BkgndBrush;
};
//-----------------------------------------------------
// FullScreenColor Wnd.cpp
//-----------------------------------------------------
#include "stdafx.h"
#include "FullScreenColo rWnd.h"
// CFullScreenColo rWnd
IMPLEMENT_DYNAM IC(CFullScreenC olorWnd, CFrameWnd)
CFullScreenColo rWnd::CFullScre enColorWnd()
{
m_BkgndBrush.Cr eateSolidBrush( RGB(0xFF,0x00,0 x00));
}
CFullScreenColo rWnd::~CFullScr eenColorWnd()
{
}
BEGIN_MESSAGE_M AP(CFullScreenC olorWnd, CFrameWnd)
ON_WM_ERASEBKGN D()
ON_WM_LBUTTONDO WN()
ON_WM_CREATE()
END_MESSAGE_MAP ()
// CFullScreenColo rWnd message handlers
BOOL CFullScreenColo rWnd::PreCreate Window(CREATEST RUCT& cs)
{
BOOL ret = CFrameWnd::PreC reateWindow(cs) ;
cs.style = WS_VISIBLE | WS_POPUP;
cs.dwExStyle = 0;
return ret;
}
int CFullScreenColo rWnd::OnCreate( LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnC reate(lpCreateS truct) == -1)
return -1;
HDC ScreenDC = ::GetDC(NULL);
MoveWindow(0, 0, ::GetDeviceCaps (ScreenDC, HORZRES),
::GetDeviceCaps (ScreenDC, VERTRES));
::ReleaseDC(NUL L, ScreenDC);
return 0;
}
BOOL CFullScreenColo rWnd::OnEraseBk gnd(CDC* pDC)
{
CRect CliRect;
GetClientRect(& CliRect);
pDC->FillRect(&CliR ect, &m_BkgndBrus h);
return TRUE;
}
void CFullScreenColo rWnd::OnLButton Down(UINT nFlags, CPoint point)
{
DestroyWindow() ;
}
//-----------------------------------------------------
// Example creating the window - click on the window to destroy it
//-----------------------------------------------------
CFullScreenColo rWnd *pFullScreenCol orWnd = new CFullScreenColo rWnd();
pFullScreenColo rWnd->Create(NULL, _T(""));
Mark
--
Mark Salsbery
Microsoft MVP - Visual C++
Thanks,
Tim