VOID DisplayDriveInfo (HWND hWnd, ULONG ulInx)
{
    CHAR  szVolumeLabel[12];
    ULONG ulTotalSpace,
          ulAllocated,
          ulAvailable;

    WinSetDlgItemText (hWnd, IDC_LOCATION, DriveInfo[ulInx].szLocation);
    WinSetDlgItemText (hWnd, IDC_REMOVABLE, DriveInfo[ulInx].szRemovable);
    WinSetDlgItemText (hWnd, IDC_FILESYSTEM, DriveInfo[ulInx].szFileSystem);
    WinSetDlgItemText (hWnd, IDC_DESCRIPTION, 
        szDriveDescription[DriveInfo[ulInx].ulDescriptionIndex]);

    WinSetPointer (HWND_DESKTOP, 
        WinQuerySysPointer (HWND_DESKTOP,SPTR_WAIT,FALSE));

    QueryVolumeLabel (DriveInfo[ulInx].szDrive[0] - 'A' + 1, szVolumeLabel);
    WinSetDlgItemText (hWnd, IDC_VOLUMELABEL, szVolumeLabel);

    QueryDiskSpace (DriveInfo[ulInx].szDrive[0] - 'A' + 1, &ulTotalSpace,
        &ulAllocated, &ulAvailable);

    FormatNumberField (hWnd, IDC_TOTALSPACE, ulTotalSpace);
    FormatNumberField (hWnd, IDC_ALLOCATED,  ulAllocated);
    FormatNumberField (hWnd, IDC_AVAILABLE,  ulAvailable);

    WinSetPointer (HWND_DESKTOP, 
        WinQuerySysPointer (HWND_DESKTOP,SPTR_ARROW,FALSE));

    return;
}
/**************************************************************************
 *
 *  Name       : InitGlobalVars()
 *
 *  Description: Performs initialization of the application  s
 *               global variables
 *
 *  Concepts   : Called once by the Init() routine
 *
 *  API's      :  WinQuerySysValue
 *                WinQuerySysPointer
 *
 *  Parameters :  [none]
 *
 *  Return     :  TRUE - initialization is successful
 *                FALSE - initialization failed
 *
 *************************************************************************/
BOOL InitGlobalVars(VOID)
{
   /* load system sizes */
   vlXScreen = WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);
   vlYScreen = WinQuerySysValue(HWND_DESKTOP, SV_CYSCREEN);
   vlcxVScroll = WinQuerySysValue(HWND_DESKTOP, SV_CXVSCROLL);
   vlcyHScroll = WinQuerySysValue(HWND_DESKTOP, SV_CYHSCROLL);
   vlcyTitle = WinQuerySysValue(HWND_DESKTOP, SV_CYTITLEBAR);
   vlcyMenu = WinQuerySysValue(HWND_DESKTOP, SV_CYMENU);
   vlcxBorder = WinQuerySysValue(HWND_DESKTOP, SV_CXSIZEBORDER);
   vlcyBorder = WinQuerySysValue(HWND_DESKTOP, SV_CYSIZEBORDER);

   /* load system pointers */
   vhptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW, FALSE);
   vhptrWait = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE);
   return TRUE;
} /* End of InitGlobalVars  */
Esempio n. 3
0
/*
 * _NewWindow - create a new window
 */
