472,791 Members | 1,547 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,791 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 3065

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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?

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.