Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / April 2008

Tip: Looking for answers? Try searching our database.

an application to detect dead pixels of LCD pixel

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kelvin - 10 Apr 2008 15:48 GMT
Hi all,

I am writing an application to detect the dead pixel of LCD panel by using
visual C++ (MFC). My flow is follow:

1. Display a dialog with a start button. When the user press the start
button. The whole screen become black colour.
2. When the user press any key by keyboard. The whole screen changes to red
then green, blue and white.
3. The screen back to "normal display".

I am a newbie in visual c++, so i don't know how to write the code to
achieve points 2 and 3.

Can anyone know how to write code for this application?

Thank a lot.
Mark Salsbery [MVP] - 10 Apr 2008 18:27 GMT
> Hi all,
>
[quoted text clipped - 10 lines]
> I am a newbie in visual c++, so i don't know how to write the code to
> achieve points 2 and 3.

Fill screen with red:

    CWnd DesktopWnd;
    DesktopWnd.Attach(::GetDesktopWindow());
    CWindowDC DesktopDC(&DesktopWnd);
    CBrush RedBrush(RGB(0xFF,0x00,0x00));
    CRect DesktopRect;
    DesktopWnd.GetWindowRect(&DesktopRect);
    DesktopDC.FillRect(&DesktopRect, &RedBrush);
    DesktopWnd.Detach();

Restore screen to normal display:

    ::InvalidateRect(NULL, NULL, TRUE);

BTW, there's an MFC newsgroup:  microsoft.public.vc.mfc

Mark

Signature

Mark Salsbery
Microsoft MVP - Visual C++

> Can anyone know how to write code for this application?
>
> Thank a lot.
Ben Voigt [C++ MVP] - 10 Apr 2008 19:19 GMT
>> Hi all,
>>
[quoted text clipped - 21 lines]
> DesktopDC.FillRect(&DesktopRect, &RedBrush);
> DesktopWnd.Detach();

Don't try to draw on the desktop window, create your own fullscreen window.

> Restore screen to normal display:
>
[quoted text clipped - 7 lines]
>>
>> Thank a lot.
Mark Salsbery [MVP] - 10 Apr 2008 19:53 GMT
>>> Hi all,
>>>
[quoted text clipped - 24 lines]
> Don't try to draw on the desktop window, create your own fullscreen
> window.

Sure, take away all my fun. :)

Cheers,
Mark

Signature

Mark Salsbery
Microsoft MVP - Visual C++

>> Restore screen to normal display:
>>
[quoted text clipped - 7 lines]
>>>
>>> Thank a lot.
Kelvin - 11 Apr 2008 04:49 GMT
Hi,

Thanks for your help!

Sorry that I still don't know how to "make" the whole screen to become black
when pressing the start button.

Could you told me how to achieve this?

Thanks a lot.

> >>> Hi all,
> >>>
[quoted text clipped - 41 lines]
> >>>
> >>> Thank a lot.
Kelvin - 11 Apr 2008 04:52 GMT
My code is follow:

void CTestScreenDlg::OnButtonStart()
{
    // TODO: Add your control notification handler code here
    CWnd DesktopWnd;
    DesktopWnd.Attach(::GetDesktopWindow());
    CWindowDC DesktopDC(&DesktopWnd);
    CBrush RedBrush(RGB(0xFF,0x00,0x00));
    CRect DesktopRect;
    DesktopWnd.GetWindowRect(&DesktopRect);
    DesktopDC.FillRect(&DesktopRect, &RedBrush);
    DesktopWnd.Detach();

}

but i cannot make the whole screen become red......

> Hi,
>
[quoted text clipped - 52 lines]
> > >>>
> > >>> Thank a lot.
Mark Salsbery [MVP] - 11 Apr 2008 06:29 GMT
That code worked for me, but as Ben mentioned, you should create a window,
make it the size of the screen, and do the drawing on that window.

The system refreshes the desktop when you draw on it, at least it did to me
on Vista :)

Mark

Signature

Mark Salsbery
Microsoft MVP - Visual C++

> My code is follow:
>
[quoted text clipped - 74 lines]
>> > >>>
>> > >>> Thank a lot.
Kelvin - 14 Apr 2008 05:56 GMT
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?

Thanks,
Tim

> That code worked for me, but as Ben mentioned, you should create a window,
> make it the size of the screen, and do the drawing on that window.
[quoted text clipped - 82 lines]
> >> > >>>
> >> > >>> Thank a lot.
Mark Salsbery [MVP] - 22 Apr 2008 22:23 GMT
> Hi Marks,
>
[quoted text clipped - 3 lines]
> 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::PreCreateWindow(CREATESTRUCT& cs)
{
    BOOL ret = CFrameWnd::PreCreateWindow(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

Signature

Mark Salsbery
Microsoft MVP - Visual C++

> Thanks,
> Tim

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.