unsigned _NewWindow( char *name, ... )
{
    LPWDATA     w;
    MENUITEM    menus;
    HWND        hwnd,frame,temp;
    char        str[80];
    int         x1,x2,y1,y2;
    ULONG       style;
    RECTL       rcl;
    va_list     al;

    _GetWindowNameAndCoords( name, str, &x1, &x2, &y1, &y2 );

    style = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER | FCF_MINMAX |
            FCF_VERTSCROLL;
    frame = WinCreateStdWindow( _MainWindow,
                WS_VISIBLE | WS_CLIPSIBLINGS,
                &style, _ClassName, str, 0, NULL, 0, &hwnd );
    if( frame == 0 ) return( FALSE );
    WinSetOwner( hwnd, _MainWindow );

    va_start( al, name );
    w = _AnotherWindowData( hwnd, al );
    w->frame = frame;
    w->text_color = CLR_WHITE;
    w->background_color = CLR_BLACK;
    WinSendMsg( frame, WM_SETICON,
        MPFROMLONG( WinQuerySysPointer( HWND_DESKTOP, SPTR_APPICON, TRUE ) ), 0 );
    WinSetWindowBits( WinWindowFromID( w->frame, FID_VERTSCROLL ), QWL_STYLE,
                        SBS_AUTOTRACK, SBS_AUTOTRACK );

    _CreateFont( w );
    _PositionScrollThumb( w );
    WinQueryWindowRect( _MainWindow, &rcl );
    WinSetWindowPos( frame, HWND_TOP,
                x1*w->xchar,
                (rcl.yTop - rcl.yBottom)-y1*w->ychar-y2*w->ychar,
                x2*w->xchar,
                y2*w->ychar,
                SWP_SIZE | SWP_MOVE | SWP_ZORDER );

    menus.iPosition = _MainWindowData->window_count - 1;
    menus.afStyle = MIS_TEXT;
    menus.afAttribute = 0;
    menus.id = DID_WIND_STDIO + w->handles[0];
    menus.hwndSubMenu = NULL;
    menus.hItem = 0;
    if ( MIT_ERROR == (BOOL)WinSendMsg( menuHandle, ( ULONG )MM_INSERTITEM, MPFROMP( &menus ), MPFROMP( str ) ) ) abort();
    temp = WinWindowFromID( frame, FID_SYSMENU );
    WinSendMsg( temp, MM_QUERYITEM, MPFROM2SHORT(SC_SYSMENU, TRUE),
                               MPFROMP((PSZ)&menus) );
    WinSendMsg( menus.hwndSubMenu, MM_DELETEITEM, MPFROM2SHORT( SC_CLOSE, TRUE ), 0 );
    WinUpdateWindow( hwnd );
    WinSetFocus( HWND_DESKTOP, hwnd );
    return( TRUE );

} /* _NewWindow */
Esempio n. 4
0
/*------------------------------------------------------------------------*/
BOOL IsOnLineEnd(POINTL mouseptl, pLines pLin,WINDOWINFO *pwi, USHORT *corner )
{
   POINTL ptl1,ptl2;

   if (!pLin)
      return FALSE;

   ptl1.x = (LONG)(pLin->ptl1.x * pwi->usFormWidth );
   ptl1.y = (LONG)(pLin->ptl1.y * pwi->usFormHeight);
   ptl1.x += (LONG)pwi->fOffx;
   ptl1.y += (LONG)pwi->fOffy;

   ptl2.x =  (LONG)(pLin->ptl2.x * pwi->usFormWidth );    
   ptl2.y =  (LONG)(pLin->ptl2.y * pwi->usFormHeight);
   ptl2.x += (LONG)pwi->fOffx;
   ptl2.y += (LONG)pwi->fOffy;

   if (mouseptl.x >= ( ptl1.x - 5 ) &&
       mouseptl.x <= ( ptl1.x + 5 ) &&
       mouseptl.y >= ( ptl1.y - 5 ) &&
       mouseptl.y <= ( ptl1.y + 5 ))
    {
       *corner = 1;
       WinSetPointer(HWND_DESKTOP,
                     WinQuerySysPointer(HWND_DESKTOP,
                                        SPTR_SIZENWSE,FALSE));
       return TRUE;
    }
    else if (mouseptl.x >= ( ptl2.x - 5 ) &&
             mouseptl.x <= ( ptl2.x + 5 ) &&
             mouseptl.y >= ( ptl2.y - 5 ) &&
             mouseptl.y <= ( ptl2.y + 5 ))
    {
       *corner = 2;
       WinSetPointer(HWND_DESKTOP,
                     WinQuerySysPointer(HWND_DESKTOP,
                                        SPTR_SIZENWSE,FALSE));

       return TRUE;
    }
    return FALSE;
}
void OS2Factory::changeCursor( CursorType_t type ) const
{
    LONG id;
    switch( type )
    {
    default:
    case kDefaultArrow: id = SPTR_ARROW;    break;
    case kResizeNWSE:   id = SPTR_SIZENWSE; break;
    case kResizeNS:     id = SPTR_SIZENS;   break;
    case kResizeWE:     id = SPTR_SIZEWE;   break;
    case kResizeNESW:   id = SPTR_SIZENESW; break;
    }

    HPOINTER hptr = WinQuerySysPointer( HWND_DESKTOP, id, FALSE );
    WinSetPointer( HWND_DESKTOP, hptr );

    m_cursorType = type;
}
Esempio n. 6
0
nsresult os2FrameWindow::SetIcon(const nsAString& aIconSpec)
{
  static HPOINTER hDefaultIcon = 0;
  HPOINTER        hWorkingIcon = 0;

  // Assume the given string is a local identifier for an icon file.
  nsCOMPtr<nsIFile> iconFile;
  mOwner->ResolveIconName(aIconSpec, NS_LITERAL_STRING(".ico"),
                          getter_AddRefs(iconFile));

  // if the file was found, try to use it
  if (iconFile) {
    nsCAutoString path;
    iconFile->GetNativePath(path);

    if (mFrameIcon) {
      WinFreeFileIcon(mFrameIcon);
    }
    mFrameIcon = WinLoadFileIcon(path.get(), FALSE);
    hWorkingIcon = mFrameIcon;
  }

  // if that doesn't work, use the app's icon (let's hope it can be
  // loaded because nobody should have to look at SPTR_APPICON)
  if (!hWorkingIcon) {
    if (!hDefaultIcon) {
      hDefaultIcon = WinLoadPointer(HWND_DESKTOP, 0, 1);
      if (!hDefaultIcon) {
        hDefaultIcon = WinQuerySysPointer(HWND_DESKTOP, SPTR_APPICON, FALSE);
      }
    }
    hWorkingIcon = hDefaultIcon;
  }

  WinSendMsg(mFrameWnd, WM_SETICON, (MPARAM)hWorkingIcon, (MPARAM)0);
  return NS_OK;
}
Esempio n. 7
0
void Window::setPointer( int type )
{
  LONG getPointer = -1;
  switch( type )
  {
    case PTR_ARROW : getPointer = SPTR_ARROW; break;
    case PTR_TEXT : getPointer = SPTR_TEXT; break;
    case PTR_WAIT : getPointer = SPTR_WAIT; break;
    case PTR_MOVE : getPointer = SPTR_SIZENS; break;
    case PTR_HAND : getPointer = SPTR_ARROW; break;
  }

  if( getPointer != -1 )
    currentPointer = WinQuerySysPointer( HWND_DESKTOP, getPointer, FALSE );
  else
    currentPointer = NULLHANDLE;

  // Display the new pointer by focring a WM_MOUSEMOVE

  POINTL pos;

  WinQueryPointerPos( HWND_DESKTOP, &pos );
  WinSetPointerPos( HWND_DESKTOP, pos.x, pos.y );
}
Esempio n. 8
0
BOOL CALLBACK CDialogDlgProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
#endif
{
   int i;
   class CDialog *dlgClass;
   CPC_MSGMAP_ENTRY *msgMap = NULL;

#if defined(__OS2__)
   dlgClass = (class CDialog *)WinQueryWindowULong (hwnd, QWL_USER);
#elif defined(__NT__)
   dlgClass = (class CDialog *)GetWindowLong (hwnd, GWL_USERDATA);
#endif

   if (dlgClass != NULL) {
      dlgClass->m_msg = msg;
#if defined(__OS2__)
      dlgClass->m_mp1 = mp1;
      dlgClass->m_mp2 = mp2;
#elif defined(__NT__)
      dlgClass->m_wParam = wParam;
      dlgClass->m_lParam = lParam;
#endif

      msgMap = dlgClass->GetMessageMap ();
   }

   switch (msg) {
#if defined(__OS2__)
      case WM_INITDLG: {
         CDIALOG_DATA *cData = (CDIALOG_DATA *)mp2;
#elif defined(__NT__)
      case WM_INITDIALOG: {
         CDIALOG_DATA *cData = (CDIALOG_DATA *)lParam;
#endif

         dlgClass = cData->Dlg;
         dlgClass->m_hWnd = hwnd;
         dlgClass->lv_Selected = -1;
#if defined(__OS2__)
         WinSetWindowULong (hwnd, QWL_USER, (ULONG)dlgClass);
#elif defined(__NT__)
         SetWindowLong (hwnd, GWL_USERDATA, (LONG)dlgClass);
#endif

         dlgClass->OnInitDialog ();
#if defined(__OS2__)
         break;
#elif defined(__NT__)
         return ((BOOL)TRUE);
#endif
      }

#if defined(__OS2__)
      case WM_CONTROL:
         for (i = 0; msgMap[i].pfn != NULL; i++) {
            if (msgMap[i].nMessage == msg) {
               if (msgMap[i].nID >= SHORT1FROMMP (mp1) && msgMap[i].nLastID <= SHORT1FROMMP (mp1)) {
                  if (msgMap[i].nCode == SHORT2FROMMP (mp1)) {
                     (dlgClass->*msgMap[i].pfn) ();
                     break;
                  }
               }
            }
         }
         return (0);
#endif

#if defined(__NT__)
      case WM_NOTIFY: {
         LPNMHDR pnmh = (LPNMHDR)lParam;
         NM_LISTVIEW *pnmv = (NM_LISTVIEW *)lParam;

         if (pnmh->code == NM_DBLCLK)
            dlgClass->OnOK ();
         else if (pnmh->code == LVN_ITEMCHANGED) {
            if (!(pnmv->uNewState & LVIS_SELECTED) && (pnmv->uOldState & LVIS_SELECTED))
               dlgClass->lv_Selected = -1;
            if (pnmv->uNewState & LVIS_SELECTED)
               dlgClass->lv_Selected = (SHORT)pnmv->iItem;
         }
         else {
            for (i = 0; msgMap[i].pfn != NULL; i++) {
               if (msgMap[i].nMessage == msg && msgMap[i].nCode == pnmh->code) {
                  if (msgMap[i].nID >= pnmh->idFrom && msgMap[i].nLastID <= pnmh->idFrom) {
                     (dlgClass->*msgMap[i].pfn) ();
                     break;
                  }
               }
            }
         }
         return (0);
      }
#endif

#if defined(__OS2__)
      case WM_CHAR:
         if (SHORT1FROMMP (mp1) & KC_VIRTUALKEY && SHORT2FROMMP (mp2) == VK_F1)
            dlgClass->OnHelp ();
         break;
#endif

      case WM_HELP:
         dlgClass->OnHelp ();
         break;
/*
#if defined(__OS2__)
      case WM_HELP: {
         USHORT id;
         HWND hwndHelpInstance;

         id = WinQueryWindowUShort (hwnd, QWS_ID);
         hwndHelpInstance = WinQueryHelpInstance (dlgClass->owner_hWnd);
         WinSendMsg (hwndHelpInstance, HM_DISPLAY_HELP, MPFROM2SHORT (id, 0), MPFROMSHORT (HM_RESOURCEID));
         break;
      }
#endif
*/

      case WM_COMMAND:
#if defined(__OS2__)
         switch (SHORT1FROMMP (mp1)) {
#elif defined(__NT__)
         switch (LOWORD (wParam)) {
#endif
            case IDOK:
               dlgClass->OnOK ();
               break;
            case IDCANCEL:
               dlgClass->OnCancel ();
               break;
            case IDHELP:
               dlgClass->OnHelp ();
               break;
            default:
               for (i = 0; msgMap[i].pfn != NULL; i++) {
#if defined(__OS2__)
                  if (msgMap[i].nMessage == msg) {
                     if (msgMap[i].nID >= SHORT1FROMMP (mp1) && msgMap[i].nLastID <= SHORT1FROMMP (mp1)) {
#elif defined(__NT__)
                  if (msgMap[i].nMessage == msg && msgMap[i].nCode == HIWORD (wParam)) {
                     if (msgMap[i].nID >= LOWORD (wParam) && msgMap[i].nLastID <= LOWORD (wParam)) {
#endif
                        (dlgClass->*msgMap[i].pfn) ();
                        break;
                     }
                  }
               }
               break;
         }
         return (0);

#if defined(__NT__)
      case WM_CLOSE:
         EndDialog (hwnd, FALSE);
         break;
#endif

      default:
         if (msgMap != NULL) {
            for (i = 0; msgMap[i].pfn != NULL; i++) {
               if (msgMap[i].nMessage == msg) {
                  (dlgClass->*msgMap[i].pfn) ();
                  return (0);
               }
            }
         }
         break;
   }

#if defined(__OS2__)
   return (WinDefDlgProc (hwnd, msg, mp1, mp2));
#elif defined(__NT__)
   return ((BOOL)FALSE);
#endif
}

CDialog::CDialog (PSZ dialogTemplate, HWND p_hWnd)
{
   strcpy (dlgTemplate, dialogTemplate);
   owner_hWnd = p_hWnd;
   help_hWnd = NULL;
#if defined(__OS2__)
   WinSetPointer (HWND_DESKTOP, WinQuerySysPointer (HWND_DESKTOP, SPTR_WAIT, FALSE));
#elif defined(__NT__)
#endif
}

CDialog::~CDialog ()
{
#if defined(__OS2__)
   if (help_hWnd != NULL)
      WinDestroyHelpInstance (help_hWnd);
#elif defined(__NT__)
#endif
}

VOID CDialog::Center ()
{
#if defined(__OS2__)
   RECTL rc;
#elif defined(__NT__)
   RECT rc;
#endif

#if defined(__OS2__)
   WinQueryWindowRect (m_hWnd, &rc);
   rc.yTop = (WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN) - (rc.yTop - rc.yBottom)) / 2;
   rc.xLeft = (WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN) - (rc.xRight - rc.xLeft)) / 2;
   WinSetWindowPos (m_hWnd, NULL, rc.xLeft, rc.yTop, 0, 0, SWP_MOVE);
#elif defined(__NT__)
   GetWindowRect (m_hWnd, &rc);
   rc.top = (GetSystemMetrics (SM_CYSCREEN) - (rc.bottom - rc.top)) / 2;
   rc.left = (GetSystemMetrics (SM_CXSCREEN) - (rc.right - rc.left)) / 2;
   SetWindowPos (m_hWnd, NULL, rc.left, rc.top, 0, 0, SWP_NOSIZE|SWP_NOZORDER);
#endif
}

LONG CDialog::DoModal ()
{
   LONG ulResult = 0L;
   CDIALOG_DATA cDialog;

   cDialog.cbSize = sizeof (CDIALOG_DATA);
   cDialog.Dlg = this;

#if defined(__OS2__)
   WinSetPointer (HWND_DESKTOP, WinQuerySysPointer (HWND_DESKTOP, SPTR_ARROW, FALSE));
   ulResult = WinDlgBox (HWND_DESKTOP, owner_hWnd, CDialogDlgProc, NULLHANDLE, atoi (dlgTemplate), &cDialog);
#elif defined(__NT__)
   ulResult = DialogBoxParam (hinst, MAKEINTRESOURCE (atoi (dlgTemplate)), owner_hWnd, (DLGPROC)CDialogDlgProc, (LPARAM)&cDialog);
#endif

   return (ulResult);
}

// ----------------------------------------------------------------------
// Windowing API replacement
// ----------------------------------------------------------------------

VOID CDialog::EndDialog (USHORT Result)
{
#if defined(__OS2__)
   WinDismissDlg (m_hWnd, Result);
#elif defined(__NT__)
   ::EndDialog (m_hWnd, Result);
#endif
}

VOID CDialog::GetDlgItemText (int id, PSZ text, USHORT size)
{
#if defined(__OS2__)
   WinQueryDlgItemText (m_hWnd, id, size, text);
#elif defined(__NT__)
   ::GetDlgItemText (m_hWnd, id, text, size);
#endif
}

VOID CDialog::GetDlgItemText (int id, USHORT size, PSZ text)
{
#if defined(__OS2__)
   WinQueryDlgItemText (m_hWnd, id, size, text);
#elif defined(__NT__)
   ::GetDlgItemText (m_hWnd, id, text, size);
#endif
}
MRESULT EXPENTRY MimeDlgProc(HWND hwndDlg,ULONG msg,MPARAM mp1,MPARAM mp2)
{
    HPOINTER  hptrOrig, hptrWait;
    static int num_entries;
    static int entry;
    static FILE *in;
    static Container *list;
    static MimeSet *mimes;
    UserData *ud;
    char buffer[1024];
    int i;
    
    switch(msg)
    {
        
        case WM_INITDLG:
            hptrWait = WinQuerySysPointer( HWND_DESKTOP, SPTR_WAIT, FALSE );
            hptrOrig = WinQueryPointer( HWND_DESKTOP );
            WinSetPointer( HWND_DESKTOP, hptrWait );
            
            WinSendMsg(WinWindowFromID(hwndDlg,MIME_NAME),EM_SETTEXTLIMIT,MPFROMSHORT(128),MPFROMSHORT(0));
            WinSendMsg(WinWindowFromID(hwndDlg,MIME_EXT), EM_SETTEXTLIMIT,MPFROMSHORT(128),MPFROMSHORT(0));
            WinSendMsg(WinWindowFromID(hwndDlg,MIME_EXE), EM_SETTEXTLIMIT,MPFROMSHORT(128),MPFROMSHORT(0));
            
            mimes = (MimeSet*)mp2;
            list = new Container();
            list->initialise(hwndDlg,MIME_CONT);
            
            num_entries = mimes->getSetNum();
            for (i=0; i<num_entries; i++)
            {
                sprintf(buffer,"%s: %s",mimes->getName(i),mimes->getExtensions(i));
//                message("%d/%d %s is %s",i,num_entries,mimes->getName(i),mimes->getExtensions(i));
                
                list->insert(buffer,(UserData*)NULL,8888L,8888L);
            }
            
            WinFocusChange(HWND_DESKTOP,WinWindowFromID(hwndDlg,MIME_CONT),0);
            
            WinSetWindowText(WinWindowFromID(hwndDlg,MIME_NAME),mimes->getName(mimes->getSetNum()-1));
            WinSetWindowText(WinWindowFromID(hwndDlg,MIME_EXT),mimes->getExtensions(mimes->getSetNum()-1));
            WinSetWindowText(WinWindowFromID(hwndDlg,MIME_EXE),mimes->getCommand(mimes->getSetNum()-1));
            list->setItemFocus(list->getLastInsert());
            
            WinSetPointer( HWND_DESKTOP, hptrOrig );
            
            entry = -1;
            break;
            
        case WM_HELP:
            showHelpWindow(HELP_MIMES);
            break;
            
            
        case WM_CLOSE:
            mimes->reload();
            delete list;
            return WinDefDlgProc(hwndDlg,msg,mp1,mp2);
            
        case WM_USER:
            list->arrange();
            break;
            
        case WM_CONTROL:
            switch(SHORT2FROMMP(mp1))
            {
                
                case CN_HELP:
                    WinSendMsg(hwndDlg,WM_HELP,0,0);
                    break;
                    
                // sent every time emphasis of an object is changed, so if
                // change from A to B, get deselect on A, and select on B
                case CN_EMPHASIS:
                {
                    PNOTIFYRECORDEMPHASIS nre = (PNOTIFYRECORDEMPHASIS)mp2;
                    ud = (UserData*)nre->pRecord;
                    
                    if (ud != NULL)
                    {
                        char *buffer = new char[4096];
                        strcpy(buffer,ud->getName());
                        char *ptr = buffer+strlen(buffer)-1;
                        while (ptr>buffer && *ptr!='.') ptr--;
                        if (*ptr == '.')
                        {
                            int index = mimes->find(ptr);
                            
                            if (index > -1)
                            {
                                entry = index;
                                WinSetWindowText(WinWindowFromID(hwndDlg,MIME_NAME),mimes->getName(index));
                                WinSetWindowText(WinWindowFromID(hwndDlg,MIME_EXT),mimes->getExtensions(index));
                                WinSetWindowText(WinWindowFromID(hwndDlg,MIME_EXE),mimes->getCommand(index));
                            }
                        }
                        delete[] buffer;
                    }
                }
                break;
                    
                case EN_CHANGE:
                {
                    if (SHORT1FROMMP(mp1) == MIME_EXE)
                    {
                        ud = list->findSelectedRecord(NULL);
                        static int lastindex = 0;
                        if (ud && entry != -1)
                        {
                            if (lastindex == entry)
                            {
                                char *buffer = new char[4096];
                                WinQueryWindowText(WinWindowFromID(hwndDlg,MIME_EXE),129,buffer);
                                mimes->setCommand(entry,buffer);
                                delete[] buffer;
                            }
                            lastindex = entry;
                        }
                    }
                }
                break;
                    
            }
            break;
            
        case WM_COMMAND:
            switch( SHORT1FROMMP( mp1 ) )
            {
                case IDM_DELETE:
//                    message("delete");
                    break;
                    
                case DID_OK:
                    // all OK, close dialog, return
                    if (entry != -1)
                    {
                        WinQueryWindowText(WinWindowFromID(hwndDlg,MIME_EXE),129,buffer);
                        mimes->setCommand(entry,buffer);
                    }
                    mimes->save();
                    delete list;
                    WinDismissDlg( hwndDlg, TRUE);
                    return (MRESULT) TRUE;
                    
                case DID_CANCEL:
                    mimes->reload();
                    delete list;
                    WinDismissDlg( hwndDlg, TRUE);
                    return (MRESULT) FALSE;
            }
            break;
            
            
        default:
            return WinDefDlgProc(hwndDlg,msg,mp1,mp2);
    }
    return (MRESULT) TRUE;
}
Esempio n. 10
0
static HPOINTER combineTwoCursors(LONG idOver, LONG idUnder)
{
    HPOINTER hptr = NULLHANDLE;

    POINTERINFO piOver, piUnder;
    HPOINTER hOver = WinQuerySysPointer(HWND_DESKTOP, idOver, FALSE);
    WinQueryPointerInfo(hOver, &piOver);
    HPOINTER hUnder = WinQuerySysPointer(HWND_DESKTOP, idUnder, FALSE);
    WinQueryPointerInfo(hUnder, &piUnder);
    if (piOver.hbmColor) {
        HPS hpsPtr, hpsTmp, hpsMask;
        HBITMAP hbmPtr, hbmTmp, hbmMask;
        qt_alloc_ps_with_bitmap(32, 32, false, hpsPtr, hbmPtr);
        qt_alloc_ps_with_bitmap(32, 32, false, hpsTmp, hbmTmp);
        qt_alloc_ps_with_bitmap(32, 64, true, hpsMask, hbmMask);
        // copy the overlying pointer
        POINTL ptls[] = { { 0, 0 }, { 31, 31 }, { 0, 0 }, { 32, 32 } };
        GpiWCBitBlt(hpsTmp, piOver.hbmColor, 4, ptls, ROP_SRCCOPY, BBO_IGNORE);
        // make its transparent pixels black
        ptls[2].y += 32; ptls[3].y += 32;
        GpiSetColor(hpsTmp, CLR_TRUE);
        GpiSetBackColor(hpsTmp, CLR_FALSE);
        GpiWCBitBlt(hpsTmp, piOver.hbmPointer, 4, ptls, 0x22, BBO_IGNORE);
        // copy the underlying pointer
        ptls[2].y -= 32; ptls[3].y -= 32;
        GpiWCBitBlt(hpsPtr, piUnder.hbmColor, 4, ptls, ROP_SRCCOPY, BBO_IGNORE);
        // make non-transparent pixels from the overlying pointer black
        ptls[2].y += 32; ptls[3].y += 32;
        GpiSetColor(hpsPtr, CLR_TRUE);
        GpiSetBackColor(hpsPtr, CLR_FALSE);
        GpiWCBitBlt(hpsPtr, piOver.hbmPointer, 4, ptls, ROP_SRCAND, BBO_IGNORE);
        // put the overlying pointer there
        ptls[2].y -= 32; ptls[3].y -= 32;
        ptls[1].x ++; ptls[1].y ++;
        GpiBitBlt(hpsPtr, hpsTmp, 4, ptls, ROP_SRCPAINT, BBO_IGNORE);
        // copy both underlying pointer's masks
        ptls[1].x --; ptls[1].y --;
        ptls[1].y += 32; ptls[3].y += 32;
        GpiWCBitBlt(hpsMask, piUnder.hbmPointer, 4, ptls, ROP_SRCCOPY, BBO_IGNORE);
        // add overlying pointer's XOR mask
        ptls[1].y -= 32; ptls[3].y -= 32;
        GpiWCBitBlt(hpsMask, piOver.hbmPointer, 4, ptls, ROP_SRCPAINT, BBO_IGNORE);
        // add overlying pointer's AND mask
        ptls[0].y += 32; ptls[2].y += 32;
        ptls[1].y += 32; ptls[3].y += 32;
        GpiWCBitBlt(hpsMask, piOver.hbmPointer, 4, ptls, ROP_SRCAND, BBO_IGNORE);
        // create the new pointer
        GpiSetBitmap(hpsPtr, NULLHANDLE);
        GpiSetBitmap(hpsMask, NULLHANDLE);
        piOver.hbmColor = hbmPtr;
        piOver.hbmPointer = hbmMask;
        piOver.hbmMiniColor = NULLHANDLE;
        piOver.hbmMiniPointer = NULLHANDLE;
        hptr = WinCreatePointerIndirect(HWND_DESKTOP, &piOver);
        qt_free_ps_with_bitmap(hpsMask,  hbmMask);
        qt_free_ps_with_bitmap(hpsTmp,  hbmTmp);
        qt_free_ps_with_bitmap(hpsPtr,  hbmPtr);
    } else {
        HPS hps;
        HBITMAP hbm;
        qt_alloc_ps_with_bitmap(32, 64, true, hps, hbm);
        POINTL ptls[] = { { 0, 0 }, { 31, 63 }, { 0, 0 }, { 32, 64 } };
        // make a copy of the underlying pointer
        GpiWCBitBlt(hps, piUnder.hbmPointer, 4, ptls, ROP_SRCCOPY, BBO_IGNORE);
        // combine AND masks
        ptls[0].y += 32; ptls[2].y += 32;
        GpiWCBitBlt(hps, piOver.hbmPointer, 4, ptls, ROP_SRCAND, BBO_IGNORE);
        // apply the overlying AND mask to the underlying XOR mask
        ptls[0].y -= 32; ptls[1].y -= 32;
        GpiWCBitBlt(hps, piOver.hbmPointer, 4, ptls, ROP_SRCAND, BBO_IGNORE);
        // apply the overlying XOR mask to the underlying XOR mask
        ptls[2].y -= 32; ptls[3].y -= 32;
        GpiWCBitBlt(hps, piOver.hbmPointer, 4, ptls, ROP_SRCINVERT, BBO_IGNORE);
        // create the new pointer
        GpiSetBitmap(hps, 0);
        hptr = WinCreatePointer(HWND_DESKTOP, hbm, TRUE,
                                piOver.xHotspot, piOver.yHotspot);
        qt_free_ps_with_bitmap(hps, hbm);
    }

    Q_ASSERT(hptr);
    return hptr;
}
// ------------------------------------------------------------------------------------------------------------
MRESULT EXPENTRY ClientWinProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
  BOOL                fOK;
  RECTL               rectl;
  SIZEL               sizel;
  HPS                 hps;

  switch( msg ) {
  case WM_CLOSE:
    globals.fCloseMsgSent = TRUE;
    WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, 0, 0 );
    WinPostMsg( globals.hwndObject, WM_QUIT, 0, 0 );
    return 0;
  case WM_COMMAND:
    switch( SHORT1FROMMP( mp1 )) {
    case ID_RUN:
      WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, 0, 0 );
      WinInvalidateRect( hwnd, NULL, FALSE );
      WinPostMsg( globals.hwndObject, WM_USER_START_REXX, (MPARAM)hwnd, 0 );
      break;
    }
    return 0;
  case WM_CREATE:
    // disable client window until application initializes
    WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, 0, 0 );
    globals.hwndFrame    = WinQueryWindow( hwnd, QW_PARENT );
    globals.hwndTitlebar = WinWindowFromID( globals.hwndFrame, FID_TITLEBAR );
    globals.hwndMenubar  = WinWindowFromID( globals.hwndFrame, FID_MENU );
    // create title bar text; set into title bar
    sprintf( globals.szCaption, "%s - %s", CAPTION, globals.szRexxFileName );
    WinSetWindowText( globals.hwndTitlebar, globals.szCaption );
    // get window DC
    globals.hdcScreen = WinOpenWindowDC( hwnd );
    assert( globals.hdcScreen );
    // create a normal PS for the screen; coordinate system is 1/100 inch per unit of measure
    sizel.cx = sizel.cy = 0;
    globals.hpsScreen = GpiCreatePS( globals.hab, globals.hdcScreen, &sizel, PU_LOENGLISH | GPIF_LONG | GPIT_NORMAL | GPIA_ASSOC );
    assert( globals.hpsScreen );
    // object window operates on thread 2
    globals.tidObject = _beginthread( threadmain, NULL, LEN_STACK, NULL );
    assert( globals.tidObject );
    return 0;
  case WM_MOUSEMOVE:
    WinSetPointer( HWND_DESKTOP, WinQuerySysPointer( HWND_DESKTOP, globals.fBusy ? SPTR_WAIT:SPTR_ARROW, FALSE ));
    return (MRESULT)1;
  case WM_PAINT:
    hps = WinBeginPaint( hwnd, globals.hpsScreen, &rectl );
    fOK = WinFillRect( hps, &rectl, SYSCLR_WINDOW );
    assert( fOK );
    if( !globals.fBusy ) {
      // playback the retained GPI drawing orders
      GpiDrawChain( globals.hpsScreen );
    }
    WinEndPaint( hps );
    return 0;
  case WM_USER_ACK:
    // object window has posted ack; re-enable the window
    WinSendMsg( hwnd, WM_USER_ENABLE_CLIENT, 0, 0 );
    return 0;
  case WM_USER_DISABLE_CLIENT:
    globals.fBusy = TRUE;
    WinEnableWindow( globals.hwndClient, FALSE );
    WinEnableMenuItem( globals.hwndMenubar, ID_RUN, FALSE );
    return 0;
  case WM_USER_ENABLE_CLIENT:
    globals.fBusy = FALSE;
    WinEnableWindow( globals.hwndClient, TRUE );
    WinEnableMenuItem( globals.hwndMenubar, ID_RUN, TRUE );
    return 0;
  }
  return WinDefWindowProc( hwnd, msg, mp1, mp2 );
}
Esempio n. 12
0
static MRESULT APIENTRY Char ( HWND Window, MESG, MPARAM1 mp1, MPARAM2 mp2 ) {

 /***************************************************************************
  * Find the instance data.                                                 *
  ***************************************************************************/

  PDATA Data = PDATA ( Sys_GetWindowData ( Window ) ) ;

 /***************************************************************************
  * Get the message data.                                                   *
  ***************************************************************************/

  USHORT Flags    = (USHORT) SHORT1FROMMP ( mp1 ) ;
//UCHAR  Repeat   = (UCHAR)   CHAR3FROMMP ( mp1 ) ;
//UCHAR  ScanCode = (UCHAR)   CHAR4FROMMP ( mp1 ) ;

//USHORT Char     = (USHORT) SHORT1FROMMP ( mp2 ) ;
  USHORT VKey     = (USHORT) SHORT2FROMMP ( mp2 ) ;

 /***************************************************************************
  * Ignore keys being released, invalid characters, dead keys and           *
  *   invalid composite characters.                                         *
  ***************************************************************************/

  if ( ( Flags & KC_KEYUP )
    OR ( Flags & KC_INVALIDCHAR )
    OR ( Flags & KC_DEADKEY )
    OR ( Flags & KC_INVALIDCOMP ) )
  {
    Sys_BeepNote ( ) ;
    return ( MRFROMSHORT ( FALSE ) ) ;
  }

 /***************************************************************************
  * Intercept the ESC virtual key to abort margin set mode.                 *
  ***************************************************************************/

  if ( Flags & KC_VIRTUALKEY ) {

    switch ( VKey ) {

      case VK_ESC: {

        if ( Data->Capture ) {

          Data->Capture = FALSE ;
          Sys_ReleaseCapture ( ) ;

          HPOINTER Ptr = WinQuerySysPointer ( HWND_DESKTOP, SPTR_ARROW, FALSE ) ;
          WinSetPointer ( HWND_DESKTOP, Ptr ) ;

          Sys_SetFocus ( Data->HadFocus ) ;

          WorkSpace PS ( "HRuler::Char", 0, Window, Data->pDevice, int(Data->Metric) ) ;
          PS.SetTransform ( Data->fxZoom, int(Data->TopLeft), 0 ) ;

          RECTL Rectangle ;
          WinQueryWindowRect ( Window, &Rectangle ) ;
          PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, Rectangle ) ;

          POINTL ButtonSize = { 8, 8 } ;
          PS.Transform ( CVTC_DEVICE, CVTC_PAGE, 1, &ButtonSize ) ;

          PS.SetMix ( FM_INVERT ) ;
          PS.SetLineType ( LINETYPE_ALTERNATE ) ;
          POINTL Point = { Data->Tick, Rectangle.yBottom } ;
          PS.Move ( Point ) ;
          Point.y = Rectangle.yTop ;
          PS.DrawLine ( Point ) ;

          Data->Mode = NOTMOVING ;
        }

        break ;
      }
    }
  }

 /***************************************************************************
  * Return.                                                                 *
  ***************************************************************************/

  return ( MRFROMSHORT ( TRUE ) ) ;
}
Esempio n. 13
0
BOOL APIENTRY InstallPager(INSTALL *pstInst)
  {
  int iIndex;
  int iCountPos;
  int iDestPathEnd;
  int iSourcePathEnd;
  APIRET rc;
  BOOL bSuccess = TRUE;
  HPOINTER hPointer;
//  int iLen;
  int iFileCount;
  int iObjectCount;
  int iEnd;
  HOBJECT hObject;
  HOBJECT *phObject;
  BOOL bObjectBad;
  unsigned int uiAttrib;
  ULONG ulFileCount;
  ULONG cbDataSize = sizeof(ULONG);
  HINI hInstalledProfile;
  HINI hSourceProfile;

  hSourceProfile = PrfOpenProfile(pstInst->hab,pstInst->pszSourceIniPath);
  iEnd = sprintf(szFileNumber,"File_");
  strcpy(szDestSpec,pstInst->pszAppsPath);
  iDestPathEnd = strlen(szDestSpec);
  szDestSpec[iDestPathEnd++] = '\\';
  szDestSpec[iDestPathEnd] = 0;
  hPointer = WinQuerySysPointer(HWND_DESKTOP,SPTR_WAIT,FALSE);
  WinSetPointer(HWND_DESKTOP,hPointer);

  strcpy(szSourceSpec,pstInst->pszSourcePath);
  iSourcePathEnd = strlen(szSourceSpec);
  szSourceSpec[iSourcePathEnd++] = '\\';

  szPagerEXEname[0] = 0;
  szInstallEXEname[0] = 0;

  sprintf(szInstalledIniPath,"%s%s",szDestSpec,pstInst->paszStrings[UNINSTALLINIFILENAME]);
  if (!MakePath(pstInst->hwndFrame,pstInst->pszAppsPath))
   return(FALSE);
  hInstalledProfile = PrfOpenProfile(pstInst->hab,szInstalledIniPath);
  cbDataSize = sizeof(ULONG);
  if (!PrfQueryProfileData(hInstalledProfile,"Installed","Files",&iFileCount,&cbDataSize))
    iFileCount = 0;
  if (!PrfQueryProfileData(hInstalledProfile,"Installed","Objects",&iObjectCount,&cbDataSize))
    iObjectCount = 0;
  sprintf(szPath,"%c:\\DELLOCKS.CMD",pstInst->chBootDrive);
  DosForceDelete(szPath);
  if (pstInst->bCopyCOMi)
    {
    strcpy(szDestSpec,pstInst->pszAppsPath);
    iDestPathEnd = strlen(szDestSpec);
    szDestSpec[iDestPathEnd++] = '\\';
    szDestSpec[iDestPathEnd] = 0;
    sprintf(pstInst->paszStrings[DRIVERINISPEC],"%s\\%s",pstInst->pszAppsPath,pstInst->paszStrings[DDNAME]);
    if (strlen(pstInst->paszStrings[CURRENTDRIVERSPEC]) != 0)
      {
      if (strcmp(pstInst->paszStrings[CURRENTDRIVERSPEC],pstInst->paszStrings[DRIVERINISPEC]) != 0)
        {
        strcpy(szPath,pstInst->paszStrings[DDNAME]);
        AppendINI(szPath);
        sprintf(szFileName,"Existing %s",szPath);
        if (pstInst->paszStrings[REMOVEOLDDRIVERSPEC] != NULL)
          strcpy(pstInst->paszStrings[REMOVEOLDDRIVERSPEC],pstInst->paszStrings[CURRENTDRIVERSPEC]);
        AppendINI(pstInst->paszStrings[DRIVERINISPEC]);
        AppendINI(pstInst->paszStrings[CURRENTDRIVERSPEC]);
        pstInst->pfnPrintProgress(szFileName,pstInst->paszStrings[DRIVERINISPEC]);
        if (pstInst->bSavedDriverIniFile)
          {
          sprintf(pstInst->paszStrings[CURRENTDRIVERSPEC],"%c:\\COMDDINI.OLD",pstInst->chBootDrive);
          DosCopy(pstInst->paszStrings[CURRENTDRIVERSPEC],pstInst->paszStrings[DRIVERINISPEC],DCPY_EXISTING);
          pstInst->bSavedDriverIniFile = FALSE;
          if (pstInst->fCurrentIni != UNINSTALL_SAVE_INI)
            DosDelete(pstInst->paszStrings[CURRENTDRIVERSPEC]);
          }
        else
          if (DosCopy(pstInst->paszStrings[CURRENTDRIVERSPEC],pstInst->paszStrings[DRIVERINISPEC],DCPY_EXISTING) != NO_ERROR)
            {
            sprintf(pstInst->paszStrings[CURRENTDRIVERSPEC],"%c:\\COMDDINI.OLD",pstInst->chBootDrive);
            DosCopy(pstInst->paszStrings[CURRENTDRIVERSPEC],pstInst->paszStrings[DRIVERINISPEC],DCPY_EXISTING);
            DosForceDelete(pstInst->paszStrings[CURRENTDRIVERSPEC]);
            }
        }
      else
        {
        rc = DosQueryPathInfo(pstInst->paszStrings[CURRENTDRIVERSPEC],1,&stFileStatus,sizeof(FILESTATUS3));
        if ((rc == ERROR_PATH_NOT_FOUND) || (rc == ERROR_FILE_NOT_FOUND))
          {
          sprintf(pstInst->paszStrings[CURRENTDRIVERSPEC],"%c:\\COMDDINI.OLD",pstInst->chBootDrive);
          DosCopy(pstInst->paszStrings[CURRENTDRIVERSPEC],pstInst->paszStrings[DRIVERINISPEC],DCPY_EXISTING);
          DosForceDelete(pstInst->paszStrings[CURRENTDRIVERSPEC]);
          }
        }
      }
    else
      {
      AppendINI(pstInst->paszStrings[DRIVERINISPEC]);
      rc = DosQueryPathInfo(pstInst->paszStrings[DRIVERINISPEC],1,&stFileStatus,sizeof(FILESTATUS3));
      if ((rc == ERROR_PATH_NOT_FOUND) || (rc == ERROR_FILE_NOT_FOUND))
        {
        sprintf(szPath,"%c:\\COMDDINI.OLD",pstInst->chBootDrive);
        DosCopy(szPath,pstInst->paszStrings[DRIVERINISPEC],DCPY_EXISTING);
        DosForceDelete(szPath);
        }
      }
    AppendINI(pstInst->paszStrings[DRIVERINISPEC]);
    sprintf(&szDestSpec[iDestPathEnd],"%s",pstInst->paszStrings[DDNAME]);
    sprintf(&szSourceSpec[iSourcePathEnd],"%s",pstInst->paszStrings[DDNAME]);
    pstInst->pfnPrintProgress(pstInst->paszStrings[DDNAME],szDestSpec);
    if ((rc = DosCopy(szSourceSpec,szDestSpec,DCPY_EXISTING)) != NO_ERROR)
      {
      bSuccess = FALSE;
      if (!DisplayCopyError(pstInst->paszStrings[DDNAME],szDestSpec,rc))
        goto gtFreePathMem;
      }
    ClearReadOnly(szDestSpec);
    itoa(++iFileCount,&szFileNumber[iEnd],10);
    PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec);
    AppendINI(szSourceSpec);
    if (DosQueryPathInfo(szSourceSpec,FIL_STANDARD,&stFileStatus,sizeof(FILESTATUS3)) == NO_ERROR)
      {
      AppendINI(szDestSpec);
      strcpy(szPath,pstInst->paszStrings[DDNAME]);
      AppendINI(szPath);
      pstInst->pfnPrintProgress(szPath,szDestSpec);
      DosCopy(szSourceSpec,szDestSpec,DCPY_EXISTING);
      ClearReadOnly(szDestSpec);
      itoa(++iFileCount,&szFileNumber[iEnd],10);
      PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec);
      }
    strcpy(szFileKey,"File_");
    iCountPos = strlen(szFileKey);
    ulFileCount = 0;
    PrfQueryProfileData(hSourceProfile,"COMi","Files",&ulFileCount,&cbDataSize);
    for (iIndex = 1;iIndex <= ulFileCount;iIndex++)
      {
      itoa(iIndex,&szFileKey[iCountPos],10);
      if (PrfQueryProfileString(hSourceProfile,"COMi",szFileKey,0,szFileName,18) != 0)
        {
        if (iIndex == 1)
          strcpy(szCOMiINFname,szFileName);
        strcpy(&szDestSpec[iDestPathEnd],szFileName);
        strcpy(&szSourceSpec[iSourcePathEnd],szFileName);
        pstInst->pfnPrintProgress(szFileName,szDestSpec);
        if ((rc = DosCopy(szSourceSpec,szDestSpec,DCPY_EXISTING)) != NO_ERROR)
          {
          bSuccess = FALSE;
          if (!DisplayCopyError(szFileName,szDestSpec,rc))
            goto gtFreePathMem;
          }
        ClearReadOnly(szDestSpec);
        itoa(++iFileCount,&szFileNumber[iEnd],10);
        PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec);
        }
      }
    MenuItemEnable(pstInst->hwndFrame,IDM_SETUP,TRUE);
    /*
    ** This entry must be placed here so the the Configuration DLL can "find" the
    ** COMi initialization file, before the device driver is actually loaded.
    */
    PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGDDNAME],"Initialization",pstInst->paszStrings[DRIVERINISPEC]);
    PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGDDNAME],"Version",pstInst->paszStrings[COMIVERSION]);
    }
  if (pstInst->bCopyPager)
    {
    bCopyLibraries = TRUE;
    szPagerEXEname[0] = 0;
    strcpy(szDestSpec,pstInst->pszAppsPath);
    iDestPathEnd = strlen(szDestSpec);
    szDestSpec[iDestPathEnd++] = '\\';
    szDestSpec[iDestPathEnd] = 0;
    strcpy(szFileKey,"File_");
    iCountPos = strlen(szFileKey);
    ulFileCount = 0;
    PrfQueryProfileData(hSourceProfile,"Pager","Files",&ulFileCount,&cbDataSize);
    for (iIndex = 1;iIndex <= ulFileCount;iIndex++)
      {
      itoa(iIndex,&szFileKey[iCountPos],10);
      if (PrfQueryProfileString(hSourceProfile,"Pager",szFileKey,0,szFileName,18) != 0)
        {
        if (iIndex == 1)
          strcpy(szPagerEXEname,szFileName);
        strcpy(&szDestSpec[iDestPathEnd],szFileName);
        strcpy(&szSourceSpec[iSourcePathEnd],szFileName);
        pstInst->pfnPrintProgress(szFileName,szDestSpec);
        if (!CopyFile(szSourceSpec,szDestSpec))
          {
          bSuccess = FALSE;
          if (!DisplayCopyError(szFileName,szDestSpec,rc))
            goto gtFreePathMem;
          }
        itoa(++iFileCount,&szFileNumber[iEnd],10);
        PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec);
        }
      }
    PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGAPPNAME],"Version",pstInst->paszStrings[APPVERSION]);
    }
  if (pstInst->bCopyUtil)
    {
    strcpy(szDestSpec,pstInst->pszAppsPath);
    iDestPathEnd = strlen(szDestSpec);
    szDestSpec[iDestPathEnd++] = '\\';
    szDestSpec[iDestPathEnd] = 0;
    strcpy(szFileKey,"File_");
    iCountPos = strlen(szFileKey);
    ulFileCount = 0;
    PrfQueryProfileData(hSourceProfile,"Utilities","Files",&ulFileCount,&cbDataSize);
    for (iIndex = 1;iIndex <= ulFileCount;iIndex++)
      {
      itoa(iIndex,&szFileKey[iCountPos],10);
      if (PrfQueryProfileString(hSourceProfile,"Utilities",szFileKey,0,szFileName,18) != 0)
        {
        strcpy(&szDestSpec[iDestPathEnd],szFileName);
        strcpy(&szSourceSpec[iSourcePathEnd],szFileName);
        pstInst->pfnPrintProgress(szFileName,szDestSpec);
        if ((rc = DosCopy(szSourceSpec,szDestSpec,DCPY_EXISTING)) != NO_ERROR)
          {
          bSuccess = FALSE;
          if (!DisplayCopyError(szFileName,szDestSpec,rc))
            goto gtFreePathMem;
          }
        ClearReadOnly(szDestSpec);
        itoa(++iFileCount,&szFileNumber[iEnd],10);
        PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec);
        }
      }
    }
  if (pstInst->bCopyInstall)
    {
    bCopyLibraries = TRUE;
    szInstallEXEname[0] = 0;
    strcpy(szDestSpec,pstInst->pszAppsPath);
    iDestPathEnd = strlen(szDestSpec);
    szDestSpec[iDestPathEnd++] = '\\';
    szDestSpec[iDestPathEnd] = 0;
    sprintf(&szDestSpec[iDestPathEnd],pstInst->paszStrings[INIFILENAME]);
    strcpy(&szSourceSpec[iSourcePathEnd],pstInst->paszStrings[INIFILENAME]);
    PrfCloseProfile(hSourceProfile);
    DosCopy(szSourceSpec,szDestSpec,DCPY_EXISTING);
    ClearReadOnly(szDestSpec);
    hSourceProfile = PrfOpenProfile(pstInst->hab,pstInst->pszSourceIniPath);
    itoa(++iFileCount,&szFileNumber[iEnd],10);
    PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec);
    strcpy(szFileKey,"File_");
    iCountPos = strlen(szFileKey);
    ulFileCount = 0;
    PrfQueryProfileData(hSourceProfile,"Install","Files",&ulFileCount,&cbDataSize);
    for (iIndex = 1;iIndex <= ulFileCount;iIndex++)
      {
      itoa(iIndex,&szFileKey[iCountPos],10);
      if (PrfQueryProfileString(hSourceProfile,"Install",szFileKey,0,szFileName,18) != 0)
        {
        if (iIndex == 1)
          strcpy(szInstallEXEname,szFileName);
        strcpy(&szDestSpec[iDestPathEnd],szFileName);
        strcpy(&szSourceSpec[iSourcePathEnd],szFileName);
        pstInst->pfnPrintProgress(szFileName,szDestSpec);
        if (!CopyFile(szSourceSpec,szDestSpec))
          {
//          bSuccess = FALSE;
          if (!DisplayCopyError(szFileName,szDestSpec,rc))
            goto gtFreePathMem;
          }
        itoa(++iFileCount,&szFileNumber[iEnd],10);
        PrfWriteProfileString(hInstalledProfile,"Installed",szFileNumber,szDestSpec);
        }
      }
    }
  PrfWriteProfileString(hInstalledProfile,"Installed","Program Path",pstInst->pszAppsPath);
  PrfWriteProfileData(hInstalledProfile,"Installed","Files",&iFileCount,sizeof(int));
  if (strlen(pstInst->paszStrings[CONFIGDDLIBRARYNAME]) != 0)
    {
    sprintf(pstInst->paszStrings[CONFIGAPPLIBRARYSPEC],"%s\\%s",pstInst->pszAppsPath,pstInst->paszStrings[CONFIGDDLIBRARYNAME]);
    PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGDDNAME],"Configuration",pstInst->paszStrings[CONFIGAPPLIBRARYSPEC]);
    }
  if (strlen(pstInst->paszStrings[CONFIGDDHELPFILENAME]) != 0)
    {
    sprintf(szPath,"%s\\%s",pstInst->pszAppsPath,pstInst->paszStrings[CONFIGDDHELPFILENAME]);
    PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGDDNAME],"Help",szPath);
    }
  if (strlen(pstInst->paszStrings[CONFIGAPPLIBRARYNAME]) != 0)
    {
    sprintf(pstInst->paszStrings[CONFIGAPPLIBRARYSPEC],"%s\\%s",pstInst->pszAppsPath,pstInst->paszStrings[CONFIGAPPLIBRARYNAME]);
    PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGAPPNAME],"Configuration",pstInst->paszStrings[CONFIGAPPLIBRARYSPEC]);
    }
  if (strlen(pstInst->paszStrings[CONFIGAPPHELPFILENAME]) != 0)
    {
    sprintf(szPath,"%s\\%s",pstInst->pszAppsPath,pstInst->paszStrings[CONFIGAPPHELPFILENAME]);
    PrfWriteProfileString(HINI_USERPROFILE,pstInst->paszStrings[CONFIGAPPNAME],"Help",szPath);
    }
  pstInst->bFilesCopied = TRUE;
  MenuItemEnable(pstInst->hwndFrame,IDM_SETUP,TRUE);

  if (pstInst->bCreateObjects)
    {
    bObjectBad = FALSE;
    strcpy(szFileNumber,"Object_");
    iEnd = strlen(szFileNumber);
    hObject = WinCreateObject("WPFolder",szFolderName,szFolderSetup,"<WP_DESKTOP>",CO_UPDATEIFEXISTS);
    if (hObject == 0)
      {
      sprintf(&szFolderName[strlen(szFolderName)],":1");
      hObject = WinCreateObject("WPFolder",szFolderName,szFolderSetup,"<WP_DESKTOP>",CO_UPDATEIFEXISTS);
      }
    if (hObject != 0)
      {
      itoa(++iObjectCount,&szFileNumber[iEnd],10);
      PrfWriteProfileData(hInstalledProfile,"Installed",szFileNumber,&hObject,sizeof(HOBJECT));
      szDestSpec[iDestPathEnd - 1] = 0;
      sprintf(szPath,"<%s>",szFolderName);
      strcpy(szFolderName,szPath);
      if (szCOMiINFname[0] != 0)
        {
        sprintf(szSetupString,"%sEXENAME=VIEW.EXE;PARAMETERS=%s\\%s",szINFobjectSetup,szDestSpec,pstInst->paszStrings[CONFIGDDNAME]);
        sprintf(szObjectName,"%s Users Guide",pstInst->paszStrings[CONFIGDDNAME]);
        hObject = WinCreateObject("WPProgram",szObjectName,szSetupString,szFolderID,CO_UPDATEIFEXISTS);
        if (hObject != 0)
          {
          itoa(++iObjectCount,&szFileNumber[iEnd],10);
          PrfWriteProfileData(hInstalledProfile,"Installed",szFileNumber,&hObject,sizeof(HOBJECT));
          }
        else
          bObjectBad = TRUE;
        }
      if (szPagerEXEname[0] != 0)
        {
        iEnd = sprintf(szSetupString,"%sEXENAME=%s\\%s;STARTUPDIR=%s;ASSOCFILTER=*.PAG;PARAMETERS=% /MSG:\"[Message: ]\" /CFG:\"%*\"",szProgramObjectSetup,szDestSpec,szPagerEXEname,szDestSpec);
        if (strlen(pstInst->paszStrings[APPICONFILE]) != 0)
          sprintf(&szSetupString[iEnd],";ICON=%s\\%s",pstInst->pszAppsPath,pstInst->paszStrings[APPICONFILE]);
        strcat(szObjectName,"Drop");
        hObject = WinCreateObject("WPProgram",szObjectName,szSetupString,szFolderID,CO_UPDATEIFEXISTS);
        if (hObject != 0)
          {
          itoa(++iObjectCount,&szFileNumber[iEnd],10);
          PrfWriteProfileData(hInstalledProfile,"Installed",szFileNumber,&hObject,sizeof(HOBJECT));
          }
        else
          bObjectBad = TRUE;
        }
      if (szInstallEXEname[0] != 0)
        {
        sprintf(szSetupString,"%sEXENAME=%s\\%s;STARTUPDIR=%s",szProgramObjectSetup,szDestSpec,szInstallEXEname,szDestSpec);
        hObject = WinCreateObject("WPProgram","OS/tools Install",szSetupString,szFolderID,CO_UPDATEIFEXISTS);
        if (hObject != 0)
          {
          itoa(++iObjectCount,&szFileNumber[iEnd],10);
          PrfWriteProfileData(hInstalledProfile,"Installed",szFileNumber,&hObject,sizeof(HOBJECT));
          }
        else
          bObjectBad = TRUE;
        }
      PrfWriteProfileData(hInstalledProfile,"Installed","Objects",&iObjectCount,sizeof(int));
      }
    }
  if (bObjectBad || (hObject == 0))
    {
    sprintf(szMessage,"At least one desktop object was not created due to an unknown system error.");
    sprintf(szCaption,"Object(s) Not Created!");
    WinMessageBox(HWND_DESKTOP,
                  HWND_DESKTOP,
                  szMessage,
                  szCaption,
                  0,
                 (MB_MOVEABLE | MB_OK));
    }
