Click to See Complete Forum and Search --> : problem with GDI


kingslee
August 28th, 2005, 07:56 AM
Hallo,
i worked simple GDI. I draw rectangle with pixels with gradient. the problem is when i minimize the window, previous all drawn rectangles are vanished. I donno know whats the problem.

Is any other good way to draw rectangles for these kind of applications?

i hereby attaching the project..

help me in this regard. suggestions are welcome.

thnx in advance

kings

g_gili
August 28th, 2005, 08:29 AM
Hallo,
i worked simple GDI. I draw rectangle with pixels with gradient. the problem is when i minimize the window, previous all drawn rectangles are vanished. I donno know whats the problem.

Is any other good way to draw rectangles for these kind of applications?

i hereby attaching the project..

help me in this regard. suggestions are welcome.

thnx in advance

kings
The previous rectangles are disapered because your window is redrawed and when your app is restored from minimize, and the client area is cleared. In your project you draw to the client area, but you did't store the drawings(only you draw it). And when the the app is restored the WM_PAINT is called and redraws your client area. I sugest to use an object array and each time when your app redraws the client area you should draw again your rects.

kingslee
August 28th, 2005, 08:52 AM
Thank you for ur reply.

I get you but .

I draw the pixels in a seperate draw function...not in WM_PAINT
I really donno how to save those position of the rectangle in the area and the color of grouppixels..

and again print on the screen when it reloads

My question may be wrong.

help me in this regard.

mfg,
kings

g_gili
August 28th, 2005, 09:09 AM
Why don't you draw rectangles on the sceen because is not to good that you draw each pixel(in your case) and store it. What happend when you draws a lot of pixels you neet to store it!! :)

kingslee
August 28th, 2005, 11:27 AM
thankyou again..
I am trying to do with rectangle.. the problem i face is to change the color ... acccording to gradient as i made it ...
anyway i try that now ...

If we make it a rectangle can we store those easily? ...

thanx in advance

cheers
kings

g_gili
August 28th, 2005, 11:35 AM
Yes you could store more effeciently, and to fill the rect just use FillRect.
to store it use somting like this:

typdef struct rects{
CRect m_rect[1000];
COLORREF m_color[1000];
}PREDRAW;

Andreas Masur
August 28th, 2005, 12:59 PM
[ Redirected thread ]

kingslee
August 28th, 2005, 01:41 PM
hallo,
sorry for posting the thread in common...
gili .. i am trying to that with arrays..
i am not very sure about the predraw in the struct ....

sorry for asking too many questions...

regards
kings

g_gili
August 28th, 2005, 01:54 PM
Don't you know how to use it?

//// kinView.h
#if !defined(AFX_KINVIEW_H__ABA90CEF_A0B6_4155_BA48_2DC13A6D5D69__INCLUDED_)
#define AFX_KINVIEW_H__ABA90CEF_A0B6_4155_BA48_2DC13A6D5D69__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
//decrare it here

typdef struct rects{
CRect m_rect[1000];
COLORREF m_color[1000];
}PREDRAW;

class CKinView : public CFormView
{
.
.
.
public:
PREDRAW m_predraw;

then how to acces it

//in your *.cpp
m_predraw.m_rect[1] //the first rect
m_predraw.m_color[1] //the first color
.
.
.
ex:
m_predraw.m_color[1]=RGB(0,0,0) //the first color is black
m_predraw.m_rect[1].SetRect(0,0,10,10); or m_predraw.m_rect[1].CopyRect(&rectSurce);

I hope you are clear, of using this! If you have some confusion just ask it! :)

kingslee
August 28th, 2005, 05:18 PM
thank you so much ..
finally i got it....
sorry for asking too many questions...
thankyou once again...
..
can we can capture this screen?and save as bmp... :-):-)
suggestions also welcome ..


mfg,
kingsly

g_gili
August 29th, 2005, 12:17 PM
try it here (http://www.codeproject.com/gdi/barry_s_screen_capture.asp).
Is a sample program that capture the screen and your client area and save it to a bmp file.
:wave:

kingslee
August 30th, 2005, 02:48 PM
thank you once again..
i will try that ...
:-j
kings