[comp.windows.ms] C++ and Windows 3.0 Programming

chiu@efi.com (Chan Chiu) (09/14/90)

Hi :
   I am studying the feasibile of using C++ with windows 3.0. 


   I understand that Glockenspiel C++ works with 3.0. I like
   to know your experience using these two together.

   Also, since windows has "far" and "pascal" declearation, I 
   assume glockenspiel also supports these "Windows c" dialect ??

   Last question I have is with memory handles. Standard C++ gets
   a pointer for an object. By using this pointer, program can peek
   inside the public section of the object. With Windows, I supposely
   get "handle" instead of pointer. Does that mean that I should avoid
   having public section at all ??

   What other differences do you observe ? I appreciate any comments.

   /Chan Chiu

patrickd@chinet.chi.il.us (Patrick Deupree) (09/19/90)

In article <1990Sep13.212524.25488@efi.com> chiu@efi.com (Chan Chiu) writes:
>Hi :
>   I understand that Glockenspiel C++ works with 3.0. I like
>   to know your experience using these two together.
>
Based on what I've heard from many people, you might want to investigate
something other than Glockenspiel C++ and Commonview (assuming you were
looking at Commonview also).  From what I've heard, the best combination
at this time would be C++/Views and Zortech C++.  Hopefully, very soon,
I'll be able to use both of these personally.

>   Last question I have is with memory handles. Standard C++ gets
>   a pointer for an object. By using this pointer, program can peek
>   inside the public section of the object. With Windows, I supposely
>   get "handle" instead of pointer. Does that mean that I should avoid
>   having public section at all ??

You know, this is something I hadn't thought about.  However, in Windows
pointers are pointers and you'll most likely have to deal with them
at one time or another.  If you're passing a pointer to a routine
where the memory at that pointer location may be swapped out, you'll want
to lock that memory.

However, I see no reason why you'd need to change what you declare as
public to private.  You should be able to use C++ more or less normally.
-- 
"What's in a name?  That which we call a rose by any other name would smell
 as sweet."             William Shakespeare
Patrick Deupree ->	patrickd@chinet.chi.il.us   (708) 328-3800
(Please note there are both a patrick and a patrickd at this site)

al@well.sf.ca.us (Alfred Fontes) (09/21/90)

patrickd@chinet.chi.il.us (Patrick Deupree) writes:
>>   inside the public section of the object. With Windows, I supposely
>>   get "handle" instead of pointer. Does that mean that I should avoid
>>   having public section at all ??

>... I see no reason why you'd need to change what you declare as
>public to private.  You should be able to use C++ more or less normally.


You could use something like:
   #include <stddef.h>
   ...
   void *Object::operator new( size_t size, HANDLE handle )
   ...
which would GlobalLock() the memory and return its address.  You would 
probably want to overload delete accordingly. 

You could also try something like:
   #include <new.h>
   ...
   ptr = new ( GlobalLock(handle) ) Object;
   ...
assuming that the proper amount of memory is tagged by the handle.  This 
will place the new object at the address returned by GlobalLock(). 

Either of these two methods should allow you to treat the objects
more or less in the standard way.