Click here to Skip to main content
15,927,699 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionThe full path of WordPad.exe ?? Pin
3-Apr-02 21:26
suss3-Apr-02 21:26 
AnswerRe: The full path of WordPad.exe ?? Pin
3-Apr-02 23:05
suss3-Apr-02 23:05 
GeneralRintime error! Pin
Mazdak3-Apr-02 21:09
Mazdak3-Apr-02 21:09 
GeneralRe: Rintime error! Pin
Niklas L3-Apr-02 22:02
Niklas L3-Apr-02 22:02 
GeneralRe: Rintime error! Pin
Mazdak3-Apr-02 22:23
Mazdak3-Apr-02 22:23 
GeneralStatusbar between titlebar and menu Pin
CSZX3-Apr-02 20:12
CSZX3-Apr-02 20:12 
Generalstruct alignment and OSVERSIONINFO Pin
3-Apr-02 19:43
suss3-Apr-02 19:43 
GeneralRe: struct alignment and OSVERSIONINFO Pin
Paul M Watt3-Apr-02 20:33
mentorPaul M Watt3-Apr-02 20:33 
Anonymous wrote:
They must check if the cbSize member is set to sizeof(...). Since that code is compiled by ms, they might have different struct aligment settings => different return value from sizeof. How does this work? Isn't there a potential bug somewhere?

The cbSize fields do not set the struct alignment, it is simply a variable that indicates how large the structure is. By testing how large the structure is, an application can tell which version of the structure is being used. Some of the structures in the newer Win32 OS have more fields to add detail to the object or structure that is being described. Any of the API functions that use these structures have conditionals in place to check the size of the structure, and determine how it can be used based on the size of teh struct.

Anonymous wrote:
Check the structure FILEGROUPDESCIPTOR. It has a serie of FILEDESCRIPTOR structures as members. How can one be convinced that my code and the ole libraries agrees on where each struct starts?

This structure is just one size for all operating systems:

typedef struct _FILEGROUPDESCRIPTOR {
    UINT cItems; 
    FILEDESCRIPTOR fgd[1]; 
} FILEGROUPDESCRIPTOR, * LPFILEGROUPDESCRIPTOR; 


The fgd field provides a static anchor to hold an array of FILEDESCRIPTOR objects, which is also only one size. The cItems field in this structure indicates how large the buffer is pointed to by fgd. The entire size of the buffer is sizeof<FILEDESCRIPTOR> * cItems.

If you were to allocate memory for this structure, this is one way that you could do it:

// We will allocate enough space for 5 FILEDESCRIPTORS.
FILEGROUPDESCRIPTOR *pfgd;

pfgd = (FILEGROUPDESCRIPTOR*) new BYTE[sizeof(FILEGROUPDESCRIPTOR + (5 * sizeof(FILEDESCRIPTOR))];
if (!pfgd)
{
  // the memory was not properly allocated.
  ...
}

// Now assign the descriptors in the array.
pfgd->fgd[0].dwFlags = 0;
...
pfgd->fgd[1].dwFlags = 0;
...


When ole or anyone else wants to access this structure they will access it in the exact same way.
GeneralRe: struct alignment and OSVERSIONINFO Pin
Joaquín M López Muñoz3-Apr-02 20:43
Joaquín M López Muñoz3-Apr-02 20:43 
GeneralRe: struct alignment and OSVERSIONINFO Pin
3-Apr-02 20:47
suss3-Apr-02 20:47 
QuestionOwnerdraw detect XP or Win9x? Pin
3-Apr-02 19:33
suss3-Apr-02 19:33 
AnswerRe: Ownerdraw detect XP or Win9x? Pin
4-Apr-02 18:22
suss4-Apr-02 18:22 
GeneralBYTE and CString Pin
Mazdak3-Apr-02 19:04
Mazdak3-Apr-02 19:04 
GeneralRe: BYTE and CString Pin
Joaquín M López Muñoz3-Apr-02 20:45
Joaquín M López Muñoz3-Apr-02 20:45 
GeneralJoaquín M López Muñoz ,this is for you!! Pin
Mazdak3-Apr-02 21:46
Mazdak3-Apr-02 21:46 
GeneralRe: Joaquín M López Muñoz ,this is for you!! Pin
Joaquín M López Muñoz3-Apr-02 22:49
Joaquín M López Muñoz3-Apr-02 22:49 
GeneralRe: Joaquín M López Muñoz ,this is for you!! Pin
Mazdak3-Apr-02 23:54
Mazdak3-Apr-02 23:54 
QuestionHow to use function "OnDeleteitem(NMHDR* pNMHDR, LRESULT* pResult) " on ctreectrl? Pin
Feng Qin3-Apr-02 18:16
Feng Qin3-Apr-02 18:16 
AnswerRe: How to use function "OnDeleteitem(NMHDR* pNMHDR, LRESULT* pResult) " on ctreectrl? Pin
Derek Waters3-Apr-02 18:41
Derek Waters3-Apr-02 18:41 
GeneralRe: How to use function "OnDeleteitem(NMHDR* pNMHDR, LRESULT* pResult) " on ctreectrl? Pin
Feng Qin3-Apr-02 19:14
Feng Qin3-Apr-02 19:14 
Generalwin32 app with msg loop but no window Pin
Dorion3-Apr-02 16:53
Dorion3-Apr-02 16:53 
GeneralRe: win32 app with msg loop but no window Pin
Joaquín M López Muñoz3-Apr-02 19:04
Joaquín M López Muñoz3-Apr-02 19:04 
GeneralDisabling "Ready" & Other Auto Status Bar Updates :: MFC Pin
valikac3-Apr-02 16:03
valikac3-Apr-02 16:03 
GeneralGetting Size & Location of ChildView :: MFC Pin
valikac3-Apr-02 14:26
valikac3-Apr-02 14:26 
GeneralRe: Getting Size & Location of ChildView :: MFC Pin
Prem Kumar3-Apr-02 15:00
Prem Kumar3-Apr-02 15:00 

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.