home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / os / mswindo / programm / misc / 4799 < prev    next >
Encoding:
Text File  |  1993-01-09  |  2.7 KB  |  78 lines

  1. Newsgroups: comp.os.ms-windows.programmer.misc
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!torn!nott!emr1!jagrant
  3. From: jagrant@emr1.emr.ca (John Grant)
  4. Subject: Re: Data Type problem !!
  5. Message-ID: <1993Jan10.035219.22954@emr1.emr.ca>
  6. Organization: Energy, Mines, and Resources, Ottawa
  7. References: <1993Jan9.085030.11967%gtonwu@Uz.nthu.edu.tw>
  8. Date: Sun, 10 Jan 1993 03:52:19 GMT
  9. Lines: 67
  10.  
  11. In article <1993Jan9.085030.11967%gtonwu@Uz.nthu.edu.tw> gtonwu@Uz.nthu.edu.tw (Tony) writes:
  12. >Hi, there 
  13. >
  14. >     I am confused by type data types of MSC ! I don't know what is the
  15. >     difference among them , since I was simply using int,unsigned,char..
  16. >     while I did programming under MS-DOS before    !
  17. >
  18. >     Would someone kind enough to tell me the distict difference of the 
  19. >     following !?
  20. >
  21. >       WORD , DWORD, LONG, WPARAM, LPARAM , ... 
  22. >
  23. >       and some others I have to know !
  24.  
  25.     They are all defined in windows.h.  Look in there and you
  26.     will see those and many others.  But you really don't
  27.     have to know what they are because you will *not* be
  28.     manipulating or touching them yourself.  MS provides
  29.     all you need.
  30.  
  31.     For example, when you get a WM_PAINT message, you need
  32.     an HDC (handle to a device context) to call any of
  33.     the GDI drawing functions.  What is it?  Who cares!
  34.     But you do need one.  So, just declare it and use
  35.     it as the function tells you:
  36.         HDC hdc;
  37.         PAINTSTRUCT ps;
  38.         ...
  39.           case WM_PAINT:  hdc=BeginPaint(hdc,&ps);
  40.                   ...gdi functions(hdc,....);
  41.                   EndPaint(hwnd,&ps);
  42.                   break;
  43.     Also, if a windows message tells you that LPARAM contains
  44.     a POINT structure, then just retrieve it with:
  45.         POINT pt;
  46.         pt=MAKEPOINT(lparam);
  47.  
  48.     Usually, the help for each function describes the functions
  49.     and their parameters, returned values etc.
  50.  
  51.     Ok, so I lied.  You do need to know a few things, like
  52.     what is a POINT structure.  You can look up all of these
  53.     things in windows.h and in the docs.
  54.  
  55.     The definitions of HWND,HDC, etc depend on whether you
  56.     use #define STRICT or not (see windows.h).  I strongly
  57.     recommend that you use:
  58.         #define STRICT
  59.         #include <windows.h>
  60.     Most of the HDC, HWND, etc are all just UINT or WORD,
  61.     i.e. just 'int' values when you get right down to it,
  62.     so it is not possible for the compiler to check whether
  63.         function1(hdc,hwnd);
  64.         or    function2(hwnd,hdc);
  65.     is correct.  If you use STRICT, then they are defined
  66.     as pointers to unique structs and the compiler can
  67.     tell you if you are wrong.  I also highly recommend
  68.     enabling every single warning message that your
  69.     compiler can possibly report.  Make sure it warns
  70.     about everything and act on every warning until
  71.     it is quiet.  Your app will be significantly more
  72.     reliable.
  73.  
  74. -- 
  75. John A. Grant                        jagrant@emr1.emr.ca
  76. Airborne Geophysics
  77. Geological Survey of Canada, Ottawa
  78.