gtFreePathMem:
  PrfCloseProfile(hInstalledProfile);
  PrfCloseProfile(hSourceProfile);
  return(bSuccess);
  }
Esempio n. 14
0
unsigned int CallDosDebug( dos_debug __far *buff )
{
    QMSG        qmsg;
    int         num_paints;
    int         i;
    struct {
        RECTL   rcl;
        HWND    hwnd;
    }           paints[MAX_PAINTS];
    HPS         ps;
    char        class_name[80];
    TID         tid;

    if( !IsPMDebugger() ) {
        return( Call32BitDosDebug( buff ) );
    }

    switch( buff->Cmd ) {
    case DBG_C_ClearWatch:
    case DBG_C_Freeze:
    case DBG_C_LinToSel:
    case DBG_C_NumToAddr:
    case DBG_C_ReadCoRegs:
    case DBG_C_ReadMemBuf:
    case DBG_C_ReadMem_D:
    case DBG_C_ReadReg:
    case DBG_C_SelToLin:
    case DBG_C_SetWatch:
    case DBG_C_ThrdStat:
    case DBG_C_WriteCoRegs:
    case DBG_C_WriteMemBuf:
    case DBG_C_WriteMem_D:
    case DBG_C_WriteReg:
        return( Call32BitDosDebug( buff ) );
    }
    switch( buff->Cmd ) {
    case DBG_C_Go:
    case DBG_C_SStep:
    case DBG_C_Term:
        ReleaseQueue( buff->Pid, buff->Tid );
    }
    DebugReqBuff = buff;
    StopBuff = *buff;
    DosSemSet( &DebugDoneSem );
    DosSemClear( &DebugReqSem );
    num_paints = 0;
    if( IsPMDebugger() ) {
        while( WinGetMsg( HabDebugger, &qmsg, 0L, 0, 0 ) || InDosDebug ) {
            WinQueryClassName( qmsg.hwnd, MAX_CLASS_NAME, class_name );
            switch( qmsg.msg ) {
            case WM_CHAR:
                if( ( SHORT1FROMMP( qmsg.mp1 ) & KC_VIRTUALKEY ) &&
                    ( SHORT2FROMMP( qmsg.mp2 ) == VK_BREAK ) ) {
                    SetBrkPending();
                    DosCreateThread( StopApplication, &tid, stack2 + STACK_SIZE );
                    DosSetPrty( PRTYS_THREAD, PRTYC_TIMECRITICAL, 10, tid );
                    WakeThreads( StopBuff.Pid );
                    DosSemWait( &StopDoneSem, SEM_INDEFINITE_WAIT );
                    DosSemSet( &StopDoneSem );
                }
                break;
            case WM_COMMAND:
                CantDoIt();
                break;
            default:
                if( strcmp( class_name, "GUIClass" ) == 0 ||
                    strcmp( class_name, "WTool" ) == 0 ) {
                    switch( qmsg.msg ) {
                    case WM_PAINT:
                        if( num_paints >= MAX_PAINTS ) --num_paints;
                        paints[num_paints].hwnd = qmsg.hwnd;
                        ps = WinBeginPaint( qmsg.hwnd, 0, &paints[ num_paints ].rcl );
                        GpiErase( ps );
                        WinEndPaint( ps );
                        num_paints++;
                        break;
                    case WM_BUTTON1DOWN:
                    case WM_BUTTON2DOWN:
                    case WM_BUTTON3DOWN:
                        CantDoIt();
                        break;
                    case WM_MOUSEMOVE:
                    {
                        HPOINTER hourglass = WinQuerySysPointer( HWND_DESKTOP, SPTR_WAIT, FALSE );
                        if( WinQueryPointer( HWND_DESKTOP ) != hourglass ) {
                            WinSetPointer( HWND_DESKTOP, hourglass );
                        }
                        break;
                    }
                    default:
                        WinDefWindowProc( qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2 );
                    }
                } else {
                    WinDispatchMsg( HabDebugger, &qmsg );
                }
            }
        }
    } else {
        DosSemWait( &DebugDoneSem, SEM_INDEFINITE_WAIT );
    }
    switch( buff->Cmd ) {
    case DBG_N_Exception:
    case DBG_N_AsyncStop:
    case DBG_N_Watchpoint:
        AssumeQueue( buff->Pid, buff->Tid );
        break;
    }
    for( i = 0; i < num_paints; ++i ) {
        WinInvalidateRect( paints[i].hwnd, &paints[i].rcl, FALSE );
    }
    return( DebugReqResult );
}
Esempio n. 15
0
void FAR wndThread(void FAR *pData)
{
  PGROPDATA  pGrop = (PGROPDATA)pData;
  PTIB       tib;
  PPIB       pib;
  ULONG      ulFrameFlags;
  QMSG       qmsg;
  SWP        swp;
  PVIDEOSYS  pVideoSys = aVideoSys[pGrop->ulVideoSysIdx];

  // Change process type code for use Win* API from VIO session 
  DosGetInfoBlocks( &tib, &pib );
  if ( pib->pib_ultype == 2 || pib->pib_ultype == 0 )
  {
    // VIO windowable or fullscreen protect-mode session.
    pib->pib_ultype = 3; // Presentation Manager protect-mode session.
    // ...and switch to the desktop (if we are in fullscreen now)?
  }

  // Select output video system.
  if ( (pGrop->ulVideoSysIdx < VIDEOSYSNUM) &&
       pVideoSys->fnInit( &pGrop->stModes, &pGrop->pVSData ) )
  {
    debug( "Requested video system %u initialized.", pGrop->ulVideoSysIdx );
    pGrop->pVideoSys = pVideoSys;
  }
  else
  {
    ULONG      ulIdx;

    debug( "Requested video system was not initialized. Try others..." );
    pGrop->pVideoSys = NULL;
    for( ulIdx = 0; ulIdx < VIDEOSYSNUM; ulIdx++ )
    {
      if ( pGrop->ulVideoSysIdx == ulIdx )
        // Ignore video system requested by the user (already verifed).
        continue;

      pVideoSys = aVideoSys[ulIdx];
      if ( pVideoSys->fnInit( &pGrop->stModes, &pGrop->pVSData ) )
      {
        debug( "Video system %u initialized.", ulIdx );
        pGrop->pVideoSys = pVideoSys;
        pGrop->ulVideoSysIdx = ulIdx;
        break;
      }
    }
  } // if ( (pGrop->ulVideoSysIdx < VIDEOSYSNUM) && pVideoSys->fnInit() ) else

  if ( pGrop->pVideoSys == NULL )
  {
    debug( "Video system is not initialized." );
  }
  else
  {
    // Output video system selected.

    // Prepare PM stuff.
    pGrop->hab = WinInitialize( 0 );
    pGrop->hmq = WinCreateMsgQueue( pGrop->hab, 0 );
    pGrop->hwndDT = WinQueryDesktopWindow(
                      WinQueryAnchorBlock( HWND_DESKTOP ), 0 );
    pGrop->hdcDT = WinQueryWindowDC( pGrop->hwndDT );
    WinQueryWindowPos( pGrop->hwndDT, &swp );
    pGrop->ulDTWidth = swp.cx;
    pGrop->ulDTHeight = swp.cy;
    pGrop->ulModeIdx = ~0; // ~0 - Mode is not selected yet.
    pGrop->hptrPointer = WinQuerySysPointer( HWND_DESKTOP, SPTR_ARROW, FALSE );

    WinRegisterClass( pGrop->hab, WIN_CLIENT_CLASS, wndProc,
                      CS_SIZEREDRAW | CS_MOVENOTIFY | CS_SYNCPAINT,
                      sizeof(PGROPDATA) );

    // Create the window.
    ulFrameFlags = FCF_TASKLIST | FCF_DLGBORDER | FCF_TITLEBAR |
                   FCF_SYSMENU | FCF_MINBUTTON | FCF_SHELLPOSITION |
                   FCF_SIZEBORDER | FCF_MINBUTTON | FCF_MAXBUTTON;
    pGrop->hwndFrame = WinCreateStdWindow( HWND_DESKTOP, 0, &ulFrameFlags,
                           WIN_CLIENT_CLASS, "grop", 0, 0, 1, &pGrop->hwnd );
    if ( pGrop->hwndFrame == NULLHANDLE )
    {
      debug( "WinCreateStdWindow() failed" );
    }
    else
    {
      WinSetWindowULong( pGrop->hwnd, 0, (ULONG)pGrop );
      // Subclass frame window to control size changes.
      pGrop->fnOldFrameWinProc = WinSubclassWindow( pGrop->hwndFrame,
                                                    wndFrameProc );
      WinSetVisibleRegionNotify( pGrop->hwnd, TRUE );

      if ( DosCreateMutexSem( NULL, &pGrop->hmtxData, 0, FALSE ) != NO_ERROR )
        debug( "DosCreateMutexSem() failed" );
      else
      {
        ULONG          ulRC;

        ulRC = DosSetPriority( PRTYS_THREAD, PRTYC_TIMECRITICAL, 31, 0 );
        if ( ulRC != NO_ERROR )
          debug( "DosSetPriority(), rc = %u", ulRC );

        ulRC = DosPostEventSem( pGrop->hevReady );   // Ready to work.
        if ( ulRC != NO_ERROR )
          debug( "DosPostEventSem(), rc = %u", ulRC );

        while( TRUE )
        {
          // Work...
          while( WinGetMsg( pGrop->hab, &qmsg, (HWND)NULLHANDLE, 0L, 0L ) )
          {
            ulRC = DosRequestMutexSem( pGrop->hmtxData, 500 );
            if ( ulRC != NO_ERROR )
              debug( "DosRequestMutexSem(), rc = ", ulRC );

            WinDispatchMsg( pGrop->hab, &qmsg );
            DosReleaseMutexSem( pGrop->hmtxData );
          }

          if ( pGrop->stCallback.fnQuit == NULL )
            break;

          debug( "Call stCallback.fnQuit()" );
          pGrop->stCallback.fnQuit( pGrop );
        }

        // Return to the desktop if we are in fullscreen.
        debug( "Fullscreen: %u", pGrop->fFullscreen );
        if ( pGrop->fFullscreen )
        {
          PVIDEOMODE pMode = &pGrop->stModes.pList[pGrop->stModes.ulDesktopMode];

          debug( "Return to the desktop..." );
          pGrop->pVideoSys->fnSetMode( pGrop->pVSData, pMode, FALSE,
                                       pGrop->hwndDT, pGrop->hdcDT );
          debug( "Returned to the desktop" );
        }

        DosCloseMutexSem( pGrop->hmtxData );
      }

      debug( "Destroy window" );
      if ( !WinDestroyWindow( pGrop->hwnd ) )
        debug( "WinDestroyWindow() failed" );
      pGrop->hwnd = NULLHANDLE;
      pGrop->hwndFrame = NULLHANDLE;
    }

    // Destroy PM stuff.
    debug( "WinDestroyMsgQueue()..." );
    WinDestroyMsgQueue( pGrop->hmq );
    debug( "WinTerminate()..." );
    WinTerminate( pGrop->hab );
    pGrop->hwndFrame = NULLHANDLE;
    pGrop->hwnd = NULLHANDLE;

    // Destroy output video system.
    if ( pGrop->stUserMode.pBuffer != NULL )
    {
      debug( "Free video system's buffer" );
      pGrop->pVideoSys->fnVideoBufFree( pGrop->pVSData,
                                        pGrop->stUserMode.pBuffer );
      pGrop->stUserMode.pBuffer = NULL;
    }
    debug( "Close video system" );
    pGrop->pVideoSys->fnDone( pGrop->pVSData, &pGrop->stModes );
    pGrop->pVideoSys = NULL;
  } // if ( pGrop->pVideoSys == NULL ) else

  pGrop->tid = ((TID)(-1));
  debug( "Post semaphore..." );
  DosPostEventSem( pGrop->hevReady );      // Finalized.
  debug( "Exit thread." );
  _endthread();
}
Esempio n. 16
0
BOOL WsetWaitPtr(VOID) {
   HPOINTER hptr = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE);
   return (hptr? WinSetPointer(HWND_DESKTOP, hptr): FALSE);
}
Esempio n. 17
0
void QCursorData::update()
{
    if (!QCursorData::initialized)
        QCursorData::initialize();

    if (cshape == Qt::BitmapCursor) {
        QPixmap pm = pixmap;
        if (pm.isNull()) {
            Q_ASSERT(bm && bmm);
            pm = *bm;
            pm.setMask(*bmm);
        }
        hptr = QPixmap::toPmHPOINTER(QIcon(pm), true, hx, hy);
        Q_ASSERT(hptr);
        isSysPtr = false;
        return;
    }

    LONG id = 0;
    char const * const * xpm = 0;
    int xpm_hx = 0;
    int xpm_hy = 0;

    switch (cshape) { // map to OS/2 cursor
    case Qt::ArrowCursor:
        id = SPTR_ARROW;
        break;
    case Qt::UpArrowCursor:
        xpm = cursor_uparrow_xpm;
        xpm_hx = cursor_uparrow_x;
        xpm_hy = cursor_uparrow_y;
        break;
    case Qt::CrossCursor:
        xpm = cursor_cross_xpm;
        xpm_hx = cursor_cross_x;
        xpm_hy = cursor_cross_y;
	    break;
    case Qt::WaitCursor:
        id = SPTR_WAIT;
	    break;
    case Qt::IBeamCursor:
    	id = SPTR_TEXT;
    	break;
    case Qt::SizeVerCursor:
    	id = SPTR_SIZENS;
    	break;
    case Qt::SizeHorCursor:
    	id = SPTR_SIZEWE;
    	break;
    case Qt::SizeBDiagCursor:
    	id = SPTR_SIZENESW;
    	break;
    case Qt::SizeFDiagCursor:
    	id = SPTR_SIZENWSE;
    	break;
    case Qt::SizeAllCursor:
    	id = SPTR_MOVE;
    	break;
    case Qt::BlankCursor:
        xpm = cursor_blank_xpm;
        xpm_hx = cursor_blank_x;
        xpm_hy = cursor_blank_y;
        break;
    case Qt::SplitVCursor:
        xpm = cursor_vsplit_xpm;
        xpm_hx = cursor_vsplit_x;
        xpm_hy = cursor_vsplit_y;
        break;
    case Qt::SplitHCursor:
        xpm = cursor_hsplit_xpm;
        xpm_hx = cursor_hsplit_x;
        xpm_hy = cursor_hsplit_y;
        break;
    case Qt::PointingHandCursor:
        xpm = cursor_hand_xpm;
        xpm_hx = cursor_hand_x;
        xpm_hy = cursor_hand_y;
        break;
    case Qt::ForbiddenCursor:
    	id = SPTR_ILLEGAL;
    	break;
    case Qt::WhatsThisCursor:
        xpm = cursor_whatsthis_xpm;
        xpm_hx = cursor_whatsthis_x;
        xpm_hy = cursor_whatsthis_y;
        break;
    case Qt::BusyCursor:
        // we create a busy cursor below as a combination of the standard
        // arrow and wait cursors
        hptr = combineTwoCursors(SPTR_ARROW, SPTR_WAIT);
        isSysPtr = false;
        return;
    case Qt::OpenHandCursor:
        xpm = cursor_openhand_xpm;
        xpm_hx = cursor_openhand_x;
        xpm_hy = cursor_openhand_y;
        break;
    case Qt::ClosedHandCursor:
        xpm = cursor_closedhand_xpm;
        xpm_hx = cursor_closedhand_x;
        xpm_hy = cursor_closedhand_y;
        break;
    default:
        qWarning("QCursor::update: Invalid cursor shape %d", cshape);
        return;
    }

    if (!id) {
#ifndef QT_NO_IMAGEFORMAT_XPM
        QPixmap pm(xpm);
        hptr = QPixmap::toPmHPOINTER(QIcon(pm), true, xpm_hx, xpm_hy);
        Q_ASSERT(hptr);
        isSysPtr = false;
        return;
#else
        id = SPTR_ARROW;
#endif
    }

    Q_ASSERT(id);

    hptr = WinQuerySysPointer(HWND_DESKTOP, id, FALSE);
    Q_ASSERT(hptr);
    isSysPtr = true;
}
Esempio n. 18
0
_WCRTLINK int   __InitDefaultWin() {
//==================================

    ULONG       style;
    RECTL       rcl;
    HWND        menhdl;
    HWND        submenu;
    MENUITEM    *menudesc;
    MENUITEM    menus;
    SWP         swp;

    _ClassName = WatcomClass;

    _AnchorBlock = WinInitialize( 0 );
    if( _AnchorBlock == 0 ) return( 0 );
    hMessageQueue = WinCreateMsgQueue( _AnchorBlock, 0 );
    if( hMessageQueue == 0 ) return( 0 );
    if( !WinRegisterClass( _AnchorBlock, _ClassName, (PFNWP)_MainDriver,
                           CS_SIZEREDRAW, 0 ) ) {
        return( 0 );
    }

    _InitMainWindowData( 0 );

    style = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER | FCF_MINMAX |
            FCF_SHELLPOSITION | FCF_TASKLIST;
    _MainFrameWindow = WinCreateStdWindow( HWND_DESKTOP,
                        WS_VISIBLE | WS_CLIPCHILDREN,
                        &style, _ClassName, "", 0, NULL, 0, &ClientWindow );

    if( _MainFrameWindow == 0 ) return( 0 );
    WinSendMsg( _MainFrameWindow, WM_SETICON,
        MPFROMLONG( WinQuerySysPointer( HWND_DESKTOP, SPTR_APPICON, TRUE ) ), 0 );
    WinQueryWindowRect( _MainWindow, &rcl );
    WinSetWindowPos( _MainFrameWindow, HWND_TOP,
                rcl.xLeft,
                rcl.yBottom,
                rcl.xLeft - rcl.xRight,
                rcl.yTop - rcl.yBottom,
                SWP_SHOW | SWP_SIZE | SWP_MOVE | SWP_MAXIMIZE );

    _InitFunctionPointers();
    _MainWindow = ClientWindow;
    WinUpdateWindow( _MainWindow );

    menudesc = &menus;
    menhdl = WinCreateMenu( _MainFrameWindow, NULL );
    WinSetWindowBits( menhdl, QWL_STYLE, MS_ACTIONBAR, MS_ACTIONBAR );
    submenu = WinCreateMenu( menhdl, NULL );

    menudesc->afStyle = MIS_TEXT;
    menudesc->afAttribute = 0;
    menudesc->hwndSubMenu = NULL;
    menudesc->hItem = 0;

    menudesc->iPosition = 0;
    menudesc->id = DID_FILE_SAVE;
    if ( MIT_ERROR == (BOOL)WinSendMsg( submenu, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "Save As..." ) ) ) abort();
    menudesc->iPosition = 1;
    menudesc->id = DID_FILE_CLEAR;
    if ( MIT_ERROR == (BOOL)WinSendMsg( submenu, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "Set Lines Between Clears..." ) ) ) abort();
    menudesc->afStyle = MIS_SEPARATOR;
    menudesc->iPosition = 2;
    menudesc->id = 0;
    if ( MIT_ERROR == (BOOL)WinSendMsg( submenu, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "Exit" ) ) ) abort();
    menudesc->afStyle = MIS_TEXT;
    menudesc->iPosition = 3;
    menudesc->id = DID_FILE_EXIT;
    if ( MIT_ERROR == (BOOL)WinSendMsg( submenu, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "Exit" ) ) ) abort();
    menudesc->iPosition = 0;
    menudesc->id = DID_MAIN_FILE;
    menudesc->hwndSubMenu = submenu;
    menudesc->afStyle = MIS_TEXT | MIS_SUBMENU;
    if ( MIT_ERROR == (BOOL)WinSendMsg( menhdl, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "~File" ) ) ) abort();

    submenu = WinCreateMenu( menhdl, NULL );
    menudesc->afStyle = MIS_TEXT;
    menudesc->iPosition = 0;
    menudesc->id = DID_EDIT_CLEAR;
    menudesc->hwndSubMenu = NULL;
    if ( MIT_ERROR == (BOOL)WinSendMsg( submenu, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "Clear" ) ) ) abort();
    menudesc->iPosition = 1;
    menudesc->id = DID_EDIT_COPY;
    if ( MIT_ERROR == (BOOL)WinSendMsg( submenu, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "Copy" ) ) ) abort();
    menudesc->iPosition = 1;
    menudesc->id = DID_MAIN_EDIT;
    menudesc->hwndSubMenu = submenu;
    menudesc->afStyle = MIS_SUBMENU;
    if ( MIT_ERROR == (BOOL)WinSendMsg( menhdl, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "~Edit" ) ) ) abort();

    submenu = WinCreateMenu( menhdl, NULL );
    _SetWinMenuHandle( submenu );
    menudesc->iPosition = 2;
    menudesc->afAttribute = 0;
    menudesc->id = DID_MAIN_WIND;
    menudesc->hwndSubMenu = submenu;
    menudesc->afStyle = MIS_SUBMENU;
    if ( MIT_ERROR == (BOOL)WinSendMsg( menhdl, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "~Windows" ) ) ) abort();

    submenu = WinCreateMenu( menhdl, NULL );
    menudesc->afStyle = MIS_TEXT;
    menudesc->iPosition = 0;
    menudesc->id = DID_HELP_ABOUT;
    menudesc->hwndSubMenu = NULL;
    if ( MIT_ERROR == (BOOL)WinSendMsg( submenu, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "About" ) ) ) abort();
    menudesc->iPosition = 3;
    menudesc->id = DID_MAIN_HELP;
    menudesc->hwndSubMenu = submenu;
    menudesc->afStyle = MIS_SUBMENU;
    if ( MIT_ERROR == (BOOL)WinSendMsg( menhdl, ( ULONG )MM_INSERTITEM, MPFROMP( menudesc ), MPFROMP( "~Help" ) ) ) abort();

    WinSendMsg( _MainFrameWindow, ( ULONG )WM_UPDATEFRAME, 0, 0 );
    _NewWindow( "Standard IO", 0,1,2,-1 );
    WinUpdateWindow( _MainFrameWindow );
    WinQueryWindowPos( _MainWindow, &swp );
    swp.fl |= SWP_MAXIMIZE;
    WinSetWindowPos( _MainWindow, HWND_TOP, swp.x, swp.y, swp.cx, swp.cy, SWP_MAXIMIZE | SWP_ACTIVATE | SWP_MOVE | SWP_SHOW | SWP_SIZE );

    return( 1 );
}
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     {
     static HAB   hab ;
     static HWND  hwndMenu ;
     static INT   iCurrentRep = IDM_10 ;
     static INT   iStatus = STATUS_READY ;
     static LONG  lCalcRep, lRepAmts [] = { 10, 100, 1000, 10000, 100000 } ;
     static ULONG ulElapsedTime ;
     double       A ;
     LONG         lRep ;

     switch (msg)
          {
          case WM_CREATE:
               hab = WinQueryAnchorBlock (hwnd) ;

               hwndMenu = WinWindowFromID (
                               WinQueryWindow (hwnd, QW_PARENT),
                               FID_MENU) ;
               return 0 ;

          case WM_COMMAND:
               switch (COMMANDMSG(&msg)->cmd)
                    {
                    case IDM_10:
                    case IDM_100:
                    case IDM_1000:
                    case IDM_10000:
                    case IDM_100000:
                         WinCheckMenuItem (hwndMenu, iCurrentRep, FALSE) ;
                         iCurrentRep = COMMANDMSG(&msg)->cmd ;
                         WinCheckMenuItem (hwndMenu, iCurrentRep, TRUE) ;
                         return 0 ;

                    case IDM_START:
                         WinEnableMenuItem (hwndMenu, IDM_START, FALSE) ;
                         WinEnableMenuItem (hwndMenu, IDM_ABORT, TRUE) ;

                         iStatus = STATUS_WORKING ;
                         WinInvalidateRect (hwnd, NULL, FALSE) ;
                         WinUpdateWindow (hwnd) ;

                         WinSetPointer (HWND_DESKTOP,
                                   WinQuerySysPointer (HWND_DESKTOP,
                                                       SPTR_WAIT, FALSE)) ;

                         if (WinQuerySysValue (HWND_DESKTOP, SV_MOUSEPRESENT)
                                   == 0)
                              WinShowPointer (HWND_DESKTOP, TRUE) ;

                         lCalcRep = lRepAmts [iCurrentRep - IDM_10] ;
                         ulElapsedTime = WinGetCurrentTime (hab) ;

                         for (A = 1.0, lRep = 0 ; lRep < lCalcRep ; lRep++)
                              A = Savage (A) ;

                         ulElapsedTime = WinGetCurrentTime (hab) -
                                        ulElapsedTime ;

                         if (WinQuerySysValue (HWND_DESKTOP, SV_MOUSEPRESENT)
                                   == 0)
                              WinShowPointer (HWND_DESKTOP, FALSE) ;

                         WinSetPointer (HWND_DESKTOP,
                                   WinQuerySysPointer (HWND_DESKTOP,
                                                       SPTR_ARROW, FALSE)) ;
                         iStatus = STATUS_DONE ;
                         WinInvalidateRect (hwnd, NULL, FALSE) ;
                         WinUpdateWindow (hwnd) ;

                         WinEnableMenuItem (hwndMenu, IDM_START, TRUE) ;
                         WinEnableMenuItem (hwndMenu, IDM_ABORT, FALSE) ;
                         return 0 ;

                    case IDM_ABORT:     // Not much we can do here
                         return 0 ;
                    }
               break ;

          case WM_PAINT:
               PaintWindow (hwnd, iStatus, lCalcRep, ulElapsedTime) ;
               return 0 ;
          }
     return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
     }
