home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / PEN / PENTKT / UTIL / PENCAL / PMALIGN.C < prev    next >
C/C++ Source or Header  |  1995-04-14  |  21KB  |  608 lines

  1. /*DDK*************************************************************************/
  2. /*                                                                           */
  3. /* COPYRIGHT    Copyright (C) 1995 IBM Corporation                           */
  4. /*                                                                           */
  5. /*    The following IBM OS/2 WARP source code is provided to you solely for  */
  6. /*    the purpose of assisting you in your development of OS/2 WARP device   */
  7. /*    drivers. You may use this code in accordance with the IBM License      */
  8. /*    Agreement provided in the IBM Device Driver Source Kit for OS/2. This  */
  9. /*    Copyright statement may not be removed.                                */
  10. /*                                                                           */
  11. /*****************************************************************************/
  12. #define INCL_WIN
  13. #define INCL_GPI
  14. #define INCL_DOSMODULEMGR
  15. #include <os2.h>
  16. #include <stdio.h>
  17. #include <cal.h>
  18. #include <calres.h>
  19. #include <penpm.h>
  20.  
  21. #define PENPMMRI  "PENPMMRI"  /* name of NLS DLL */
  22.  
  23. #ifdef DEBUG
  24. extern FILE * stream;
  25. extern BOOL dbfile;
  26. #endif
  27. extern HAB  habMain;
  28. extern ULONG scrWidth,scrHeight;
  29. extern HWND hwndClient;
  30. extern FONTMETRICS    fm;
  31. HMODULE hmodMRI = 0;
  32.  
  33. HWND hwndAdjust;
  34. HPS  hpsAdjust;
  35. HDC  hdcAdjust;
  36. char adjName[] = "ADJ";
  37. HPOINTER     hptrTarget;              //pointer to target icon
  38. HPOINTER     hptrSYS;                 //pointer to system pointer
  39. ULONG        maxLineSize;
  40.  
  41. //-----------------------------------------------------------------------------
  42. // These global variables are used to control the mode of the window
  43. // procedure.
  44. //-----------------------------------------------------------------------------
  45. #define MODE_ALIGN   1
  46. #define MODE_TEST    2
  47. #define MODE_IDLE    3
  48.  
  49. TARGETAREA * ptargetarea;             //pointer to target area to paint target
  50. TARGETAREA   nocursorarea;            //target area where there is nocursor
  51. BOOL         areaChangePending;       //change nocusor area is pending
  52. BOOL         nocursorValid;           //the nocursor target area is valid
  53. HPOINTER     hptrMSE;                 //pointer that the MOUSEMOVE should use
  54. CHAR       * boxText;                 //pointer to text in the box
  55.  
  56. //-----------------------------------------------------------------------------
  57. // got to move out this text to the resource file
  58. //-----------------------------------------------------------------------------
  59. #define MAX_LINE_SIZE 100
  60. #define MAX_BUT_SIZE 30
  61. CHAR  calText[MAX_LINE_SIZE*3 + 5];
  62. CHAR  tesText[MAX_LINE_SIZE*5 + 8];
  63. CHAR  deftext[MAX_LINE_SIZE+2];
  64. CHAR  deftitle[MAX_LINE_SIZE+2];
  65. CHAR  DDerrText[MAX_LINE_SIZE+2];
  66. CHAR  szButtonLabel[6][MAX_BUT_SIZE];
  67.  
  68. //-----------------------------------------------------------------------------
  69. // local procedures
  70. //-----------------------------------------------------------------------------
  71. MRESULT APIENTRY AdjustWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2);
  72. void draw_text( HPS hps, char *text, RECTL *text_box, FONTMETRICS *pfm);
  73. BOOL landingArea(POINTL *ptl,TARGETAREA * ptargetarea);
  74. void notifyPM (LONG notifyCmd,TARGETAREA * ptargetarea);
  75. void setMode(LONG mode);
  76. void initMode();
  77. void updateNocursorArea(POINTL * pptl);
  78. void updatearea(void);
  79.  
  80. //*****************************************************************************
  81. // Window proc for alignment
  82. //*****************************************************************************
  83. MRESULT APIENTRY AdjustWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2)
  84. {
  85.    #define  NUMBUTTONS 6
  86.    BOOL           pmrc;
  87.    static   HWND  hwndButton[NUMBUTTONS];
  88.    static   RECTL textBox;
  89.    SIZEL          sizlPage;
  90.    SHORT          id;
  91.    USHORT         mesRC;
  92.    static   LONG  bitCenX;
  93.    static   LONG  bitCenY;
  94.    HELPINIT       helpInit;
  95.    static   CHAR  szWindowTitle[1];
  96.    static   HWND  hwndHelpInstance = NULLHANDLE;
  97.    ULONG          butPos;
  98.    ULONG          butSize;
  99.  
  100.    switch (msg) {
  101.    case WM_CREATE:
  102.  
  103.       hdcAdjust = WinOpenWindowDC (hwnd);
  104.       sizlPage.cx = 0;
  105.       sizlPage.cy = 0;
  106.       hpsAdjust = GpiCreatePS (habMain,hdcAdjust,&sizlPage,PU_PELS|GPIA_ASSOC);
  107.       hptrTarget=WinLoadPointer(HWND_DESKTOP,0L,ID_TAR);
  108.       hptrSYS=WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW,FALSE);
  109.  
  110.       {
  111.          POINTERINFO ptrinfo;
  112.          BITMAPINFOHEADER2 bminfo;
  113.  
  114.          pmrc=WinQueryPointerInfo(hptrTarget,&ptrinfo);
  115.          bminfo.cbFix=sizeof(BITMAPINFOHEADER2);
  116.          pmrc=GpiQueryBitmapInfoHeader(ptrinfo.hbmPointer,&bminfo);
  117.          bitCenX=bminfo.cx/2;
  118.          bitCenY=bminfo.cx/2;
  119.  
  120.          if (AlignInit(scrWidth,scrHeight,bminfo.cx,bminfo.cx)) {
  121.             WinMessageBox(HWND_DESKTOP,hwnd,DDerrText,"",0,
  122.                        MB_OK | MB_ERROR | MB_SYSTEMMODAL | MB_MOVEABLE);
  123.             WinDestroyWindow(hwnd);
  124.             break;
  125.          }
  126.       }
  127.       initMode();
  128.       setMode(MODE_TEST);
  129.  
  130.       GpiSetBackMix(hpsAdjust,BM_OVERPAINT);
  131.  
  132. // do some size figuring
  133.  
  134.       maxLineSize += 10; //add some fudge factor
  135.       if (scrWidth>=fm.lAveCharWidth*maxLineSize) {
  136.          textBox.xLeft=(scrWidth-fm.lAveCharWidth*maxLineSize)/2;
  137.          textBox.xRight=(scrWidth+fm.lAveCharWidth*maxLineSize)/2;
  138.       } else {
  139.          textBox.xLeft=1;
  140.          textBox.xRight=scrWidth-1;
  141.       } /* endif */
  142. #ifdef DEBUG
  143.       if (dbfile) fprintf(stream,"xLeft=%d xRight=%d\n",textBox.xLeft,textBox.xRight);
  144. #endif
  145.       textBox.yTop=(scrHeight+fm.lMaxBaselineExt*7)/2 ;
  146.       textBox.yBottom=(scrHeight-fm.lMaxBaselineExt*7)/2;
  147.  
  148. // set up the rest of the window
  149.  
  150.       butSize=0;
  151.       for (id=0; id<(NUMBUTTONS); id++) {
  152.          butSize+=fm.lAveCharWidth*(strlen(szButtonLabel[id])+5);
  153.       } /* endfor */
  154.       butPos = (scrWidth-butSize)/2;
  155.  
  156.       for (id=0; id<(NUMBUTTONS-1); id++) {
  157.          butSize=fm.lAveCharWidth*(strlen(szButtonLabel[id])+5);
  158. #ifdef DEBUG
  159.          //if (dbfile) fprintf(stream,"butPos = %d, butSize = %d\n",butPos,butSize);
  160. #endif
  161.          hwndButton[id]=WinCreateWindow(
  162.             hwnd,
  163.             WC_BUTTON,
  164.             szButtonLabel[id],
  165.             WS_VISIBLE|BS_PUSHBUTTON,
  166.             butPos,scrHeight/5,
  167.             butSize,2*fm.lMaxBaselineExt,
  168.             hwnd,
  169.             HWND_BOTTOM,
  170.             IDM_BASE+id,
  171.             NULL,
  172.             NULL);
  173.  
  174.             butPos+=butSize;
  175.       } /* endfor */
  176.  
  177.       butSize=fm.lAveCharWidth*(strlen(szButtonLabel[5])+5);
  178. #ifdef DEBUG
  179.       //if (dbfile) fprintf(stream,"butPos = %d, butSize = %d\n",butPos,butSize);
  180. #endif
  181.       hwndButton[5]=WinCreateWindow(
  182.          hwnd,
  183.          WC_BUTTON,
  184.          szButtonLabel[5],
  185.          WS_VISIBLE|BS_PUSHBUTTON|BS_HELP,
  186.          butPos,scrHeight/5,
  187.          butSize,2*fm.lMaxBaselineExt,
  188.          hwnd,
  189.          HWND_BOTTOM,
  190.          IDM_BASE+5,
  191.          NULL,
  192.          NULL);
  193.  
  194. // inititalize help init structure
  195.  
  196.       helpInit.cb = sizeof(HELPINIT);
  197.       helpInit.ulReturnCode = 0L;
  198.  
  199.       helpInit.pszTutorialName = (PSZ)NULL;   /* if tutorial added,             */
  200.                                               /* add name here                  */
  201.       helpInit.phtHelpTable = (PHELPTABLE)MAKELONG(HELPTABLE_RESID,
  202.                                0xFFFF);
  203.       helpInit.hmodHelpTableModule = NULLHANDLE;
  204.       helpInit.hmodAccelActionBarModule = NULLHANDLE;
  205.       helpInit.idAccelTable = 0;
  206.       helpInit.idActionBar = 0;
  207.  
  208.       szWindowTitle[0] = '\0';
  209.       helpInit.pszHelpWindowTitle = (PSZ)szWindowTitle;
  210.       helpInit.fShowPanelId = CMIC_HIDE_PANEL_ID;
  211.       helpInit.pszHelpLibraryName = "psetup.hlp";
  212.  
  213.       hwndHelpInstance = WinCreateHelpInstance((HAB)0, &helpInit);
  214.  
  215. #ifdef DEBUG
  216.       if (!hwndHelpInstance || helpInit.ulReturnCode)
  217.       {
  218.          if (dbfile) fprintf(stream,"HwndHelpInstance is Bad\n");
  219.  
  220.          WinMessageBox(HWND_DESKTOP,HWND_DESKTOP,"HwndHelpInstance is Bad",
  221.                    "",0,
  222.                    MB_OK | MB_INFORMATION | MB_SYSTEMMODAL | MB_MOVEABLE);
  223.       }
  224.  
  225.       if (!WinAssociateHelpInstance(hwndHelpInstance, hwnd))
  226.       {
  227.        WinMessageBox(HWND_DESKTOP,HWND_DESKTOP,"WinAssociateHelp is Bad",
  228.                  "",0,
  229.                  MB_OK | MB_INFORMATION | MB_SYSTEMMODAL | MB_MOVEABLE);
  230.       }
  231. #else
  232.       WinAssociateHelpInstance( hwndHelpInstance, hwnd );
  233. #endif
  234.       break;
  235.  
  236.    case WM_TOUCHDOWN:                                  // Touchdown ocurred
  237.       return  (MRESULT) ( TDN_IMMEDIATE                // Never Issue BUTxDOWN
  238.                         + TDN_NO_INK_STROKE);          // Don't Ink Stroke
  239.       break;
  240.  
  241. // We want to hide the cursor when the pen is in the targetarea. The targetarea
  242. // is the icon that the pen should be placed on during alignment mode.
  243. // The nocursorArea is the rectl where we don't want a cursor to show.
  244. //
  245. // Thats the easy part. When a targetarea moves to a new spot, we want to keep
  246. // the old nocursor area til the pen moves out of the old target area. This way
  247. // the old target area is blank and it encourages the pen to move to the new
  248. // target area. This is indicated by the areaChangePending flag.
  249. case WM_MOUSEMOVE:
  250.       {
  251.          POINTL ptl;
  252.          WinQueryPointerPos(HWND_DESKTOP,&ptl);
  253.  
  254.          if (areaChangePending) {
  255.             updateNocursorArea(&ptl);   //update area if pen has moved
  256.          } /* endif */
  257.  
  258.          if (nocursorValid) {        //we have a nocursor area
  259.             if (landingArea(&ptl,&nocursorarea)) {
  260.                WinSetPointer(HWND_DESKTOP,(HPOINTER)NULL);  //hide the cursor
  261.             } else {
  262.                WinSetPointer(HWND_DESKTOP,hptrMSE);     //outside, OK to show
  263.             } /* endif */
  264.          } else {
  265.             WinSetPointer(HWND_DESKTOP,hptrMSE); // no nocusor area, OK to show
  266.          } /* endif */
  267.       }
  268.       break;
  269.  
  270.    case WM_COMMAND:
  271.       switch (COMMANDMSG(&msg)->cmd) {
  272.       case IDM_DEFAULTS:
  273.          AlignStop();
  274.          setMode(MODE_IDLE);
  275.          WinPostMsg(hwndAdjust,DEFAULTS_PART2,0,0);
  276.          break;
  277.       case IDM_CALIBRATE:
  278.          AlignStop();
  279.          setMode(MODE_ALIGN);
  280.          AlignStart();
  281.          break;
  282.       case IDM_TEST:
  283.          AlignStop();
  284.          setMode(MODE_TEST);
  285.          break;
  286.       case IDM_OK:
  287.          AlignStop();
  288.          AlignCommit();
  289.          WinDestroyWindow(hwnd);
  290.          break;
  291.       case IDM_CANCEL:
  292.          AlignStop();
  293.          AlignCancel();
  294.          WinDestroyWindow(hwnd);
  295.          break;
  296.       default:
  297.          return WinDefWindowProc(hwnd,msg,mp1,mp2);
  298.       } /* endswitch */
  299.       WinInvalidateRect (hwnd, NULL, FALSE);
  300.       break;
  301.  
  302.    case WM_BUTTON1DOWN:
  303.       WinSetFocus (HWND_DESKTOP, hwnd);
  304.       break;
  305.  
  306. // these next two case are messages from the align program background thread
  307.    case PAINT_TARGET :              //move to a new collection point
  308.       ptargetarea=mp2;              //select a target area
  309.       areaChangePending=TRUE;       //nocursor area change pending
  310.       WinInvalidateRect (hwnd, NULL, FALSE);  //repaint
  311.       break;
  312.    case ALIGNMENT_DONE:             //done
  313.       ptargetarea=0;                //no target to paint, no new nocursor area
  314.       areaChangePending=TRUE;       //keep nocursor area till its moved from
  315.       setMode(MODE_TEST);
  316.       WinInvalidateRect (hwnd, NULL, FALSE);  //repaint
  317.       break;
  318.  
  319. // I send this to myself to do the second part of default comand
  320.    case DEFAULTS_PART2:             //done
  321.       mesRC=WinMessageBox(HWND_DESKTOP,hwnd,deftext,deftitle,0,MB_OKCANCEL|MB_NOICON);
  322.       if (mesRC==MBID_OK) {
  323.           AlignDefaults();
  324.       } /* endif */
  325.       setMode(MODE_TEST);
  326.       WinInvalidateRect (hwnd, NULL, FALSE);  //repaint
  327.       break;
  328.  
  329.    case WM_PAINT:
  330.       {
  331.          RECTL rcl;
  332.  
  333.          WinBeginPaint(hwnd,hpsAdjust,NULL);
  334.          WinQueryWindowRect(hwnd,&rcl);
  335.          WinFillRect(hpsAdjust,&rcl,CLR_BACKGROUND);
  336.          if (ptargetarea) {
  337.             WinDrawPointer(hpsAdjust,(ptargetarea->xcen)-bitCenX,
  338.                (ptargetarea->ycen)-bitCenY,
  339.                hptrTarget,DP_NORMAL);
  340.          } /* endif */
  341.          if (boxText) {
  342.             draw_text(hpsAdjust,boxText,&textBox,&fm);
  343.          } /* endif */
  344.          WinEndPaint(hpsAdjust);
  345.       }
  346.       break;
  347.  
  348.    case WM_DESTROY:
  349.       AlignTerminate();
  350.       GpiDestroyPS(hpsAdjust);
  351.       WinSendMsg(hwnd,WM_CLOSE,NULL,NULL);
  352.       break;
  353.  
  354.    default:
  355.       return WinDefWindowProc(hwnd,msg,mp1,mp2);
  356.    } /* endswitch */
  357.  
  358.    return FALSE;
  359. }
  360. //***************************************************************************** */
  361. // S U P P O R T   R O U T I N E S
  362. //*****************************************************************************
  363.  
  364. //-----------------------------------------------------------------------------
  365. // draw text in the box
  366. //-----------------------------------------------------------------------------
  367. void draw_text( HPS hps, char *text, RECTL *text_box, FONTMETRICS *pfm)
  368. {
  369.    RECTL  line_box;
  370.    char   line[MAX_LINE_SIZE+2];
  371.    char   *lp;
  372.  
  373.    WinDrawBorder( hps, text_box, 1, 1,
  374.                   CLR_NEUTRAL, CLR_BACKGROUND,
  375.                   DB_STANDARD );
  376.  
  377.    line_box.xLeft   = text_box->xLeft   + pfm->lAveCharWidth;
  378.    line_box.xRight  = text_box->xRight  - pfm->lAveCharWidth;
  379.    line_box.yTop    = text_box->yTop    - pfm->lMaxBaselineExt;
  380.    line_box.yBottom = line_box.yTop     - pfm->lMaxBaselineExt;
  381.  
  382.    for ( lp=line; TRUE; text++ ) {
  383.       if ( *text == '\n' || *text == '\0' ) {
  384.          *lp = '\0';
  385.          WinDrawText (hps, -1, line, &line_box,
  386.                      CLR_NEUTRAL, CLR_BACKGROUND,
  387.                      DT_CENTER | DT_ERASERECT) ;
  388.          lp=line;
  389.          line_box.yBottom -= pfm->lMaxBaselineExt;
  390.          line_box.yTop    -= pfm->lMaxBaselineExt;
  391.          if ( *text == '\0' ) {
  392.             break;
  393.          }
  394.       }
  395.       else {
  396.          *lp++ = *text;
  397.       }
  398.    }
  399. }
  400.  
  401. //-----------------------------------------------------------------------------
  402. // see if point is in target area
  403. //-----------------------------------------------------------------------------
  404. BOOL landingArea(POINTL *ptl,TARGETAREA * ptargetarea)
  405. {
  406.    if (ptargetarea) {
  407.       return ( (ptl->x >= ptargetarea->xlow ) &&
  408.                (ptl->x <= ptargetarea->xhigh) &&
  409.                (ptl->y >= ptargetarea->ylow ) &&
  410.                (ptl->y <= ptargetarea->yhigh) );
  411.    } else {
  412.       return 0;
  413.    } /* endif */
  414. }
  415. //-----------------------------------------------------------------------------
  416. // select new mode
  417. //-----------------------------------------------------------------------------
  418. void setMode(LONG mode)
  419. {
  420.    switch (mode) {
  421.    case MODE_ALIGN:
  422. #ifdef DEBUG
  423.       if (dbfile) fprintf(stream,"-- ALIGN MODE ----\n");
  424. #endif
  425.       hptrMSE=hptrSYS;       //use system pointer for mouse moves
  426.       boxText=calText;       //select box text
  427.       break;
  428.    case MODE_TEST:
  429. #ifdef DEBUG
  430.       if (dbfile) fprintf(stream,"-- TEST  MODE ----\n");
  431. #endif
  432.       hptrMSE=hptrTarget;    //use target pointer for mouse moves
  433.       boxText=tesText;       //select box text
  434.       break;
  435.    default:
  436. #ifdef DEBUG
  437.       if (dbfile) {
  438.          fprintf(stream,"setMode: invalid mode=%d\n",mode);
  439.       } /* endif */
  440. #endif
  441.    case MODE_IDLE:
  442. #ifdef DEBUG
  443.       if (dbfile) fprintf(stream,"-- IDLE  MODE ----\n");
  444. #endif
  445.       hptrMSE=hptrSYS;       //use system pointer for mouse moves
  446.       boxText=0;             //no text
  447.       break;
  448.    } /* endswitch */
  449.    ptargetarea=0;         //cancel a possible painted target icon
  450.    WinSetPointer(HWND_DESKTOP,hptrMSE);
  451. }
  452. //-----------------------------------------------------------------------------
  453. // Initialize variables used in toState procdure
  454. //-----------------------------------------------------------------------------
  455. void initMode(void)
  456. {
  457.    hptrMSE=hptrSYS;
  458.    ptargetarea = 0;
  459.    areaChangePending=FALSE;
  460.    nocursorValid = FALSE;
  461. }
  462. //-----------------------------------------------------------------------------
  463. // update the nocursor area if the locator has moved out of the old
  464. // nocursor area. If there currently isn't a nocursor area, then just
  465. // set it to the current targetarea.
  466. //-----------------------------------------------------------------------------
  467. void updateNocursorArea(POINTL * pptl)
  468. {
  469.    if (nocursorValid) {
  470.       if (!(landingArea(pptl,&nocursorarea))) {
  471.          updatearea();
  472.       } /* endif */
  473.    } else {
  474.       updatearea();
  475.    } /* endif */
  476. }
  477. //-----------------------------------------------------------------------------
  478. // update the nocursor area if their is a new area to update to
  479. // nocursor area
  480. //-----------------------------------------------------------------------------
  481. void updatearea(void)
  482. {
  483.    if (ptargetarea) {
  484.       nocursorarea=*ptargetarea;
  485.       nocursorValid=TRUE;
  486.    } else {
  487.       nocursorValid = FALSE;
  488.    } /* endif */
  489.    areaChangePending=FALSE;
  490. }
  491. //***************************************************************************** */
  492. //   E X T E R N A L   R O U T I N E S
  493. //*****************************************************************************
  494.  
  495. //-----------------------------------------------------------------------------
  496. // called by alignment thread to control window proc
  497. //-----------------------------------------------------------------------------
  498. void notifyPM (LONG notifyCmd,TARGETAREA * ptargetarea)
  499. {
  500.    BOOL pmrc;
  501.    MPARAM mp1,mp2;
  502.  
  503.    pmrc=WinPostMsg(hwndAdjust,notifyCmd,mp1,ptargetarea);
  504.  
  505. }
  506.  
  507. //-----------------------------------------------------------------------------
  508. // called to register the window class
  509. //-----------------------------------------------------------------------------
  510. void registerAlign(void)
  511. {
  512.    WinRegisterClass(habMain,adjName,(PFNWP)AdjustWndProc,
  513.                          CS_SIZEREDRAW+CS_CLIPCHILDREN,0);
  514. }
  515.  
  516. //-----------------------------------------------------------------------------
  517. // called to create the window
  518. //-----------------------------------------------------------------------------
  519. LONG createAlign (HWND owner)
  520. {
  521.    HWND hwndclient;
  522.    ULONG createflags=FCF_ICON|FCF_TASKLIST;
  523.    CHAR  szFile[CCHMAXPATH];
  524.    APIRET rc;
  525.    LONG i,l;
  526.    LONG strSize;
  527.  
  528. // load strings
  529.  
  530.    strcpy(szFile,PENPMMRI);
  531.    rc=DosLoadModule(szFile,CCHMAXPATH,szFile,&hmodMRI);
  532. #ifdef DEBUG
  533.    if (rc) {
  534.       if (dbfile) fprintf(stream,"DosLoadModule for %s rc=%d\n",szFile,rc);
  535.    } else {
  536. #else
  537.    if ( !rc ) {
  538. #endif
  539.  
  540.       for (i=0,l=0;i<3;i++) {   //glue all CALTEXT messages together
  541.          strSize=WinLoadString(habMain,hmodMRI,IDS_CALTEXT+i,MAX_LINE_SIZE,&calText[l]);
  542. #ifdef DEBUG
  543.          //if (dbfile) fprintf(stream,"%d %s\n",strSize,&calText[l]);
  544. #endif
  545.          if (maxLineSize < strSize) {
  546.             maxLineSize = strSize;
  547.          } /* endif */
  548.          l+=strSize;
  549.          calText[l++]='\n';
  550.       } /* endfor */
  551.       calText[--l]='\0';
  552.  
  553.       for (i=0,l=0;i<5;i++) {   //glue all TESTEXT messages together
  554.          strSize=WinLoadString(habMain,hmodMRI,IDS_TESTEXT+i,MAX_LINE_SIZE,&tesText[l]);
  555. #ifdef DEBUG
  556.          //if (dbfile) fprintf(stream,"%d %s\n",strSize,&tesText[l]);
  557. #endif
  558.          if (maxLineSize < strSize) {
  559.             maxLineSize = strSize;
  560.          } /* endif */
  561.          l+=strSize;
  562.          tesText[l++]='\n';
  563.       } /* endfor */
  564.       tesText[--l]='\0';
  565.  
  566.       WinLoadString (habMain,hmodMRI,IDS_DEFTEXT,MAX_LINE_SIZE,deftext);
  567.       WinLoadString (habMain,hmodMRI,IDS_DEFTITLE,MAX_LINE_SIZE,deftitle);
  568.       WinLoadString (habMain,hmodMRI,IDS_ERR1,MAX_LINE_SIZE,DDerrText);
  569.       WinLoadString (habMain,hmodMRI,IDS_OK,MAX_BUT_SIZE,szButtonLabel[0]);
  570.       WinLoadString (habMain,hmodMRI,IDS_ALIGN,MAX_BUT_SIZE,szButtonLabel[1]);
  571.       WinLoadString (habMain,hmodMRI,IDS_DEFAULTS,MAX_BUT_SIZE,szButtonLabel[2]);
  572.       WinLoadString (habMain,hmodMRI,IDS_TEST,MAX_BUT_SIZE,szButtonLabel[3]);
  573.       WinLoadString (habMain,hmodMRI,IDS_CANCEL,MAX_BUT_SIZE,szButtonLabel[4]);
  574.       WinLoadString (habMain,hmodMRI,IDS_HELP,MAX_BUT_SIZE,szButtonLabel[5]);
  575.    } /* endif */
  576.  
  577. // do PM stuff
  578.  
  579.    hwndAdjust=WinCreateStdWindow(
  580.       HWND_DESKTOP,        //parent
  581.       FS_TASKLIST,         //frame window style
  582.       &createflags,        // frame creation flags
  583.       adjName,             //class
  584.       NULL,                //text
  585.       0L,                  //style
  586.       NULLHANDLE,          //resource
  587.       ID_APP,              //resource ID
  588.       &hwndclient);        //client hwnd
  589.  
  590.    WinSetWindowPos(
  591.       hwndAdjust,          //window handle
  592.       HWND_TOP,            //sibling
  593.       0,0,                 //position
  594.       scrWidth,scrHeight,  //size
  595.       SWP_SIZE|SWP_ZORDER|SWP_SHOW|SWP_ACTIVATE); //options
  596.  
  597.  
  598.    return 0;
  599. }
  600.  
  601. //-----------------------------------------------------------------------------
  602. // called to destroy the window
  603. //-----------------------------------------------------------------------------
  604. void destroyAlign(void)
  605. {
  606.    WinDestroyWindow(hwndAdjust);
  607. }
  608.