AKB Forums

Go Back   AKB Forums > Technical sections > Languages, Compilers and Interpreters
Home Register Blogs FAQ Members List Calendar Downloads Arcade Mark Forums Read

Languages, Compilers and Interpreters C,C++,C#,.NET,Java,PHP,Perl,SQL and more

Troubles when posting message? Click here! :: Проблемы с отправлением сообщения? Нажмите сюда!

Reply
 
LinkBack Thread Tools Display Modes
Old May 20, 2004, 00:36   #1
Младенец
 
Join Date: May 2004
Location: pakistan
Posts: 14
Rep Power: 0
Reputation: 10
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
burhankhan is offline   Reply With Quote Quote selected
Old May 20, 2004, 05:36   #2
The Reloaded
 
Aram Hambardzumyan's Avatar
 
Join Date: Jan 2002
Location: behind the flesh and gelatinе of soft dull eyes
Posts: 3,178
Rep Power: 7
Reputation: 45
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
Aram Hambardzumyan is offline   Reply With Quote Quote selected
Old May 20, 2004, 09:03   #3
Administrator
 
greka's Avatar
 
Join Date: Sep 2001
Location: @work
Posts: 5,347
Rep Power: 10
Reputation: 23
Send a message via ICQ to 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.
__________________
И повешенные могут качаться в неположенную сторону. /С.Е.Лец/
greka is offline   Reply With Quote Quote selected
Old May 20, 2004, 13:03   #4
Грустно...
 
Agregat's Avatar
 
Join Date: Aug 2002
Location: Там, где всегда идут дожди
Posts: 21,545
Rep Power: 11
Reputation: 169
Send a message via ICQ to Agregat Send a message via MSN to Agregat
Или проще: GetDC()
__________________
http://аvitya.livejournal.com
Хотели, как лучше, а получилось даже хуже...
Лозунг шахматиста: На каждый шах - ответим матом!
Agregat is offline   Reply With Quote Quote selected
Old May 21, 2004, 00:07   #5
Младенец
 
Join Date: May 2004
Location: pakistan
Posts: 14
Rep Power: 0
Reputation: 10
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
burhankhan is offline   Reply With Quote Quote selected
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Essay -The Simple Story greka Literary nook 43 Aug 26, 2002 18:19
Just a simple Warcraft III artwork... Jaguar General 2 Aug 3, 2002 07:58
ASCII code in c++ Boyov Languages, Compilers and Interpreters 12 Jul 18, 2002 04:42
Top secret Microsoft code Nosferatu Fun 0 Apr 13, 2002 05:56
Adding and removing devices in code??? Jai Languages, Compilers and Interpreters 2 Nov 1, 2001 15:32


All times are GMT. The time now is 18:07.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
This board was founded on September 29, 2001
Powered by Viper Internet

Affordable Web Hosting | ParevNet

Buy text link