473,394 Members | 1,697 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Drawing on transparent window

Hi,

I have this kind of class:

// SplashWnd.cpp : implementation of the CSplashWnd class

//

/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"

#include "CapturePrevWnd.h"

#include "Resource.h"

#ifdef _DEBUG

#define new DEBUG_NEW

#undef THIS_FILE

static char THIS_FILE[] = __FILE__;

#endif

/////////////////////////////////////////////////////////////////////////////

// CSplashWnd class

CCapturePrevWnd* CCapturePrevWnd::m_pSplashWnd = NULL;

CCapturePrevWnd::CCapturePrevWnd()

{

start.SetPoint(0,0);

end.SetPoint(0,0);

}

CCapturePrevWnd::~CCapturePrevWnd()

{

// Clear the static window pointer.

ASSERT(m_pSplashWnd == this);

m_pSplashWnd = NULL;

}

BEGIN_MESSAGE_MAP(CCapturePrevWnd, CWnd)

//{{AFX_MSG_MAP(CSplashWnd)

ON_WM_CREATE()

ON_WM_PAINT()

ON_WM_LBUTTONDOWN()

ON_WM_LBUTTONUP()

ON_WM_MOUSEMOVE()

//}}AFX_MSG_MAP

END_MESSAGE_MAP()

void CCapturePrevWnd::ShowCaptureScreen(CWnd* pParentWnd /*= NULL*/)

{

if (m_pSplashWnd != NULL)

return;

// Allocate a new splash screen, and create the window.

m_pSplashWnd = new CCapturePrevWnd;

if (!m_pSplashWnd->Create(pParentWnd))

delete m_pSplashWnd;

else m_pSplashWnd->UpdateWindow();

}

BOOL CCapturePrevWnd::Create(CWnd* pParentWnd /*= NULL*/)

{

return CreateEx(0,

AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW |CS_DBLCLKS,
AfxGetApp()->LoadStandardCursor(IDC_CROSS)),

NULL, WS_POPUP | WS_VISIBLE | WS_EX_TRANSPARENT | WS_BORDER |
WS_MAXIMIZE,
0, 0, 0, 0,

pParentWnd->GetSafeHwnd(), NULL);

}

void CCapturePrevWnd::HideCaptureScreen()

{

// Destroy the window, and update the mainframe.

DestroyWindow();

AfxGetMainWnd()->UpdateWindow();

}

void CCapturePrevWnd::PostNcDestroy()

{

// Free the C++ class.

delete this;

}

int CCapturePrevWnd::OnCreate(LPCREATESTRUCT lpCreateStruct)

{

if (CWnd::OnCreate(lpCreateStruct) == -1)

return -1;

// Center the window.

//CenterWindow();

return 0;

}

void CCapturePrevWnd::OnPaint()

{

CRect selRect = GetSelRect();

if(!selRect.IsRectEmpty())

{

CClientDC dc(this);

//dc.SetROP2(R2_NOTXORPEN);

dc.DrawFocusRect(&selRect);

}

}

void CCapturePrevWnd::OnLButtonDown(UINT nFlags, CPoint point)

{

start = end = point;

Invalidate();

UpdateWindow();

}

void CCapturePrevWnd::OnMouseMove(UINT nFlags, CPoint point)

{

switch(nFlags)

{

case MK_LBUTTON:

end = point;

Invalidate();

UpdateWindow();

break;

}

}

void CCapturePrevWnd::OnLButtonUp(UINT nFlags, CPoint point)

{

end = point;

CRect rect = GetSelRect();

if(!rect.IsRectEmpty())

{

CBitmap bitmap;

CClientDC dc(NULL);

CDC memDC;

CBitmap* pOldBitmap;

memDC.CreateCompatibleDC(&dc);

bitmap.CreateCompatibleBitmap(&dc, rect.Width(),rect.Height() );

pOldBitmap = memDC.SelectObject(&bitmap);

memDC.BitBlt(0, 0, rect.Width()-2,rect.Height()-2, &dc, rect.left+1,
rect.top+1, SRCCOPY);


OpenClipboard() ;

EmptyClipboard() ;

SetClipboardData (CF_BITMAP, bitmap.GetSafeHandle() ) ;

CloseClipboard () ;

memDC.SelectObject(pOldBitmap);

bitmap.Detach();

}

HideCaptureScreen();

}

CRect CCapturePrevWnd::GetSelRect()

{

return CRect(min(start.x,end.x), min(start.y,end.y),

max(start.x,end.x), max(start.y,end.y));

}

this class is suppose to give an ability to draw rectangle on the
desktop
(on top of everything).

All works well except: when I'm drawing the rectangle with mouse the
transparent window doesn't remove the old, already drawn, rectangles in
order
to draw a new one with right dimensions.

All rectangles from every redraw are staing on the window.

How do I solve this problem?

Sep 15 '06 #1
1 3109

Sh******@gmail.com wrote:
Hi,

I have this kind of class:

implementation of the CSplashWnd class
What is CSplashWnd? It's not part of the standard.
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
Oh, must be some sort of Windows header.
this class is suppose to give an ability to draw rectangle on the
desktop
(on top of everything).

All works well except: when I'm drawing the rectangle with mouse the
transparent window doesn't remove the old, already drawn, rectangles in
order
to draw a new one with right dimensions.

All rectangles from every redraw are staing on the window.

How do I solve this problem?
By asking in a windows group. This is off topic here.

-Brian

Sep 15 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: news.microsoft.com | last post by:
Hello group, My goal is to attach an image over another image. Top image should be transparent so the back image is visible through the top one. Bellow is a test code in VB.NET. You need to...
1
by: David Hoffer | last post by:
I am creating a custom user control and I am having problems with setting the transparent color of the bitmap. Here is my code... protected override void OnPaint( PaintEventArgs e ) { ...
0
by: Mike Starkey | last post by:
I have created a transparent control and I am using to to create drawing objects Inside the transparent objects I have created I am trying to using the draw shapes oval, rectangle etc. An example...
3
by: Peter Oliphant | last post by:
I'm importing a jpeg via: Bitmap* image = new Bitmap( filename ) ; Then, using the Drawing::Graphics object, I execute DrawImage( image, x, y ). My problem is that the original image was...
0
by: eruess | last post by:
Here's the scenario: I've got a whole bunch (for the sake of argument, let's say thousands) of different little 32x14 .png files that act as buttons all over a very large website. Each button...
4
by: Brian Henry | last post by:
I have an icon I want to draw onto the screen, but I want to streatch it out to be about 256x256 and make it about 75% transparent how would I go about this? do i need to convert it to a bitmap...
3
by: kamleshgk | last post by:
Hi, I have a requirement to draw a rectangle and a line on a the container control and sometimes as i move the mouse the drawing must occur on top of user controls and other controls, which are...
4
by: Dale | last post by:
I am creating GIF images with transparent backgrounds on-the-fly for a web app and rendering them by using System.Drawing.Image.Save(Response.OutputStream, ImageType.GIF). I am confident that...
7
by: raylopez99 | last post by:
I have a logical drawing space much bigger than the viewport (the screen) and I'd like to center the viewport (the screen) to be at the center of the logical drawing space. After following the...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.