Esempio n. 20
0
MRESULT EXPENTRY ClientWinProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
{
    PGLOBALS            pg;
    RECTL               rectl;
    ULONG               rc;
    LONG                lrc;
    char                szWork[ LEN_WORKSTRING ];
    FILE                *f;
    SWP                 swp;

    switch( msg ) {

    case WM_CLOSE:
        // mshell does not close, but at least it can minimize and get out of the way
        pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER );
        WinSetWindowPos( pg->hwndFrame, HWND_BOTTOM, 0, 0, 0, 0, SWP_MINIMIZE );
        return (MRESULT) 0;

    case WM_CREATE:
        // see create.c
        pg = Create( hwnd );
        break;

    case WM_COMMAND:
        // see menu.c
        return Command( hwnd, msg, mp1, mp2 );

    case WM_CONTROL:
        pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER );

        switch( SHORT1FROMMP( mp1 )) {

            case ID_LISTBOX:

                switch( SHORT2FROMMP( mp1 )) {

                case LN_ENTER:
                    // user wants to start a program
                    WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, 0, 0 );

                    // see object.c
                    // get index from listbox; works as index to aStartem array
                    lrc = (LONG) WinSendMsg( pg->hwndListbox,
                                             LM_QUERYSELECTION,
                                             (MPARAM)LIT_FIRST, 0 );
#ifdef DEBUG
                    pmassert( pg->hab, LIT_NONE != lrc );
#endif

                    // pass index of program to start in mp2
                    WinPostMsg( pg->hwndObject,
                                WM_USER_START,
                                (MPARAM) hwnd,
                                (MPARAM) lrc );
                    break;
                }
                break;
        }
        return (MRESULT) 0;

    case WM_ERASEBACKGROUND:
        // see Petzold, WM_PAINT below
        return (MRESULT) 1;

    case WM_MOUSEMOVE:
        // display which pointer?
        if( WinIsWindowEnabled( hwnd )) {
            // not disabled; display regular pointer
            WinSetPointer( HWND_DESKTOP,
                           WinQuerySysPointer( HWND_DESKTOP, SPTR_ARROW, FALSE ));
        } else {
            // disabled; display hourglass
            WinSetPointer( HWND_DESKTOP,
                           WinQuerySysPointer( HWND_DESKTOP, SPTR_WAIT, FALSE ));
        }
        return (MRESULT) 0;

    case WM_NACK_NO_INI:
        pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER );
        WinSendMsg( hwnd, WM_USER_ENABLE_CLIENT, 0, 0 );

#define PSZNOINIPROMPT "\
Can't find \\MSHELL.INI, a plain text file used to configure MShell.\n\
\n\
Create a default one?"

        rc = (ULONG)WinMessageBox( HWND_DESKTOP,
                                   pg->hwndFrame,
                                   PSZNOINIPROMPT,
                                   CAPTION,
                                   0,
                                   MB_ICONEXCLAMATION | MB_YESNOCANCEL );
        if( MBID_YES == rc ) {

#define PSZDEFINI "\
* MSHELL.INI defines programs that MShell can start\n\
* Configure MSHELL.EXE using the RUNWORKPLACE setting in CONFIG.SYS\n\
* MSHELL.EXE finds its INI in the root of the boot drive\n\
* Each line in the INI file has two parts:\n\
*  1: program title text to appear in MShell window\n\
*  2: the CMD.EXE start command to start the program\n\
* Separate the parts with a semicolon\n\
* Lines starting with ! start automatically at bootup\n\
* Comment lines begin with  *\n\
\n\
* command processors\n\
OS/2 Command Prompt; start /f\n\
DOS Command Prompt; start /f /fs /dos\n\
Win-OS/2; start /fs /dos /c winos2\n\
\n\
* other stuff\n\
Help for Start; start help start\n\
Solitaire; start /f klondike\n\
\n\
* example to start from other than C:\\\n\
* PM Program; d: & cd \\pmpgm & start pmpgm\n"

            if( f = fopen( "\\MSHELL.INI", "w" )) {
                fprintf( f, PSZDEFINI );
                fclose( f );
            }

            // make like user pressed refresh
            WinPostMsg( hwnd, WM_COMMAND, (MPARAM)IDM_REFRESH, 0 );
        }
        return (MRESULT) 0;

    case WM_NACK_NO_SPOOLER:
        pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER );
        WinMessageBox( HWND_DESKTOP,
                       pg->hwndFrame,
                       "Sorry, could not start the spooler.",
                       CAPTION,
                       0,
                       MB_CANCEL );
        return (MRESULT) 0;

    case WM_NACK_SYNTAX_ERROR:
        pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER );
        // line number of INI file in mp2
        sprintf( szWork, "Line %d of \\mshell.ini is unrecognized.", (SHORT) mp2 );
        WinMessageBox( HWND_DESKTOP, pg->hwndFrame, szWork, CAPTION, 0, MB_CANCEL );
        return (MRESULT) 0;

    case WM_PAINT:
        // see WM_ERASEBACKGROUND above;
        // see Petzold sections on control windows which are children of the client window
        break;

    case WM_SAVEAPPLICATION:
        // save restored position
        pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER );
        WinQueryWindowPos( pg->hwndFrame, &swp );

        if( swp.fl &  SWP_MINIMIZE ) {
            // mshell is currently minimized
            pg->profile.swpMinimized.x  = swp.x;
            pg->profile.swpMinimized.y  = swp.y;
            // get restored size from window words
            pg->profile.swp.x  = WinQueryWindowUShort( pg->hwndFrame, QWS_XRESTORE  );
            pg->profile.swp.y  = WinQueryWindowUShort( pg->hwndFrame, QWS_YRESTORE  );
            pg->profile.swp.cx = WinQueryWindowUShort( pg->hwndFrame, QWS_CXRESTORE );
            pg->profile.swp.cy = WinQueryWindowUShort( pg->hwndFrame, QWS_CYRESTORE );
        } else if( swp.fl &  SWP_MAXIMIZE ) {
            // mshell is currently maximized
            // get restored size from window words
            pg->profile.swp.x  = WinQueryWindowUShort( pg->hwndFrame, QWS_XRESTORE  );
            pg->profile.swp.y  = WinQueryWindowUShort( pg->hwndFrame, QWS_YRESTORE  );
            pg->profile.swp.cx = WinQueryWindowUShort( pg->hwndFrame, QWS_CXRESTORE );
            pg->profile.swp.cy = WinQueryWindowUShort( pg->hwndFrame, QWS_CYRESTORE );
            // get minimized icon position from window words
            pg->profile.swpMinimized.x  = WinQueryWindowUShort( pg->hwndFrame, QWS_XMINIMIZE );
            pg->profile.swpMinimized.y  = WinQueryWindowUShort( pg->hwndFrame, QWS_YMINIMIZE );
        } else {
            // mshell is in the restored state
            pg->profile.swp = swp;
            // get minimized icon position from window words
            pg->profile.swpMinimized.x  = WinQueryWindowUShort( pg->hwndFrame, QWS_XMINIMIZE );
            pg->profile.swpMinimized.y  = WinQueryWindowUShort( pg->hwndFrame, QWS_YMINIMIZE );
        }

        // write to ini
        PrfWriteProfileData( HINI_PROFILE,
                             INI_APP,
                             INIKEY_PROFILE,
                             (PVOID)&pg->profile,
                             sizeof( PROFILE ));

#if 0
        // save restored position
        // TO DO: save icon position
        pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER );
        WinQueryWindowPos( pg->hwndFrame, &(pg->profile.swp) );
        if( 0 == ( pg->profile.swp.fl & ( SWP_MINIMIZE | SWP_MAXIMIZE ))) {
            // app in restored state, swp struct fine the way it is.
        }else{
            // app currently min'd or max'd. pull restore info from win words
            pg->profile.swp.x  = WinQueryWindowUShort( pg->hwndFrame, QWS_XRESTORE);
            pg->profile.swp.y  = WinQueryWindowUShort( pg->hwndFrame, QWS_YRESTORE);
            pg->profile.swp.cx = WinQueryWindowUShort( pg->hwndFrame, QWS_CXRESTORE);
            pg->profile.swp.cy = WinQueryWindowUShort( pg->hwndFrame, QWS_CYRESTORE);
        }
        // write to ini
        PrfWriteProfileData( HINI_PROFILE,
                             INI_APP,
                             INIKEY_PROFILE,
                             (PVOID)&(pg->profile),
                             sizeof( PROFILE ));
