Advertisement
TLama

Untitled

Sep 5th, 2014
560
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.33 KB | None | 0 0
  1. // PRINTER_OPTION_FLAGS as defined in winspool.h
  2. typedef enum _PRINTER_OPTION_FLAGS
  3. {
  4.     PRINTER_OPTION_NO_CACHE       = 1 << 0,
  5.     PRINTER_OPTION_CACHE          = 1 << 1,
  6.     PRINTER_OPTION_CLIENT_CHANGE  = 1 << 2,
  7.     PRINTER_OPTION_NO_CLIENT_DATA = 1 << 3,
  8. } PRINTER_OPTION_FLAGS;
  9.  
  10. // PRINTER_OPTION_FLAGS literally translated to Delphi
  11. type
  12.   PRINTER_OPTION_FLAGS = (
  13.     PRINTER_OPTION_NO_CACHE       = 1 shl 0,
  14.     PRINTER_OPTION_CACHE          = 1 shl 1,
  15.     PRINTER_OPTION_CLIENT_CHANGE  = 1 shl 2,
  16.     PRINTER_OPTION_NO_CLIENT_DATA = 1 shl 3
  17.   );
  18.  
  19. // but because Delphi would not allow you to directly assign the enum elements to that DWORD field without
  20. // typecasting, it's more comfortable to translate those enum elements as constants in this case
  21. const
  22.   PRINTER_OPTION_NO_CACHE       = 1 shl 0;
  23.   PRINTER_OPTION_CACHE          = 1 shl 1;
  24.   PRINTER_OPTION_CLIENT_CHANGE  = 1 shl 2;
  25.   PRINTER_OPTION_NO_CLIENT_DATA = 1 shl 3;
  26.  
  27. // otherwise, you would need to write something like follows (which is the most precise, but requires more
  28. // writing and still gives you no type safety because you can mistype what is shown on the second line)
  29. var
  30.   Options: PRINTER_OPTIONSA;
  31. begin
  32.   ...
  33.   Options.dwFlags := DWORD(PRINTER_OPTION_NO_CACHE);
  34.   ...
  35.   Options.dwFlags := DWORD(alClient); // <- not much typesafe, right ?
  36. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement