473,653 Members | 2,989 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 ::CCapturePrevW nd()

{

start.SetPoint( 0,0);

end.SetPoint(0, 0);

}

CCapturePrevWnd ::~CCapturePrev Wnd()

{

// Clear the static window pointer.

ASSERT(m_pSplas hWnd == this);

m_pSplashWnd = NULL;

}

BEGIN_MESSAGE_M AP(CCapturePrev Wnd, CWnd)

//{{AFX_MSG_MAP(C SplashWnd)

ON_WM_CREATE()

ON_WM_PAINT()

ON_WM_LBUTTONDO WN()

ON_WM_LBUTTONUP ()

ON_WM_MOUSEMOVE ()

//}}AFX_MSG_MAP

END_MESSAGE_MAP ()

void CCapturePrevWnd ::ShowCaptureSc reen(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(pParent Wnd))

delete m_pSplashWnd;

else m_pSplashWnd->UpdateWindow() ;

}

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

{

return CreateEx(0,

AfxRegisterWndC lass(CS_HREDRAW |CS_VREDRAW |CS_DBLCLKS,
AfxGetApp()->LoadStandardCu rsor(IDC_CROSS) ),

NULL, WS_POPUP | WS_VISIBLE | WS_EX_TRANSPARE NT | WS_BORDER |
WS_MAXIMIZE,
0, 0, 0, 0,

pParentWnd->GetSafeHwnd( ), NULL);

}

void CCapturePrevWnd ::HideCaptureSc reen()

{

// Destroy the window, and update the mainframe.

DestroyWindow() ;

AfxGetMainWnd()->UpdateWindow() ;

}

void CCapturePrevWnd ::PostNcDestroy ()

{

// Free the C++ class.

delete this;

}

int CCapturePrevWnd ::OnCreate(LPCR EATESTRUCT lpCreateStruct)

{

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

return -1;

// Center the window.

//CenterWindow();

return 0;

}

void CCapturePrevWnd ::OnPaint()

{

CRect selRect = GetSelRect();

if(!selRect.IsR ectEmpty())

{

CClientDC dc(this);

//dc.SetROP2(R2_N OTXORPEN);

dc.DrawFocusRec t(&selRect);

}

}

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

{

start = end = point;

Invalidate();

UpdateWindow();

}

void CCapturePrevWnd ::OnMouseMove(U INT nFlags, CPoint point)

{

switch(nFlags)

{

case MK_LBUTTON:

end = point;

Invalidate();

UpdateWindow();

break;

}

}

void CCapturePrevWnd ::OnLButtonUp(U INT nFlags, CPoint point)

{

end = point;

CRect rect = GetSelRect();

if(!rect.IsRect Empty())

{

CBitmap bitmap;

CClientDC dc(NULL);

CDC memDC;

CBitmap* pOldBitmap;

memDC.CreateCom patibleDC(&dc);

bitmap.CreateCo mpatibleBitmap( &dc, rect.Width(),re ct.Height() );

pOldBitmap = memDC.SelectObj ect(&bitmap);

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


OpenClipboard() ;

EmptyClipboard( ) ;

SetClipboardDat a (CF_BITMAP, bitmap.GetSafeH andle() ) ;

CloseClipboard () ;

memDC.SelectObj ect(pOldBitmap) ;

bitmap.Detach() ;

}

HideCaptureScre en();

}

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 3127

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
2409
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 create a form, a button (Button1) and an Picture Box (picBox). "watermark.jpg" is any jpg image, "beispiel.tif" is a multipage TIFF image with the white background, which will turn to transparent. The most important thing here is that the TIFF image...
1
4935
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 ) { System.Drawing.Imaging.ImageAttributes imageAttributes = new System.Drawing.Imaging.ImageAttributes();
0
1180
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 would be like in word are when you drag an oval onto the screen, the drawing resizes as the control does. The problem I am running into is actually drawing the rectangle. I am attempting to use this code here: Rect = new Rectangle(this.Bounds.X...
3
2572
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 200x200, but it's drawing something smaller (something like 130x130, about 2/3 the original size). I am using transforms, but I've verified that scaling is set to 1.0 on both x and y axis.
0
2622
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 image has 4 transparent pixels; the upper left, upper right, lower left & lower right. This is to help give the otherwise square button graphic a slightly rounded look to it.
4
2757
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 first then paint it larger? and how would i make the entire image transparent at 75% transparency (25% opaque) thanks!
3
8450
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 placed in the container control... I'm using System.Drawing namespace (C#) to perform the drawing. But as i move the mouse and draw the rectangles, the drawing takes place behind the user controls....I have a requirement to
4
10237
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 the transparency is working properly because if I save the created image to the local hard disk and then view it in a web page or an image editor, the transparency is correct. I can also view the transparency on-the-fly in a Windows.Forms...
7
3550
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 excellent transforms specified on Bob Powell's site, I still wonder if there's an easier way of centering it than the following procedure? Here is what I do now (it's awkward but it works): 1) I follow the transforms specified on Bob Powell's...
0
8370
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8283
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8704
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8470
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7302
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5620
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4147
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.