Armenian Knowledge Base  

Go Back   Armenian Knowledge Base > Technical sections > Languages, Compilers, Interpreters
Register

Reply
 
LinkBack Thread Tools
Old 20.05.2004, 01:36   #1
Младенец
 
Join Date: 05 2004
Location: pakistan
Age: 33
Posts: 14
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Angry Simple code but does not running

Hi:
I want to draw a rectangle in a dialog when i click on a button.

I write this code in the onbutton click function:

CPaintDC dc(this);
CRect r(20,20,100,100);
dc.Rectangle(&r);



This code does not showing any thing or any error.

What is mistake.
Burhan
Reply With Quote
Old 20.05.2004, 06:36   #2
The Reloaded
 
Aram Hambardzumyan's Avatar
 
Join Date: 01 2002
Location: behind the flesh and gelatinе of soft dull eyes
Posts: 3,387
Downloads: 4
Uploads: 0
Reputation: 146 | 4
Default

in CPaintDC's overview msdn says:
Quote:
A CPaintDC object can only be used when responding to a WM_PAINT message, usually in your OnPaint message-handler member function'.
try using CCLientDC in your case
Reply With Quote
Old 20.05.2004, 10:03   #3
Академик
 
greka's Avatar
 
Join Date: 09 2001
Location: inside myself
Posts: 5,369
Downloads: 0
Uploads: 0
Reputation: 18 | 5
Default

it's bad practice to start acquaintance with graphics using buttons.

For implementing owner-drawing buttons you have to create custom class (as well as override some methods, capture mouse, etc). It's easier to use CBitmapButton.
Sample here: http://www.codeproject.com/buttonctrl/hoverbutton.asp
or here:
http://www.codeproject.com/buttonctrl/

Better explained sample here:
http://www.codeproject.com/buttonctr...overbutton.asp

hope this will by handy for you.
__________________
И повешенные могут качаться в неположенную сторону. /С.Е.Лец/
Reply With Quote
Old 20.05.2004, 14:03   #4
Грустно...
 
Agregat's Avatar
 
Join Date: 08 2002
Location: Там, где всегда идут дожди
Age: 35
Posts: 21,717
Downloads: 2
Uploads: 0
Reputation: 250 | 8
Default

Или проще: GetDC()
Reply With Quote
Old 21.05.2004, 01:07   #5
Младенец
 
Join Date: 05 2004
Location: pakistan
Age: 33
Posts: 14
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Exclamation

Quote:
Originally Posted by greka
it's bad practice to start acquaintance with graphics using buttons.

For implementing owner-drawing buttons you have to create custom class (as well as override some methods, capture mouse, etc). It's easier to use CBitmapButton.
Sample here: http://www.codeproject.com/buttonctrl/hoverbutton.asp
or here:
http://www.codeproject.com/buttonctrl/

Better explained sample here:
http://www.codeproject.com/buttonctr...overbutton.asp

hope this will by handy for you.
Sorry u cannot understand what i want to say.
I don't need any hoverbutton or owner draw button control.
It is not metter what type of button i am using.

Problem was that when i click on button a rectangle should draw on the client area of dialog. And my code is not running. Code is above.

I hope u will understand.
Thanks for ur oppinon.

Burhan
Reply With Quote
Sponsored Links
Reply

Thread Tools


На правах рекламы:
реклама

All times are GMT. The time now is 08:51.


Powered by vBulletin® Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.