#endif

        break;

    case WM_SIZE:
        pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER );
        WinQueryWindowRect( hwnd, &rectl );
        WinSetWindowPos( pg->hwndListbox,
                         HWND_TOP,
                         0, 0,
                         rectl.xRight,
                         rectl.yTop,
                         SWP_SIZE | SWP_MOVE | SWP_SHOW );
        return (MRESULT) 0;

    case WM_USER_ACK:
        // re-enable the window
        pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER );

        switch( (ULONG)mp1 ) {

            case WM_CREATE:
                WinSetFocus( HWND_DESKTOP, pg->hwndListbox );
                break;
        }
        WinSendMsg( hwnd, WM_USER_ENABLE_CLIENT, 0, 0 );
        return (MRESULT) 0;

    case WM_USER_DISABLE_CLIENT:
        // this message sent; disable menu action bar as well
        pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER );
        WinEnableWindow( pg->hwndClient,  FALSE );
        WinEnableWindow( pg->hwndMenubar, FALSE );
        WinEnableWindow( pg->hwndListbox, FALSE );
        return (MRESULT) 0;

    case WM_USER_ENABLE_CLIENT:
        // this message sent; enable client and action bar
        pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER );
        WinEnableWindow( pg->hwndClient,  TRUE );
        WinEnableWindow( pg->hwndMenubar, TRUE );
        WinEnableWindow( pg->hwndListbox, TRUE );
        return (MRESULT) 0;
    }

    return( WinDefWindowProc( hwnd, msg, mp1, mp2 ));
}
// Frame_window - окно рамки.
HPOINTER Diver_QueryWindowIcon( HWND Frame_window )
{
 // Для некоторых окон есть значки по умолчанию, но устанавливать их нельзя.
 if( IsEPMEditorWindow( Frame_window ) || WindowIsCreatedBy( APP_EPM, Frame_window ) )
  {
   if( Diver.RTSettings.EPM_icon == NULLHANDLE )
    {
     ULONG Boot_drive = 0;
     DosQuerySysInfo( QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, (PULONG) &Boot_drive, sizeof( Boot_drive ) );

     if( Boot_drive )
      {
       CHAR Path[ SIZE_OF_PATH ] = "*:";
       Path[ 0 ] = (CHAR) Boot_drive + 64; strcat( Path, "\\OS2\\Apps\\Epm.exe" );

       if( FileExists( Path ) ) Diver.RTSettings.EPM_icon = WinLoadFileIcon( Path, 0 );
      }
    }

   if( Diver.RTSettings.EPM_icon != NULLHANDLE ) return Diver.RTSettings.EPM_icon;
   else return Resources.Default_icons[ ICON_VIEWDOC ];
  }

 // Для некоторых окон значки по умолчанию можно установить раз и навсегда, отправив сообщение в окно.
 HPOINTER Icon = NULLHANDLE;

 if( Icon == NULLHANDLE )
  {
   if( IsWinListWindow( Frame_window ) ) Icon = Resources.Default_icons[ ICON_WINLIST ];
  }

 if( Icon == NULLHANDLE )
  {
   if( WindowIsCreatedBy( APP_VIEWDOC, Frame_window ) ) Icon = Resources.Default_icons[ ICON_VIEWDOC ];
  }

 if( Icon == NULLHANDLE )
  {
   if( WindowIsCreatedBy( APP_PMCHKDSK, Frame_window ) )
    {
     if( Diver.RTSettings.HDD_icon == NULLHANDLE )
      {
       ULONG Boot_drive = 0;
       DosQuerySysInfo( QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, (PULONG) &Boot_drive, sizeof( Boot_drive ) );

       if( Boot_drive )
        {
         CHAR Path[ SIZE_OF_PATH ] = "*:";
         Path[ 0 ] = (CHAR) Boot_drive + 64; strcat( Path, "\\eCS\\Bin\\PMFormat.exe" );
         if( FileExists( Path ) ) Diver.RTSettings.HDD_icon = WinLoadFileIcon( Path, 0 );
        }
      }

     if( Diver.RTSettings.HDD_icon == NULLHANDLE )
      {
       CHAR Path[ SIZE_OF_PATH ] = "";
       HOBJECT WPDrives_object = QueryWPSObject( "<WP_DRIVES>" );
       if( WPDrives_object != NULLHANDLE ) WinQueryObjectPath( WPDrives_object, Path, SIZE_OF_PATH );
       if( Path[ 0 ] != 0 ) Diver.RTSettings.HDD_icon = WinLoadFileIcon( Path, 0 );
      }

     if( Diver.RTSettings.HDD_icon != NULLHANDLE ) Icon = Diver.RTSettings.HDD_icon;
    }
  }

 if( Icon == NULLHANDLE )
  {
   if( WindowIsCreatedBy( APP_APPLETVIEWER, Frame_window ) )
    {
     HWND Related_window = FindRelatedFrameWindow( Frame_window, &IsHotJavaBrowserWindow );

     if( Related_window != NULLHANDLE )
      {
       Icon = (HPOINTER) WinSendMsg( Related_window, WM_QUERYICON, 0, 0 );
      }
    }
  }

 // Если значок был выбран - ставим и возвращаем его.
 if( Icon != NULLHANDLE )
  {
   if( DrawSystemMenusSettingIsON() )
    {
     WinPostQueueMsg( Enhancer.Modules.Changer->Message_queue, SM_CHANGE_ICON, (MPARAM) Frame_window, (MPARAM) Icon );
    }

   return Icon;
  }

 // Узнаем значок окна.
 Icon = (HPOINTER) WinSendMsg( Frame_window, WM_QUERYICON, 0, 0 );

 // Если это пустой значок - ставим изображение по умолчанию.
 HWND Desktop = QueryDesktopWindow();

 if( Icon == WinQuerySysPointer( Desktop, SPTR_APPICON, 0 ) )
  {
   Icon = WinQuerySysPointer( Desktop, SPTR_PROGRAM, 0 );

   if( DrawSystemMenusSettingIsON() )
    {
     WinPostQueueMsg( Enhancer.Modules.Changer->Message_queue, SM_CHANGE_ICON, (MPARAM) Frame_window, (MPARAM) Icon );
    }

   return Icon;
  }

 // Если значок неизвестен - возвращаем значок владельца, главного окна, или значок по умолчанию.
 // Менять значок во всех случаях нельзя - может возникнуть постоянное рисование, которое выглядит как "мигание" рамки.
 if( Icon == NULLHANDLE )
  {
   // Узнаем окно рабочего стола.
   HWND Desktop = QueryDesktopWindow();

   // Просматриваем всех владельцев.
   HWND Owner_window = WinQueryWindow( Frame_window, QW_FRAMEOWNER );

   while( Owner_window != Desktop && Owner_window != NULLHANDLE )
    {
     // Если владелец - окно рамки:
     if( IsFrameWindow( Owner_window ) )
      {
       // Узнаем его значок.
       Icon = (HPOINTER) WinSendMsg( Owner_window, WM_QUERYICON, 0, 0 );

       // Если он есть - возвращаем его.
       if( Icon != NULLHANDLE ) return Icon;
      }

     // Узнаем следующего владельца.
     Owner_window = WinQueryWindow( Owner_window, QW_FRAMEOWNER );
    }

   // Узнаем главное окно приложения.
   HWND Main_window = QueryMainWindow( Frame_window );

   // Если это другое окно:
   if( Main_window != Frame_window )
    {
     // Узнаем его значок.
     Icon = (HPOINTER) WinSendMsg( Main_window, WM_QUERYICON, 0, 0 );

     // Если он есть - возвращаем его.
     if( Icon != NULLHANDLE ) return Icon;
    }

   // Узнаем очередь сообщений окна.
   HMQ Message_queue = WinQueryWindowULong( Frame_window, QWL_HMQ );

   // Узнаем окно оболочки.
   HWND Shell_window = GetDetectedShellWindow();

   if( Shell_window != NULLHANDLE )
    {
     // Узнаем очередь сообщений для окна оболочки.
     HMQ Shell_queue = WinQueryWindowULong( Shell_window, QWL_HMQ );

     // Если очереди совпадают - возвращаем его значок.
     if( Shell_queue == Message_queue ) return (HPOINTER) WinSendMsg( Shell_window, WM_QUERYICON, 0, 0 );

     // Если еще как-нибудь можно установить, что окно создано оболочкой - возвращаем значок окна оболочки.
     if( IsWorkplaceShellWindow( Frame_window ) ) return (HPOINTER) WinSendMsg( Shell_window, WM_QUERYICON, 0, 0 );
    }

   {
    // Перебираем окна в окне рабочего стола.
    HENUM Enumeration = WinBeginEnumWindows( Desktop ); HWND Window = NULLHANDLE;
    while( ( Window = WinGetNextWindow( Enumeration ) ) != NULLHANDLE )
     {
      // Если это то же самое окно - продолжаем перебор окон.
      if( Window == Frame_window ) continue;

      // Узнаем расположение окна и его состояние.
      SWP Window_state = {0}; WinQueryWindowPos( Window, &Window_state );

      // Если окно не скрыто и не уменьшено в значок:
      if( !( Window_state.fl & SWP_HIDE ) ) if( !( Window_state.fl & SWP_MINIMIZE ) )
       {
        // Если в это окно нельзя переключиться - продолжаем перебор окон.
        if( !PermissionForSwitching( Window ) ) continue;
       }

      // Узнаем очередь сообщений окна.
      HMQ Window_queue = WinQueryWindowULong( Window, QWL_HMQ );

      // Если очереди совпадают - узнаем его значок.
      if( Window_queue == Message_queue )
       {
        // Узнаем значок окна.
        Icon = (HPOINTER) WinSendMsg( Window, WM_QUERYICON, 0, 0 );

        // Если он есть - возвращаем его.
        if( Icon != NULLHANDLE )
         {
          // Завершаем перебор окон.
          WinEndEnumWindows( Enumeration );

          // Возвращаем значок.
          return Icon;
         }
       }
     }
    WinEndEnumWindows( Enumeration );
   }

   // Узнаем путь к приложению, создавшему окно.
   CHAR Path[ SIZE_OF_PATH ] = ""; GetDetectedExePath( Frame_window, Path );

   // Если его удалось определить:
   if( Path[ 0 ] != 0 )
    {
     // Узнаем имя приложения, создавшего окно.
     CHAR Name[ SIZE_OF_PATH ] = ""; GetDetectedExeName( Frame_window, Name );

     // Составляем полный путь.
     strcat( Path, "\\" ); strcat( Path, Name );

     // Загружаем значок для файла приложения.
     Icon = WinLoadFileIcon( Path, 0 );

     // Загрузка длится долго, поэтому в этом случае надо заменить значок окна. При
     // повторной загрузке возможна утечка памяти, так что лучше сделать это немедленно,
     // не посылая сообщений в поток Changer.
     WinSendMsg( Frame_window, WM_SETICON, (MPARAM) Icon, 0 );

     // Запоминаем, что значок был загружен с диска.
     BYTE Icon_was_loaded = 1; SetProperty( Frame_window, PRP_ICON_WAS_LOADED, &Icon_was_loaded );

     // Возвращаем значок.
     return Icon;
    }

   // Для окон постоянного размера выбираем простой значок.
   if( WindowIsDialog( Frame_window ) )
    {
     return Resources.Default_icons[ ICON_LEAF ];
    }
   // Для остальных окон - он зависит от того, можно ли переключиться в окно.
   else
    {
     HSWITCH Switch_handle = WinQuerySwitchHandle( Frame_window, NULLHANDLE );

     if( Switch_handle != NULLHANDLE ) return Resources.Default_icons[ ICON_LEAVES ];
     else return Resources.Default_icons[ ICON_LEAF ];
    }

   // И наконец, значок мог быть задан в свойствах раньше.
   FindProperty( Frame_window, PRP_ICON, &Icon );
  }

 // Возврат.
 return Icon;
}
Esempio n. 22
0
MRESULT	EXPENTRY ROPsTestWndProc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)

{
CHAR			szTitle[300];  /* Title	Bar Text		*/
HPS			hPS;	   /* Presentation Space Handle		*/
LONG			lClrBack;  /* Colour Holder			*/
LONG			lClrFore;  /* Colour Holder			*/
LONG			lScrollInc;/* Scroll Increment			*/
PBITMAPARRAYFILEHEADER	pbafh;	   /* Bitmap Array File	Header Pointer	*/
PBITMAPARRAYFILEHEADER2	pbafh2;	   /* Bitmap Array File	Header Pointer	*/
PBITMAPFILEHEADER	pbfh;	   /* Bitmap File Header Pointer	*/
PBITMAPFILEHEADER2	pbfh2;	   /* Bitmap File Header Pointer	*/
PBITMAPINFO		pbmi;	   /* Bitmap Info Pointer		*/
PBITMAPINFO2		pbmi2;	   /* Bitmap Info Pointer		*/
POINTL			ptl;	   /* Pointer Position			*/
RECTL			rcl;	   /* Window Rectangle			*/
register INT i;			   /* Index				*/

switch ( msg )
   {
/************************************************************************/
/* Window being	created, perform window	initialization			*/
/************************************************************************/

   case	WM_CREATE :

       hptrWait	 = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT,	FALSE);
       hptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW,	FALSE);

       cxScreen	= WinQuerySysValue(HWND_DESKTOP, SV_CXSCREEN);

       hmenuROPs = WinWindowFromID(WinQueryWindow(hWnd,	QW_PARENT), FID_MENU);
       hwndHScroll = WinWindowFromID(WinQueryWindow(hWnd, QW_PARENT), FID_HORZSCROLL);
       hwndVScroll = WinWindowFromID(WinQueryWindow(hWnd, QW_PARENT), FID_VERTSCROLL);

		       /************************************************/
		       /* PDSGetTemplate is used to allow controls in  */
		       /* windows.  Do not remove this function	if you */
		       /* intend to include controls within the	window.*/
		       /************************************************/

       PDSGetTemplate(hWnd, WIN_ROPSTEST);
       break;

/************************************************************************/
/* Window being	sized							*/
/************************************************************************/

   case	WM_SIZE	:
       if ( cBitmaps )
	   SizeBitmapStack(hWnd);

       WinQueryWindowRect(hWnd,	&rcl);

       if ( (lHorzRange	= cxROP	- (cxWindow = rcl.xRight - rcl.xLeft)) < 0L )
	   {
	   lHorzRange =	0L;
	   rclROP.xLeft	 = 0L;
	   rclROP.xRight = cxROP;
	   }
       else
	   rclROP.xRight = rclROP.xLeft	+ cxWindow;
       if ( (lVertRange	= cyROP	- (cyWindow = rcl.yTop - rcl.yBottom)) < 0L )
	   {
	   lVertRange =	0L;
	   rclROP.yBottom  = 0L;
	   rclROP.yTop	   = cyROP;
	   }
       else
	   rclROP.yBottom = (rclROP.yTop = cyROP - lVertPos) - cyWindow;

       WinSendMsg(hwndVScroll, SBM_SETSCROLLBAR, MPFROMSHORT(lVertPos),
		  MPFROM2SHORT(0, lVertRange));
       WinSendMsg(hwndVScroll, SBM_SETTHUMBSIZE, MPFROM2SHORT(cyWindow,	cyROP),	0L);

       WinSendMsg(hwndHScroll, SBM_SETSCROLLBAR, MPFROMSHORT(lHorzPos),
		  MPFROM2SHORT(0, lHorzRange));
       WinSendMsg(hwndHScroll, SBM_SETTHUMBSIZE, MPFROM2SHORT(cxWindow,	cxROP),	0L);
       WinInvalidateRect(hWnd, NULL, FALSE);
       break;

/************************************************************************/
/* Perform menu	initialization						*/
/************************************************************************/

   case	WM_INITMENU :
       switch (	SHORT1FROMMP(mp1) )
	   {
	   case	IDM_DISPLAY :
	       WinSendMsg(hmenuROPs, MM_SETITEMATTR, MPFROM2SHORT(IDM_BITMAPARRAY, TRUE),
			  MPFROM2SHORT(MIA_CHECKED, fBitmapArray ? MIA_CHECKED : 0));
	       WinSendMsg(hmenuROPs, MM_SETITEMATTR, MPFROM2SHORT(IDM_ROPARRAY,	TRUE),
			  MPFROM2SHORT(MIA_CHECKED, fBitmapArray ? 0 : MIA_CHECKED));
	       break;

	   case	IDM_FILE :
	       break;

	   }
       break;

/************************************************************************/
/* Process key press from keyboard					*/
/************************************************************************/

   case	WM_CHAR	:
       if ( CHARMSG(&msg)->fs &	KC_VIRTUALKEY )
	   switch ( CHARMSG(&msg)->vkey	)
	       {
	       case VK_PAGEUP :
		   WinSendMsg(hWnd, WM_VSCROLL,	MPFROMSHORT(FID_VERTSCROLL), MPFROM2SHORT(0, SB_PAGEUP));
		   return(0L);

	       case VK_PAGEDOWN	:
		   WinSendMsg(hWnd, WM_VSCROLL,	MPFROMSHORT(FID_VERTSCROLL), MPFROM2SHORT(0, SB_PAGEDOWN));
		   return(0L);
	       }
		       /************************************************/
		       /* PDSKeyProc is	used to	allow controls in      */
		       /* windows.  Do not remove this function	if you */
		       /* intend to include controls within the	window.*/
		       /************************************************/

       return(PDSKeyProc(hWnd, msg, mp1, mp2));

/************************************************************************/
/* Button 2 being depressed						*/
/************************************************************************/

   case	WM_BUTTON2DOWN :
       if ( !fBitmapArray && hbmROP )
	   {
	   lHorzPos = SHORT1FROMMR(WinSendMsg(hwndHScroll, SBM_QUERYPOS, 0L, 0L));
	   lVertPos = SHORT1FROMMR(WinSendMsg(hwndVScroll, SBM_QUERYPOS, 0L, 0L));

	   lRop	= (lVertPos + (cyWindow	- SHORT2FROMMP(mp1))) /	cyImage	* 16 + (lHorzPos + SHORT1FROMMP(mp1)) /	cxImage;
	   WinDlgBox(HWND_DESKTOP, hwndROPsFrame, (PFNWP)ViewROPDlgProc,
		     (HMODULE)NULL, DLG_VIEWROP, NULL);
	   }
       break;

/************************************************************************/
/* Process vertical scroll requests					*/
/************************************************************************/

   case	WM_VSCROLL :
       lVertPos	= SHORT1FROMMR(WinSendMsg(hwndVScroll, SBM_QUERYPOS, 0L, 0L));
       switch (	HIUSHORT(mp2) )
	   {
	   case	SB_LINEUP :
	       lScrollInc = -cyImage;
	       break;

	   case	SB_LINEDOWN :
	       lScrollInc = cyImage;
	       break;

	   case	SB_PAGEUP :
	       lScrollInc = -cyWindow;
	       break;

	   case	SB_PAGEDOWN :
	       lScrollInc = cyWindow;
	       break;

	   case	SB_SLIDERPOSITION :
	   case	SB_SLIDERTRACK :
	       lScrollInc = SHORT1FROMMP(mp2) -	lVertPos;
	       break;

	   default :
	       return(0L);
	   }

       if ( lScrollInc = max(-lVertPos,	min(lScrollInc,	lVertRange - lVertPos))	)
	   {
	   rclROP.yBottom = (rclROP.yTop = cyROP - (lVertPos +=	lScrollInc)) - cyWindow;
	   WinInvalidateRect(hWnd, NULL, FALSE);
	   WinSendMsg(hwndVScroll, SBM_SETPOS, MPFROM2SHORT(lVertPos, 0), 0L);
	   }
       break;

/************************************************************************/
/* Process horizontal scroll requests					*/
/************************************************************************/

   case	WM_HSCROLL :
       lHorzPos	= SHORT1FROMMR(WinSendMsg(hwndHScroll, SBM_QUERYPOS, 0L, 0L));
       switch (	HIUSHORT(mp2) )
	   {
	   case	SB_LINELEFT :
	       lScrollInc = -cxImage;
	       break;

	   case	SB_LINERIGHT :
	       lScrollInc = cxImage;
	       break;

	   case	SB_PAGELEFT :
	       lScrollInc = -cxWindow;
	       break;

	   case	SB_PAGERIGHT :
	       lScrollInc = cxWindow;
	       break;

	   case	SB_SLIDERPOSITION :
	   case	SB_SLIDERTRACK :
	       lScrollInc = SHORT1FROMMP(mp2) -	lHorzPos;
	       break;

	   default :
	       return(0L);
	   }

       if ( lScrollInc = max(-lHorzPos,	min(lScrollInc,	lHorzRange - lHorzPos))	)
	   {
	   rclROP.xRight = (rclROP.xLeft = (lHorzPos +=	lScrollInc)) + cxWindow;
	   WinInvalidateRect(hWnd, NULL, FALSE);
	   WinSendMsg(hwndHScroll, SBM_SETPOS, MPFROM2SHORT(lHorzPos, 0), 0L);
	   }
       break;

/************************************************************************/
/* Process control selections						*/
/************************************************************************/

   case	WM_CONTROL :
       switch (	SHORT2FROMMP(mp1) )
	   {
	   }
       break;

/************************************************************************/
/* Process menu	and button selections					*/
/************************************************************************/

   case	WM_COMMAND :
       switch (	SHORT1FROMMP(mp1) )
	   {
	   case	IDM_OPTIONS :
	       if ( WinDlgBox(HWND_DESKTOP, hwndROPsFrame, (PFNWP)OptionsDlgProc,
			      (HMODULE)NULL, DLG_OPTIONS, NULL)	)
		   {
		   WinSetPointer(HWND_DESKTOP, hptrWait);
		   CreateROPBitmap(hWnd);
		   WinInvalidateRect(hWnd, NULL, FALSE);
		   WinSetPointer(HWND_DESKTOP, hptrArrow);
		   }
	       break;
	   case	IDM_OPEN :
	       if ( WinDlgBox(HWND_DESKTOP, hwndROPsFrame, (PFNWP)OpenBitmapDlgProc,
			      (HMODULE)NULL, DLG_OPENBITMAP, NULL) )
		   {
		   WinSetPointer(HWND_DESKTOP, hptrWait);
		   hbmView = hbmGetBitmap(szBitmapFile);
		   SizeBitmap(hWnd);
		   if (	cBitmaps )
		       SizeBitmapStack(hWnd);
		   CreateROPBitmap(hWnd);
		   WinInvalidateRect(hWnd, NULL, FALSE);
		   strcat(memcpy(szTitle, "Bitmap Viewer - ", 17), szBitmapFile);
		   if (	fWindowsBitmap )
		       strcat(szTitle, " [Windows 3.x format]");
		   else
		       if ( f20Bitmap )
			   strcat(szTitle, " [OS/2 2.x format]");
		       else
			   strcat(szTitle, " [OS/2 1.x format]");
		   WinSetWindowText(hwndROPsFrame, szTitle);
		   WinSetPointer(HWND_DESKTOP, hptrArrow);
		   }
	       break;

	   case	IDM_ROPARRAY :
	       fBitmapArray = FALSE;
	       WinInvalidateRect(hWnd, NULL, FALSE);
	       break;

	   case	IDM_BITMAPARRAY	:
	       fBitmapArray = TRUE;
	       WinInvalidateRect(hWnd, NULL, FALSE);
	       break;
	   }
       break;

/************************************************************************/
/* Erase window	background						*/
/************************************************************************/

   case	WM_ERASEBACKGROUND :
       WinQueryWindowRect(hWnd,	&rcl);
       WinFillRect((HPS)LONGFROMMP(mp1), &rcl, CLR_PALEGRAY);
       break;

/************************************************************************/
/* Paint client	window							*/
/************************************************************************/

   case	WM_PAINT :
       GpiCreateLogColorTable(hPS = WinBeginPaint(hWnd,	(HPS)NULL, &rcl), 0UL, LCOLF_RGB, 0L, 0L, (PLONG)NULL);

		       /* Display the bitmap array images side-by-side	*/
       if ( fBitmapArray )
	   {
	   WinFillRect(hPS, &rcl, RGBCLR_PALEGRAY);
	   for ( i = 0;	i < cBitmaps; i++ )
	       {
		       /* Check	to see if the image is a 2-colour which	*/
		       /* menas	that the colours have to be set		*/
		       /* explicitely					*/

	       if ( abm[i].cColours == 2L )
		   {
		   lClrBack = lClrFore = 0L;

		       /* Check	to see if a 2.x	format bitmap since the	*/
		       /* the structures are slightly different		*/

		   if (	f20Bitmap )
		       {
		       /* Locate the bitmap information	structure	*/

		       if ( (cBitmaps == 1) && !fBitmapArray )
			   {
			   pbfh2 = (PBITMAPFILEHEADER2)abm[i].pb;
			   pbmi2 = (PBITMAPINFO2)&pbfh2->bmp2;
			   }
		       else
			   {
			   pbafh2 = (PBITMAPARRAYFILEHEADER2)abm[i].pb;
			   pbmi2 = (PBITMAPINFO2)&pbafh2->bfh2.bmp2;
			   }
			   /* Transfer the RGB info to the colour	*/
			   /* holders					*/

		       memcpy(&lClrBack, &pbmi2->argbColor[0], 3);
		       memcpy(&lClrFore, &pbmi2->argbColor[1], 3);
		       }
		   else
		       {
		       /* Locate the bitmap information	structure	*/

		       if ( (cBitmaps == 1) && !fBitmapArray )
			   {
			   pbfh	= (PBITMAPFILEHEADER)abm[i].pb;
			   pbmi	= (PBITMAPINFO)&pbfh->bmp;
			   }
		       else
			   {
			   pbafh = (PBITMAPARRAYFILEHEADER)abm[i].pb;
			   pbmi	= (PBITMAPINFO)&pbafh->bfh.bmp;
			   }
			   /* Transfer the RGB info to the colour	*/
			   /* holders					*/

		       memcpy(&lClrBack, &pbmi->argbColor[0], 3);
		       memcpy(&lClrFore, &pbmi->argbColor[1], 3);
		       }
			   /* Draw the 2-colour	bitmap using the	*/
			   /* provided colours from the	bitmap		*/

		   WinDrawBitmap(hPS, abm[i].hbm, (PRECTL)NULL,	(PPOINTL)(PVOID)&abm[i].rclDest,
				 lClrFore, lClrBack, DBM_NORMAL);
		   }
	       else
			   /* Draw the bitmap from the array		*/

		   WinDrawBitmap(hPS, abm[i].hbm, (PRECTL)NULL,	(PPOINTL)(PVOID)&abm[i].rclDest,
				 RGB_WHITE, RGB_BLACK, DBM_NORMAL);

			   /* Draw the 3-D frame around	the image	*/

	       GpiSetColor(hPS,	RGBCLR_SHADOW);
	       GpiMove(hPS, &abm[i].aptlArea[7]);
	       GpiPolyLine(hPS,	2L, &abm[i].aptlArea[4]);

	       GpiSetColor(hPS,	RGB_WHITE);
	       GpiPolyLine(hPS,	2L, &abm[i].aptlArea[6]);

	       GpiSetColor(hPS,	RGB_BLACK);
	       GpiMove(hPS, &abm[i].aptlArea[3]);
	       GpiPolyLine(hPS,	2L, &abm[i].aptlArea[0]);

	       GpiSetColor(hPS,	RGBCLR_PALEGRAY);
	       GpiPolyLine(hPS,	2L, &abm[i].aptlArea[2]);
	       }
	   }
       else
	   {
	   if (	(rclROP.xRight < cxWindow) || (rclROP.yTop < cyWindow) )
	       WinFillRect(hPS,	&rcl, RGBCLR_PALEGRAY);
	   ptl.x = ptl.y = 0L;
	   WinDrawBitmap(hPS, hbmROP, &rclROP, &ptl, 0L, 0L, DBM_NORMAL);
	   }
       WinEndPaint(hPS);
       break;

/************************************************************************/
/* Window being	destroyed, perform clean-up operations			*/
/************************************************************************/

   case	WM_DESTROY :
       for ( i = 0; i <	cBitmaps; i++ )
	   GpiDeleteBitmap(abm[i].hbm);

       if ( hbmROP )
	   GpiDeleteBitmap(hbmROP);

       if ( pb )
	   free(pb);
       break;

			/* Default message processing			*/
   default :
       return(WinDefWindowProc(hWnd, msg, mp1, mp2));
   }
