Thread: Re: [Dev-C++] Whoops - drawing in Windows
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Daniel G. <sp...@ho...> - 2002-10-24 10:01:40
|
Nope maybe not, serialising is for saving and restoring.
I think you have to store the info in to an array, but looking at this old
code I cannot remember what exactly you have to do. I worked on the Scribble
tutorial that comes with VC++ - have a look on MSDN for it.
>From: "Vlada Djurovic" <dj...@im...>
>To: "'DevC++ help'" <dev...@li...>
>Subject: [Dev-C++] drawing in Windows
>Date: Thu, 24 Oct 2002 10:32:16 +0200
>
>Hi, everybody
>Here's my problem: I'm trying to write a simple drawing app (just for
>exercise) and so far its been going OK. I can draw lines in client area in
>different colors, but when ever I minimize or maximize the window, or
>something similar happenes, all the content of the window is gone. I tried
>to use a memory DC an bitmap to save the contents in, and BitBlt it back in
>response to WM_PAINT message, but the program just "froze". Can anybody
>give me a hint how to do it? Here's the code used for drawing lines without
>any restoring parts:
>
> case WM_MOUSEMOVE:
> {
> switch(iTool) /* iTool is used for dtetrmining which
>drawing tool is selected(line, rect etc.)*/
> {
> case 0:
> {
> if(wParam==MK_LBUTTON) /*if line is selected
>(itool=0) and left button presed*/
> {
> HDC hDC=GetDC(hwnd);
>
> HPEN hPen=CreatePen(PS_SOLID,iCurWidth,crCurColor);
> HPEN hOldPen=(HPEN)SelectObject(hDC,hPen);
> CLine* pLine=new
>CLine(ptPrevPos,MAKEPOINTS(lParam),iCurWidth,crCurColor); /*create new line
>object*/
> pLine->DrawLine(hDC);
> ptPrevPos=MAKEPOINTS(lParam);
> SelectObject(hDC,hOldPen);
> DeleteDC(hDC);
> }
> }
> break;
> case 1: /* nothing here yet*/
> break;
> }
> }
_________________________________________________________________
Get a speedy connection with MSN Broadband. Join now!
http://resourcecenter.msn.com/access/plans/freeactivation.asp
|
|
From: Daniel G. <sp...@ho...> - 2002-10-24 12:16:09
|
I'm sure the linked list is the right way to do it, I just can't remember
the specifics.
>From: "Vlada Djurovic" <dj...@im...>
>To: "Daniel Glenfield"
><sp...@ho...>,<dev...@li...>
>Subject: Re: [Dev-C++] Whoops - drawing in Windows
>Date: Thu, 24 Oct 2002 14:02:32 +0200
>
>
>----- Original Message -----
>From: "Daniel Glenfield" <sp...@ho...>
>To: <dj...@im...>; <dev...@li...>
>Sent: Thursday, October 24, 2002 11:59 AM
>Subject: Re: [Dev-C++] Whoops - drawing in Windows
>
>
> > Nope maybe not, serialising is for saving and restoring.
> >
> > I think you have to store the info in to an array, but looking at this
>old
> > code I cannot remember what exactly you have to do. I worked on the
>Scribble
> > tutorial that comes with VC++ - have a look on MSDN for it.
> >
> >
>I tried to store all the info in a linked list, but I think I did something
>wrong because the program just froze when I tried to draw something. Then I
>thought it would be easier to store the drawing in a compatible memory
>bitmap and then just copy it back in the client area when it needs to be
>redrawn, but this also didn't work because the program froze again. That's
>why I was asking if anyone can give me some guidelines about how to do this
>(the bitmap way).
>As for the tutorials, I read the book "Teach yourself VC++ in 21 days"
>which
>also has some stuff about this, but although I think I did everything the
>way it's done in VC++- it doesn't work.
>
>Regards, Vlada
> >
> > >From: "Vlada Djurovic" <dj...@im...>
> > >To: "'DevC++ help'" <dev...@li...>
> > >Subject: [Dev-C++] drawing in Windows
> > >Date: Thu, 24 Oct 2002 10:32:16 +0200
> > >
> > >Hi, everybody
> > >Here's my problem: I'm trying to write a simple drawing app (just for
> > >exercise) and so far its been going OK. I can draw lines in client area
>in
> > >different colors, but when ever I minimize or maximize the window, or
> > >something similar happenes, all the content of the window is gone. I
>tried
> > >to use a memory DC an bitmap to save the contents in, and BitBlt it
>back
>in
> > >response to WM_PAINT message, but the program just "froze". Can anybody
> > >give me a hint how to do it? Here's the code used for drawing lines
>without
> > >any restoring parts:
> > >
> > > case WM_MOUSEMOVE:
> > > {
> > > switch(iTool) /* iTool is used for dtetrmining
>which
> > >drawing tool is selected(line, rect etc.)*/
> > > {
> > > case 0:
> > > {
> > > if(wParam==MK_LBUTTON) /*if line is selected
> > >(itool=0) and left button presed*/
> > > {
> > > HDC hDC=GetDC(hwnd);
> > >
> > > HPEN
>hPen=CreatePen(PS_SOLID,iCurWidth,crCurColor);
> > > HPEN hOldPen=(HPEN)SelectObject(hDC,hPen);
> > > CLine* pLine=new
> > >CLine(ptPrevPos,MAKEPOINTS(lParam),iCurWidth,crCurColor); /*create new
>line
> > >object*/
> > > pLine->DrawLine(hDC);
> > > ptPrevPos=MAKEPOINTS(lParam);
> > > SelectObject(hDC,hOldPen);
> > > DeleteDC(hDC);
> > > }
> > > }
> > > break;
> > > case 1: /* nothing here yet*/
> > > break;
> > > }
> > > }
> >
> >
> > _________________________________________________________________
> > Get a speedy connection with MSN Broadband. Join now!
> > http://resourcecenter.msn.com/access/plans/freeactivation.asp
> >
>
>
>
>-------------------------------------------------------
>This sf.net email is sponsored by: Influence the future
>of Java(TM) technology. Join the Java Community
>Process(SM) (JCP(SM)) program now.
>http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/javavote
>_______________________________________________
>Dev-cpp-users mailing list
>Dev...@li...
>TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
>https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
_________________________________________________________________
Internet access plans that fit your lifestyle -- join MSN.
http://resourcecenter.msn.com/access/plans/default.asp
|
|
From: Per W. <pw...@ia...> - 2002-10-24 13:34:09
|
There isn't a right or wrong between lists or bitmaps. The question is
what problems to solve.
Just fix repaint of window:
Simple bitmap will make perfect redraw in constant time, using constant
amount of memory.
Support undo, rescaling etc:
If all paint operations are stored in a list (or vector, ...) it the
amount of needed memory and needed redraw time will increase with the
complexity of the drawing. However, the additional bonus is easy support
for undo - just remove last entry from the list and redraw. Also, if all
coordinates are stored as a percentage of the window size, it is possible
to resize the window, and at repaint getting the image stretched
correspondingly, without any strange jaggies introduced by the resize of a
bitmap.
/Per W
On Thu, 24 Oct 2002, Daniel Glenfield wrote:
> I'm sure the linked list is the right way to do it, I just can't remember
> the specifics.
>
>
>
>
>
>
> >From: "Vlada Djurovic" <dj...@im...>
> >To: "Daniel Glenfield"
> ><sp...@ho...>,<dev...@li...>
> >Subject: Re: [Dev-C++] Whoops - drawing in Windows
> >Date: Thu, 24 Oct 2002 14:02:32 +0200
> >
> >
> >----- Original Message -----
> >From: "Daniel Glenfield" <sp...@ho...>
> >To: <dj...@im...>; <dev...@li...>
> >Sent: Thursday, October 24, 2002 11:59 AM
> >Subject: Re: [Dev-C++] Whoops - drawing in Windows
> >
> >
> > > Nope maybe not, serialising is for saving and restoring.
> > >
> > > I think you have to store the info in to an array, but looking at this
> >old
> > > code I cannot remember what exactly you have to do. I worked on the
> >Scribble
> > > tutorial that comes with VC++ - have a look on MSDN for it.
> > >
> > >
> >I tried to store all the info in a linked list, but I think I did something
> >wrong because the program just froze when I tried to draw something. Then I
> >thought it would be easier to store the drawing in a compatible memory
> >bitmap and then just copy it back in the client area when it needs to be
> >redrawn, but this also didn't work because the program froze again. That's
> >why I was asking if anyone can give me some guidelines about how to do this
> >(the bitmap way).
> >As for the tutorials, I read the book "Teach yourself VC++ in 21 days"
> >which
> >also has some stuff about this, but although I think I did everything the
> >way it's done in VC++- it doesn't work.
> >
> >Regards, Vlada
> > >
> > > >From: "Vlada Djurovic" <dj...@im...>
> > > >To: "'DevC++ help'" <dev...@li...>
> > > >Subject: [Dev-C++] drawing in Windows
> > > >Date: Thu, 24 Oct 2002 10:32:16 +0200
> > > >
> > > >Hi, everybody
> > > >Here's my problem: I'm trying to write a simple drawing app (just for
> > > >exercise) and so far its been going OK. I can draw lines in client area
> >in
> > > >different colors, but when ever I minimize or maximize the window, or
> > > >something similar happenes, all the content of the window is gone. I
> >tried
> > > >to use a memory DC an bitmap to save the contents in, and BitBlt it
> >back
> >in
> > > >response to WM_PAINT message, but the program just "froze". Can anybody
> > > >give me a hint how to do it? Here's the code used for drawing lines
> >without
> > > >any restoring parts:
> > > >
> > > > case WM_MOUSEMOVE:
> > > > {
> > > > switch(iTool) /* iTool is used for dtetrmining
> >which
> > > >drawing tool is selected(line, rect etc.)*/
> > > > {
> > > > case 0:
> > > > {
> > > > if(wParam==MK_LBUTTON) /*if line is selected
> > > >(itool=0) and left button presed*/
> > > > {
> > > > HDC hDC=GetDC(hwnd);
> > > >
> > > > HPEN
> >hPen=CreatePen(PS_SOLID,iCurWidth,crCurColor);
> > > > HPEN hOldPen=(HPEN)SelectObject(hDC,hPen);
> > > > CLine* pLine=new
> > > >CLine(ptPrevPos,MAKEPOINTS(lParam),iCurWidth,crCurColor); /*create new
> >line
> > > >object*/
> > > > pLine->DrawLine(hDC);
> > > > ptPrevPos=MAKEPOINTS(lParam);
> > > > SelectObject(hDC,hOldPen);
> > > > DeleteDC(hDC);
> > > > }
> > > > }
> > > > break;
> > > > case 1: /* nothing here yet*/
> > > > break;
> > > > }
> > > > }
> > >
> > >
> > > _________________________________________________________________
> > > Get a speedy connection with MSN Broadband. Join now!
> > > http://resourcecenter.msn.com/access/plans/freeactivation.asp
> > >
> >
> >
> >
> >-------------------------------------------------------
> >This sf.net email is sponsored by: Influence the future
> >of Java(TM) technology. Join the Java Community
> >Process(SM) (JCP(SM)) program now.
> >http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/javavote
> >_______________________________________________
> >Dev-cpp-users mailing list
> >Dev...@li...
> >TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> >https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>
> _________________________________________________________________
> Internet access plans that fit your lifestyle -- join MSN.
> http://resourcecenter.msn.com/access/plans/default.asp
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by: Influence the future
> of Java(TM) technology. Join the Java Community
> Process(SM) (JCP(SM)) program now.
> http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/javavote
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: Vlada D. <dj...@im...> - 2002-10-24 12:01:07
|
----- Original Message -----
From: "Daniel Glenfield" <sp...@ho...>
To: <dj...@im...>; <dev...@li...>
Sent: Thursday, October 24, 2002 11:59 AM
Subject: Re: [Dev-C++] Whoops - drawing in Windows
> Nope maybe not, serialising is for saving and restoring.
>
> I think you have to store the info in to an array, but looking at this old
> code I cannot remember what exactly you have to do. I worked on the
Scribble
> tutorial that comes with VC++ - have a look on MSDN for it.
>
>
I tried to store all the info in a linked list, but I think I did something
wrong because the program just froze when I tried to draw something. Then I
thought it would be easier to store the drawing in a compatible memory
bitmap and then just copy it back in the client area when it needs to be
redrawn, but this also didn't work because the program froze again. That's
why I was asking if anyone can give me some guidelines about how to do this
(the bitmap way).
As for the tutorials, I read the book "Teach yourself VC++ in 21 days" which
also has some stuff about this, but although I think I did everything the
way it's done in VC++- it doesn't work.
Regards, Vlada
>
> >From: "Vlada Djurovic" <dj...@im...>
> >To: "'DevC++ help'" <dev...@li...>
> >Subject: [Dev-C++] drawing in Windows
> >Date: Thu, 24 Oct 2002 10:32:16 +0200
> >
> >Hi, everybody
> >Here's my problem: I'm trying to write a simple drawing app (just for
> >exercise) and so far its been going OK. I can draw lines in client area
in
> >different colors, but when ever I minimize or maximize the window, or
> >something similar happenes, all the content of the window is gone. I
tried
> >to use a memory DC an bitmap to save the contents in, and BitBlt it back
in
> >response to WM_PAINT message, but the program just "froze". Can anybody
> >give me a hint how to do it? Here's the code used for drawing lines
without
> >any restoring parts:
> >
> > case WM_MOUSEMOVE:
> > {
> > switch(iTool) /* iTool is used for dtetrmining
which
> >drawing tool is selected(line, rect etc.)*/
> > {
> > case 0:
> > {
> > if(wParam==MK_LBUTTON) /*if line is selected
> >(itool=0) and left button presed*/
> > {
> > HDC hDC=GetDC(hwnd);
> >
> > HPEN
hPen=CreatePen(PS_SOLID,iCurWidth,crCurColor);
> > HPEN hOldPen=(HPEN)SelectObject(hDC,hPen);
> > CLine* pLine=new
> >CLine(ptPrevPos,MAKEPOINTS(lParam),iCurWidth,crCurColor); /*create new
line
> >object*/
> > pLine->DrawLine(hDC);
> > ptPrevPos=MAKEPOINTS(lParam);
> > SelectObject(hDC,hOldPen);
> > DeleteDC(hDC);
> > }
> > }
> > break;
> > case 1: /* nothing here yet*/
> > break;
> > }
> > }
>
>
> _________________________________________________________________
> Get a speedy connection with MSN Broadband. Join now!
> http://resourcecenter.msn.com/access/plans/freeactivation.asp
>
|
|
From: Per W. <pw...@ia...> - 2002-10-24 13:19:59
|
One question: Aren't you creating a lot of pens in your drawing loop.
Every time the mouse is moved, you create a new pen, with the same
specification as the pen you crated at your previous mouse move.
Exactly where are the "consumed" pens supposed to be released? At least in
Win32, you only have a finite set of available resource handles, so it
isn't possible to create new pens all the time. The task manager in Win2k
or WinXP may be configured to display number of handles used in the
application. That number shouldn't continuously increase when the program
is run.
Leaking pens, brushes, ... is a quick way of getting a program into
troubles - a lot more quickly than if the program leaks memory. There is
no swapping for resources.
/Per W
On Thu, 24 Oct 2002, Vlada Djurovic wrote:
>
> ----- Original Message -----
> From: "Daniel Glenfield" <sp...@ho...>
> To: <dj...@im...>; <dev...@li...>
> Sent: Thursday, October 24, 2002 11:59 AM
> Subject: Re: [Dev-C++] Whoops - drawing in Windows
>
>
> > Nope maybe not, serialising is for saving and restoring.
> >
> > I think you have to store the info in to an array, but looking at this old
> > code I cannot remember what exactly you have to do. I worked on the
> Scribble
> > tutorial that comes with VC++ - have a look on MSDN for it.
> >
> >
> I tried to store all the info in a linked list, but I think I did something
> wrong because the program just froze when I tried to draw something. Then I
> thought it would be easier to store the drawing in a compatible memory
> bitmap and then just copy it back in the client area when it needs to be
> redrawn, but this also didn't work because the program froze again. That's
> why I was asking if anyone can give me some guidelines about how to do this
> (the bitmap way).
> As for the tutorials, I read the book "Teach yourself VC++ in 21 days" which
> also has some stuff about this, but although I think I did everything the
> way it's done in VC++- it doesn't work.
>
> Regards, Vlada
> >
> > >From: "Vlada Djurovic" <dj...@im...>
> > >To: "'DevC++ help'" <dev...@li...>
> > >Subject: [Dev-C++] drawing in Windows
> > >Date: Thu, 24 Oct 2002 10:32:16 +0200
> > >
> > >Hi, everybody
> > >Here's my problem: I'm trying to write a simple drawing app (just for
> > >exercise) and so far its been going OK. I can draw lines in client area
> in
> > >different colors, but when ever I minimize or maximize the window, or
> > >something similar happenes, all the content of the window is gone. I
> tried
> > >to use a memory DC an bitmap to save the contents in, and BitBlt it back
> in
> > >response to WM_PAINT message, but the program just "froze". Can anybody
> > >give me a hint how to do it? Here's the code used for drawing lines
> without
> > >any restoring parts:
> > >
> > > case WM_MOUSEMOVE:
> > > {
> > > switch(iTool) /* iTool is used for dtetrmining
> which
> > >drawing tool is selected(line, rect etc.)*/
> > > {
> > > case 0:
> > > {
> > > if(wParam==MK_LBUTTON) /*if line is selected
> > >(itool=0) and left button presed*/
> > > {
> > > HDC hDC=GetDC(hwnd);
> > >
> > > HPEN
> hPen=CreatePen(PS_SOLID,iCurWidth,crCurColor);
> > > HPEN hOldPen=(HPEN)SelectObject(hDC,hPen);
> > > CLine* pLine=new
> > >CLine(ptPrevPos,MAKEPOINTS(lParam),iCurWidth,crCurColor); /*create new
> line
> > >object*/
> > > pLine->DrawLine(hDC);
> > > ptPrevPos=MAKEPOINTS(lParam);
> > > SelectObject(hDC,hOldPen);
> > > DeleteDC(hDC);
> > > }
> > > }
> > > break;
> > > case 1: /* nothing here yet*/
> > > break;
> > > }
> > > }
> >
> >
> > _________________________________________________________________
> > Get a speedy connection with MSN Broadband. Join now!
> > http://resourcecenter.msn.com/access/plans/freeactivation.asp
> >
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by: Influence the future
> of Java(TM) technology. Join the Java Community
> Process(SM) (JCP(SM)) program now.
> http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/javavote
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|
|
From: Vlada D. <dj...@im...> - 2002-10-25 07:04:08
|
----- Original Message -----
From: "Per Westermark" <pw...@ia...>
To: "Vlada Djurovic" <dj...@im...>
Cc: "Daniel Glenfield" <sp...@ho...>;
<dev...@li...>
Sent: Thursday, October 24, 2002 3:19 PM
Subject: Re: [Dev-C++] Whoops - drawing in Windows
> One question: Aren't you creating a lot of pens in your drawing loop.
> Every time the mouse is moved, you create a new pen, with the same
> specification as the pen you crated at your previous mouse move.
>
> Exactly where are the "consumed" pens supposed to be released? At least in
> Win32, you only have a finite set of available resource handles, so it
> isn't possible to create new pens all the time. The task manager in Win2k
> or WinXP may be configured to display number of handles used in the
> application. That number shouldn't continuously increase when the program
> is run.
>
If I understand correct, you say I should create one global pen object and
use it every time I need to draw something. Where should that object be
defined?
> Leaking pens, brushes, ... is a quick way of getting a program into
> troubles - a lot more quickly than if the program leaks memory. There is
> no swapping for resources.
>
Can it be the reason for the program to freeze?
> /Per W
>
> On Thu, 24 Oct 2002, Vlada Djurovic wrote:
>
> >
> > ----- Original Message -----
> > From: "Daniel Glenfield" <sp...@ho...>
> > To: <dj...@im...>; <dev...@li...>
> > Sent: Thursday, October 24, 2002 11:59 AM
> > Subject: Re: [Dev-C++] Whoops - drawing in Windows
> >
> >
> > > Nope maybe not, serialising is for saving and restoring.
> > >
> > > I think you have to store the info in to an array, but looking at this
old
> > > code I cannot remember what exactly you have to do. I worked on the
> > Scribble
> > > tutorial that comes with VC++ - have a look on MSDN for it.
> > >
> > >
> > I tried to store all the info in a linked list, but I think I did
something
> > wrong because the program just froze when I tried to draw something.
Then I
> > thought it would be easier to store the drawing in a compatible memory
> > bitmap and then just copy it back in the client area when it needs to be
> > redrawn, but this also didn't work because the program froze again.
That's
> > why I was asking if anyone can give me some guidelines about how to do
this
> > (the bitmap way).
> > As for the tutorials, I read the book "Teach yourself VC++ in 21 days"
which
> > also has some stuff about this, but although I think I did everything
the
> > way it's done in VC++- it doesn't work.
> >
> > Regards, Vlada
> > >
> > > >From: "Vlada Djurovic" <dj...@im...>
> > > >To: "'DevC++ help'" <dev...@li...>
> > > >Subject: [Dev-C++] drawing in Windows
> > > >Date: Thu, 24 Oct 2002 10:32:16 +0200
> > > >
> > > >Hi, everybody
> > > >Here's my problem: I'm trying to write a simple drawing app (just for
> > > >exercise) and so far its been going OK. I can draw lines in client
area
> > in
> > > >different colors, but when ever I minimize or maximize the window, or
> > > >something similar happenes, all the content of the window is gone. I
> > tried
> > > >to use a memory DC an bitmap to save the contents in, and BitBlt it
back
> > in
> > > >response to WM_PAINT message, but the program just "froze". Can
anybody
> > > >give me a hint how to do it? Here's the code used for drawing lines
> > without
> > > >any restoring parts:
> > > >
> > > > case WM_MOUSEMOVE:
> > > > {
> > > > switch(iTool) /* iTool is used for dtetrmining
> > which
> > > >drawing tool is selected(line, rect etc.)*/
> > > > {
> > > > case 0:
> > > > {
> > > > if(wParam==MK_LBUTTON) /*if line is selected
> > > >(itool=0) and left button presed*/
> > > > {
> > > > HDC hDC=GetDC(hwnd);
> > > >
> > > > HPEN
> > hPen=CreatePen(PS_SOLID,iCurWidth,crCurColor);
> > > > HPEN hOldPen=(HPEN)SelectObject(hDC,hPen);
> > > > CLine* pLine=new
> > > >CLine(ptPrevPos,MAKEPOINTS(lParam),iCurWidth,crCurColor); /*create
new
> > line
> > > >object*/
> > > > pLine->DrawLine(hDC);
> > > > ptPrevPos=MAKEPOINTS(lParam);
> > > > SelectObject(hDC,hOldPen);
> > > > DeleteDC(hDC);
> > > > }
> > > > }
> > > > break;
> > > > case 1: /* nothing here yet*/
> > > > break;
> > > > }
> > > > }
> > >
> > >
> > > _________________________________________________________________
> > > Get a speedy connection with MSN Broadband. Join now!
> > > http://resourcecenter.msn.com/access/plans/freeactivation.asp
> > >
> >
> >
> >
> > -------------------------------------------------------
> > This sf.net email is sponsored by: Influence the future
> > of Java(TM) technology. Join the Java Community
> > Process(SM) (JCP(SM)) program now.
> >
http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/javavote
> > _______________________________________________
> > Dev-cpp-users mailing list
> > Dev...@li...
> > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
> >
>
|
|
From: Per W. <pw...@ia...> - 2002-10-25 08:10:18
|
It doesn't matter where you define it, as long as the compiler may see the pen when inside the draw code. However, if you keep a global pen, you must make sure that whenever the user is changing colour, line width etc, you have to unselect and free the old pen and create a new pen. /Per W |
|
From: Carlos d. M. <cg...@wo...> - 2002-10-24 14:23:52
|
You can create a DC where you select a bitmap, you draw in that bitmap an=
d you
BitBlt to the window each time you need it: when sizing and restoring, wh=
en you
draw something...
Daniel Glenfield escribi=F3:
> Nope maybe not, serialising is for saving and restoring.
>
> I think you have to store the info in to an array, but looking at this =
old
> code I cannot remember what exactly you have to do. I worked on the Scr=
ibble
> tutorial that comes with VC++ - have a look on MSDN for it.
>
> >From: "Vlada Djurovic" <dj...@im...>
> >To: "'DevC++ help'" <dev...@li...>
> >Subject: [Dev-C++] drawing in Windows
> >Date: Thu, 24 Oct 2002 10:32:16 +0200
> >
> >Hi, everybody
> >Here's my problem: I'm trying to write a simple drawing app (just for
> >exercise) and so far its been going OK. I can draw lines in client are=
a in
> >different colors, but when ever I minimize or maximize the window, or
> >something similar happenes, all the content of the window is gone. I t=
ried
> >to use a memory DC an bitmap to save the contents in, and BitBlt it ba=
ck in
> >response to WM_PAINT message, but the program just "froze". Can anybod=
y
> >give me a hint how to do it? Here's the code used for drawing lines wi=
thout
> >any restoring parts:
> >
> > case WM_MOUSEMOVE:
> > {
> > switch(iTool) /* iTool is used for dtetrmining =
which
> >drawing tool is selected(line, rect etc.)*/
> > {
> > case 0:
> > {
> > if(wParam=3D=3DMK_LBUTTON) /*if line is selecte=
d
> >(itool=3D0) and left button presed*/
> > {
> > HDC hDC=3DGetDC(hwnd);
> >
> > HPEN hPen=3DCreatePen(PS_SOLID,iCurWidth,crCur=
Color);
> > HPEN hOldPen=3D(HPEN)SelectObject(hDC,hPen);
> > CLine* pLine=3Dnew
> >CLine(ptPrevPos,MAKEPOINTS(lParam),iCurWidth,crCurColor); /*create new=
line
> >object*/
> > pLine->DrawLine(hDC);
> > ptPrevPos=3DMAKEPOINTS(lParam);
> > SelectObject(hDC,hOldPen);
> > DeleteDC(hDC);
> > }
> > }
> > break;
> > case 1: /* nothing here yet*/
> > break;
> > }
> > }
>
> _________________________________________________________________
> Get a speedy connection with MSN Broadband. Join now!
> http://resourcecenter.msn.com/access/plans/freeactivation.asp
>
> -------------------------------------------------------
> This sf.net email is sponsored by: Influence the future
> of Java(TM) technology. Join the Java Community
> Process(SM) (JCP(SM)) program now.
> http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/java=
vote
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|