Click here to Skip to main content
15,902,817 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionUltimate Toolbox's drawing style Pin
sawerr18-Jun-08 3:10
sawerr18-Jun-08 3:10 
AnswerRe: Ultimate Toolbox's drawing style Pin
Saurabh.Garg18-Jun-08 3:15
Saurabh.Garg18-Jun-08 3:15 
GeneralRe: Ultimate Toolbox's drawing style Pin
Maximilien18-Jun-08 3:18
Maximilien18-Jun-08 3:18 
AnswerRe: Ultimate Toolbox's drawing style Pin
James R. Twine18-Jun-08 3:32
James R. Twine18-Jun-08 3:32 
GeneralRe: Ultimate Toolbox's drawing style Pin
sawerr18-Jun-08 3:44
sawerr18-Jun-08 3:44 
GeneralRe: Ultimate Toolbox's drawing style Pin
James R. Twine18-Jun-08 4:07
James R. Twine18-Jun-08 4:07 
GeneralRe: Ultimate Toolbox's drawing style Pin
sawerr18-Jun-08 4:38
sawerr18-Jun-08 4:38 
AnswerRe: Ultimate Toolbox's drawing style Pin
Nibu babu thomas18-Jun-08 6:20
Nibu babu thomas18-Jun-08 6:20 
sawerr wrote:
some of controls source code overrode OnDrawItem and put drawing code in there


Well OnDrawItem is mainly provdided to facilitate owner drawing controls without sub classing them. An e.g. would be a tab control, we can owner draw a tab control without sub classing it using this function.

Signature of OnDrawItem is as follows, nIDCtl points to the ID of the controls that's meant to owner drawn. So here you will get the id of your tab control and you can owner draw it here.

afx_msg void OnDrawItem(int nIDCtl, LPDRAWITEMSTRUCT lpDrawItemStruct);

There is another option, that's by subclassing and overriding DrawItem virtual function. Note that DrawItem get's called by OnDrawItem.

Stack trace to DrawItem virtual member function is as follows...

CListBoxEx::DrawItem(tagDRAWITEMSTRUCT * 0x0012f6d4) line 20
CListBox::OnChildNotify(unsigned int 43, unsigned int 1000, long 1242836, long * 0x00000000) line 125
CWnd::SendChildNotifyLastMsg(long * 0x00000000) line 2683
CWnd::ReflectLastMsg(HWND__ * 0x0004089a, long * 0x00000000) line 2721
CWnd::OnDrawItem(int 1000, tagDRAWITEMSTRUCT * 0x0012f6d4) line 1156 + 14 bytes
CLearnDrawingDlg::OnDrawItem(int 1000, tagDRAWITEMSTRUCT * 0x0012f6d4) line 46
CWnd::OnWndMsg(unsigned int 43, unsigned int 1000, long 1242836, long * 0x0012f4f0) line 1930



sawerr wrote:
How does a control developer make decision when only Onpaint or only Drawitem or both of them must be used?


DrawItem messages makes things easier for developers, we get OD flags that tells which action requires painting.

For e.g.

ODS_CHECKED
ODS_FOCUS
ODS_DISABLED.

We just have to do the painting stuff. But if we are going via OnPaint then we are on our own, we've got to find out when an item is selected, when it's in focus, when it's disabled based on every paint event that we get. Maybe even scrolling too. So that's for the tough guys. Wink | ;)

So basically for quick and easy painting things we got via OnDrawItem, or DrawItem else for full control we go via OnPaint.

This is my understanding on this topic!

sawerr wrote:
downloaded Ultimate Toolbox


I did have the privilege of working on this project with Nishant! Didn't do much development though. Smile | :) My first impression was that it's well written and it works well. It was a great learning experience.


Nibu babu thomas
Microsoft MVP for VC++


Code must be written to be read, not by the compiler, but by another human being.

Programming Blog: http://nibuthomas.wordpress.com

GeneralRe: Ultimate Toolbox's drawing style Pin
sawerr18-Jun-08 6:58
sawerr18-Jun-08 6:58 
GeneralRe: Ultimate Toolbox's drawing style Pin
Nibu babu thomas19-Jun-08 2:16
Nibu babu thomas19-Jun-08 2:16 
GeneralRe: Ultimate Toolbox's drawing style Pin
sawerr19-Jun-08 6:24
sawerr19-Jun-08 6:24 
GeneralRe: Ultimate Toolbox's drawing style Pin
Nibu babu thomas19-Jun-08 17:19
Nibu babu thomas19-Jun-08 17:19 
QuestionHow to get ASCII Character from Decimal value Pin
tns_ranjith18-Jun-08 2:59
tns_ranjith18-Jun-08 2:59 
AnswerRe: How to get ASCII Character from Decimal value Pin
toxcct18-Jun-08 3:04
toxcct18-Jun-08 3:04 
AnswerRe: How to get ASCII Character from Decimal value Pin
CPallini18-Jun-08 3:13
mveCPallini18-Jun-08 3:13 
QuestionRe: How to get ASCII Character from Decimal value Pin
James R. Twine18-Jun-08 3:35
James R. Twine18-Jun-08 3:35 
QuestionProperty Sheet eVC++ WinCE - Urgent Pin
Trupti Mehta18-Jun-08 2:54
Trupti Mehta18-Jun-08 2:54 
Questionget internal ip, getaddrinfo() Pin
smedowns7718-Jun-08 2:50
smedowns7718-Jun-08 2:50 
QuestionRe: get internal ip, getaddrinfo() Pin
David Crow18-Jun-08 2:57
David Crow18-Jun-08 2:57 
AnswerRe: get internal ip, getaddrinfo() Pin
Jijo.Raj18-Jun-08 3:01
Jijo.Raj18-Jun-08 3:01 
AnswerRe: get internal ip, getaddrinfo() Pin
Mark Salsbery18-Jun-08 10:23
Mark Salsbery18-Jun-08 10:23 
QuestionKeyboard messages not received by my window Pin
theCPkid18-Jun-08 2:24
theCPkid18-Jun-08 2:24 
QuestionDynamic Data Exchange using C++ : Urgent Pin
Vishrant Shah18-Jun-08 0:38
Vishrant Shah18-Jun-08 0:38 
GeneralUrgent? No cookie for you... Pin
CPallini18-Jun-08 1:41
mveCPallini18-Jun-08 1:41 
AnswerRe: Dynamic Data Exchange using C++ : Urgent Pin
Alan Balkany18-Jun-08 3:36
Alan Balkany18-Jun-08 3:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.