return(0L);
}
Esempio n. 23
0
void Window::createWindow( Window *parent, Window *owner, char *text, 
                           char *windowClass,
                           Window *behind, ULONG windowStyle, int x, int y,
                           int width, int height )
{
  char str[50], *wClass;

  mouseButtonDown = FALSE;

  this->parent = parent;

  if( parent->getType() == DIALOG)
  	behind = (Window *)parent->getLastControl();

  type = WINDOW;
  this->id = Iterator::getNext();

  Application::tempthis = this;

  oldWndProc = NULL;

  if( windowClass == 0L )
  {
    currentPointer = WinQuerySysPointer( HWND_DESKTOP, SPTR_ARROW, FALSE );

		strcpy( str, "KONBASEWINDOW" );
		if( !baseClassRegistered )
		{
			baseClassRegistered = TRUE;
			if( !WinRegisterClass( Application::hab, (PSZ)str, //(PSZ)itoa( id, str, 10),
												WndProc, CS_SIZEREDRAW | CS_MOVENOTIFY | CS_SYNCPAINT,
												sizeof(Window *) ) )
			{
				exit( 1 );
			}
		}
    wClass = str;
  }
  else
  {
    currentPointer = NULLHANDLE;
    wClass = windowClass;
  }

	if( windowStyle & WS_DISABLED )
	{
		windowStyle &= ~WS_DISABLED;
		isPopupWin = TRUE;
	}

  hWndFrame = hWndClient = WinCreateWindow( (isPopupWin) ? HWND_DESKTOP : parent->getHWND(), wClass, text,
                                            windowStyle, x, y, width, height,
                                            owner->getHWND(),
                                            (behind == NULL) ? HWND_TOP : behind->getHWND(),
                                            id, 0L, 0L );

  // Subclass window

  if( wClass == windowClass )
  {
    WinSetWindowULong(hWndFrame,0,(ULONG)this);
    oldWndProc = WinSubclassWindow( hWndFrame, (PFNWP)WndProc );
  }

  if( hWndFrame == NULLHANDLE )
  {
    DosBeep( 1000, 100 );
    char wText[501];
    WinQueryWindowText( parent->getHWNDFrame(), 500, wText );
  }

  graphics = new Graphics( WinGetPS( hWndClient ) );
}
Esempio n. 24
0
MRESULT	EXPENTRY DriverWndProc(HWND hWnd, ULONG	msg, MPARAM mp1, MPARAM	mp2)

{
CHAR	     szFile[CCHMAXPATH];   /* File HOlder			*/
FILEFINDBUF3 findbuf;		   /* File Find	Buffer			*/
FONTMETRICS  fm;		   /* Font Metrics Structure		*/
HDIR	     hDir = (HDIR)HDIR_CREATE; /* Directory Handle		*/
HPS	     hPS;		   /* Presentation Space Handle		*/
HWND	     hwndListBox;	   /* List Box Window Handle		*/
LISTBOXCDATA lbwcd;		   /* List Box Window Control Data	*/
POWNERITEM   poi;		   /* Owner Item			*/
RECTL	     rcl;		   /* Client Window Rectangle		*/
ULONG	     ulFileCnt = 1UL;	   /* File Counter Holder		*/
register INT i,	k, n;		   /* Loop Counter			*/

switch ( msg )
   {
		       /* Perform window initialization			*/
   case	WM_CREATE :
       hptrArrow = WinQuerySysPointer(HWND_DESKTOP, SPTR_ARROW,	FALSE);
       WinSetPointer(HWND_DESKTOP, hptrWait = WinQuerySysPointer(HWND_DESKTOP, SPTR_WAIT, FALSE));
       memset(&lbwcd, 0, sizeof(LISTBOXCDATA));
       lbwcd.cb	= sizeof(LISTBOXCDATA);
       lbwcd.ulVersion = LBV_110;
       lbwcd.vdata.lbcd1_1.flExtStyles = LSXS_CHECKBOX | LSXS_EDITABLE;

       hwndList1 = WinCreateWindow(hWnd, "ListBoxWindow", "", LS_HORZSCROLL | LS_EXTENDEDSEL | WS_VISIBLE,
				   10L,	10L, 100L, 175L, hWnd,
				   HWND_TOP, 1024UL, (PVOID)&lbwcd, (PVOID)NULL);

       hwndListx = WinCreateWindow(hWnd, "ListBoxWindow", "", LS_HORZSCROLL | LS_EXTENDEDSEL | WS_VISIBLE,
				   125L, 10L, 100L, 175L, hWnd,
				   HWND_TOP, 1024UL, (PVOID)&lbwcd, (PVOID)NULL);

       hwndList2 = WinCreateWindow(hWnd, "ListBoxWindow", "", WS_VISIBLE, 10L, 190L, 250L, 200L, hWnd,
				   HWND_TOP, 1025UL, (PVOID)&lbwcd, (PVOID)NULL);

       WinSendMsg(hwndList1, LMXM_SETSOUNDEVENT, MPFROMLONG(LSND_SINGLECLICK),
		  MPFROMP("ahooga.wav"));
       WinSendMsg(hwndListx, LMXM_SETSOUNDEVENT, MPFROMLONG(LSND_DOUBLECLICK),
		  MPFROMP("flush.wav"));

       hwndListA = WinCreateWindow(hWnd, WC_LISTBOX, "", LS_OWNERDRAW |	LS_HORZSCROLL |	LS_MULTIPLESEL | WS_VISIBLE,
				   275L, 10L, 100L, 175L, hWnd,
				   HWND_TOP, 1026UL, (PVOID)NULL, (PVOID)NULL);

		       /* Sub-class the	default	window procedure with	*/
		       /* new one which	will handle specific messages	*/
		       /* allowing better control over the sizing frame	*/

       hwndListB = WinCreateWindow(hWnd, WC_LISTBOX, "", WS_VISIBLE | LS_EXTENDEDSEL, 275L, 190L, 250L,	200L, hWnd,
				   HWND_TOP, 1027UL, (PVOID)NULL, (PVOID)NULL);

       for ( i = 0; i <	10; i++	)
	   {
	   sprintf(szFile, "Item %04d Item %04d Item %04d", i, i, i);
	       WinSendMsg(hwndListx, LM_INSERTITEM,
			  MPFROMLONG(LIT_END),
			  MPFROMP(szFile));
	   }

       n = (INT)WinSendMsg(hwndList2, LMX_CALCLINECOUNT, MPFROMLONG(175L), 0L);

       k = 0;

       WinSendMsg(hwndList2, LM_SETITEMHEIGHT, MPFROMLONG(36L),	0L);

       if ( !DosFindFirst("*.*", &hDir,	FILE_NORMAL,
			  (PVOID)&findbuf, sizeof(FILEFINDBUF3),
			  &ulFileCnt, FIL_STANDARD) )
	   {
	   do
	       {
	       WinSendMsg(hwndList2, LM_INSERTITEM,
			  MPFROMLONG(LIT_SORTDESCENDING),
			  MPFROMP(findbuf.achName));
	       WinSendMsg(hwndList1, LM_INSERTITEM,
			  MPFROMLONG(LIT_SORTASCENDING),
			  MPFROMP(findbuf.achName));
	       if ( ++k	> n )
		   WinSendMsg(hwndList2, LM_SETTOPINDEX, MPFROMLONG(k -	n), 0L);
	       WinSendMsg(hwndListB, LM_INSERTITEM,
			  MPFROMLONG(LIT_SORTDESCENDING),
			  MPFROMP(findbuf.achName));
	       WinSendMsg(hwndListA, LM_INSERTITEM,
			  MPFROMLONG(LIT_SORTASCENDING),
			  MPFROMP(findbuf.achName));
	       }
	       while ( !DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3), &ulFileCnt) );
	   DosFindClose(hDir);
	   }
       break;

   case	WM_BUTTON1DOWN :
       WinEnableWindowUpdate(hwndListA,	FALSE);
       WinEnableWindowUpdate(hwndList1,	FALSE);

       WinSendMsg(hwndListA, LM_DELETEALL, 0L, 0L);
       WinSendMsg(hwndList1, LM_DELETEALL, 0L, 0L);
       i = 0;
       if ( !DosFindFirst("*.*", &hDir,	FILE_NORMAL,
			  (PVOID)&findbuf, sizeof(FILEFINDBUF3),
			  &ulFileCnt, FIL_STANDARD) )
	   {
	   do
	       {
	       WinSendMsg(hwndListA, LM_INSERTITEM,
			  MPFROMLONG(LIT_SORTASCENDING),
			  MPFROMP(findbuf.achName));
	       WinSendMsg(hwndList1, LM_INSERTITEM,
			  MPFROMLONG(LIT_SORTASCENDING),
			  MPFROMP(findbuf.achName));
	       ++i;
	       }
	       while ( !DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3), &ulFileCnt) );
	   DosFindClose(hDir);
	   }
       WinShowWindow(hwndListA,	TRUE);
       WinShowWindow(hwndList1,	TRUE);

       while ( i )
	   {
	   if (	i % 2 )
	       {
	       WinSendMsg(hwndListA, LM_SELECTITEM, MPFROMLONG(i - 1), MPFROMLONG(TRUE));
	       WinSendMsg(hwndList1, LM_SELECTITEM, MPFROMLONG(i - 1), MPFROMLONG(TRUE));
	       }
	   --i;
	   }
       break;

   case	WM_CONTROL :
       switch (	SHORT2FROMMP(mp1) )
	   {
		       /* Process double click on a List Box		*/

	   case	LN_SELECT :
	       switch (	SHORT1FROMMP(mp1) )
		   {
		   case	1024UL :
		   /*  WinAlarm(HWND_DESKTOP, WA_NOTE);	  */
		       break;

		   case	1027UL :
		   /*  WinAlarm(HWND_DESKTOP, WA_ERROR);  */
		       break;
		   }
	       break;
	   }
       break;


   case	WM_MEASUREITEM :
       GpiQueryFontMetrics(hPS = WinGetPS(hWnd), sizeof(FONTMETRICS), &fm);
       WinReleasePS(hPS);
       return(MRFROMLONG(fm.lMaxBaselineExt));

		       /* Draw a list box item				*/
   case	WM_DRAWITEM :

       if ( SHORT1FROMMP(mp1) == 1024 )
	   hwndListBox = hwndList1;
       else
	   if (	SHORT1FROMMP(mp1) == 1026 )
	       hwndListBox = hwndListA;

		       /* Point	to Owner Item information		*/

       poi = (POWNERITEM)mp2;
       GpiCreateLogColorTable(poi->hps,	0L, LCOLF_RGB, 0L, 0L, (PLONG)NULL);

       i = (INT)LONGFROMMR(WinSendMsg(hwndListBox, LM_QUERYITEMTEXTLENGTH,
				      MPFROMLONG(poi->idItem), 0L));

       i = (INT)LONGFROMMR(WinSendMsg(hwndListBox, LM_QUERYITEMTEXT,
				      MPFROM2SHORT(poi->idItem,	CCHMAXPATH),
				      MPFROMP(szFile)));

		       /* Check	to see if item to be drawn or		*/
		       /* highlighted					*/

       if ( poi->fsState != poi->fsStateOld )
	   {
	   WinFillRect(poi->hps, &poi->rclItem,	RGBCLR_DIALOGBACKGROUND);

	   if (	poi->fsState )
	       WinDrawText(poi->hps, -1L, szFile, &poi->rclItem,
			   RGB_BLACK, RGBCLR_DIALOGBACKGROUND, DT_LEFT | DT_VCENTER |
			   DT_ERASERECT);

		       /* Set item highlighting	by inverting the items	*/
		       /* rectangle colour				*/

	   WinInvertRect(poi->hps, &poi->rclItem);

	   if (	!poi->fsState )
	       WinDrawText(poi->hps, -1L, szFile, &poi->rclItem,
			   RGB_BLACK, RGBCLR_DIALOGBACKGROUND, DT_LEFT | DT_VCENTER |
			   DT_ERASERECT);
	   poi->fsState	= poi->fsStateOld = 0;
	   }
       else
	   {
		       /* Item needs to	be drawn, get item rectangle	*/
		       /* item position					*/

	   WinFillRect(poi->hps, &poi->rclItem,	RGBCLR_DIALOGBACKGROUND);

	   WinDrawText(poi->hps, -1L, szFile, &poi->rclItem,
		       RGB_BLACK, RGBCLR_DIALOGBACKGROUND, DT_LEFT | DT_VCENTER	|
		       DT_ERASERECT);
	   }
       return(MRFROMLONG(TRUE));

   case	WM_BUTTON1DBLCLK :
       i = 0;
       if ( !DosFindFirst("*.*", &hDir,	FILE_NORMAL,
			  (PVOID)&findbuf, sizeof(FILEFINDBUF3),
			  &ulFileCnt, FIL_STANDARD) )
	   {
	   do
	       {
	       ++i;
	       }
	       while ( !DosFindNext(hDir, &findbuf, sizeof(FILEFINDBUF3), &ulFileCnt) );
	   DosFindClose(hDir);
	   }

       while ( i )
	   {
	   if (	i % 2 )
	       {
	       WinSendMsg(hwndListA, LM_SELECTITEM, MPFROMLONG(i - 1), MPFROMLONG(FALSE));
	       WinSendMsg(hwndList1, LM_SELECTITEM, MPFROMLONG(i - 1), MPFROMLONG(FALSE));
	       }
	   --i;
	   }
       break;

   case	WM_BUTTON2DOWN :

       for ( i = 0; i <	5; i++ )
	   WinSendMsg(hwndListx, LM_DELETEITEM,	MPFROMSHORT(2),	0L);

#if 0
       WinSendMsg(hwndListA, LM_SELECTITEM, MPFROMLONG(LIT_NONE), MPFROMLONG(TRUE));

       i = LIT_FIRST;
       while ( (i = (INT)LONGFROMMR(WinSendMsg(hwndList1, LM_QUERYSELECTION, MPFROMLONG(i), 0L))) != LIT_NONE )
	   WinSendMsg(hwndList1, LM_SELECTITEM,	MPFROMLONG(i), MPFROMLONG(FALSE));
#endif
       break;
		       /* Erase	background				*/

   case	WM_ERASEBACKGROUND :
       WinQueryWindowRect(hWnd,	&rcl);
       WinFillRect((HPS)mp1, &rcl, SYSCLR_DIALOGBACKGROUND);
       break;
		       /* Paint	the main client	window			*/
   case	WM_PAINT :
       WinSetPointer(HWND_DESKTOP, hptrWait);

       WinFillRect(hPS = WinBeginPaint(hWnd, (HPS)NULL,	&rcl), &rcl, SYSCLR_DIALOGBACKGROUND);

       WinEndPaint(hPS);
       WinSetPointer(HWND_DESKTOP, hptrArrow);
       break;
		       /* Close	Down					*/
   case	WM_CLOSE :

       WinPostMsg(hWnd,	WM_QUIT, 0L, 0L);
       break;

   case	WM_DESTROY :
       WinDestroyPointer(hptrArrow);
       WinDestroyPointer(hptrWait);
       break;
		       /* Default message processing			*/
   default:
       return(WinDefWindowProc(hWnd, msg, mp1, mp2));
   }
return(0L);
}
/*************************************************************************
 *
 * Name       : WinProc(hwnd, msg, mp1, mp2)
 *
 * Description: Processes the messages sent to the main client
 *              window.  This routine processes the basic
 *              messages all client windows should process.
 *
 * Concepts   : This procedure provides service routines for the general
 *              PM events (messages) that PM sends to the window, as well
 *              as the user initiated events (messages) that are generated
 *              when the user selects the action bar and pulldown menu
 *              controls or the corresponding keyboard accelerators.
 *
 *              The switch statement shown below distributes the window
 *              messages to the respective message service routines, which
 *              are set apart by the case statements.  The window
 *              procedures must provide an appropriate service routine for
 *              its end user initiated messages, as well as the general PM
 *              messages (like the WM_CLOSE message). If a message is sent
 *              to this procedure for which there is no programmed case
 *              clause (i.e., no service routine), the message is defaulted
 *              function WinDefWindowProc, where it is disposed of by PM.
 *
 *              Time-consuming tasks are posted to the object window where
 *              they can be performed without the 1/10 second turnaround
 *              time imposed on the client window. When the object window
 *              is busy, the client window is usually disabled. The object
 *              window then posts an acknowledgement
 *              back to the client when the lengthy task is completed.
 *
 *              Cases under the big switch appear in alphabetical order.
 *
 *  API's     :   WinLoadString
 *                WinMessageBox
 *                WinQueryWindowULong
 *                WinSendMsg
 *                WinPostMsg
 *                WinIsWindowEnabled
 *                WinSetPointer
 *                WinQuerySysPointer
 *                WinBeginPaint
 *                WinQueryWindowRect
 *                WinFillRect
 *                WinEndPaint
 *                WinInvalidateRect
 *                WinSetWindowText
 *                GpiDrawChain
 *                GpiConvert
 *                GpiSetDefaultViewMatrix
 *                GpiAssociate
 *                GpiDestroyPS
 *                GpiDeleteBitmap
 *                GpiDeleteMetafile
 *
 * Parameters : HWND         window handle
 *              ULONG        message
 *              MPARAM       message parameter 1
 *              MPARAM       message parameter 2
 *
 * Result     : MRESULT      message result
 *
 *************************************************************************/
MRESULT EXPENTRY WinProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
{
   BOOL                bOK;
   PMAIN_PARM       pmp;
   HPS                 hps;
   RECTL              rectl;
   PSZ                 psz;
   CHAR               szWork[ LEN_WORKSTRING ];
   SHORT              sStep;
   ULONG              ulWork;
   SHORT              sNewPos;
   ULONG              rc;

   switch(msg)
   {
   case WM_CLOSE:
      /* obtain the main parameter pointer from window words */
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );
#ifdef OSA_AWARE
      /* Do OSA termination */
      TerminateOSA(hwnd);
#endif
      if( pmp->fBusy )
      {
         /* OK to close when object window is busy?  */
         WinLoadString( pmp->hab, (HMODULE)NULLHANDLE,
                   ERRMSG_CLOSE_QUESTION, LEN_WORKSTRING, szWork );
         ulWork = WinMessageBox( HWND_DESKTOP,
                                 pmp->hwndFrame,
                                 szWork,
                                 pmp->pszTitle,
                                 (USHORT)0,
                                 MB_YESNOCANCEL | MB_MOVEABLE |
                                 MB_CUANOTIFICATION | MB_APPLMODAL);

         if( ulWork == MBID_YES )
         {
            /* close down the application in spite of being busy */
            pmp->fCancel = TRUE;
            /* disable client during exit */
            WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, (MPARAM)0 , (MPARAM)0  );
            /* start a watchdog timer to ensure a timely death */
            WinStartTimer( pmp->hab, hwnd, ID_DEATH_TIMER, LEN_DEATH_TIMER );
            /* Tell object window to close, quit, and post me a WM_QUIT */
            WinPostMsg( pmp->hwndObject, WM_USER_CLOSE, (MPARAM)hwnd, (MPARAM)0 );
         }
      }
      else
      {
         /* not busy, so initiate closure by telling object window to close */
         WinPostMsg( pmp->hwndObject, WM_USER_CLOSE, (MPARAM)hwnd, (MPARAM)0 );
      }
      return (MRESULT)NULL;


   case WM_COMMAND:
      /* do menu activities; see menu.c */
      return Menu( hwnd, msg, mp1, mp2 );


   case WM_CREATE:

      /*
       * Do one-time, startup processing in PRTCREAT.C.
       * This function allocates the pmp, a pointer to the program's
       * main parameters. See the declaration of this block of
       * parameters in PRTSAMP.H, the MAIN_PARM structure.
       *
       * The Create() function allocates this structure and
       * begins to initialize it. Throughout all the code, the pmp->
       * pointer is usually obtainable with a call to WinQueryWindowULong.
       * Window word space for this pointer was reserved on the call
       * to WinRegisterClass.
       *
       * Create() allocates, initializes, and stores the pmp pointer
       * in the client window words. It then starts thread 2 of the
       * application on which the object window operates. The pmp
       * pointer is passed to thread 2 with _beginthread in PRTCREAT.C.
       * The pmp is passed to the object window on the call to
       * WinCreateWindow in PRTOBJ.C. Finally, the object window stores
       * the pmp in its window words under the WM_CREATE case of the
       * ObjectWinProc in PRTOBJ.C.
       *
       */

      Create( hwnd );
#ifdef OSA_AWARE
      /* Do OSA Initialization */
      InitOSA(hwnd);
#endif

#ifdef OSA_AWARE
        /* Generate a Apple Event - Open Application to myself  (Workaround) */
        rc =  GenerateOSAEvent(hwnd, msg, MPFROMSHORT(IDM_AEOPENAPP), mp2);
