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

Reply
 
Thread Tools

Simple code but does not running
Old 20.05.2004, 00:36   #1
Младенец
 
Join Date: 05 2004
Location: pakistan
Age: 41
Posts: 14
Rep Power: 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

Old 20.05.2004, 05: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
Rep Power: 5
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

Old 20.05.2004, 09:03   #3
Академик
 
greka's Avatar
 
Join Date: 09 2001
Location: inside myself
Posts: 5,369
Rep Power: 6
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.
__________________
И повешенные могут качаться в неположенную сторону. /С.Е.Лец/

Old 20.05.2004, 13:03   #4
Грустно...
 
Agregat's Avatar
 
Join Date: 08 2002
Location: Там, где всегда идут дожди
Age: 43
Posts: 21,717
Rep Power: 9
Default

Или проще: GetDC()
__________________
http://аvitya.livejournal.com
Хотели, как лучше, а получилось даже хуже...
Лозунг шахматиста: На каждый шах - ответим матом!

Old 21.05.2004, 00:07   #5
Младенец
 
Join Date: 05 2004
Location: pakistan
Age: 41
Posts: 14
Rep Power: 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




Реклама:
реклама
Buy text link .

All times are GMT. The time now is 09:15.
Top

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