home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 17.ddi / SAMPLES / SHOWGDI / DIALOGS.C_ / DIALOGS.C
Encoding:
C/C++ Source or Header  |  1993-02-08  |  60.4 KB  |  1,686 lines

  1. /****************************************************************************
  2.  Dialogs.c
  3.  
  4.  The Dialogs module contains all of the dialog handler procs.
  5.  
  6. ****************************************************************************/
  7.  
  8. #include "windows.h"
  9. #include <stdlib.h>
  10.  
  11. #include "resource.h"
  12.  
  13. #include "util.h"
  14. #include "main.h"
  15. #include "view.h"
  16. #include "dc.h"
  17. #include "draw.h"
  18. #include "dib.h"
  19.  
  20. #include "dialogs.h"
  21.  
  22.  
  23. /****************************************************************************
  24.    General dialog utilities
  25. ****************************************************************************/
  26.  
  27. #define GetIntField( hDlg, item )   \
  28.    ((int) GetDlgItemInt( hDlg, item, NULL, TRUE))
  29.  
  30. #define SetIntField( hDlg, item, value  )   \
  31.    SetDlgItemInt( hDlg, item, value, TRUE)
  32.  
  33. #define GetCheckField( hDlg, item ) \
  34.    (SendDlgItemMessage( hDlg, item, BM_GETCHECK, 0, 0L) != 0)
  35.  
  36. #define SetCheckField( hDlg, item, value ) \
  37.    SendDlgItemMessage( hDlg, item, BM_SETCHECK, value, 0L)
  38.  
  39. #define EnableItem( hDlg, item, enable ) \
  40.    EnableWindow( GetDlgItem( hDlg, item ), enable )
  41.  
  42.  
  43. int RunDlg( LPSTR name, FARPROC procInst, HWND parent )
  44. /* Run the dialog template 'name' with handler proc given by 'procInst'
  45.    which was calculated via MakeProcInstance() and return the result. */
  46. {
  47.    int   result;
  48.  
  49.    result = DialogBox( hInst, name, parent, procInst );
  50.    FreeProcInstance( procInst );
  51.    return result;
  52. }
  53.  
  54.  
  55. void CenterDialog( HWND hDlg )
  56. /* Center the dialog w.r.t. hwndMain. */
  57. {
  58.    RECT  mainRect, dlgRect;
  59.    int   screenWidth, screenHeight;
  60.    int   x, y;
  61.  
  62.    /* Center's its dialogs relative to the main window. However,
  63.       if the window is off the screen, the whole dialog is shown. */
  64.    GetWindowRect( hwndMain, &mainRect);
  65.    GetWindowRect( hDlg, &dlgRect );
  66.    screenWidth = GetSystemMetrics( SM_CXSCREEN );
  67.    screenHeight = GetSystemMetrics( SM_CYSCREEN );
  68.  
  69.    /* Calculate the new position; first center, then ensure the whole dialog
  70.       is on the screen */
  71.    x = (Width( mainRect )-Width( dlgRect )) / 2 + mainRect.left;
  72.    y = (Height( mainRect )-Height( dlgRect )) / 2 + mainRect.top;
  73.    x = Max( 0, Min( screenWidth - Width( dlgRect ), x ));
  74.    y = Max( 0, Min( screenHeight - Height( dlgRect ), y ));
  75.    SetWindowPos( hDlg, NULL, x, y, 0, 0, 
  76.                  SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
  77. }
  78.  
  79.  
  80. LPSTR FileNameFromPath( LPSTR path )
  81. /* Return the filename portion of a pathname. */
  82. {
  83.    LPSTR p;
  84.  
  85.    if (path == NULL)
  86.       return NULL;
  87.  
  88.    p = path + lstrlen( path ) - 1;
  89.    while( p > path && *p != '\\' && *p != ':' )
  90.       p--;
  91.    return (p > path) ? (p + 1) : path;
  92. }
  93.  
  94.  
  95. /****************************************************************************
  96.    About box
  97. ****************************************************************************/
  98.  
  99. DLGPROC AboutDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  100. {
  101.    switch (msg) {
  102.       case WM_INITDIALOG:
  103.          CenterDialog( hDlg );
  104.          return (TRUE);
  105.  
  106.       case WM_COMMAND:
  107.          if (wParam == IDOK) {
  108.             EndDialog( hDlg, TRUE );
  109.          }else if (wParam == IDCANCEL) {
  110.             EndDialog( hDlg, FALSE );
  111.          }
  112.          return (TRUE);
  113.    }
  114.    return (FALSE);
  115. }
  116.  
  117.  
  118. /****************************************************************************
  119.    View menu dialogs
  120. ****************************************************************************/
  121.  
  122. DLGPROC SetScaleDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  123. {
  124.    int   newScale;
  125.  
  126.    switch (msg) {
  127.       case WM_INITDIALOG:
  128.          CenterDialog( hDlg );
  129.          SetIntField( hDlg, IF_SCALE, viewScale );
  130.          return (TRUE);
  131.  
  132.       case WM_COMMAND:
  133.          if (wParam == IDOK) {
  134.             newScale = GetIntField( hDlg, IF_SCALE );
  135.             if (newScale >= MIN_SCALE && newScale <= MAX_SCALE) {
  136.                viewScale = newScale;
  137.                EndDialog( hDlg, TRUE );
  138.             }else{
  139.                SetIntField( hDlg, IF_SCALE, Max( MIN_SCALE, Min( MAX_SCALE,
  140.                      newScale ) ) );
  141.             }
  142.          }else if (wParam == IDCANCEL) {
  143.             EndDialog( hDlg, FALSE );
  144.          }
  145.          return (TRUE);
  146.    }
  147.    return (FALSE);
  148. }
  149.  
  150.  
  151. DLGPROC DrawingSizeDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  152. {
  153.    switch (msg) {
  154.       case WM_INITDIALOG:
  155.          CenterDialog( hDlg );
  156.          SetIntField( hDlg, IF_X, drawSize.x );
  157.          SetIntField( hDlg, IF_Y, drawSize.y );
  158.          return (TRUE);
  159.  
  160.       case WM_COMMAND:
  161.          if (wParam == IDOK) {
  162.             drawSize.x = GetIntField( hDlg, IF_X );
  163.             drawSize.y = GetIntField( hDlg, IF_Y );
  164.             EndDialog( hDlg, TRUE );
  165.          }else if (wParam == IDCANCEL) {
  166.             EndDialog( hDlg, FALSE );
  167.          }
  168.          return (TRUE);
  169.    }
  170.    return (FALSE);
  171. }
  172.  
  173.  
  174. /****************************************************************************
  175.    Dialogs progs for DC settings
  176. ****************************************************************************/
  177.  
  178. DLGPROC CoordsDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  179. {
  180.    switch (msg) {
  181.       case WM_INITDIALOG:
  182.          CenterDialog( hDlg );
  183.          SetCheckField( hDlg, BF_MM_TEXT, (dcv.mapMode == MM_TEXT) );
  184.          SetCheckField( hDlg, BF_MM_TWIPS, (dcv.mapMode == MM_TWIPS) );
  185.          SetCheckField( hDlg, BF_MM_ISOTROPIC, (dcv.mapMode == MM_ISOTROPIC) );
  186.          SetCheckField( hDlg, BF_MM_ANISOTROPIC, (dcv.mapMode == MM_ANISOTROPIC) );
  187.          SetCheckField( hDlg, BF_MM_LOMETRIC, (dcv.mapMode == MM_LOMETRIC) );
  188.          SetCheckField( hDlg, BF_MM_HIMETRIC, (dcv.mapMode == MM_HIMETRIC) );
  189.          SetCheckField( hDlg, BF_MM_LOENGLISH, (dcv.mapMode == MM_LOENGLISH) );
  190.          SetCheckField( hDlg, BF_MM_HIENGLISH, (dcv.mapMode == MM_HIENGLISH) );
  191.          SetIntField( hDlg, IF_VO_X, dcv.viewportOrg.x );
  192.          SetIntField( hDlg, IF_VO_Y, dcv.viewportOrg.y );
  193.          SetIntField( hDlg, IF_VE_X, dcv.viewportExt.x );
  194.          SetIntField( hDlg, IF_VE_Y, dcv.viewportExt.y );
  195.          SetIntField( hDlg, IF_WO_X, dcv.windowOrg.x );
  196.          SetIntField( hDlg, IF_WO_Y, dcv.windowOrg.y );
  197.          SetIntField( hDlg, IF_WE_X, dcv.windowExt.x );
  198.          SetIntField( hDlg, IF_WE_Y, dcv.windowExt.y );
  199.          return (TRUE);
  200.  
  201.       case WM_COMMAND:
  202.          if (wParam == IDOK) {
  203.             if (GetCheckField( hDlg, BF_MM_TEXT ))
  204.                dcv.mapMode = MM_TEXT;
  205.             else if (GetCheckField( hDlg, BF_MM_TWIPS ))
  206.                dcv.mapMode = MM_TWIPS;
  207.             else if (GetCheckField( hDlg, BF_MM_ISOTROPIC ))
  208.                dcv.mapMode = MM_ISOTROPIC;
  209.             else if (GetCheckField( hDlg, BF_MM_ANISOTROPIC ))
  210.                dcv.mapMode = MM_ANISOTROPIC;
  211.             else if (GetCheckField( hDlg, BF_MM_LOMETRIC ))
  212.                dcv.mapMode = MM_LOMETRIC;
  213.             else if (GetCheckField( hDlg, BF_MM_HIMETRIC ))
  214.                dcv.mapMode = MM_HIMETRIC;
  215.             else if (GetCheckField( hDlg, BF_MM_LOENGLISH ))
  216.                dcv.mapMode = MM_LOENGLISH;
  217.             else if (GetCheckField( hDlg, BF_MM_HIENGLISH ))
  218.                dcv.mapMode = MM_HIENGLISH;
  219.             else
  220.                dcv.mapMode = MM_TEXT;
  221.             dcv.viewportOrg.x = GetIntField( hDlg, IF_VO_X );
  222.             dcv.viewportOrg.y = GetIntField( hDlg, IF_VO_Y );
  223.             dcv.viewportExt.x = GetIntField( hDlg, IF_VE_X );
  224.             dcv.viewportExt.y = GetIntField( hDlg, IF_VE_Y );
  225.             dcv.windowOrg.x = GetIntField( hDlg, IF_WO_X );
  226.             dcv.windowOrg.y = GetIntField( hDlg, IF_WO_Y );
  227.             dcv.windowExt.x = GetIntField( hDlg, IF_WE_X );
  228.             dcv.windowExt.y = GetIntField( hDlg, IF_WE_Y );
  229.             EndDialog( hDlg, TRUE );
  230.          }else if (wParam == IDCANCEL) {
  231.             EndDialog( hDlg, FALSE );
  232.          }
  233.          return (TRUE);
  234.    }
  235.    return (FALSE);
  236. }
  237.  
  238.  
  239. DLGPROC ClipDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  240. {
  241.    switch (msg) {
  242.       case WM_INITDIALOG:
  243.          CenterDialog( hDlg );
  244.          SetCheckField( hDlg, BF_INTERSECT_CLIP, dcv.intersect );
  245.          SetIntField( hDlg, IF_INTERSECT_LEFT, dcv.rIntersect.left );
  246.          SetIntField( hDlg, IF_INTERSECT_TOP, dcv.rIntersect.top );
  247.          SetIntField( hDlg, IF_INTERSECT_RIGHT, dcv.rIntersect.right );
  248.          SetIntField( hDlg, IF_INTERSECT_BOTTOM, dcv.rIntersect.bottom );
  249.          SetCheckField( hDlg, BF_EXCLUDE_CLIP, dcv.exclude );
  250.          SetIntField( hDlg, IF_EXCLUDE_LEFT, dcv.rExclude.left );
  251.          SetIntField( hDlg, IF_EXCLUDE_TOP, dcv.rExclude.top );
  252.          SetIntField( hDlg, IF_EXCLUDE_RIGHT, dcv.rExclude.right );
  253.          SetIntField( hDlg, IF_EXCLUDE_BOTTOM, dcv.rExclude.bottom );
  254.          return (TRUE);
  255.  
  256.       case WM_COMMAND:
  257.          if (wParam == IDOK) {
  258.             dcv.intersect = GetCheckField( hDlg, BF_INTERSECT_CLIP );
  259.             dcv.rIntersect.left = GetIntField( hDlg, IF_INTERSECT_LEFT );
  260.             dcv.rIntersect.top = GetIntField( hDlg, IF_INTERSECT_TOP );
  261.             dcv.rIntersect.right = GetIntField( hDlg, IF_INTERSECT_RIGHT );
  262.             dcv.rIntersect.bottom = GetIntField( hDlg, IF_INTERSECT_BOTTOM );
  263.             dcv.exclude = GetCheckField( hDlg, BF_EXCLUDE_CLIP );
  264.             dcv.rExclude.left = GetIntField( hDlg, IF_EXCLUDE_LEFT );
  265.             dcv.rExclude.top = GetIntField( hDlg, IF_EXCLUDE_TOP );
  266.             dcv.rExclude.right = GetIntField( hDlg, IF_EXCLUDE_RIGHT );
  267.             dcv.rExclude.bottom = GetIntField( hDlg, IF_EXCLUDE_BOTTOM );
  268.             EndDialog( hDlg, TRUE );
  269.          }else if (wParam == IDCANCEL) {
  270.             EndDialog( hDlg, FALSE );
  271.          }
  272.          return (TRUE);
  273.    }
  274.    return (FALSE);
  275. }
  276.  
  277.  
  278. DLGPROC BkColorDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  279. {
  280.    switch (msg) {
  281.       case WM_INITDIALOG:
  282.          CenterDialog( hDlg );
  283.          SetIntField( hDlg, IF_RGB_R, (int) GetRValue( dcv.bkColor ) );
  284.          SetIntField( hDlg, IF_RGB_G, (int) GetGValue( dcv.bkColor ) );
  285.          SetIntField( hDlg, IF_RGB_B, (int) GetBValue( dcv.bkColor ) );
  286.          return (TRUE);
  287.  
  288.       case WM_COMMAND:
  289.          if (wParam == IDOK) {
  290.             dcv.bkColor = RGB( GetIntField( hDlg, IF_RGB_R ),
  291.                                GetIntField( hDlg, IF_RGB_G ),
  292.                                GetIntField( hDlg, IF_RGB_B ) );
  293.             EndDialog( hDlg, TRUE );
  294.          }else if (wParam == IDCANCEL) {
  295.             EndDialog( hDlg, FALSE );
  296.          }
  297.          return (TRUE);
  298.    }
  299.    return (FALSE);
  300. }
  301.  
  302.  
  303. DLGPROC BkModeDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  304. {
  305.    switch (msg) {
  306.       case WM_INITDIALOG:
  307.          CenterDialog( hDlg );
  308.          SetCheckField( hDlg, BF_OPAQUE, (dcv.bkMode == OPAQUE) );
  309.          SetCheckField( hDlg, BF_TRANSPARENT, (dcv.bkMode == TRANSPARENT) );
  310.          return (TRUE);
  311.  
  312.       case WM_COMMAND:
  313.          if (wParam == IDOK) {
  314.             dcv.bkMode = GetCheckField( hDlg, BF_TRANSPARENT ) ? 
  315.                   TRANSPARENT : OPAQUE;
  316.             EndDialog( hDlg, TRUE );
  317.          }else if (wParam == IDCANCEL) {
  318.             EndDialog( hDlg, FALSE );
  319.          }
  320.          return (TRUE);
  321.    }
  322.    return (FALSE);
  323. }
  324.  
  325.  
  326. DLGPROC BrushOrgDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  327. {
  328.    switch (msg) {
  329.       case WM_INITDIALOG:
  330.          CenterDialog( hDlg );
  331.          SetIntField( hDlg, IF_X, dcv.brushOrg.x );
  332.          SetIntField( hDlg, IF_Y, dcv.brushOrg.y );
  333.          return (TRUE);
  334.  
  335.       case WM_COMMAND:
  336.          if (wParam == IDOK) {
  337.             dcv.brushOrg.x = GetIntField( hDlg, IF_X );
  338.             dcv.brushOrg.y = GetIntField( hDlg, IF_Y );
  339.             EndDialog( hDlg, TRUE );
  340.          }else if (wParam == IDCANCEL) {
  341.             EndDialog( hDlg, FALSE );
  342.          }
  343.          return (TRUE);
  344.    }
  345.    return (FALSE);
  346. }
  347.  
  348.  
  349. DLGPROC PenPosDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  350. {
  351.    switch (msg) {
  352.       case WM_INITDIALOG:
  353.          CenterDialog( hDlg );
  354.          SetIntField( hDlg, IF_TO_X, dcv.penPos.x );
  355.          SetIntField( hDlg, IF_TO_Y, dcv.penPos.y );
  356.          return (TRUE);
  357.  
  358.       case WM_COMMAND:
  359.          if (wParam == IDOK) {
  360.             dcv.penPos.x = GetIntField( hDlg, IF_TO_X );
  361.             dcv.penPos.y = GetIntField( hDlg, IF_TO_Y );
  362.             EndDialog( hDlg, TRUE );
  363.          }else if (wParam == IDCANCEL) {
  364.             EndDialog( hDlg, FALSE );
  365.          }
  366.          return (TRUE);
  367.    }
  368.    return (FALSE);
  369. }
  370.  
  371.  
  372. #if FALSE
  373.  
  374. DLGPROC RelAbsDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  375. {
  376.    switch (msg) {
  377.       case WM_INITDIALOG:
  378.          CenterDialog( hDlg );
  379.          SetCheckField( hDlg, BF_ABSOLUTE, (dcv.relAbs == ABSOLUTE) );
  380.          SetCheckField( hDlg, BF_RELATIVE, (dcv.relAbs == RELATIVE) );
  381.          return (TRUE);
  382.  
  383.       case WM_COMMAND:
  384.          if (wParam == IDOK) {
  385.             dcv.relAbs = GetCheckField( hDlg, BF_RELATIVE ) ?
  386.                   RELATIVE : ABSOLUTE;
  387.             EndDialog( hDlg, TRUE );
  388.          }else if (wParam == IDCANCEL) {
  389.             EndDialog( hDlg, FALSE );
  390.          }
  391.          return (TRUE);
  392.    }
  393.    return (FALSE);
  394. }
  395.  
  396. #endif
  397.  
  398.  
  399. DLGPROC FontDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  400. {
  401.    switch (msg) {
  402.       case WM_INITDIALOG:
  403.          CenterDialog( hDlg );
  404.          SetDlgItemText( hDlg, SF_FACENAME,  dcv.font.lfFaceName );
  405.          SetIntField( hDlg, IF_HEIGHT,       dcv.font.lfHeight );
  406.          SetIntField( hDlg, IF_WIDTH,        dcv.font.lfWidth );
  407.          SetIntField( hDlg, IF_ESCAPEMENT,   dcv.font.lfEscapement );
  408.          SetIntField( hDlg, IF_ORIENTATION,  dcv.font.lfOrientation );
  409.          SetIntField( hDlg, IF_WEIGHT,       dcv.font.lfWeight );
  410.          SetCheckField( hDlg, BF_ITALIC,     dcv.font.lfItalic );
  411.          SetCheckField( hDlg, BF_UNDERLINE,  dcv.font.lfUnderline );
  412.          SetCheckField( hDlg, BF_STRIKEOUT,  dcv.font.lfStrikeOut );
  413.          SetCheckField( hDlg, BF_CS_ANSI,    (dcv.font.lfCharSet == ANSI_CHARSET) );
  414.          SetCheckField( hDlg, BF_CS_OEM,     (dcv.font.lfCharSet == OEM_CHARSET) );
  415.          SetCheckField( hDlg, BF_CS_SYMBOL,  (dcv.font.lfCharSet == SYMBOL_CHARSET) );
  416.          SetCheckField( hDlg, BF_OP_DEFAULT, (dcv.font.lfOutPrecision == OUT_DEFAULT_PRECIS) );
  417.          SetCheckField( hDlg, BF_OP_STRING,  (dcv.font.lfOutPrecision == OUT_STRING_PRECIS) );
  418.          SetCheckField( hDlg, BF_OP_CHAR,    (dcv.font.lfOutPrecision == OUT_CHARACTER_PRECIS) );
  419.          SetCheckField( hDlg, BF_OP_STROKE,  (dcv.font.lfOutPrecision == OUT_STROKE_PRECIS) );
  420.          SetCheckField( hDlg, BF_CP_DEFAULT, (dcv.font.lfClipPrecision == CLIP_DEFAULT_PRECIS) );
  421.          SetCheckField( hDlg, BF_CP_CHAR,    (dcv.font.lfClipPrecision == CLIP_CHARACTER_PRECIS) );
  422.          SetCheckField( hDlg, BF_CP_STROKE,  (dcv.font.lfClipPrecision == CLIP_STROKE_PRECIS) );
  423.          SetCheckField( hDlg, BF_Q_DEFAULT,  (dcv.font.lfQuality == DEFAULT_QUALITY) );
  424.          SetCheckField( hDlg, BF_Q_DRAFT,    (dcv.font.lfQuality == DRAFT_QUALITY) );
  425.          SetCheckField( hDlg, BF_Q_PROOF,    (dcv.font.lfQuality == PROOF_QUALITY) );
  426.          SetCheckField( hDlg, BF_P_DEFAULT,  ((dcv.font.lfPitchAndFamily & 3) == DEFAULT_PITCH) );
  427.          SetCheckField( hDlg, BF_P_FIXED,    ((dcv.font.lfPitchAndFamily & 3) == FIXED_PITCH) );
  428.          SetCheckField( hDlg, BF_P_VARIABLE, ((dcv.font.lfPitchAndFamily & 3) == VARIABLE_PITCH) );
  429.          SetCheckField( hDlg, BF_F_DONTCARE, ((dcv.font.lfPitchAndFamily & ~3) == FF_DONTCARE) );
  430.          SetCheckField( hDlg, BF_F_ROMAN,    ((dcv.font.lfPitchAndFamily & ~3) == FF_ROMAN) );
  431.          SetCheckField( hDlg, BF_F_SWISS,    ((dcv.font.lfPitchAndFamily & ~3) == FF_SWISS) );
  432.          SetCheckField( hDlg, BF_F_MODERN,   ((dcv.font.lfPitchAndFamily & ~3) == FF_MODERN) );
  433.          SetCheckField( hDlg, BF_F_SCRIPT,   ((dcv.font.lfPitchAndFamily & ~3) == FF_SCRIPT) );
  434.          SetCheckField( hDlg, BF_F_DECORATIVE, ((dcv.font.lfPitchAndFamily & ~3) == FF_DECORATIVE) );
  435.          return (TRUE);
  436.  
  437.       case WM_COMMAND:
  438.          if (wParam == IDOK) {
  439.             GetDlgItemText( hDlg, SF_FACENAME, dcv.font.lfFaceName, LF_FACESIZE );
  440.             dcv.font.lfHeight = GetIntField( hDlg, IF_HEIGHT );
  441.             dcv.font.lfWidth = GetIntField( hDlg, IF_WIDTH );
  442.             dcv.font.lfEscapement = GetIntField( hDlg, IF_ESCAPEMENT );
  443.             dcv.font.lfOrientation = GetIntField( hDlg, IF_ORIENTATION );
  444.             dcv.font.lfWeight = GetIntField( hDlg, IF_WEIGHT );
  445.             dcv.font.lfItalic = (BYTE) GetCheckField( hDlg, BF_ITALIC );
  446.             dcv.font.lfUnderline = (BYTE) GetCheckField( hDlg, BF_UNDERLINE );
  447.             dcv.font.lfStrikeOut = (BYTE) GetCheckField( hDlg, BF_STRIKEOUT );
  448.  
  449.             if (GetCheckField( hDlg, BF_CS_ANSI )) {
  450.                dcv.font.lfCharSet = ANSI_CHARSET;
  451.             }else if (GetCheckField( hDlg, BF_CS_OEM )) {
  452.                dcv.font.lfCharSet = OEM_CHARSET;
  453.             }else{
  454.                dcv.font.lfCharSet = SYMBOL_CHARSET;
  455.             }
  456.             if (GetCheckField( hDlg, BF_OP_DEFAULT )) { 
  457.                dcv.font.lfOutPrecision = OUT_DEFAULT_PRECIS;
  458.             }else if (GetCheckField( hDlg, BF_OP_STRING )) {
  459.                dcv.font.lfOutPrecision = OUT_STRING_PRECIS;
  460.             }else if (GetCheckField( hDlg, BF_OP_CHAR )) {    
  461.                dcv.font.lfOutPrecision = OUT_CHARACTER_PRECIS;
  462.             }else{
  463.                dcv.font.lfOutPrecision = OUT_STROKE_PRECIS;
  464.             }
  465.             if (GetCheckField( hDlg, BF_CP_DEFAULT )) {
  466.                dcv.font.lfClipPrecision = CLIP_DEFAULT_PRECIS;
  467.             }else if (GetCheckField( hDlg, BF_CP_CHAR )) {
  468.                dcv.font.lfClipPrecision = CLIP_CHARACTER_PRECIS;
  469.             }else{
  470.                dcv.font.lfClipPrecision = CLIP_STROKE_PRECIS;
  471.             }
  472.             if (GetCheckField( hDlg, BF_Q_DEFAULT )) {  
  473.                dcv.font.lfQuality = DEFAULT_QUALITY;
  474.             }else if (GetCheckField( hDlg, BF_Q_DRAFT )) {
  475.                dcv.font.lfQuality = DRAFT_QUALITY;
  476.             }else{
  477.                dcv.font.lfQuality = PROOF_QUALITY;
  478.             }
  479.             dcv.font.lfPitchAndFamily = 0;
  480.             if (GetCheckField( hDlg, BF_P_DEFAULT ))     dcv.font.lfPitchAndFamily |= DEFAULT_PITCH; 
  481.             if (GetCheckField( hDlg, BF_P_FIXED ))       dcv.font.lfPitchAndFamily |= FIXED_PITCH;   
  482.             if (GetCheckField( hDlg, BF_P_VARIABLE ))    dcv.font.lfPitchAndFamily |= VARIABLE_PITCH;
  483.             if (GetCheckField( hDlg, BF_F_DONTCARE ))    dcv.font.lfPitchAndFamily |= FF_DONTCARE;  
  484.             if (GetCheckField( hDlg, BF_F_ROMAN ))       dcv.font.lfPitchAndFamily |= FF_ROMAN;     
  485.             if (GetCheckField( hDlg, BF_F_SWISS ))       dcv.font.lfPitchAndFamily |= FF_SWISS;     
  486.             if (GetCheckField( hDlg, BF_F_MODERN ))      dcv.font.lfPitchAndFamily |= FF_MODERN;    
  487.             if (GetCheckField( hDlg, BF_F_SCRIPT ))      dcv.font.lfPitchAndFamily |= FF_SCRIPT;    
  488.             if (GetCheckField( hDlg, BF_F_DECORATIVE ))  dcv.font.lfPitchAndFamily |= FF_DECORATIVE;
  489.             EndDialog( hDlg, TRUE );
  490.          }else if (wParam == IDCANCEL) {
  491.             EndDialog( hDlg, FALSE );
  492.          }
  493.          return (TRUE);
  494.    }
  495.    return (FALSE);
  496. }
  497.  
  498.  
  499. DLGPROC TextAlignDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  500. {
  501.    int   horz, vert, update;
  502.  
  503.    switch (msg) {
  504.       case WM_INITDIALOG:
  505.          CenterDialog( hDlg );
  506.          horz = dcv.textAlign & (TA_LEFT | TA_CENTER | TA_RIGHT);
  507.          vert = dcv.textAlign & (TA_TOP | TA_BASELINE | TA_BOTTOM);
  508.          update = dcv.textAlign & (TA_UPDATECP | TA_NOUPDATECP);
  509.          SetCheckField( hDlg, BF_LEFT, (horz == TA_LEFT) );
  510.          SetCheckField( hDlg, BF_CENTER, (horz == TA_CENTER) );
  511.          SetCheckField( hDlg, BF_RIGHT, (horz == TA_RIGHT) );
  512.          SetCheckField( hDlg, BF_TOP, (vert == TA_TOP) );
  513.          SetCheckField( hDlg, BF_BASELINE, (vert == TA_BASELINE) );
  514.          SetCheckField( hDlg, BF_BOTTOM, (vert == TA_BOTTOM) );
  515.          SetCheckField( hDlg, BF_UPDATECP, (update == TA_UPDATECP) );
  516.          return (TRUE);
  517.  
  518.       case WM_COMMAND:
  519.          if (wParam == IDOK) {
  520.             dcv.textAlign = 0;
  521.             if (GetCheckField( hDlg, BF_LEFT ))
  522.                dcv.textAlign |= TA_LEFT;
  523.             if (GetCheckField( hDlg, BF_CENTER ))
  524.                dcv.textAlign |= TA_CENTER;
  525.             if (GetCheckField( hDlg, BF_RIGHT ))
  526.                dcv.textAlign |= TA_RIGHT;
  527.             if (GetCheckField( hDlg, BF_TOP ))
  528.                dcv.textAlign |= TA_TOP;
  529.             if (GetCheckField( hDlg, BF_BASELINE ))
  530.                dcv.textAlign |= TA_BASELINE;
  531.             if (GetCheckField( hDlg, BF_BOTTOM ))
  532.                dcv.textAlign |= TA_BOTTOM;
  533.             if (GetCheckField( hDlg, BF_UPDATECP )) {
  534.                dcv.textAlign |= TA_UPDATECP;
  535.             }else{
  536.                dcv.textAlign |= TA_NOUPDATECP;
  537.             }
  538.             EndDialog( hDlg, TRUE );
  539.          }else if (wParam == IDCANCEL) {
  540.             EndDialog( hDlg, FALSE );
  541.          }
  542.          return (TRUE);
  543.    }
  544.    return (FALSE);
  545. }
  546.  
  547.  
  548. DLGPROC TextJustDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  549. {
  550.    switch (msg) {
  551.       case WM_INITDIALOG:
  552.          CenterDialog( hDlg );
  553.          SetIntField( hDlg, IF_WIDTH, dcv.breakExtra );
  554.          SetIntField( hDlg, IF_N, dcv.breakCount );
  555.          return (TRUE);
  556.  
  557.       case WM_COMMAND:
  558.          if (wParam == IDOK) {
  559.             dcv.breakExtra = GetIntField( hDlg, IF_WIDTH );
  560.             dcv.breakCount = GetIntField( hDlg, IF_N );
  561.             EndDialog( hDlg, TRUE );
  562.          }else if (wParam == IDCANCEL) {
  563.             EndDialog( hDlg, FALSE );
  564.          }
  565.          return (TRUE);
  566.    }
  567.    return (FALSE);
  568. }
  569.  
  570.  
  571. DLGPROC TextExtraDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  572. {
  573.    switch (msg) {
  574.       case WM_INITDIALOG:
  575.          CenterDialog( hDlg );
  576.          SetIntField( hDlg, IF_WIDTH, dcv.textExtra );
  577.          return (TRUE);
  578.  
  579.       case WM_COMMAND:
  580.          if (wParam == IDOK) {
  581.             dcv.textExtra = GetIntField( hDlg, IF_WIDTH );
  582.             EndDialog( hDlg, TRUE );
  583.          }else if (wParam == IDCANCEL) {
  584.             EndDialog( hDlg, FALSE );
  585.          }
  586.          return (TRUE);
  587.    }
  588.    return (FALSE);
  589. }
  590.  
  591.  
  592. DLGPROC TextColorDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  593. {
  594.    switch (msg) {
  595.       case WM_INITDIALOG:
  596.          CenterDialog( hDlg );
  597.          SetIntField( hDlg, IF_RGB_R, (int) GetRValue( dcv.textColor ) );
  598.          SetIntField( hDlg, IF_RGB_G, (int) GetGValue( dcv.textColor ) );
  599.          SetIntField( hDlg, IF_RGB_B, (int) GetBValue( dcv.textColor ) );
  600.          return (TRUE);
  601.  
  602.       case WM_COMMAND:
  603.          if (wParam == IDOK) {
  604.             dcv.textColor = RGB( GetIntField( hDlg, IF_RGB_R ),
  605.                                  GetIntField( hDlg, IF_RGB_G ),
  606.                                  GetIntField( hDlg, IF_RGB_B ) );
  607.             EndDialog( hDlg, TRUE );
  608.          }else if (wParam == IDCANCEL) {
  609.             EndDialog( hDlg, FALSE );
  610.          }
  611.          return (TRUE);
  612.    }
  613.    return (FALSE);
  614. }
  615.  
  616.  
  617. DLGPROC ROP2DlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  618. {
  619.    int   i;
  620.  
  621.    switch (msg) {
  622.       case WM_INITDIALOG:
  623.          CenterDialog( hDlg );
  624.          for (i = BF_BLACK; i <= BF_WHITE; i++) {
  625.             SetCheckField( hDlg, i, FALSE );
  626.          }
  627.          if (dcv.rop2 >= R2_BLACK && dcv.rop2 <= R2_WHITE) {
  628.             SetCheckField( hDlg, dcv.rop2 - R2_BLACK + BF_BLACK, TRUE );
  629.          }else{
  630.             SetCheckField( hDlg, BF_COPYPEN, TRUE );
  631.          }
  632.          return (TRUE);
  633.  
  634.       case WM_COMMAND:
  635.          if (wParam == IDOK) {
  636.             for (i = BF_BLACK; i <= BF_WHITE; i++) {
  637.                if (GetCheckField( hDlg, i ))
  638.                   dcv.rop2 = i - BF_BLACK + R2_BLACK;
  639.             }
  640.             EndDialog( hDlg, TRUE );
  641.          }else if (wParam == IDCANCEL) {
  642.             EndDialog( hDlg, FALSE );
  643.          }
  644.          return (TRUE);
  645.    }
  646.    return (FALSE);
  647. }
  648.  
  649.  
  650. DLGPROC PolyModeDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  651. {
  652.    switch (msg) {
  653.       case WM_INITDIALOG:
  654.          CenterDialog( hDlg );
  655.          SetCheckField( hDlg, BF_ALTERNATE, (dcv.polyFillMode == ALTERNATE) );
  656.          SetCheckField( hDlg, BF_WINDING, (dcv.polyFillMode == WINDING) );
  657.          return (TRUE);
  658.  
  659.       case WM_COMMAND:
  660.          if (wParam == IDOK) {
  661.             dcv.polyFillMode = GetCheckField( hDlg, BF_WINDING ) ?
  662.                WINDING : ALTERNATE;
  663.             EndDialog( hDlg, TRUE );
  664.          }else if (wParam == IDCANCEL) {
  665.             EndDialog( hDlg, FALSE );
  666.          }
  667.          return (TRUE);
  668.    }
  669.    return (FALSE);
  670. }
  671.  
  672.  
  673. DLGPROC BltModeDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  674. {
  675.    switch (msg) {
  676.       case WM_INITDIALOG:
  677.          CenterDialog( hDlg );
  678.          SetCheckField( hDlg, BF_BLACKONWHITE, (dcv.bltMode == BLACKONWHITE) );
  679.          SetCheckField( hDlg, BF_WHITEONBLACK, (dcv.bltMode == WHITEONBLACK) );
  680.          SetCheckField( hDlg, BF_COLORONCOLOR, (dcv.bltMode == COLORONCOLOR) );
  681.          return (TRUE);
  682.  
  683.       case WM_COMMAND:
  684.          if (wParam == IDOK) {
  685.             if (GetCheckField( hDlg, BF_BLACKONWHITE )) {
  686.                dcv.bltMode = BLACKONWHITE;
  687.             }else if (GetCheckField( hDlg, BF_WHITEONBLACK )) {
  688.                dcv.bltMode = WHITEONBLACK;
  689.             }else{
  690.                dcv.bltMode = COLORONCOLOR;
  691.             }
  692.             EndDialog( hDlg, TRUE );
  693.          }else if (wParam == IDCANCEL) {
  694.             EndDialog( hDlg, FALSE );
  695.          }
  696.          return (TRUE);
  697.    }
  698.    return (FALSE);
  699. }
  700.  
  701.  
  702. DLGPROC SolidBrushDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  703. {
  704.    switch (msg) {
  705.       case WM_INITDIALOG:
  706.          CenterDialog( hDlg );
  707.          SetIntField( hDlg, IF_RGB_R, (int) GetRValue( dcv.brush.lbColor ) );
  708.          SetIntField( hDlg, IF_RGB_G, (int) GetGValue( dcv.brush.lbColor ) );
  709.          SetIntField( hDlg, IF_RGB_B, (int) GetBValue( dcv.brush.lbColor ) );
  710.          return (TRUE);
  711.  
  712.       case WM_COMMAND:
  713.          if (wParam == IDOK) {
  714.             dcv.brush.lbColor = RGB( GetIntField( hDlg, IF_RGB_R ),
  715.                                      GetIntField( hDlg, IF_RGB_G ),
  716.                                      GetIntField( hDlg, IF_RGB_B ) );
  717.             dcv.brush.lbStyle = BS_SOLID;
  718.             EndDialog( hDlg, TRUE );
  719.          }else if (wParam == IDCANCEL) {
  720.             EndDialog( hDlg, FALSE );
  721.          }
  722.          return (TRUE);
  723.    }
  724.    return (FALSE);
  725. }
  726.  
  727.  
  728. DLGPROC HatchBrushDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  729. {
  730.    int   hatch;
  731.  
  732.    switch (msg) {
  733.       case WM_INITDIALOG:
  734.          CenterDialog( hDlg );
  735.          hatch = (dcv.brush.lbStyle == BS_HATCHED) ? 
  736.                dcv.brush.lbHatch : HS_HORIZONTAL;
  737.          SetCheckField( hDlg, BF_VERTICAL, (hatch == HS_VERTICAL) );
  738.          SetCheckField( hDlg, BF_HORIZONTAL, (hatch == HS_HORIZONTAL) );
  739.          SetCheckField( hDlg, BF_CROSS, (hatch == HS_CROSS) );
  740.          SetCheckField( hDlg, BF_FDIAGONAL, (hatch == HS_FDIAGONAL) );
  741.          SetCheckField( hDlg, BF_BDIAGONAL, (hatch == HS_BDIAGONAL) );
  742.          SetCheckField( hDlg, BF_DIAGCROSS, (hatch == HS_DIAGCROSS) );
  743.          SetIntField( hDlg, IF_RGB_R, (int) GetRValue( dcv.brush.lbColor ) );
  744.          SetIntField( hDlg, IF_RGB_G, (int) GetGValue( dcv.brush.lbColor ) );
  745.          SetIntField( hDlg, IF_RGB_B, (int) GetBValue( dcv.brush.lbColor ) );
  746.          return (TRUE);
  747.  
  748.       case WM_COMMAND:
  749.          if (wParam == IDOK) {
  750.             if (GetCheckField( hDlg, BF_VERTICAL )) {
  751.                dcv.brush.lbHatch = HS_VERTICAL;
  752.             }else if (GetCheckField( hDlg, BF_HORIZONTAL )) {
  753.                dcv.brush.lbHatch = HS_HORIZONTAL;
  754.             }else if (GetCheckField( hDlg, BF_CROSS )) {
  755.                dcv.brush.lbHatch = HS_CROSS;
  756.             }else if (GetCheckField( hDlg, BF_FDIAGONAL )) {
  757.                dcv.brush.lbHatch = HS_FDIAGONAL;
  758.             }else if (GetCheckField( hDlg, BF_BDIAGONAL )) {
  759.                dcv.brush.lbHatch = HS_BDIAGONAL;
  760.             }else{
  761.                dcv.brush.lbHatch = HS_DIAGCROSS;
  762.             }
  763.             dcv.brush.lbColor = RGB( GetIntField( hDlg, IF_RGB_R ),
  764.                                      GetIntField( hDlg, IF_RGB_G ),
  765.                                      GetIntField( hDlg, IF_RGB_B ) );
  766.             dcv.brush.lbStyle = BS_HATCHED;
  767.             EndDialog( hDlg, TRUE );
  768.          }else if (wParam == IDCANCEL) {
  769.             EndDialog( hDlg, FALSE );
  770.          }
  771.          return (TRUE);
  772.    }
  773.    return (FALSE);
  774. }
  775.  
  776.  
  777. DLGPROC PatBrushDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  778. {
  779.    unsigned    i;
  780.  
  781.    switch (msg) {
  782.       case WM_INITDIALOG:
  783.          CenterDialog( hDlg );
  784.          for (i = 0; i < 64; i++) {
  785.             SetCheckField( hDlg, i + BF_PATTERN_FIRST, dcv.patChecks[i] );
  786.          }
  787.          return (TRUE);
  788.  
  789.       case WM_COMMAND:
  790.          if (wParam == BF_CLEAR) {
  791.             for (i = 0; i < 64; i++) {
  792.                dcv.patChecks[i] = 0;
  793.                SetCheckField( hDlg, i + BF_PATTERN_FIRST, 0 );
  794.             }
  795.          }else if (wParam == IDOK) {
  796.             for (i = 0; i < 64; i++) {
  797.                dcv.patChecks[i] = (BYTE) GetCheckField( hDlg, i + BF_PATTERN_FIRST );
  798.             }
  799.             dcv.brush.lbStyle = BS_PATTERN;
  800.             EndDialog( hDlg, TRUE );
  801.          }else if (wParam == IDCANCEL) {
  802.             EndDialog( hDlg, FALSE );
  803.          }
  804.          return (TRUE);
  805.    }
  806.    return (FALSE);
  807. }
  808.  
  809.  
  810. DLGPROC DIBPatBrushDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  811. {
  812.    switch (msg) {
  813.       case WM_INITDIALOG:
  814.          CenterDialog( hDlg );
  815.          if (curDIB == NULL) {
  816.             SetDlgItemText( hDlg, SF_DIB, "(none)" );
  817.             EnableItem( hDlg, IDOK, FALSE );
  818.          }else{
  819.             SetDlgItemText( hDlg, SF_DIB, FileNameFromPath( curDIBName ) );
  820.          }
  821.          return (TRUE);
  822.  
  823.       case WM_COMMAND:
  824.          if (wParam == BF_OPEN) {
  825.             if (OpenNewCurDIB( hDlg )) {
  826.                SetDlgItemText( hDlg, SF_DIB, FileNameFromPath( curDIBName ) );
  827.                EnableItem( hDlg, IDOK, TRUE );
  828.             }
  829.          }else if (wParam == IDOK) {
  830.             dcv.brush.lbStyle = BS_DIBPATTERN;
  831.             EndDialog( hDlg, TRUE );
  832.          }else if (wParam == IDCANCEL) {
  833.             EndDialog( hDlg, FALSE );
  834.          }
  835.          return (TRUE);
  836.    }
  837.    return (FALSE);
  838. }
  839.  
  840.  
  841. DLGPROC PenWidthDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  842. {
  843.    switch (msg) {
  844.       case WM_INITDIALOG:
  845.          CenterDialog( hDlg );
  846.          SetIntField( hDlg, IF_WIDTH, dcv.pen.lopnWidth.x );
  847.          return (TRUE);
  848.  
  849.       case WM_COMMAND:
  850.          if (wParam == IDOK) {
  851.             dcv.pen.lopnWidth.x = dcv.pen.lopnWidth.y 
  852.                   = GetIntField( hDlg, IF_WIDTH );
  853.             EndDialog( hDlg, TRUE );
  854.          }else if (wParam == IDCANCEL) {
  855.             EndDialog( hDlg, FALSE );
  856.          }
  857.          return (TRUE);
  858.    }
  859.    return (FALSE);
  860. }
  861.  
  862.  
  863. DLGPROC PenColorDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  864. {
  865.    switch (msg) {
  866.       case WM_INITDIALOG:
  867.          CenterDialog( hDlg );
  868.          SetIntField( hDlg, IF_RGB_R, (int) GetRValue( dcv.pen.lopnColor ) );
  869.          SetIntField( hDlg, IF_RGB_G, (int) GetGValue( dcv.pen.lopnColor ) );
  870.          SetIntField( hDlg, IF_RGB_B, (int) GetBValue( dcv.pen.lopnColor ) );
  871.          return (TRUE);
  872.  
  873.       case WM_COMMAND:
  874.          if (wParam == IDOK) {
  875.             dcv.pen.lopnColor = RGB( GetIntField( hDlg, IF_RGB_R ),
  876.                                      GetIntField( hDlg, IF_RGB_G ),
  877.                                      GetIntField( hDlg, IF_RGB_B ) );
  878.             EndDialog( hDlg, TRUE );
  879.          }else if (wParam == IDCANCEL) {
  880.             EndDialog( hDlg, FALSE );
  881.          }
  882.          return (TRUE);
  883.    }
  884.    return (FALSE);
  885. }
  886.  
  887.  
  888. /****************************************************************************
  889.    Dialogs progs for drawing commands
  890. ****************************************************************************/
  891.  
  892. DLGPROC SetPixelDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  893. {
  894.    switch (msg) {
  895.       case WM_INITDIALOG:
  896.          CenterDialog( hDlg );
  897.          SetIntField( hDlg, IF_X, dv.pt.x );
  898.          SetIntField( hDlg, IF_Y, dv.pt.y );
  899.          SetIntField( hDlg, IF_RGB_R, (int) GetRValue( dv.rgb ) );
  900.          SetIntField( hDlg, IF_RGB_G, (int) GetGValue( dv.rgb ) );
  901.          SetIntField( hDlg, IF_RGB_B, (int) GetBValue( dv.rgb ) );
  902.          return (TRUE);
  903.  
  904.       case WM_COMMAND:
  905.          if (wParam == IDOK) {
  906.             dv.pt.x = GetIntField( hDlg, IF_X );
  907.             dv.pt.y = GetIntField( hDlg, IF_Y );
  908.             dv.rgb = RGB( GetIntField( hDlg, IF_RGB_R ),
  909.                           GetIntField( hDlg, IF_RGB_G ),
  910.                           GetIntField( hDlg, IF_RGB_B ) );
  911.             EndDialog( hDlg, TRUE );
  912.          }else if (wParam == IDCANCEL) {
  913.             EndDialog( hDlg, FALSE );
  914.          }
  915.          return (TRUE);
  916.    }
  917.    return (FALSE);
  918. }
  919.  
  920.  
  921. DLGPROC LineToDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  922. {
  923.    switch (msg) {
  924.       case WM_INITDIALOG:
  925.          CenterDialog( hDlg );
  926.          SetIntField( hDlg, IF_TO_X, dv.pt.x );
  927.          SetIntField( hDlg, IF_TO_Y, dv.pt.y );
  928.          return (TRUE);
  929.  
  930.       case WM_COMMAND:
  931.          if (wParam == IDOK) {
  932.             dv.pt.x = GetIntField( hDlg, IF_TO_X );
  933.             dv.pt.y = GetIntField( hDlg, IF_TO_Y );
  934.             EndDialog( hDlg, TRUE );
  935.          }else if (wParam == IDCANCEL) {
  936.             EndDialog( hDlg, FALSE );
  937.          }
  938.          return (TRUE);
  939.    }
  940.    return (FALSE);
  941. }
  942.  
  943.  
  944. DLGPROC LineDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  945. {
  946.    switch (msg) {
  947.       case WM_INITDIALOG:
  948.          CenterDialog( hDlg );
  949.          SetIntField( hDlg, IF_FROM_X, dv.ptFrom.x );
  950.          SetIntField( hDlg, IF_FROM_Y, dv.ptFrom.y );
  951.          SetIntField( hDlg, IF_TO_X, dv.pt.x );
  952.          SetIntField( hDlg, IF_TO_Y, dv.pt.y );
  953.          return (TRUE);
  954.  
  955.       case WM_COMMAND:
  956.          if (wParam == IDOK) {
  957.             dv.ptFrom.x = GetIntField( hDlg, IF_FROM_X );
  958.             dv.ptFrom.y = GetIntField( hDlg, IF_FROM_Y );
  959.             dv.pt.x = GetIntField( hDlg, IF_TO_X );
  960.             dv.pt.y = GetIntField( hDlg, IF_TO_Y );
  961.             EndDialog( hDlg, TRUE );
  962.          }else if (wParam == IDCANCEL) {
  963.             EndDialog( hDlg, FALSE );
  964.          }
  965.          return (TRUE);
  966.    }
  967.    return (FALSE);
  968. }
  969.  
  970.  
  971. DLGPROC RectangleDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  972. {
  973.    switch (msg) {
  974.       case WM_INITDIALOG:
  975.          CenterDialog( hDlg );
  976.          SetIntField( hDlg, IF_LEFT, dv.r.left );
  977.          SetIntField( hDlg, IF_TOP, dv.r.top );
  978.          SetIntField( hDlg, IF_RIGHT, dv.r.right );
  979.          SetIntField( hDlg, IF_BOTTOM, dv.r.bottom );
  980.          return (TRUE);
  981.  
  982.       case WM_COMMAND:
  983.          if (wParam == IDOK) {
  984.             dv.r.left = GetIntField( hDlg, IF_LEFT );
  985.             dv.r.top = GetIntField( hDlg, IF_TOP );
  986.             dv.r.right = GetIntField( hDlg, IF_RIGHT );
  987.             dv.r.bottom = GetIntField( hDlg, IF_BOTTOM );
  988.             EndDialog( hDlg, TRUE );
  989.          }else if (wParam == IDCANCEL) {
  990.             EndDialog( hDlg, FALSE );
  991.          }
  992.          return (TRUE);
  993.    }
  994.    return (FALSE);
  995. }
  996.  
  997.  
  998. DLGPROC EllipseDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  999. {
  1000.    return RectangleDlgProc( hDlg, msg, wParam, lParam );
  1001. }
  1002.  
  1003.  
  1004. DLGPROC RoundRectDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  1005. {
  1006.    switch (msg) {
  1007.       case WM_INITDIALOG:
  1008.          CenterDialog( hDlg );
  1009.          SetIntField( hDlg, IF_LEFT, dv.r.left );
  1010.          SetIntField( hDlg, IF_TOP, dv.r.top );
  1011.          SetIntField( hDlg, IF_RIGHT, dv.r.right );
  1012.          SetIntField( hDlg, IF_BOTTOM, dv.r.bottom );
  1013.          SetIntField( hDlg, IF_DIAM_X, dv.corner.x );
  1014.          SetIntField( hDlg, IF_DIAM_Y, dv.corner.y );
  1015.          return (TRUE);
  1016.  
  1017.       case WM_COMMAND:
  1018.          if (wParam == IDOK) {
  1019.             dv.r.left = GetIntField( hDlg, IF_LEFT );
  1020.             dv.r.top = GetIntField( hDlg, IF_TOP );
  1021.             dv.r.right = GetIntField( hDlg, IF_RIGHT );
  1022.             dv.r.bottom = GetIntField( hDlg, IF_BOTTOM );
  1023.             dv.corner.x = GetIntField( hDlg, IF_DIAM_X );
  1024.             dv.corner.y = GetIntField( hDlg, IF_DIAM_Y );
  1025.             EndDialog( hDlg, TRUE );
  1026.          }else if (wParam == IDCANCEL) {
  1027.             EndDialog( hDlg, FALSE );
  1028.          }
  1029.          return (TRUE);
  1030.    }
  1031.    return (FALSE);
  1032. }
  1033.  
  1034.  
  1035. DLGPROC ArcDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  1036. {
  1037.    switch (msg) {
  1038.       case WM_INITDIALOG:
  1039.          CenterDialog( hDlg );
  1040.          SetIntField( hDlg, IF_LEFT, dv.r.left );
  1041.          SetIntField( hDlg, IF_TOP, dv.r.top );
  1042.          SetIntField( hDlg, IF_RIGHT, dv.r.right );
  1043.          SetIntField( hDlg, IF_BOTTOM, dv.r.bottom );
  1044.          SetIntField( hDlg, IF_START_X, dv.startPt.x );
  1045.          SetIntField( hDlg, IF_START_Y, dv.startPt.y );
  1046.          SetIntField( hDlg, IF_END_X, dv.endPt.x );
  1047.          SetIntField( hDlg, IF_END_Y, dv.endPt.y );
  1048.          return (TRUE);
  1049.  
  1050.       case WM_COMMAND:
  1051.          if (wParam == IDOK) {
  1052.             dv.r.left = GetIntField( hDlg, IF_LEFT );
  1053.             dv.r.top = GetIntField( hDlg, IF_TOP );
  1054.             dv.r.right = GetIntField( hDlg, IF_RIGHT );
  1055.             dv.r.bottom = GetIntField( hDlg, IF_BOTTOM );
  1056.             dv.startPt.x = GetIntField( hDlg, IF_START_X );
  1057.             dv.startPt.y = GetIntField( hDlg, IF_START_Y );
  1058.             dv.endPt.x = GetIntField( hDlg, IF_END_X );
  1059.             dv.endPt.y = GetIntField( hDlg, IF_END_Y );
  1060.             EndDialog( hDlg, TRUE );
  1061.          }else if (wParam == IDCANCEL) {
  1062.             EndDialog( hDlg, FALSE );
  1063.          }
  1064.          return (TRUE);
  1065.    }
  1066.    return (FALSE);
  1067. }
  1068.  
  1069.  
  1070. DLGPROC PieDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  1071. {
  1072.    return ArcDlgProc( hDlg, msg, wParam, lParam );
  1073. }
  1074.  
  1075.  
  1076. DLGPROC ChordDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  1077. {
  1078.    return ArcDlgProc( hDlg, msg, wParam, lParam );
  1079. }
  1080.  
  1081.  
  1082. DLGPROC PolylineDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  1083. {
  1084.    int   i, field;
  1085.  
  1086.    switch (msg) {
  1087.       case WM_INITDIALOG:
  1088.          CenterDialog( hDlg );
  1089.          SetIntField( hDlg, IF_N, dv.nPts );
  1090.          for (i = 0, field = IF_PTS_FIRST; i < MAX_PTS; i++) {
  1091.             SetIntField( hDlg, field++, dv.pts[i].x );
  1092.             SetIntField( hDlg, field++, dv.pts[i].y );
  1093.          }
  1094.          return (TRUE);
  1095.  
  1096.       case WM_COMMAND:
  1097.          if (wParam == IDOK) {
  1098.             dv.nPts = GetIntField( hDlg, IF_N );
  1099.             for (i = 0, field = IF_PTS_FIRST; i < MAX_PTS; i++) {
  1100.                dv.pts[i].x = GetIntField( hDlg, field++ );
  1101.                dv.pts[i].y = GetIntField( hDlg, field++ );
  1102.             }
  1103.             EndDialog( hDlg, TRUE );
  1104.          }else if (wParam == IDCANCEL) {
  1105.             EndDialog( hDlg, FALSE );
  1106.          }
  1107.          return (TRUE);
  1108.    }
  1109.    return (FALSE);
  1110. }
  1111.  
  1112.  
  1113. DLGPROC PolygonDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  1114. {
  1115.    return PolylineDlgProc( hDlg, msg, wParam, lParam );
  1116. }
  1117.  
  1118.  
  1119. DLGPROC PolyPolygonDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  1120. {
  1121.    int   i, field;
  1122.  
  1123.    switch (msg) {
  1124.       case WM_INITDIALOG:
  1125.          CenterDialog( hDlg );
  1126.          SetIntField( hDlg, IF_N, dv.nPolys );
  1127.          for (i = 0, field = IF_COUNT0; i < MAX_COUNTS; i++) {
  1128.             SetIntField( hDlg, field++, dv.counts[i] );
  1129.          }
  1130.          for (i = 0, field = IF_PTS_FIRST; i < MAX_POLYPOLY_PTS; i++) {
  1131.             SetIntField( hDlg, field++, dv.pts[i].x );
  1132.             SetIntField( hDlg, field++, dv.pts[i].y );
  1133.          }
  1134.          return (TRUE);
  1135.  
  1136.       case WM_COMMAND:
  1137.          if (wParam == IDOK) {
  1138.             dv.nPolys = GetIntField( hDlg, IF_N );
  1139.             for (i = 0, field = IF_COUNT0; i < MAX_COUNTS; i++) {
  1140.                dv.counts[i] = GetIntField( hDlg, field++ );
  1141.             }
  1142.             for (i = 0, field = IF_PTS_FIRST; i < MAX_POLYPOLY_PTS; i++) {
  1143.                dv.pts[i].x = GetIntField( hDlg, field++ );
  1144.                dv.pts[i].y = GetIntField( hDlg, field++ );
  1145.             }
  1146.             EndDialog( hDlg, TRUE );
  1147.          }else if (wParam == IDCANCEL) {
  1148.             EndDialog( hDlg, FALSE );
  1149.          }
  1150.          return (TRUE);
  1151.    }
  1152.    return (FALSE);
  1153. }
  1154.  
  1155.  
  1156. DLGPROC PatBltDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  1157. {
  1158.    int   i;
  1159.    int   other;
  1160.  
  1161.    static struct {
  1162.       int   field;
  1163.       DWORD rop;
  1164.    } rops[] = {
  1165.       { BF_PATCOPY,     PATCOPY },
  1166.       { BF_PATINVERT,   PATINVERT },
  1167.       { BF_DSTINVERT,   DSTINVERT },
  1168.       { BF_BLACKNESS,   BLACKNESS },
  1169.       { BF_WHITENESS,   WHITENESS },
  1170.       { -1,             0L }
  1171.    };
  1172.  
  1173.    #define ROP_STRING_LEN  12
  1174.    char  ropHexString[ROP_STRING_LEN];   /* hex representation of 'rop' */
  1175.    
  1176.    switch (msg) {
  1177.       case WM_INITDIALOG:
  1178.          CenterDialog( hDlg );
  1179.          SetIntField( hDlg, IF_X, dv.r.left );
  1180.          SetIntField( hDlg, IF_Y, dv.r.top );
  1181.          SetIntField( hDlg, IF_WIDTH, Width( dv.r ) );
  1182.          SetIntField( hDlg, IF_HEIGHT, Height( dv.r ) );
  1183.          if (dv.rop == 0L ) {
  1184.             dv.rop = PATCOPY;
  1185.          }
  1186.          for (i = 0, other = TRUE; rops[i].field != -1; i++) {
  1187.             if (dv.rop == rops[i].rop) {
  1188.                SetCheckField( hDlg, rops[i].field, TRUE );
  1189.                other = FALSE;
  1190.             }else{
  1191.                SetCheckField( hDlg, rops[i].field, FALSE );
  1192.             }
  1193.          }
  1194.          SetCheckField( hDlg, BF_OTHER, other );
  1195.          ltoa( dv.rop, ropHexString, 16);
  1196.          SetDlgItemText( hDlg, SF_ROP, ropHexString );
  1197.          return (TRUE);
  1198.  
  1199.       case WM_COMMAND:
  1200.          if (wParam == IDOK) {
  1201.             dv.r.left = GetIntField( hDlg, IF_X );
  1202.             dv.r.top = GetIntField( hDlg, IF_Y );
  1203.             dv.r.right = dv.r.left + GetIntField( hDlg, IF_WIDTH );
  1204.             dv.r.bottom = dv.r.top + GetIntField( hDlg, IF_HEIGHT );
  1205.             for (i = 0, other = TRUE; rops[i].field != -1; i++) {
  1206.                if (GetCheckField( hDlg, rops[i].field )) {
  1207.                   dv.rop = rops[i].rop;
  1208.                   other = FALSE;
  1209.                }
  1210.             }
  1211.             if (other) {
  1212.                GetDlgItemText( hDlg, SF_ROP, ropHexString, ROP_STRING_LEN );
  1213.                dv.rop = HexToLong( ropHexString );
  1214.             }
  1215.             EndDialog( hDlg, TRUE );
  1216.          }else if (wParam == IDCANCEL) {
  1217.             EndDialog( hDlg, FALSE );
  1218.          }
  1219.          return (TRUE);
  1220.    }
  1221.    return (FALSE);
  1222. }
  1223.  
  1224.  
  1225. DLGPROC BitBltDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  1226. {
  1227.    /* BitBlt is a strict subset of StretchBlt */
  1228.    return StretchBltDlgProc( hDlg, msg, wParam, lParam );
  1229. }
  1230.  
  1231.  
  1232. DLGPROC StretchBltDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  1233. {
  1234.    int   i;
  1235.    int   other;
  1236.  
  1237.    static struct {
  1238.       int   field;
  1239.       DWORD rop;
  1240.    } rops[] = {
  1241.       { BF_SRCPAINT,    SRCPAINT },
  1242.       { BF_SRCCOPY,     SRCCOPY },
  1243.       { BF_SRCAND,      SRCAND },
  1244.       { BF_SRCINVERT,   SRCINVERT },
  1245.       { BF_SRCERASE,    SRCERASE },
  1246.       { BF_NOTSRCCOPY,  NOTSRCCOPY },
  1247.       { BF_NOTSRCERASE, NOTSRCERASE },
  1248.       { BF_MERGECOPY,   MERGECOPY },
  1249.       { BF_MERGEPAINT,  MERGEPAINT },
  1250.       { BF_PATCOPY,     PATCOPY },
  1251.       { BF_PATPAINT,    PATPAINT },
  1252.       { BF_PATINVERT,   PATINVERT },
  1253.       { BF_DSTINVERT,   DSTINVERT },
  1254.       { BF_BLACKNESS,   BLACKNESS },
  1255.       { BF_WHITENESS,   WHITENESS },
  1256.       { -1,             0L }
  1257.    };
  1258.  
  1259.    #define ROP_STRING_LEN  12
  1260.    char  ropHexString[ROP_STRING_LEN];   /* hex representation of 'rop' */
  1261.    
  1262.    switch (msg) {
  1263.       case WM_INITDIALOG:
  1264.          CenterDialog( hDlg );
  1265.          SetIntField( hDlg, IF_X, dv.r.left );
  1266.          SetIntField( hDlg, IF_Y, dv.r.top );
  1267.          SetIntField( hDlg, IF_WIDTH, Width( dv.r ) );
  1268.          SetIntField( hDlg, IF_HEIGHT, Height( dv.r ) );
  1269.          SetIntField( hDlg, IF_SRC_X, dv.rFrom.left );
  1270.          SetIntField( hDlg, IF_SRC_Y, dv.rFrom.top );
  1271.          SetIntField( hDlg, IF_SRC_WIDTH, Width( dv.rFrom ) );
  1272.          SetIntField( hDlg, IF_SRC_HEIGHT, Height( dv.rFrom ) );
  1273.          if (dv.rop == 0L ) {
  1274.             dv.rop = SRCCOPY;
  1275.          }
  1276.          for (i = 0, other = TRUE; rops[i].field != -1; i++) {
  1277.             if (dv.rop == rops[i].rop) {
  1278.                SetCheckField( hDlg, rops[i].field, TRUE );
  1279.                other = FALSE;
  1280.             }else{
  1281.                SetCheckField( hDlg, rops[i].field, FALSE );
  1282.             }
  1283.          }
  1284.          SetCheckField( hDlg, BF_OTHER, other );
  1285.          ltoa( dv.rop, ropHexString, 16);
  1286.          SetDlgItemText( hDlg, SF_ROP, ropHexString );
  1287.          return (TRUE);
  1288.  
  1289.       case WM_COMMAND:
  1290.          if (wParam == IDOK) {
  1291.             dv.r.left = GetIntField( hDlg, IF_X );
  1292.             dv.r.top = GetIntField( hDlg, IF_Y );
  1293.             dv.r.right = dv.r.left + GetIntField( hDlg, IF_WIDTH );
  1294.             dv.r.bottom = dv.r.top + GetIntField( hDlg, IF_HEIGHT );
  1295.             dv.rFrom.left = GetIntField( hDlg, IF_SRC_X );
  1296.             dv.rFrom.top = GetIntField( hDlg, IF_SRC_Y );
  1297.             dv.rFrom.right = dv.rFrom.left + GetIntField( hDlg, IF_SRC_WIDTH );
  1298.             dv.rFrom.bottom = dv.rFrom.top + GetIntField( hDlg, IF_SRC_HEIGHT );
  1299.             for (i = 0, other = TRUE; rops[i].field != -1; i++) {
  1300.                if (GetCheckField( hDlg, rops[i].field )) {
  1301.                   dv.rop = rops[i].rop;
  1302.                   other = FALSE;
  1303.                }
  1304.             }
  1305.             if (other) {
  1306.                GetDlgItemText( hDlg, SF_ROP, ropHexString, ROP_STRING_LEN );
  1307.                dv.rop = HexToLong( ropHexString );
  1308.             }
  1309.             EndDialog( hDlg, TRUE );
  1310.          }else if (wParam == IDCANCEL) {
  1311.             EndDialog( hDlg, FALSE );
  1312.          }
  1313.          return (TRUE);
  1314.    }
  1315.    return (FALSE);
  1316. }
  1317.  
  1318.  
  1319. DLGPROC DIBToDeviceDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  1320. {
  1321.    switch (msg) {
  1322.       case WM_INITDIALOG:
  1323.          CenterDialog( hDlg );
  1324.          if (curDIB == NULL) {
  1325.             SetDlgItemText( hDlg, SF_DIB, "(none)" );
  1326.             EnableItem( hDlg, IDOK, FALSE );
  1327.             EnableItem( hDlg, BF_DIBSIZE, FALSE );
  1328.             EnableItem( hDlg, BF_ONEBAND, FALSE );
  1329.          }else{
  1330.             SetDlgItemText( hDlg, SF_DIB, FileNameFromPath( curDIBName ) );
  1331.          }
  1332.          SetIntField( hDlg, IF_X, dv.r.left );
  1333.          SetIntField( hDlg, IF_Y, dv.r.top );
  1334.          SetIntField( hDlg, IF_SRC_X, dv.rFrom.left );
  1335.          SetIntField( hDlg, IF_SRC_Y, dv.rFrom.top );
  1336.          SetIntField( hDlg, IF_SRC_WIDTH, Width( dv.rFrom ) );
  1337.          SetIntField( hDlg, IF_SRC_HEIGHT, Height( dv.rFrom ) );
  1338.          SetIntField( hDlg, IF_STARTSCAN, dv.startScan );
  1339.          SetIntField( hDlg, IF_NUMSCANS, dv.numScans );
  1340.          return (TRUE);
  1341.  
  1342.       case WM_COMMAND:
  1343.          if (wParam == BF_OPEN) {
  1344.             if (OpenNewCurDIB( hDlg )) {
  1345.                SetDlgItemText( hDlg, SF_DIB, FileNameFromPath( curDIBName ) );
  1346.                EnableItem( hDlg, IDOK, TRUE );
  1347.                EnableItem( hDlg, BF_DIBSIZE, TRUE );
  1348.                EnableItem( hDlg, BF_ONEBAND, TRUE );
  1349.             }
  1350.          }else if (wParam == BF_DIBSIZE) {
  1351.             SetIntField( hDlg, IF_SRC_X, 0 );
  1352.             SetIntField( hDlg, IF_SRC_Y, 0 );
  1353.             SetIntField( hDlg, IF_SRC_WIDTH, curDIBSize.x );
  1354.             SetIntField( hDlg, IF_SRC_HEIGHT, curDIBSize.y );
  1355.          }else if (wParam == BF_ONEBAND) {
  1356.             SetIntField( hDlg, IF_STARTSCAN, 0 );
  1357.             SetIntField( hDlg, IF_NUMSCANS, curDIBSize.y );
  1358.          }else if (wParam == IDOK) {
  1359.             dv.r.left = GetIntField( hDlg, IF_X );
  1360.             dv.r.top = GetIntField( hDlg, IF_Y );
  1361.             dv.rFrom.left = GetIntField( hDlg, IF_SRC_X );
  1362.             dv.rFrom.top = GetIntField( hDlg, IF_SRC_Y );
  1363.             dv.rFrom.right = dv.rFrom.left + GetIntField( hDlg, IF_SRC_WIDTH );
  1364.             dv.rFrom.bottom = dv.rFrom.top + GetIntField( hDlg, IF_SRC_HEIGHT );
  1365.             dv.startScan = GetIntField( hDlg, IF_STARTSCAN );
  1366.             dv.numScans = GetIntField( hDlg, IF_NUMSCANS );
  1367.             EndDialog( hDlg, TRUE );
  1368.          }else if (wParam == IDCANCEL) {
  1369.             EndDialog( hDlg, FALSE );
  1370.          }
  1371.          return (TRUE);
  1372.    }
  1373.    return (FALSE);
  1374. }
  1375.  
  1376.  
  1377. DLGPROC StretchDIBDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  1378. {
  1379.    int   i;
  1380.    int   other;
  1381.  
  1382.    static struct {
  1383.       int   field;
  1384.       DWORD rop;
  1385.    } rops[] = {
  1386.       { BF_SRCPAINT,    SRCPAINT },
  1387.       { BF_SRCCOPY,     SRCCOPY },
  1388.       { BF_SRCAND,      SRCAND },
  1389.       { BF_SRCINVERT,   SRCINVERT },
  1390.       { BF_SRCERASE,    SRCERASE },
  1391.       { BF_NOTSRCCOPY,  NOTSRCCOPY },
  1392.       { BF_NOTSRCERASE, NOTSRCERASE },
  1393.       { BF_MERGECOPY,   MERGECOPY },
  1394.       { BF_MERGEPAINT,  MERGEPAINT },
  1395.       { BF_PATCOPY,     PATCOPY },
  1396.       { BF_PATPAINT,    PATPAINT },
  1397.       { BF_PATINVERT,   PATINVERT },
  1398.       { BF_DSTINVERT,   DSTINVERT },
  1399.       { BF_BLACKNESS,   BLACKNESS },
  1400.       { BF_WHITENESS,   WHITENESS },
  1401.       { -1,             0L }
  1402.    };
  1403.  
  1404.    #define ROP_STRING_LEN  12
  1405.    char  ropHexString[ROP_STRING_LEN];   /* hex representation of 'rop' */
  1406.    
  1407.    switch (msg) {
  1408.       case WM_INITDIALOG:
  1409.          CenterDialog( hDlg );
  1410.          if (curDIB == NULL) {
  1411.             SetDlgItemText( hDlg, SF_DIB, "(none)" );
  1412.             EnableItem( hDlg, IDOK, FALSE );
  1413.             EnableItem( hDlg, BF_DIBSIZE, FALSE );
  1414.          }else{
  1415.             SetDlgItemText( hDlg, SF_DIB, FileNameFromPath( curDIBName ) );
  1416.          }
  1417.          SetIntField( hDlg, IF_X, dv.r.left );
  1418.          SetIntField( hDlg, IF_Y, dv.r.top );
  1419.          SetIntField( hDlg, IF_WIDTH, Width( dv.r ) );
  1420.          SetIntField( hDlg, IF_HEIGHT, Height( dv.r ) );
  1421.          SetIntField( hDlg, IF_SRC_X, dv.rFrom.left );
  1422.          SetIntField( hDlg, IF_SRC_Y, dv.rFrom.top );
  1423.          SetIntField( hDlg, IF_SRC_WIDTH, Width( dv.rFrom ) );
  1424.          SetIntField( hDlg, IF_SRC_HEIGHT, Height( dv.rFrom ) );
  1425.          if (dv.rop == 0L ) {
  1426.             dv.rop = SRCCOPY;
  1427.          }
  1428.          for (i = 0, other = TRUE; rops[i].field != -1; i++) {
  1429.             if (dv.rop == rops[i].rop) {
  1430.                SetCheckField( hDlg, rops[i].field, TRUE );
  1431.                other = FALSE;
  1432.             }else{
  1433.                SetCheckField( hDlg, rops[i].field, FALSE );
  1434.             }
  1435.          }
  1436.          SetCheckField( hDlg, BF_OTHER, other );
  1437.          ltoa( dv.rop, ropHexString, 16);
  1438.          SetDlgItemText( hDlg, SF_ROP, ropHexString );
  1439.          return (TRUE);
  1440.  
  1441.       case WM_COMMAND:
  1442.          if (wParam == BF_OPEN) {
  1443.             if (OpenNewCurDIB( hDlg )) {
  1444.                SetDlgItemText( hDlg, SF_DIB, FileNameFromPath( curDIBName ) );
  1445.                EnableItem( hDlg, IDOK, TRUE );
  1446.                EnableItem( hDlg, BF_DIBSIZE, TRUE );
  1447.             }
  1448.          }else if (wParam == BF_DIBSIZE) {
  1449.             SetIntField( hDlg, IF_SRC_X, 0 );
  1450.             SetIntField( hDlg, IF_SRC_Y, 0 );
  1451.             SetIntField( hDlg, IF_SRC_WIDTH, curDIBSize.x );
  1452.             SetIntField( hDlg, IF_SRC_HEIGHT, curDIBSize.y );
  1453.          }else if (wParam == IDOK) {
  1454.             dv.r.left = GetIntField( hDlg, IF_X );
  1455.             dv.r.top = GetIntField( hDlg, IF_Y );
  1456.             dv.r.right = dv.r.left + GetIntField( hDlg, IF_WIDTH );
  1457.             dv.r.bottom = dv.r.top + GetIntField( hDlg, IF_HEIGHT );
  1458.             dv.rFrom.left = GetIntField( hDlg, IF_SRC_X );
  1459.             dv.rFrom.top = GetIntField( hDlg, IF_SRC_Y );
  1460.             dv.rFrom.right = dv.rFrom.left + GetIntField( hDlg, IF_SRC_WIDTH );
  1461.             dv.rFrom.bottom = dv.rFrom.top + GetIntField( hDlg, IF_SRC_HEIGHT );
  1462.             for (i = 0, other = TRUE; rops[i].field != -1; i++) {
  1463.                if (GetCheckField( hDlg, rops[i].field )) {
  1464.                   dv.rop = rops[i].rop;
  1465.                   other = FALSE;
  1466.                }
  1467.             }
  1468.             if (other) {
  1469.                GetDlgItemText( hDlg, SF_ROP, ropHexString, ROP_STRING_LEN );
  1470.                dv.rop = HexToLong( ropHexString );
  1471.             }
  1472.             EndDialog( hDlg, TRUE );
  1473.          }else if (wParam == IDCANCEL) {
  1474.             EndDialog( hDlg, FALSE );
  1475.          }
  1476.          return (TRUE);
  1477.    }
  1478.    return (FALSE);
  1479. }
  1480.  
  1481.  
  1482. DLGPROC TextOutDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  1483. {
  1484.    switch (msg) {
  1485.       case WM_INITDIALOG:
  1486.          CenterDialog( hDlg );
  1487.          SetDlgItemText( hDlg, SF_TEXT,  dv.text );
  1488.          SetIntField( hDlg, IF_X, dv.pt.x );
  1489.          SetIntField( hDlg, IF_Y, dv.pt.y );
  1490.          return (TRUE);
  1491.  
  1492.       case WM_COMMAND:
  1493.          if (wParam == IDOK) {
  1494.             GetDlgItemText( hDlg, SF_TEXT, dv.text, MAX_TEXT_LEN );
  1495.             dv.pt.x = GetIntField( hDlg, IF_X );
  1496.             dv.pt.y = GetIntField( hDlg, IF_Y );
  1497.             EndDialog( hDlg, TRUE );
  1498.          }else if (wParam == IDCANCEL) {
  1499.             EndDialog( hDlg, FALSE );
  1500.          }
  1501.          return (TRUE);
  1502.    }
  1503.    return (FALSE);
  1504. }
  1505.  
  1506.  
  1507. DLGPROC ExtTextOutDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  1508. {
  1509.    int   i;
  1510.  
  1511.    switch (msg) {
  1512.       case WM_INITDIALOG:
  1513.          CenterDialog( hDlg );
  1514.          SetDlgItemText( hDlg, SF_TEXT,  dv.text );
  1515.          SetIntField( hDlg, IF_X, dv.pt.x );
  1516.          SetIntField( hDlg, IF_Y, dv.pt.y );
  1517.          SetIntField( hDlg, IF_LEFT, dv.r.left );
  1518.          SetIntField( hDlg, IF_TOP, dv.r.top );
  1519.          SetIntField( hDlg, IF_RIGHT, dv.r.right );
  1520.          SetIntField( hDlg, IF_BOTTOM, dv.r.bottom );
  1521.          SetCheckField( hDlg, BF_CLIPPED, ((dv.options & ETO_CLIPPED) != 0) );
  1522.          SetCheckField( hDlg, BF_OPAQUE, ((dv.options & ETO_OPAQUE) != 0) );
  1523.          SetCheckField( hDlg, BF_USE_DX, dv.useDx );
  1524.          for (i = 0; i < MAX_DX; i++ ) {
  1525.             SetIntField( hDlg, i + IF_DX_FIRST, dv.dxArray[i] );
  1526.          }
  1527.          return (TRUE);
  1528.  
  1529.       case WM_COMMAND:
  1530.          if (wParam == IDOK) {
  1531.             GetDlgItemText( hDlg, SF_TEXT, dv.text, MAX_TEXT_LEN );
  1532.             dv.pt.x = GetIntField( hDlg, IF_X );
  1533.             dv.pt.y = GetIntField( hDlg, IF_Y );
  1534.             dv.r.left = GetIntField( hDlg, IF_LEFT );
  1535.             dv.r.top = GetIntField( hDlg, IF_TOP );
  1536.             dv.r.right = GetIntField( hDlg, IF_RIGHT );
  1537.             dv.r.bottom = GetIntField( hDlg, IF_BOTTOM );
  1538.             dv.options = 0;
  1539.             if (GetCheckField( hDlg, BF_CLIPPED ))
  1540.                dv.options |= ETO_CLIPPED;
  1541.             if (GetCheckField( hDlg, BF_OPAQUE ))
  1542.                dv.options |= ETO_OPAQUE;
  1543.             dv.useDx = GetCheckField( hDlg, BF_USE_DX );
  1544.             for (i = 0; i < MAX_DX; i++ ) {
  1545.                dv.dxArray[i] = GetIntField( hDlg, i + IF_DX_FIRST );
  1546.             }
  1547.             EndDialog( hDlg, TRUE );
  1548.          }else if (wParam == IDCANCEL) {
  1549.             EndDialog( hDlg, FALSE );
  1550.          }
  1551.          return (TRUE);
  1552.    }
  1553.    return (FALSE);
  1554. }
  1555.  
  1556. DLGPROC DrawTextDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  1557. {
  1558.    #define  horzMask    (DT_LEFT | DT_CENTER | DT_RIGHT)
  1559.    #define  vertMask    (DT_TOP | DT_VCENTER | DT_BOTTOM)
  1560.  
  1561.    switch (msg) {
  1562.       case WM_INITDIALOG:
  1563.          CenterDialog( hDlg );
  1564.          SetDlgItemText( hDlg, SF_TEXT,  dv.text );
  1565.          SetIntField( hDlg, IF_LEFT, dv.r.left );
  1566.          SetIntField( hDlg, IF_TOP, dv.r.top );
  1567.          SetIntField( hDlg, IF_RIGHT, dv.r.right );
  1568.          SetIntField( hDlg, IF_BOTTOM, dv.r.bottom );
  1569.          SetCheckField( hDlg, BF_LEFT, ((dv.format & horzMask) == DT_LEFT) );
  1570.          SetCheckField( hDlg, BF_CENTER, ((dv.format & horzMask) == DT_CENTER) );
  1571.          SetCheckField( hDlg, BF_RIGHT, ((dv.format & horzMask) == DT_RIGHT) );
  1572.          SetCheckField( hDlg, BF_TOP, ((dv.format & vertMask) == DT_TOP) );
  1573.          SetCheckField( hDlg, BF_VCENTER, ((dv.format & vertMask) == DT_VCENTER) );
  1574.          SetCheckField( hDlg, BF_BOTTOM, ((dv.format & vertMask) == DT_BOTTOM) );
  1575.          SetCheckField( hDlg, BF_SINGLELINE, dv.format & DT_SINGLELINE );
  1576.          SetCheckField( hDlg, BF_WORDBREAK, dv.format & DT_WORDBREAK );
  1577.          SetCheckField( hDlg, BF_EXPANDTABS, dv.format & DT_EXPANDTABS );
  1578.          SetCheckField( hDlg, BF_TABSTOP, dv.format & DT_TABSTOP );
  1579.          if (dv.format & DT_TABSTOP) {
  1580.             SetCheckField( hDlg, BF_NOCLIP, FALSE );
  1581.             SetCheckField( hDlg, BF_NOPREFIX, FALSE );
  1582.             SetCheckField( hDlg, BF_EXTERNAL, FALSE );
  1583.             SetCheckField( hDlg, BF_INTERNAL, FALSE );
  1584.             SetCheckField( hDlg, BF_CALCRECT, FALSE );
  1585.          }else{
  1586.             SetCheckField( hDlg, BF_NOCLIP, dv.format & DT_NOCLIP );
  1587.             SetCheckField( hDlg, BF_NOPREFIX, dv.format & DT_NOPREFIX );
  1588.             SetCheckField( hDlg, BF_EXTERNAL, dv.format & DT_EXTERNALLEADING );
  1589.             SetCheckField( hDlg, BF_INTERNAL, dv.format & DT_INTERNAL );
  1590.             SetCheckField( hDlg, BF_CALCRECT, dv.format & DT_CALCRECT );
  1591.          }
  1592.          if (dv.tabStop <= 0)
  1593.             dv.tabStop = 8;
  1594.          SetIntField( hDlg, IF_TABSTOP, dv.tabStop );
  1595.          return (TRUE);
  1596.  
  1597.       case WM_COMMAND:
  1598.          if (wParam == IDOK) {
  1599.             GetDlgItemText( hDlg, SF_TEXT, dv.text, MAX_TEXT_LEN );
  1600.             dv.r.left = GetIntField( hDlg, IF_LEFT );
  1601.             dv.r.top = GetIntField( hDlg, IF_TOP );
  1602.             dv.r.right = GetIntField( hDlg, IF_RIGHT );
  1603.             dv.r.bottom = GetIntField( hDlg, IF_BOTTOM );
  1604.             dv.format = 0;
  1605.             if (GetCheckField( hDlg, BF_CENTER ))
  1606.                dv.format |= DT_CENTER;
  1607.             else if (GetCheckField( hDlg, BF_RIGHT ))
  1608.                dv.format |= DT_RIGHT;
  1609.             else
  1610.                dv.format |= DT_LEFT;
  1611.             if (GetCheckField( hDlg, BF_VCENTER ))
  1612.                dv.format |= DT_VCENTER;
  1613.             else if (GetCheckField( hDlg, BF_BOTTOM ))
  1614.                dv.format |= DT_BOTTOM;
  1615.             else
  1616.                dv.format |= DT_TOP;
  1617.             if (GetCheckField( hDlg, BF_SINGLELINE ))
  1618.                dv.format |= DT_SINGLELINE;
  1619.             if (GetCheckField( hDlg, BF_WORDBREAK ))
  1620.                dv.format |= DT_WORDBREAK;
  1621.             if (GetCheckField( hDlg, BF_NOCLIP ))
  1622.                dv.format |= DT_NOCLIP;
  1623.             if (GetCheckField( hDlg, BF_NOPREFIX ))
  1624.                dv.format |= DT_NOPREFIX;
  1625.             if (GetCheckField( hDlg, BF_EXTERNAL ))
  1626.                dv.format |= DT_EXTERNALLEADING;
  1627.             if (GetCheckField( hDlg, BF_INTERNAL ))
  1628.                dv.format |= DT_INTERNAL;
  1629.             if (GetCheckField( hDlg, BF_CALCRECT ))
  1630.                dv.format |= DT_CALCRECT;
  1631.             if (GetCheckField( hDlg, BF_EXPANDTABS ))
  1632.                dv.format |= DT_EXPANDTABS;
  1633.             if (GetCheckField( hDlg, BF_TABSTOP )) {
  1634.                dv.format |= DT_TABSTOP;
  1635.                dv.format &= 0x00FF;
  1636.                dv.tabStop = GetIntField( hDlg, IF_TABSTOP );
  1637.                dv.format |= (dv.tabStop << 8);
  1638.             }
  1639.             EndDialog( hDlg, TRUE );
  1640.          }else if (wParam == IDCANCEL) {
  1641.             EndDialog( hDlg, FALSE );
  1642.          }
  1643.          return (TRUE);
  1644.    }
  1645.    return (FALSE);
  1646. }
  1647.  
  1648.  
  1649. DLGPROC FloodFillDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  1650. {
  1651.    return SetPixelDlgProc( hDlg, msg, wParam, lParam );
  1652. }
  1653.  
  1654.  
  1655. DLGPROC ExtFloodFillDlgProc( HWND hDlg, unsigned msg, WORD wParam, DWORD lParam )
  1656. {
  1657.    switch (msg) {
  1658.       case WM_INITDIALOG:
  1659.          CenterDialog( hDlg );
  1660.          SetIntField( hDlg, IF_X, dv.pt.x );
  1661.          SetIntField( hDlg, IF_Y, dv.pt.y );
  1662.          SetIntField( hDlg, IF_RGB_R, (int) GetRValue( dv.rgb ) );
  1663.          SetIntField( hDlg, IF_RGB_G, (int) GetGValue( dv.rgb ) );
  1664.          SetIntField( hDlg, IF_RGB_B, (int) GetBValue( dv.rgb ) );
  1665.          SetCheckField( hDlg, BF_BORDER, (dv.floodType == FLOODFILLBORDER) );
  1666.          SetCheckField( hDlg, BF_SURFACE, (dv.floodType == FLOODFILLSURFACE) );
  1667.          return (TRUE);
  1668.  
  1669.       case WM_COMMAND:
  1670.          if (wParam == IDOK) {
  1671.             dv.pt.x = GetIntField( hDlg, IF_X );
  1672.             dv.pt.y = GetIntField( hDlg, IF_Y );
  1673.             dv.rgb = RGB( GetIntField( hDlg, IF_RGB_R ),
  1674.                           GetIntField( hDlg, IF_RGB_G ),
  1675.                           GetIntField( hDlg, IF_RGB_B ) );
  1676.             dv.floodType = (GetCheckField( hDlg, BF_SURFACE )) ?
  1677.                            FLOODFILLSURFACE : FLOODFILLBORDER;
  1678.             EndDialog( hDlg, TRUE );
  1679.          }else if (wParam == IDCANCEL) {
  1680.             EndDialog( hDlg, FALSE );
  1681.          }
  1682.          return (TRUE);
  1683.    }
  1684.    return (FALSE);
  1685. }
  1686.