Click here to Skip to main content
15,916,189 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: IMPLEMENT_DYNCREATE Pin
alex.barylski16-May-04 19:03
alex.barylski16-May-04 19:03 
GeneralRe: IMPLEMENT_DYNCREATE Pin
Prakash Nadar16-May-04 21:43
Prakash Nadar16-May-04 21:43 
GeneralRe: IMPLEMENT_DYNCREATE Pin
Roger Allen16-May-04 22:49
Roger Allen16-May-04 22:49 
GeneralRe: IMPLEMENT_DYNCREATE Pin
alex.barylski17-May-04 13:19
alex.barylski17-May-04 13:19 
GeneralMacro explaination Pin
ShankarPS16-May-04 18:24
ShankarPS16-May-04 18:24 
GeneralRe: Macro explaination Pin
Ryan Binns16-May-04 18:42
Ryan Binns16-May-04 18:42 
GeneralRe: Macro explaination Pin
ShankarPS16-May-04 19:02
ShankarPS16-May-04 19:02 
GeneralRe: Macro explaination Pin
Ryan Binns16-May-04 19:34
Ryan Binns16-May-04 19:34 
#define OFF(type, field) ((LONG)(LONG_PTR)&(((type *)0)->field))
Take the following structure:
struct ThisStruct
{
    char  field1; // at offset 0
    short field2; // at offset 1
    int   field3; // at offset 3
    int   field4; // at offset 7
};
If we call the macro as such: OFF(ThisStruct, field3)

Firstly, the macro creates a pointer to a ThisStruct structure at address 0: ((ThisStruct *)0)
Next, it refers to a particular field inside that structure: ((ThisStruct *)0)->field3
Next, it takes the address of that field: &(((ThisStruct *)0)->field3)
Since field3 is 3 bytes from the beginning of the structure, and the structure is at address 0, the pointer will hold the value 3.
Lastly, the macro converts the pointer to a LONG_PTR and finally to a LONG, to give an integer result - the offset of the field from the beginning of the structure.

Hope this helps,

Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"

GeneralASSERT message Pin
alex.barylski16-May-04 17:56
alex.barylski16-May-04 17:56 
QuestionHow do you close an MFC Dialog application programatically? Pin
Steve Messer16-May-04 17:49
Steve Messer16-May-04 17:49 
AnswerRe: How do you close an MFC Dialog application programatically? Pin
Joe Woodbury16-May-04 19:00
professionalJoe Woodbury16-May-04 19:00 
GeneralRe: How do you close an MFC Dialog application programatically? Pin
Steve Messer16-May-04 21:14
Steve Messer16-May-04 21:14 
GeneralRe: How do you close an MFC Dialog application programatically? Pin
David Crow17-May-04 2:48
David Crow17-May-04 2:48 
GeneralRe: How do you close an MFC Dialog application programatically? Pin
Steve Messer17-May-04 4:13
Steve Messer17-May-04 4:13 
GeneralRe: How do you close an MFC Dialog application programatically? Pin
David Crow17-May-04 4:29
David Crow17-May-04 4:29 
GeneralRe: How do you close an MFC Dialog application programatically? Pin
Steve Messer17-May-04 4:40
Steve Messer17-May-04 4:40 
GeneralRe: How do you close an MFC Dialog application programatically? Pin
Steve Messer17-May-04 4:15
Steve Messer17-May-04 4:15 
GeneralRe: How do you close an MFC Dialog application programatically? Pin
David Crow17-May-04 4:30
David Crow17-May-04 4:30 
AnswerRe: How do you close an MFC Dialog application programatically? Pin
toxcct16-May-04 22:10
toxcct16-May-04 22:10 
GeneralLooking for source code of Web search engine. Pin
George216-May-04 16:40
George216-May-04 16:40 
GeneralRe: Looking for source code of Web search engine. Pin
ShankarPS16-May-04 18:42
ShankarPS16-May-04 18:42 
GeneralRe: Looking for source code of Web search engine. Pin
George217-May-04 0:41
George217-May-04 0:41 
GeneralRe: Looking for source code of Web search engine. Pin
alex.barylski16-May-04 18:58
alex.barylski16-May-04 18:58 
GeneralRe: Looking for source code of Web search engine. Pin
George217-May-04 0:45
George217-May-04 0:45 
GeneralDefault Project Settings Pin
Jack Puppy16-May-04 16:13
Jack Puppy16-May-04 16:13 

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.