#endif
      return (MRESULT)NULL;


   case WM_HSCROLL:
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );

      /* Compute some fraction of scroll bar range for a unit of scrolling. */
      sStep  = pmp->sHScrollRange / 50;

      switch( SHORT2FROMMP( mp2 ))
      {
      case SB_LINELEFT:
         pmp->sHScrollPos -= sStep;
         break;
      case SB_PAGELEFT:
         pmp->sHScrollPos -= pmp->sizelClient.cx;
         break;
      case SB_LINERIGHT:
         pmp->sHScrollPos += sStep;
         break;
      case SB_PAGERIGHT:
         pmp->sHScrollPos += pmp->sizelClient.cx;
         break;
      case SB_SLIDERPOSITION:
      case SB_SLIDERTRACK:
         pmp->sHScrollPos = SHORT1FROMMP( mp2 );
         break;
      }

      /* Don't allow step assignments to exceed limits of zero to range. */
      pmp->sHScrollPos = max( (SHORT)0,
                              min( pmp->sHScrollPos, pmp->sHScrollRange ));

      if( pmp->sHScrollPos != SHORT1FROMMR(WinSendMsg( pmp->hwndHScroll,
          SBM_QUERYPOS, (MPARAM)0, (MPARAM)0 )))
      {
         /*
          * New scroll bar thumbbutton position is different than current.
          * Set a new X translation value to effect the scroll.
          * Current scale setting affects the X element of the matrix.
          */
         pmp->matlfDefView.lM31 = OFFSET_XY_TWIPS - (LONG)(pmp->floatScale *
                                                 (float)( pmp->sHScrollPos));
         bOK = GpiSetDefaultViewMatrix( pmp->hpsClient,
                                        9,
                                        &pmp->matlfDefView,
                                        TRANSFORM_REPLACE );
         pmassert( pmp->hab, bOK );
         CalibrateHorizontalScrollBar( pmp );
         WinInvalidateRect( hwnd, NULL, FALSE );
      }
      return (MRESULT) 0;


   case WM_MOUSEMOVE:
      /* display which pointer? -- could query pmp->fBusy or... */
      if( WinIsWindowEnabled( hwnd ))
      {
         /* not disabled; display regular pointer */
         WinSetPointer( HWND_DESKTOP,
                        WinQuerySysPointer( HWND_DESKTOP, SPTR_ARROW, FALSE ));
      }
      else
      {
         /* disabled; display hourglass because I'm busy */
         WinSetPointer( HWND_DESKTOP,
                        WinQuerySysPointer( HWND_DESKTOP, SPTR_WAIT, FALSE ));
      }
     return (MRESULT) 1;



   case WM_NACK_BITMAP_NOT_SUPPORTED:
      /*
       * Object window does not support this format of bitmap -
       * show a message box.
       */
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );
      WinSendMsg( hwnd, WM_USER_ENABLE_CLIENT, (MPARAM)0, (MPARAM)0 );
      bOK = WinLoadString( pmp->hab, (HMODULE)0,
                   ERRMSG_BITMAP_NOT_SUPPORTED, LEN_WORKSTRING, szWork );
      pmassert( pmp->hab, bOK );
      WinMessageBox( HWND_DESKTOP,
                     pmp->hwndFrame,
                     szWork,
                     pmp->pszTitle,
                     (USHORT)0,
                     MB_OK | MB_MOVEABLE | MB_CUACRITICAL | MB_APPLMODAL);

      pmp->ulNextMode        = MODE_UNKNOWN;
      pmp->szNextFilename[0] = 0;
      WinPostMsg( hwnd, WM_USER_NEW_MODE, (MPARAM)0, (MPARAM)0 );
      return (MRESULT) 0;


   case WM_NACK_BITMAP_ERROR:
      /*
       * Object window had error loading the bitmap file -
       * show a message box
       */
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );
      WinSendMsg( hwnd, WM_USER_ENABLE_CLIENT, (MPARAM)0, (MPARAM)0 );
      bOK = WinLoadString( pmp->hab,
                           (HMODULE)NULLHANDLE,
                           ERRMSG_BAD_BITMAP,
                           LEN_WORKSTRING,
                           szWork );
      pmassert( pmp->hab, bOK );
      WinMessageBox( HWND_DESKTOP,
                     pmp->hwndFrame,
                     szWork,
                     pmp->pszTitle,
                     (USHORT)0,
                     MB_OK | MB_MOVEABLE | MB_CUAWARNING | MB_APPLMODAL);

      pmp->ulNextMode        = MODE_UNKNOWN;
      pmp->szNextFilename[0] = 0;
      WinPostMsg( hwnd, WM_USER_NEW_MODE, (MPARAM)0, (MPARAM)0 );
      return (MRESULT) 0;


   case WM_NACK_FILE_READING_ERROR:
      /*
       * Object window had a problem with reading the disk -
       * show a message box.
       */
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );
      WinSendMsg( hwnd, WM_USER_ENABLE_CLIENT, (MPARAM)0, (MPARAM)0 );
      bOK = WinLoadString( pmp->hab, (HMODULE)NULLHANDLE,
                           ERRMSG_READ_ERROR, LEN_WORKSTRING, szWork );
      pmassert( pmp->hab, bOK );
      WinMessageBox( HWND_DESKTOP,
                     pmp->hwndFrame,
                     szWork,
                     pmp->pszTitle,
                     (USHORT)0,
                     MB_OK | MB_MOVEABLE | MB_CUACRITICAL | MB_APPLMODAL);
      pmp->ulNextMode        = MODE_UNKNOWN;
      pmp->szNextFilename[0] = 0;
      WinPostMsg( hwnd, WM_USER_NEW_MODE, (MPARAM)0, (MPARAM)0 );
      return (MRESULT) 0;


   case WM_PAINT:
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );

      /* do not rely on client window rectangle being correct */
      WinQueryUpdateRect( hwnd, &rectl );
      WinQueryWindowRect( hwnd, &rectl );

      /* current mode of the program affects window painting */
      switch( pmp->ulMode )
      {
      case MODE_UNKNOWN:
         WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, (MPARAM)0, (MPARAM)0 );
         WinPostMsg( pmp->hwndObject, WM_USER_PAINT_DEFAULT_SCREEN,
                        (MPARAM)hwnd, (MPARAM)0 );
         /* must call default window proc for window validation */
         break;

      case MODE_TEXT:
         if( pmp->fBusy )
         {
            /*
             * Object window is busy with the client PS drawing into
             * retained segments. Use a cached micro PS to merely
             * fill the client window with a background wash.
             *
             * Proper painting of the text will occur in due time
             * because the WM_USER_ACK case below will
             * invalidate the client window and force a paint.
             * The object window won't be busy then.
             */
            hps = WinBeginPaint( hwnd, (HPS) 0, &rectl );
            pmassert( pmp->hab, hps );
            bOK = WinFillRect( hps, &rectl, SYSCLR_WINDOW );
            pmassert( pmp->hab, bOK );
            WinEndPaint( hps );
         }
         else
         {
            /* PS not busy. Use GpiDrawChain to repaint the text */
            hps = WinBeginPaint( hwnd, (HPS)pmp->hpsClient, &rectl );
            pmassert( pmp->hab, hps );
            bOK = WinFillRect( pmp->hpsClient, &rectl, SYSCLR_WINDOW );
            pmassert( pmp->hab, bOK );
            /*
             * GpiDrawChain re-plays the GpiCharString orders that were
             * retain in the WM_USER_PAGINATE case in prtobj.c
             */
            bOK = GpiDrawChain( pmp->hpsClient );
            pmassert( pmp->hab, bOK );
            bOK = WinEndPaint( pmp->hpsClient );
            pmassert( pmp->hab, bOK );
         }
         return (MRESULT) 0;

      case MODE_BITMAP:
         if( pmp->hbm )
         {
            WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, (MPARAM)0, (MPARAM)0 );
            WinPostMsg( pmp->hwndObject, WM_USER_PAINT_BITMAP,
                        (MPARAM)hwnd, (MPARAM)0 );
         }
         /* must call default window proc for window validation */
         break;

      case MODE_METAFILE:
         hps = WinBeginPaint( hwnd, (HPS) 0, &rectl );
         pmassert( pmp->hab, hps );
         WinFillRect( hps, &rectl, SYSCLR_WINDOW );
         if( pmp->hmf )
         {
            WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, (MPARAM)0, (MPARAM)0 );
            WinPostMsg( pmp->hwndObject, WM_USER_PAINT_METAFILE,
                        (MPARAM)hwnd, (MPARAM)0 );
         }
         WinEndPaint( hps );
         return (MRESULT) 0;

      default:
         pmassert( pmp->hab, NULL == "bad case in WM_PAINT" );
      }
      break;


#ifdef OSA_AWARE
   case WM_SEMANTICEVENT:
      /* Handle Apple Event Manager Semantic Event */
      WinMessageBox( HWND_DESKTOP,
                     HWND_DESKTOP,
                     "WM_SEMANTIC_EVENT was received",
                     "WinProc",
                     (USHORT)0,
                     MB_OK | MB_NOICON);
      /* Call ProcessSemanticEvent to process the Apple Event */
      ProcessSemanticEvent( hwnd, msg, mp1, mp2 );
      return (MRESULT) 0;
#endif


   case WM_SIZE:
      /* Do size process if frame is not minimized  */
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );

      /*
       * If the object window is busy drawing, the GPI calls here can fail
       * because the PS is busy. Check for this situation and delay
       * the sizing operation by a few milliseconds.
       */
      if( pmp->fBusy )
      {
          WinStartTimer( pmp->hab, hwnd, ID_SIZE_TIMER, LEN_SIZE_TIMER );
          return (MRESULT) 0;
      }

      ulWork = WinQueryWindowULong( pmp->hwndFrame, QWL_STYLE );

      if( !( ulWork & WS_MINIMIZED ))
      {
         /* Frame is not minimized. Get window size in pels. */
         WinQueryWindowRect( hwnd, &rectl );

         /* how many twips will fit into the client window now? */
         bOK = GpiConvert( pmp->hpsClient, CVTC_DEVICE,
                           CVTC_WORLD, 2L, (PPOINTL)&rectl );
         pmassert( pmp->hab, bOK );

         /* compute client size in twips, store in pmp */
         pmp->sizelClient.cx = rectl.xRight - rectl.xLeft;
         pmp->sizelClient.cy = rectl.yTop   - rectl.yBottom;

         /* Try to keep the current position still in view by calculating */
         /* the difference between size required and client window. */
         /* The scroll position is then either 0 or the minimum of the */
         /* difference and the old scroll position */
         sNewPos = (LONG)FixedInchesToTwips(pmp->form.fxxWidth) +
                    (((float)(2 * OFFSET_XY_TWIPS)) / pmp->floatScale) -
                   pmp->sizelClient.cx;
         pmp->sHScrollPos = min( max( 0, sNewPos), pmp->sHScrollPos);
         sNewPos = (LONG)FixedInchesToTwips(pmp->form.fxyHeight) +
                    (((float)(2 * OFFSET_XY_TWIPS)) / pmp->floatScale) -
                   pmp->sizelClient.cy;
         pmp->sVScrollPos = min( max( 0, sNewPos), pmp->sVScrollPos);

         /* recalibrate the scroll bars */
         CalibrateHorizontalScrollBar( pmp );
         CalibrateVerticalScrollBar( pmp );

         /*
          * Modify def-view matrix translation to home the displayed page.
          * This depends on the current scaling value.
          */
         pmp->matlfDefView.lM31 = OFFSET_XY_TWIPS - (LONG)(pmp->floatScale *
                                                 (float)( pmp->sHScrollPos));
         pmp->matlfDefView.lM32 = OFFSET_XY_TWIPS + (LONG)(pmp->floatScale *
                          (float)( pmp->sVScrollPos - pmp->sVScrollRange ));
         bOK = GpiSetDefaultViewMatrix( pmp->hpsClient, 9,
                          &pmp->matlfDefView, TRANSFORM_REPLACE );
         pmassert( pmp->hab, bOK );

         /* force a paint */
         WinInvalidateRect( hwnd, NULL, FALSE );
      }
      return (MRESULT) 0;




   case WM_TIMER:
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );
      switch( (ULONG) mp1 )
      {
      case ID_DEATH_TIMER:
         /* object window never posted a quit in allotted time.
         WinPostMsg( hwnd, WM_QUIT, 0, 0 );
         break;
      case ID_SIZE_TIMER:
         /* object window was busy with the PS before; try sizing now */
         bOK = WinStopTimer( pmp->hab, hwnd, ID_SIZE_TIMER );
         pmassert( pmp->hab, bOK );
         WinSendMsg( hwnd, WM_SIZE, 0, 0 );
         break;
      }
      return (MRESULT) 0;





   case WM_USER_ACK:
      /*
       * Object window is done processing lengthy task.
       * mp1 contains the WM_USER msg originally posted to the object window
       * mp2 may contain a result code, depending on mp1
       */
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );

      /* reenable the client window */
      WinSendMsg( hwnd, WM_USER_ENABLE_CLIENT, (MPARAM)0, (MPARAM)0 );

      switch( (ULONG)mp1 )
      {
      case WM_USER_LOAD_BITMAP:
      case WM_USER_LOAD_METAFILE:
      case WM_USER_LOAD_TEXT:
         /*
          * Do size processing so that document will
          * "home" in the client window.
          */
         WinSendMsg( hwnd, WM_SIZE, (MPARAM)0, (MPARAM)0 );
         break;
      case WM_USER_PAGINATE:
         switch( (ULONG)mp2  )
         {
         case PAGINATE_EOF:
         case PAGINATE_EOF_PART_PAGE:
            /* seek top of file */
            fseek( pmp->f, 0, SEEK_SET );
         }
         WinInvalidateRect( hwnd, NULL, FALSE );
         break;
      }

      return (MRESULT) 0;


   case WM_USER_DISABLE_CLIENT:
      /*
       * usually disable before posting a task to the object window
       * this message may be sent; disable menu action bar as well
       */
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );
      pmp->fBusy = TRUE;
      WinEnableWindow( pmp->hwndClient,  FALSE );
      WinEnableWindow( pmp->hwndMenubar, FALSE );
      WinEnableControl( pmp->hwndFrame, FID_HORZSCROLL,  FALSE );
      WinEnableControl( pmp->hwndFrame, FID_VERTSCROLL,  FALSE );
      WinEnableMenuItem( pmp->hwndMenubar, IDM_PAGEDOWN, FALSE );
      WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWFULL, FALSE );
      WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWHALF, FALSE );
      return (MRESULT)0;


   case WM_USER_ENABLE_CLIENT:
      /*
       * usually enable upon receipt of object window ack/nack
       * this message may be sent; enable menu actions if text mode
       */
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );
      pmp->fBusy = FALSE;
      WinEnableWindow( pmp->hwndClient,  TRUE );
      WinEnableWindow( pmp->hwndMenubar, TRUE );
      WinEnableControl( pmp->hwndFrame, FID_HORZSCROLL,  TRUE );
      WinEnableControl( pmp->hwndFrame, FID_VERTSCROLL,  TRUE );
      WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWFULL, TRUE );
      WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWHALF, TRUE );
      if( pmp->ulMode == MODE_TEXT )
      {
         WinEnableMenuItem( pmp->hwndMenubar, IDM_PAGEDOWN, TRUE );
      }
      return (MRESULT) 0;



   case WM_USER_NEW_MODE:
      /*
       * The program now has a new file, file type, or printer, or
       * printer form, orientation, resolution, etc. The receipt
       * and processing of this message works to reset the program:
       * Old file, bitmap, or metafile handles are closed, and
       * new ones get opened. The titlebar shows the new filename.
       * This case works very much like a program reset.
       */
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );

      /* close processing on current file */

      switch( pmp->ulMode )
      {
      case MODE_BITMAP:
        /* destroy previous memory dc, ps, and hbm */
        if( pmp->hpsMemory )
        {
          GpiAssociate( pmp->hpsMemory, (HDC)0 );
          GpiDestroyPS( pmp->hpsMemory );
          pmp->hpsMemory = (HPS) 0;
        }
        if( pmp->hdcMemory )
        {
          DevCloseDC( pmp->hdcMemory );
          pmp->hdcMemory = (HDC) 0;
        }
        if( pmp->hbm )
        {
          GpiDeleteBitmap( pmp->hbm );
          pmp->hbm = (HBITMAP) 0;
        }
        break;

      case MODE_METAFILE:
        /* destroy old metafile handle */
        if( pmp->hmf )
        {
          GpiDeleteMetaFile( pmp->hmf );
          pmp->hmf = (HMF) 0;
        }
        break;

      case MODE_TEXT:
        fclose( pmp->f );
        pmp->f = (FILE *) 0;
        /* turn off options for text mode */
        WinEnableMenuItem( pmp->hwndMenubar, IDM_PAGEDOWN, FALSE );
        WinEnableMenuItem( pmp->hwndMenubar, IDM_SETFONT,  FALSE );
        break;
      }

      /* turn off options for all modes */
      WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWHALF, FALSE );
      WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWFULL, FALSE );
      WinEnableControl( pmp->hwndFrame, FID_HORZSCROLL,  FALSE );
      WinEnableControl( pmp->hwndFrame, FID_VERTSCROLL,  FALSE );

      /* copy over current values with the next values */
      pmp->ulMode = pmp->ulNextMode;
      strcpy( pmp->szFilename, pmp->szNextFilename );

      /* enable the print menu option if mode is known and there
         is a printer set up. */
      WinEnableMenuItem( pmp->hwndMenubar, IDM_PRINT,
       (pmp->ulMode != MODE_UNKNOWN && pmp->hpsPrinterInfo ) );


      /* update title bar text and show filename in use */
      if( *pmp->szFilename )
      {
         /* parse full-qualified filename to just get filename and extension */
         psz = strrchr( pmp->szFilename, '\\' );
         if (psz && *psz)
         {
             ++psz;
         }
         else
         {
             psz = pmp->szFilename;
         }
         sprintf( szWork, "%s - %s", pmp->pszTitle, psz );
      }
      else
      {
         strcpy( szWork, pmp->pszTitle );
      }
      WinSetWindowText( pmp->hwndTitlebar, szWork );

      /* enable options for all modes */
      WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWHALF, TRUE  );
      WinEnableMenuItem( pmp->hwndMenubar, IDM_VIEWFULL, TRUE  );
      WinEnableControl( pmp->hwndFrame, FID_HORZSCROLL,  TRUE  );
      WinEnableControl( pmp->hwndFrame, FID_VERTSCROLL,  TRUE  );

      /* process this new mode */
      switch( pmp->ulMode )
      {
      case MODE_BITMAP:
        /* load the bitmap into memory so it is compatible with the screen */
        WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, 0, 0 );
        WinPostMsg( pmp->hwndObject, WM_USER_LOAD_BITMAP,
                    (MPARAM)hwnd, (MPARAM)FLAGS_SCREEN );
        break;

      case MODE_METAFILE:
        /* make object window read metafile */
        WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, 0, 0 );
        WinPostMsg( pmp->hwndObject, WM_USER_LOAD_METAFILE, (MPARAM)hwnd, 0 );
        break;

      case MODE_TEXT:
        /* turn on options for text mode */
        WinEnableMenuItem( pmp->hwndMenubar, IDM_PAGEDOWN, TRUE  );
        WinEnableMenuItem( pmp->hwndMenubar, IDM_SETFONT,  TRUE  );
        /* reset view matrix that was last in effect for viewing text pages; */
        /* this gets lost after viewing a metafile */
        bOK = GpiSetDefaultViewMatrix( pmp->hpsClient, 9,
                                       &pmp->matlfDefView, TRANSFORM_REPLACE );
        pmassert( pmp->hab, bOK );
        /* disable until text loaded */
        WinSendMsg( hwnd, WM_USER_DISABLE_CLIENT, 0, 0 );
        /* tell object window to load the text file */
        bOK = WinPostMsg( pmp->hwndObject, WM_USER_LOAD_TEXT, (MPARAM)hwnd, 0 );
        pmassert( pmp->hab, bOK );
        break;


      case MODE_UNKNOWN:
        /* size screen to get correct scrollbars */
        WinPostMsg( pmp->hwndClient, WM_SIZE, 0, 0 );
        break;

      }
      return (MRESULT) 0;

   case WM_VSCROLL:
      pmp = (PMAIN_PARM) WinQueryWindowULong( hwnd, QWL_USER );

      /* Compute some fraction of scroll bar range for a unit of scrolling. */
      sStep  = pmp->sVScrollRange / 50;

      switch( SHORT2FROMMP( mp2 ))
      {
      case SB_LINEUP:
         pmp->sVScrollPos -= sStep;
         break;
      case SB_PAGEUP:
         pmp->sVScrollPos -= pmp->sizelClient.cy;
         break;
      case SB_LINEDOWN:
         pmp->sVScrollPos += sStep;
         break;
      case SB_PAGEDOWN:
         pmp->sVScrollPos += pmp->sizelClient.cy;
         break;
      case SB_SLIDERPOSITION:
      case SB_SLIDERTRACK:
         sNewPos          = SHORT1FROMMP( mp2 );
         pmp->sVScrollPos = sNewPos;
         break;
      }

      /* Don't allow step assignments to exceed limits of zero to range. */
      pmp->sVScrollPos = max( (SHORT)0,
                              min( pmp->sVScrollPos, pmp->sVScrollRange ));

      if( pmp->sVScrollPos != SHORT1FROMMR(WinSendMsg( pmp->hwndVScroll,
          SBM_QUERYPOS, (MPARAM)0, (MPARAM)0 )))
      {
         /*
          * New scroll bar thumbbutton position is different than current.
          * Set a new Y translation value to effect the scroll.
          * Current scale setting affects the Y element of the matrix.
          */
         pmp->matlfDefView.lM32 = OFFSET_XY_TWIPS + (LONG)(pmp->floatScale *
                          (float)( pmp->sVScrollPos - pmp->sVScrollRange ));

         pmp->matlfDefView.lM32 =  (LONG)(pmp->floatScale *
             (float)( OFFSET_XY_TWIPS +
                      pmp->sVScrollPos -
                      pmp->sVScrollRange ));

         bOK = GpiSetDefaultViewMatrix( pmp->hpsClient,
                                        9,
                                        &pmp->matlfDefView,
                                        TRANSFORM_REPLACE );
         pmassert( pmp->hab, bOK );
         CalibrateVerticalScrollBar( pmp );
         WinInvalidateRect( hwnd, NULL, FALSE );
      }
      return (MRESULT) 0;
   }
   return WinDefWindowProc( hwnd, msg, mp1, mp2 );
}  /* End of WinProc */
MRESULT EXPENTRY ClientWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2)
     {
     static INT aiPuzzle[NUMROWS][NUMCOLS],
                iBlankRow, iBlankCol, cxSquare, cySquare ;
     CHAR       szNum[10] ;
     HPS        hps ;
     HWND       hwndFrame ;
     INT        iRow, iCol, iMouseRow, iMouseCol, i ;
     POINTL     ptl ;
     RECTL      rcl, rclInvalid, rclIntersect ;
     SIZEL      sizl ;

     switch (msg)
          {
          case WM_CREATE:
                              // Calculate square size in pixels

               hps = WinGetPS (hwnd) ;
               sizl.cx = sizl.cy = 0 ;
               GpiSetPS (hps, &sizl, PU_LOENGLISH) ;
               ptl.x = SQUARESIZE ;
               ptl.y = SQUARESIZE ;
               GpiConvert (hps, CVTC_PAGE, CVTC_DEVICE, 1L, &ptl) ;
               WinReleasePS (hps) ;

               cxSquare = ptl.x ;
               cySquare = ptl.y ;

                              // Calculate client window size and position

               rcl.xLeft   = (WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN) -
                                           NUMCOLS * cxSquare) / 2 ;
               rcl.yBottom = (WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN) -
                                           NUMROWS * cySquare) / 2 ;
               rcl.xRight  = rcl.xLeft   + NUMCOLS * cxSquare ;
               rcl.yTop    = rcl.yBottom + NUMROWS * cySquare ;

                              // Set frame window position and size

               hwndFrame = WinQueryWindow (hwnd, QW_PARENT) ;
               WinCalcFrameRect (hwndFrame, &rcl, FALSE) ;
               WinSetWindowPos  (hwndFrame, NULLHANDLE,
                                 rcl.xLeft, rcl.yBottom,
                                 rcl.xRight - rcl.xLeft,
                                 rcl.yTop - rcl.yBottom,
                                 SWP_MOVE | SWP_SIZE | SWP_ACTIVATE) ;

                              // Initialize the aiPuzzle array

               WinSendMsg (hwnd, WM_COMMAND, MPFROMSHORT (IDM_NORMAL), NULL) ;
               return 0 ;

          case WM_PAINT:
               hps = WinBeginPaint (hwnd, NULLHANDLE, &rclInvalid) ;

                              // Draw the squares

               for (iRow = NUMROWS - 1 ; iRow >= 0 ; iRow--)
                    for (iCol = 0 ; iCol < NUMCOLS ; iCol++)
                         {
                         rcl.xLeft   = cxSquare * iCol ;
                         rcl.yBottom = cySquare * iRow ;
                         rcl.xRight  = rcl.xLeft   + cxSquare ;
                         rcl.yTop    = rcl.yBottom + cySquare ;

                         if (!WinIntersectRect (0, &rclIntersect,
                                                &rcl, &rclInvalid))
                              continue ;

                         if (iRow == iBlankRow && iCol == iBlankCol)
                              WinFillRect (hps, &rcl, CLR_BLACK) ;
                         else
                              {
                              WinDrawBorder (hps, &rcl, 5, 5,
                                             CLR_PALEGRAY, CLR_DARKGRAY,
                                             DB_STANDARD | DB_INTERIOR) ;

                              WinDrawBorder (hps, &rcl, 2, 2,
                                             CLR_BLACK, 0L, DB_STANDARD) ;

                              sprintf (szNum, "%d", aiPuzzle[iRow][iCol]) ;

                              WinDrawText (hps, -1, szNum,
                                           &rcl, CLR_WHITE, CLR_DARKGRAY,
                                           DT_CENTER | DT_VCENTER) ;
                              }
                         }
               WinEndPaint (hps) ;
               return 0 ;

          case WM_BUTTON1DOWN:
               iMouseCol = MOUSEMSG(&msg)->x / cxSquare ;
               iMouseRow = MOUSEMSG(&msg)->y / cySquare ;

                              // Check if mouse was in valid area

               if ( iMouseRow < 0          || iMouseCol < 0           ||
                    iMouseRow >= NUMROWS   || iMouseCol >= NUMCOLS    ||
                   (iMouseRow != iBlankRow && iMouseCol != iBlankCol) ||
                   (iMouseRow == iBlankRow && iMouseCol == iBlankCol))
                         break ;

                              // Move a row right or left

               if (iMouseRow == iBlankRow)
                    {
                    if (iMouseCol < iBlankCol)
                         for (iCol = iBlankCol ; iCol > iMouseCol ; iCol--)
                              aiPuzzle[iBlankRow][iCol] =
                                   aiPuzzle[iBlankRow][iCol - 1] ;
                    else
                         for (iCol = iBlankCol ; iCol < iMouseCol ; iCol++)
                              aiPuzzle[iBlankRow][iCol] =
                                   aiPuzzle[iBlankRow][iCol + 1] ;
                    }
                              // Move a column up or down
               else
                    {
                    if (iMouseRow < iBlankRow)
                         for (iRow = iBlankRow ; iRow > iMouseRow ; iRow--)
                              aiPuzzle[iRow][iBlankCol] =
                                   aiPuzzle[iRow - 1][iBlankCol] ;
                    else
                         for (iRow = iBlankRow ; iRow < iMouseRow ; iRow++)
                              aiPuzzle[iRow][iBlankCol] =
                                   aiPuzzle[iRow + 1][iBlankCol] ;
                    }
                              // Calculate invalid rectangle

               rcl.xLeft   = cxSquare *  min (iMouseCol, iBlankCol) ;
               rcl.yBottom = cySquare *  min (iMouseRow, iBlankRow) ;
               rcl.xRight  = cxSquare * (max (iMouseCol, iBlankCol) + 1) ;
               rcl.yTop    = cySquare * (max (iMouseRow, iBlankRow) + 1) ;

                              // Set new array and blank values

               iBlankRow = iMouseRow ;
               iBlankCol = iMouseCol ;
               aiPuzzle[iBlankRow][iBlankCol] = 0 ;

                              // Invalidate rectangle

               WinInvalidateRect (hwnd, &rcl, FALSE) ;
               break ;

          case WM_CHAR:
               if (!(CHARMSG(&msg)->fs & KC_VIRTUALKEY) ||
                     CHARMSG(&msg)->fs & KC_KEYUP)
                         return 0 ;

                              // Mimic a WM_BUTTON1DOWN message

               iMouseCol = iBlankCol ;
               iMouseRow = iBlankRow ;

               switch (CHARMSG(&msg)->vkey)
                    {
                    case VK_LEFT:   iMouseCol++ ;  break ;
                    case VK_RIGHT:  iMouseCol-- ;  break ;
                    case VK_UP:     iMouseRow-- ;  break ;
                    case VK_DOWN:   iMouseRow++ ;  break ;
                    default:        return 0 ;
                    }
               WinSendMsg (hwnd, WM_BUTTON1DOWN,
                           MPFROM2SHORT (iMouseCol * cxSquare,
                                         iMouseRow * cySquare), NULL) ;
               return 0 ;

          case WM_COMMAND:
               switch (COMMANDMSG(&msg)->cmd)
                    {
                              // Initialize aiPuzzle array

                    case IDM_NORMAL:
                    case IDM_INVERT:
                         for (iRow = 0 ; iRow < NUMROWS ; iRow++)
                              for (iCol = 0 ; iCol < NUMCOLS ; iCol++)
                                   aiPuzzle[iRow][iCol] = iCol + 1 +
                                        NUMCOLS * (NUMROWS - iRow - 1) ;

                         if (COMMANDMSG(&msg)->cmd == IDM_INVERT)
                              {
                              aiPuzzle[0][NUMCOLS-2] = NUMCOLS * NUMROWS - 2 ;
                              aiPuzzle[0][NUMCOLS-3] = NUMCOLS * NUMROWS - 1 ;
                              }
                         aiPuzzle[iBlankRow = 0][iBlankCol = NUMCOLS - 1] = 0 ;
                         WinInvalidateRect (hwnd, NULL, FALSE) ;
                         return 0 ;

                              // Randomly scramble the squares

                    case IDM_SCRAMBLE:
                         WinSetPointer (HWND_DESKTOP, WinQuerySysPointer (
                                        HWND_DESKTOP, SPTR_WAIT, FALSE)) ;

                         srand ((int) WinGetCurrentTime (0)) ;

                         for (i = 0 ; i < SCRAMBLEREP ; i++)
                              {
                              WinSendMsg (hwnd, WM_BUTTON1DOWN,
                                   MPFROM2SHORT (rand() % NUMCOLS * cxSquare,
                                        iBlankRow * cySquare), NULL) ;
                              WinUpdateWindow (hwnd) ;

                              WinSendMsg (hwnd, WM_BUTTON1DOWN,
                                   MPFROM2SHORT (iBlankCol * cxSquare,
                                        rand() % NUMROWS * cySquare), NULL) ;
                              WinUpdateWindow (hwnd) ;
                              }
                         WinSetPointer (HWND_DESKTOP, WinQuerySysPointer (
                                        HWND_DESKTOP, SPTR_ARROW, FALSE));
                         return 0 ;
                    }
               break ;
          }
     return WinDefWindowProc (hwnd, msg, mp1, mp2) ;
     }
