Click here to Skip to main content
15,905,508 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneraladdObject() Pin
1-Feb-02 3:42
suss1-Feb-02 3:42 
GeneralRe: addObject() Pin
Jon Hulatt1-Feb-02 4:09
Jon Hulatt1-Feb-02 4:09 
GeneralProblem with menu/activex control event Pin
Roger Allen1-Feb-02 3:28
Roger Allen1-Feb-02 3:28 
GeneralRe: Problem with menu/activex control event Pin
Joaquín M López Muñoz1-Feb-02 3:37
Joaquín M López Muñoz1-Feb-02 3:37 
GeneralRe: Problem with menu/activex control event Pin
Roger Allen1-Feb-02 4:38
Roger Allen1-Feb-02 4:38 
GeneralRe: Problem with menu/activex control event Pin
Joaquín M López Muñoz1-Feb-02 5:33
Joaquín M López Muñoz1-Feb-02 5:33 
GeneralC++ objects in global memory... Pin
Chris Losinger1-Feb-02 2:26
professionalChris Losinger1-Feb-02 2:26 
GeneralRe: C++ objects in global memory... Pin
Joaquín M López Muñoz1-Feb-02 3:05
Joaquín M López Muñoz1-Feb-02 3:05 
Does that seem reasonable?

It looks very reasonable to me except for one thing. IMHO instead of
HGLOBAL hObj = GlobalAlloc(GPTR, sizeof(CMyClass));
CMyClass *pClass = (CMyClass *)hObj;
pClass->Init();
return (HMYOBJ)hObj;
it's simpler to write
CMyClass *pClass = new CMyClass(); // init stuff in the ctor
return (HMYOBJ)pClass;
which works just the same.

If you want to take extra precautions to make sure that the object passed back from the user app is a valid pointer, you can have an internal table of pointers and pass an index to that table, instead of the actual pointer --that's how Win32 does it most of the time.

Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
GeneralWinsock2 Pin
31-Jan-02 23:43
suss31-Jan-02 23:43 
GeneralRe: Winsock2 Pin
Peter Weyzen1-Feb-02 12:41
Peter Weyzen1-Feb-02 12:41 
GeneralRe: Winsock2 Pin
2-Feb-02 23:02
suss2-Feb-02 23:02 
GeneralDownloading and booting WinCE on a LapTop Pin
Gert Boddaert31-Jan-02 23:14
Gert Boddaert31-Jan-02 23:14 
GeneralRe: Downloading and booting WinCE on a LapTop Pin
Gert Boddaert1-Feb-02 5:45
Gert Boddaert1-Feb-02 5:45 
GeneralpItem->CreateNewItem(clsid); and Ms Word Pin
Braulio Dez31-Jan-02 23:09
Braulio Dez31-Jan-02 23:09 
QuestionOLE automation how does it work??? Pin
Gérald Mercet31-Jan-02 22:18
Gérald Mercet31-Jan-02 22:18 
AnswerRe: OLE automation how does it work??? Pin
Braulio Dez31-Jan-02 23:19
Braulio Dez31-Jan-02 23:19 
GeneralCArchive and CompoundFile Pin
wangyiming31-Jan-02 22:04
wangyiming31-Jan-02 22:04 
GeneralRe: CArchive and CompoundFile Pin
wangyiming1-Feb-02 15:11
wangyiming1-Feb-02 15:11 
Generaltrouble Pin
31-Jan-02 21:31
suss31-Jan-02 21:31 
GeneralRe: trouble Pin
Johan Rosengren22-Jun-04 8:42
Johan Rosengren22-Jun-04 8:42 
Questiondoes Windows registry record the bootup and shutdown time? Pin
DengJW31-Jan-02 21:01
DengJW31-Jan-02 21:01 
GeneralSTL - Newbie... Pin
Bernhard31-Jan-02 20:34
Bernhard31-Jan-02 20:34 
GeneralRe: STL - Newbie... Pin
Joaquín M López Muñoz31-Jan-02 23:41
Joaquín M López Muñoz31-Jan-02 23:41 
GeneralRe: STL - Newbie... Pin
Bernhard31-Jan-02 23:51
Bernhard31-Jan-02 23:51 
GeneralSorry i was in a hurry... Pin
Bernhard31-Jan-02 23:53
Bernhard31-Jan-02 23:53 

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.