VOID QueryDrives (HWND hWnd)
{
    PFSQBUFFER2        pfsq2;
    ULONG              ulLen,
                       ulInx,
                       ulAction,
                       ulParmLen,
                       ulDataLen;
    APIRET             RetCode;
    HFILE              hFile;
    BIOSPARAMETERBLOCK bpb;
    CHAR               szDrive[3] = " :";
    BYTE               cBlock     = 0;

    WinSetPointer (HWND_DESKTOP, 
        WinQuerySysPointer (HWND_DESKTOP,SPTR_WAIT,FALSE));

    /* Allocate buffer */
    DosAllocMem ((PPVOID)&pfsq2, 1024L, fALLOC);

    DosError (FERR_DISABLEHARDERR);

    ulNumDrives = 0L;

    for (ulInx = 0; ulInx < 26; ulInx++)
    {
        szDrive[0] = (CHAR)('A' + ulInx);

        ulLen = 1024L;
        RetCode = DosQueryFSAttach (szDrive, 0L, FSAIL_QUERYNAME, pfsq2, &ulLen);

        DriveInfo[ulNumDrives].szDrive[0]         = szDrive[0];
        DriveInfo[ulNumDrives].szDrive[1]         = '\0';

        if (RetCode == ERROR_NOT_READY)
        {
            /* Assume local, removable, and FAT file system */
            strcpy (DriveInfo[ulNumDrives].szLocation,   "Local");
            strcpy (DriveInfo[ulNumDrives].szRemovable,  "Yes");
            strcpy (DriveInfo[ulNumDrives].szFileSystem, "FAT");
            DriveInfo[ulNumDrives].ulDescriptionIndex = 10L;
            ulNumDrives++;
        }
        else if (RetCode != ERROR_INVALID_DRIVE)
        {
            bpb.fsDeviceAttr = 0;

            /* Attempt to open the device */
            if (!DosOpen (szDrive, &hFile, &ulAction, 0L,
                FILE_NORMAL, FILE_OPEN, OPEN_FLAGS_DASD | OPEN_SHARE_DENYNONE, 0L))
            {
                ulParmLen = sizeof(BYTE);
                ulDataLen = sizeof(BIOSPARAMETERBLOCK);
                DosDevIOCtl (hFile, IOCTL_DISK, DSK_GETDEVICEPARAMS,
                    (PVOID)&cBlock, ulParmLen, &ulParmLen,
                    (PVOID)&bpb, ulDataLen, &ulDataLen);
                DosClose (hFile);
            }
            else
            {
                /* Remote drives may not allow themselves to be opened
                   with the OPEN_FLAGS_DASD access flag.  Default to
                   not removable and description of unknown. */
                bpb.fsDeviceAttr = 0x0001;
                bpb.bDeviceType  = 7;
            }

            /* Is the drive remote?      */
            if (pfsq2->iType == FSAT_REMOTEDRV)
                strcpy (DriveInfo[ulNumDrives].szLocation, "Remote");
            else
                strcpy (DriveInfo[ulNumDrives].szLocation, "Local");

            /* Is the drive removable?   */
            if (bpb.fsDeviceAttr & 0x0001)
                strcpy (DriveInfo[ulNumDrives].szRemovable, "No");
            else
                strcpy (DriveInfo[ulNumDrives].szRemovable, "Yes");
                                  
            /* Set the description index */
            if (bpb.bDeviceType < 10)
                DriveInfo[ulNumDrives].ulDescriptionIndex = (LONG)bpb.bDeviceType;
            else
                DriveInfo[ulNumDrives].ulDescriptionIndex = 7L;

            /* Set the file system name  */
            strncpy (DriveInfo[ulNumDrives].szFileSystem,
                       (PSZ)(pfsq2->szName + 1 + pfsq2->cbName), 15);

            ulNumDrives++;
        }
    }

    DosError (FERR_ENABLEHARDERR);

    DosFreeMem (pfsq2);

    /* Add items to the drive listbox */
    for (ulInx = 0; ulInx < ulNumDrives; ulInx++)
        WinSendDlgItemMsg (hWnd, IDC_DRIVELIST, LM_INSERTITEM, (MPARAM)LIT_END, 
            DriveInfo[ulInx].szDrive);
    WinSendDlgItemMsg (hWnd, IDC_DRIVELIST, LM_SELECTITEM, 0L, (MPARAM)TRUE);

    WinSetPointer (HWND_DESKTOP, 
        WinQuerySysPointer (HWND_DESKTOP,SPTR_ARROW,FALSE));
    return;
}
Esempio n. 28
0
static MRESULT APIENTRY Button1Up ( HWND Window, MESG, MPARAM1 mp1, MPARAM2 ) {

 /***************************************************************************
  * Find the instance data.                                                 *
  ***************************************************************************/

  PDATA Data = PDATA ( Sys_GetWindowData ( Window ) ) ;

 /***************************************************************************
  * If the mouse wasn't captured, return.                                   *
  ***************************************************************************/

  if ( NOT Data->Capture )
    return ( MRFROMSHORT ( FALSE ) ) ;

 /***************************************************************************
  * Get the presentation space.                                             *
  ***************************************************************************/

  WorkSpace PS ( "HRuler::Button1Up", 0, Window, Data->pDevice, int(Data->Metric) ) ;
  PS.SetTransform ( Data->fxZoom, int(Data->TopLeft), 0 ) ;

 /***************************************************************************
  * Find out where the mouse touched.                                       *
  ***************************************************************************/

  RECTL Rectangle ;
  WinQueryWindowRect ( Window, &Rectangle ) ;

  POINTL Mouse = { SHORT1FROMMP(mp1), SHORT2FROMMP(mp1) } ;
  PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, 1, &Mouse ) ;

  PS.Transform ( CVTC_DEVICE, CVTC_DEFAULTPAGE, Rectangle ) ;

  POINTL ButtonSize = { 8, 8 } ;
  PS.Transform ( CVTC_DEVICE, CVTC_PAGE, 1, &ButtonSize ) ;

  #ifdef DEBUG
     Log ( "HRuler::Button1Up:   Mouse at %i,%i (%i,%i).  Rectangle %i,%i-%i,%i.  ButtonSize %i.%i (8x8).",
        Mouse.x, Mouse.y, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1), 
        Rectangle.xLeft, Rectangle.yBottom, Rectangle.xRight, Rectangle.yTop,
        ButtonSize.x, ButtonSize.y ) ;
  #endif

 /***************************************************************************
  * Erase the previous hairline.                                            *
  ***************************************************************************/

  PS.SetMix ( FM_INVERT ) ;
  PS.SetLineType ( LINETYPE_ALTERNATE ) ;
  POINTL Point = { Data->Tick, Rectangle.yBottom } ;
  PS.Move ( Point ) ;
  Point.y = Rectangle.yTop ;
  PS.DrawLine ( Point ) ;

 /***************************************************************************
  * Release the mouse.                                                      *
  ***************************************************************************/

  Data->Capture = FALSE ;
  Sys_ReleaseCapture ( ) ;

 /***************************************************************************
  * Restore the normal mouse pointer.                                       *
  ***************************************************************************/

  HPOINTER Ptr = WinQuerySysPointer ( HWND_DESKTOP, SPTR_ARROW, FALSE ) ;
  WinSetPointer ( HWND_DESKTOP, Ptr ) ;

 /***************************************************************************
  * Restore the keyboard focus.                                             *
  ***************************************************************************/

  Sys_SetFocus ( Data->HadFocus ) ;

 /***************************************************************************
  * Process final location of mouse.                                        *
  ***************************************************************************/

  switch ( Data->Mode ) {

    case MOVELEFT:
    {
      Data->Tick = TICK(Mouse.x) ;
      if ( ( Data->Tick < 0 ) OR ( Data->Tick >= Data->RightMargin ) )
      {
        Sys_BeepError ( ) ;
        break ;
      }
      Sys_SendMessage ( OWNER(Window), WM_SET_LEFTMARGIN, MPFROMLONG(Data->Tick), 0 ) ;
      break ;
    }

    case MOVERIGHT:
    {
      Data->Tick = TICK(Mouse.x) ;
      if ( ( Data->Tick <= Data->LeftMargin ) OR ( Data->Tick > Data->PageWidth ) )
      {
        Sys_BeepError ( ) ;
        break ;
      }
      Sys_SendMessage ( OWNER(Window), WM_SET_RIGHTMARGIN, MPFROMLONG(Data->Tick), 0 ) ;
      break ;
    }

    case MOVETAB:
    {
      Data->Tick = TICK(Mouse.x) ;
      if ( ( Mouse.y > Rectangle.yTop )
        OR ( Mouse.y < Rectangle.yBottom )
        OR ( Data->Tick <= Data->LeftMargin )
        OR ( Data->Tick >= Data->RightMargin ) )
      {
        Sys_SendMessage ( OWNER(Window), WM_CLEAR_TAB, MPFROMLONG(Data->Tabs[Data->TabIndex]), 0 ) ;
        break ;
      }

      Sys_SendMessage ( OWNER(Window), WM_MOVE_TAB, MPFROMLONG(Data->Tabs[Data->TabIndex]), MPFROMLONG(Data->Tick) ) ;
      break ;
    }

    case SETTAB:
    {
      Data->Tick = TICK(Mouse.x) ;
      if ( ( Mouse.y > Rectangle.yTop )
        OR ( Mouse.y < Rectangle.yBottom )
        OR ( Data->Tick <= Data->LeftMargin )
        OR ( Data->Tick >= Data->RightMargin ) )
      {
        Sys_BeepError ( ) ;
        break ;
      }

      Sys_SendMessage ( OWNER(Window), WM_SET_TAB, MPFROMLONG(Data->Tick), 0 ) ;
      break ;
    }
  }

 /***************************************************************************
  * Reset mode.                                                             *
  ***************************************************************************/

  Data->Mode = NOTMOVING ;

 /***************************************************************************
  * We're done.                                                             *
  ***************************************************************************/

  return ( MRFROMSHORT ( TRUE ) ) ;
}
VOID main()
{

  if ( (hab = WinInitialize( 0L )) == (HAB) NULL ){
     printf( "ToolBar Error:  WinInitialize failed \n" );
     return;
  }
  else {
     if ( (hmq = WinCreateMsgQueue( hab, 0 )) == (HMQ) NULL ){
        printf( "ToolBar Error:  WinCreateMsgQueue failed \n" );
        return;
     }
     else {

       ULONG fulCreate= FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER |
                        FCF_MINMAX | FCF_SHELLPOSITION | FCF_ICON  ;
               /*
                *  Note: no menu was specificed in create flags
                */

        WinSetPointer( HWND_DESKTOP,
                       WinQuerySysPointer(HWND_DESKTOP,SPTR_WAIT,TRUE));

        WinRegisterClass(hab, szClassName, (PFNWP)MainWindowProc, CS_SIZEREDRAW, 0);

        hwndFrame = WinCreateStdWindow(HWND_DESKTOP,
                                       0L,
                                       (PULONG)&fulCreate,
                                       szClassName ,
                                       szMainTitle,
                                       0L,
                                       (HMODULE)NULL,
                                       ID_MAIN_WIN,
                                       &hwndClient);
        if ( hwndFrame == NULLHANDLE ) {
           ShowErrorWindow( "Error creating Main window !", TRUE );
        }
        else {
           PFNWP     pfnwpOldFrameProc ;

             /* ---------  subclass frame proc  ------------------ */
           pfnwpOldFrameProc = WinSubclassWindow( hwndFrame,
                                                  (PFNWP) NewFrameProc );
           if ( pfnwpOldFrameProc == (PFNWP)0L ){
               ShowErrorWindow( "Error subclassing frame window !", TRUE );
           }
           else {
              PID       pid ;
              SWCNTRL   swCntrl;
              HSWITCH   hSwitch ;
              LONG      lRGB;

                /* -------  store old frame proc with handle  ------- */
              WinSetWindowULong( hwndFrame,
                                 QWL_USER,
                                 (ULONG) pfnwpOldFrameProc );

                /* ------------------ load menus  ------------------- */
              hwndMenuBar = WinLoadMenu( hwndFrame,
                                         (HMODULE)NULL,
                                         MID_MENUBAR );

              hwndToolBar = WinLoadMenu( hwndFrame,
                                         (HMODULE)NULL,
                                         MID_TOOLBAR );
                /*
                 *  Note that the last menu loaded, the toolbar, is the
                 *  one that is associated with the frame as "the" menu.
                 *  this means that hwndMenuBar is the only link to the
                 *  regular action bar, so hang onto it tightly
                 */

                /* ---------- set toolbar background color ---------- */
              lRGB =  WinQuerySysColor( HWND_DESKTOP, SYSCLR_BUTTONDARK, 0L );
              WinSetPresParam( hwndToolBar,
                               PP_BACKGROUNDCOLOR,
                               4L,
                               (PVOID)lRGB );

                /* ---------  set window size and pos  -------------- */
              WinSetWindowPos( hwndFrame,
                               HWND_TOP,
                               0, 0, 370, 300, 
                               SWP_SIZE | SWP_SHOW | SWP_ACTIVATE );

               /* ----------- add program to tasklist  --------------- */
              WinQueryWindowProcess( hwndFrame, &pid, NULL );
              swCntrl.hwnd = hwndFrame ;
              swCntrl.hwndIcon = (HWND) NULL ;
              swCntrl.hprog = (HPROGRAM) NULL ;
              swCntrl.idProcess = pid ;
              swCntrl.idSession = (LONG) NULL ;
              swCntrl.uchVisibility = SWL_VISIBLE ;
              swCntrl.fbJump = SWL_JUMPABLE ;
              sprintf( swCntrl.szSwtitle, szMainTitle );
              hSwitch = WinAddSwitchEntry((PSWCNTRL)&swCntrl);


              WinSetPointer(HWND_DESKTOP,
                            WinQuerySysPointer(HWND_DESKTOP,SPTR_ARROW,TRUE));

                 /* ---------- start the main processing loop ----------- */
              while (WinGetMsg(hab, &qmsg,NULLHANDLE,0,0)){
                  WinDispatchMsg(hab, &qmsg);
              }

              WinRemoveSwitchEntry( hSwitch );
           } /* end of else ( pfnwpOldFrameProc ) */

           WinSetPointer(HWND_DESKTOP,
                         WinQuerySysPointer(HWND_DESKTOP,SPTR_ARROW,TRUE));
           WinDestroyWindow(hwndFrame);
        }  /* end of else (hwndFrame == NULLHANDLE) */

        WinSetPointer(HWND_DESKTOP,
                      WinQuerySysPointer(HWND_DESKTOP,SPTR_ARROW,TRUE));
        WinDestroyMsgQueue(hmq);
     }  /* end of else ( ...WinCreateMsgQueue() */

   WinTerminate(hab);
   }  /* end of else (...WinInitialize(NULL) */
}  /*  end of main() */
Esempio n. 30
0
static VOID _wmMouseMove(PGROPDATA pGrop, SHORT lX, SHORT lY)
{
  POINTL     pointl;

  if ( ( pGrop->hptrPointer == NULLHANDLE ) &&
       ( pGrop->fCapture /*|| pGrop->fFullscreen*/ ) )
  {
    // Unvisible pointer when mouse captured /*or fullscreen*/ - relative mouse
    // mode. Send relative mouse coordinates (offset) to the application.

    // Mouse pointer is unvisible.
    WinSetPointer( pGrop->hwndDT, NULLHANDLE );

    // Internal information about pointer in relative coordinates mode.
    pGrop->fMouseInViewArea = TRUE;
    pGrop->ulMouseX = pGrop->stUserMode.ulWidth / 2;
    pGrop->ulMouseY = pGrop->stUserMode.ulHeight / 2;

    // Center of the window in window coordinates.
    pointl.x = ( pGrop->rectlWinArea.xRight -
                 pGrop->rectlWinArea.xLeft ) / 2;
    pointl.y = ( pGrop->rectlWinArea.yTop -
                 pGrop->rectlWinArea.yBottom ) / 2;

    // Call user's function with relative coordinates.
    if ( pGrop->stCallback.fnMouseMove != NULL )
      pGrop->stCallback.fnMouseMove( pGrop, TRUE,
                                     lX - pointl.x, lY - pointl.y );

    // Keep mouse at center of the window.

    // Center of the window in screen coordinates.
    pointl.x = ( pGrop->rectlWinArea.xRight +
                 pGrop->rectlWinArea.xLeft ) / 2;
    pointl.y = ( pGrop->rectlWinArea.yTop +
                 pGrop->rectlWinArea.yBottom ) / 2;
    // Do not handle mouse move message when we moves to center of the window.
    pGrop->lSkipMouseMove++;
    if ( !WinSetPointerPos( pGrop->hwndDT, pointl.x, pointl.y ) )
      debug( "WinSetPointerPos() failed" );

    return;
  }

  if ( pGrop->fFullscreen || ( pGrop->fCapture && pGrop->fActive ) )
  {
    // Restrict the movement of the mouse view area.
    SHORT    lXva = lX, lYva = lY;

    if ( lX < pGrop->rectlViewArea.xLeft )
      lX = pGrop->rectlViewArea.xLeft;
    else if ( lX >= pGrop->rectlViewArea.xRight )
      lX = pGrop->rectlViewArea.xRight - 1;
    if ( lY < pGrop->rectlViewArea.yBottom )
      lY = pGrop->rectlViewArea.yBottom;
    else if ( lY >= pGrop->rectlViewArea.yTop )
      lY = pGrop->rectlViewArea.yTop - 1;

    if ( lX != lXva || lY != lYva )
    {
      pointl.x = lX;
      pointl.y = lY;
      WinMapWindowPoints( pGrop->hwnd, pGrop->hwndDT, &pointl, 1 );
      pGrop->lSkipMouseMove++;
      WinSetPointerPos( pGrop->hwndDT, pointl.x, pointl.y );
    }
  }

  // Set application pointer when mouse on the view area or system pointer
  // when it on "unused" space of window (around view area in our window).
  pointl.x = lX;
  pointl.y = lY;
  WinSetPointer( pGrop->hwndDT,
                 WinPtInRect( pGrop->hab, &pGrop->rectlViewArea, &pointl )
                   ? pGrop->hptrPointer
                   : WinQuerySysPointer( HWND_DESKTOP, SPTR_ARROW, FALSE ) );

  pGrop->fMouseInViewArea = 
    lX >= pGrop->rectlViewArea.xLeft && lX < pGrop->rectlViewArea.xRight &&
    lY >= pGrop->rectlViewArea.yBottom && lY < pGrop->rectlViewArea.yTop;

  if ( pGrop->fMouseInViewArea )
  {
    ULONG      ulVAWidth = pGrop->rectlViewArea.xRight -
                           pGrop->rectlViewArea.xLeft;
    ULONG      ulVAHeight = pGrop->rectlViewArea.yTop -
                            pGrop->rectlViewArea.yBottom;

    // Set coordinates relative to the bottom-left corner of the view area.
    lX -= pGrop->rectlViewArea.xLeft;
    lY -= pGrop->rectlViewArea.yBottom;

    // Scale coordinates to the user work area.
    lX = pGrop->stUserMode.ulWidth * lX / ulVAWidth;
    lY = pGrop->stUserMode.ulHeight * lY / ulVAHeight;

    if ( ( pGrop->ulMouseX != lX ) || ( pGrop->ulMouseY != lY ) )
    {
      // Coordinates hava been changed.

      pGrop->ulMouseX = lX;
      pGrop->ulMouseY = lY;

      // Call user's function.
      if ( pGrop->stCallback.fnMouseMove != NULL )
        pGrop->stCallback.fnMouseMove( pGrop, FALSE, lX, lY );
    }
  }
}