コード例 #1
0
void        LocateObject( HWND hwnd)

{
    ULONG           rc = 0;
    HWND            hRtn;
    ULONG           ulHndl;
    PRWSHDR         pHdr = 0;
    PMINIRECORDCORE pRec;

do
{
    pRec = precMenu;
    precMenu = 0;

    // this should only be called if the single-object menu was used
    if (pRec == 0)
        ERRNBR( 1)

    // get the object's handle from the Key column,
    ulHndl = strtoul( ((char**)&pRec[1])[eKEY], 0, 10);

    // RWSCMD_LOCATE opens the folder containing the target object,
    // then moves the selection to it, scrolling the window if needed
    ERRRTN( RwsCall( &pHdr, RWSP_CMD,   RWSCMD_LOCATE,
                            RWSR_ASIS,  0, 1,
                            RWSI_OHNDL, 0, ulHndl))     // object

    // if this isn't the active window, the focus is not ours to give away
    if (WinQueryActiveWindow( HWND_DESKTOP) != hwnd)
        break;

    // get the hwnd of the target window, then move the focus to it
    hRtn = RwsGetResult( pHdr, 0, 0);
    if (hRtn == 0 || hRtn == (ULONG)-1)
        ERRNBR( 2)

    WinFocusChange( HWND_DESKTOP, hRtn, 0);

} while (fFalse);

    if (rc)
    {
        RwsGetRcString( rc, sizeof( szError), szError);
        printf( "LocateObject:  rc= %d %s\n", rc, szError);
    }

    // free the server request block
    RwsFreeMem( pHdr);

    return;
}
コード例 #2
0
ファイル: OS2WIN.CPP プロジェクト: OS2World/APP-EDITOR-Kon
void SComboBox::ComboListBox::setFocus()
{
  WinFocusChange( HWND_DESKTOP, getHWNDFrame(), FC_NOLOSEFOCUS|FC_NOLOSEACTIVE|FC_NOLOSESELECTION);
}
コード例 #3
0
/****************************************************************************
   Main Message Cue Dialog Procedure
*****************************************************************************/
MRESULT EXPENTRY MainDlgProc (HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
    {
        BOOL    Handled = TRUE;
        MRESULT mReturn  = 0;
        ULONG   ulScrWidth, ulScrHeight;
        RECTL   Rectl;
        POINTL  Pointl;
        HINI    hini;
        ULONG   temp;

        switch (msg)
            {

                /* Called on startup */
                case WM_INITDLG:
                    ulScrWidth  = WinQuerySysValue (HWND_DESKTOP, SV_CXSCREEN);
                    ulScrHeight = WinQuerySysValue (HWND_DESKTOP, SV_CYSCREEN);
                    UPDATE_HOURS = TRUE;
                    UPDATE_DATE = TRUE;
                    DTSWITCH = FALSE;
                    hini = HINI_USERPROFILE;
                    Pointl.x = Pointl.y = 10;
                    if(PrfQueryProfileSize(hini,pAppname,pKeyname,(PULONG)&temp) &&temp)
                        { 
                            if(temp == sizeof(POINTL)) PrfQueryProfileData(hini, pAppname,
                                                       pKeyname, &Pointl, (PULONG)&temp);
                        }
                    WinQueryWindowRect (hWnd, &Rectl);
/*
                    WinSetWindowPos (hWnd, HWND_TOP, Pointl.x,
                            Pointl.y, 0, 0, SWP_SHOW | SWP_MOVE | SWP_ACTIVATE);
*/
                    WinSetWindowPos (hWnd, HWND_TOP, (ulScrWidth-Rectl.xRight)/2,
                            (ulScrHeight-Rectl.yTop) - 10, 0, 0, SWP_SHOW | SWP_MOVE | SWP_ACTIVATE);
                    /* A neat little trick to float the window on top... */
                    WinFocusChange(HWND_DESKTOP,HWND_TOP,0);
                    timerID = WinStartTimer(hab, hWnd, 1, 1000L);
                    break;
                case WM_TIMER:
                    if(SHORT1FROMMP(mp1) == timerID)
                        {
                            while(DosGetDateTime( &(datetime[DTSWITCH?1:0]) ));
                            UPDATE_HOURS = (    (datetime[DTSWITCH?1:0].minutes != datetime[DTSWITCH?0:1].minutes)
                                             || (datetime[DTSWITCH?1:0].hours   != datetime[DTSWITCH?0:1].hours  ) );
                            UPDATE_DATE |= (    (datetime[DTSWITCH?1:0].day     != datetime[DTSWITCH?0:1].day    )
                                             || (datetime[DTSWITCH?1:0].weekday != datetime[DTSWITCH?0:1].weekday)
                                             || (datetime[DTSWITCH?1:0].month   != datetime[DTSWITCH?0:1].month  )
                                             || (datetime[DTSWITCH?1:0].year    != datetime[DTSWITCH?0:1].year   ) );
                            ClockSetDateString( &(datetime[DTSWITCH?1:0]));
                            DTSWITCH = !DTSWITCH;
                            if(UPDATE_HOURS)
                                {
                                    WinSetDlgItemText (hWnd, IDD_TIME, szHours);
                                    if(UPDATE_DATE)
                                        { 
                                            WinSetWindowText(hWndFrame,(PSZ)szTitle);
                                            UPDATE_DATE = FALSE;
                                        }
                                            UPDATE_HOURS = FALSE;
                                }
                            WinSetDlgItemText (hWnd, IDD_SEC, szSecs);
                        }
                    Handled = FALSE;
                    break;
                case WM_SYSCOMMAND:
                case WM_COMMAND:
                    switch (LOUSHORT(mp1))
                      {
                            case SC_CLOSE:
                                hini = HINI_USERPROFILE;
                                WinStopTimer(hab, hWnd, timerID);
                                Pointl.x = Pointl.y = 0;
                                WinMapWindowPoints(hWnd, HWND_DESKTOP, &Pointl, 1);
                                temp = sizeof(POINTL);
                                PrfWriteProfileData(hini, pAppname, pKeyname, &Pointl, temp);
                                WinPostMsg(hWnd, WM_QUIT, 0L, 0L);
                                break;
                            default:
                                Handled = (msg == WM_COMMAND);
                                break;
                        }
                    break; // forget this break and you are in dead trouble !!!
                default:
                    Handled = FALSE;
                    break;
            }
        if (!Handled) mReturn = WinDefDlgProc (hWnd, msg, mp1, mp2);
        return (mReturn);
    }
コード例 #4
0
  /* Message processing for our PM Window class */
  MRESULT EXPENTRY  Message_Process( HWND    handle,
                                     ULONG   mess,
                                     MPARAM  parm1,
                                     MPARAM  parm2 )
  {
     static HDC     screen_dc;
     static HPS     screen_ps;
     static BOOL    minimized;

     SIZEL   sizl;
     SWP     swp;

     grPMSurface*  surface;

    /* get the handle to the window's surface -- note that this */
    /* value will be null when the window is created            */
    surface = (grPMSurface*)WinQueryWindowPtr( handle, QWL_USER );
    if (!surface)
    {
      surface = the_surface;
      WinSetWindowPtr( handle, QWL_USER, surface );
    }

    switch( mess )
    {
    case WM_DESTROY:
      /* warn the main thread to quit if it didn't know */
      surface->event.type = gr_event_key;
      surface->event.key  = grKeyEsc;
      DosPostEventSem( surface->event_lock );
      break;

    case WM_CREATE:
      /* set original magnification */
      minimized = FALSE;

      /* create Device Context and Presentation Space for screen. */
      screen_dc = WinOpenWindowDC( handle );
      screen_ps = GpiCreatePS( surface->anchor,
                               screen_dc,
                               &sizl,
                               PU_PELS | GPIT_MICRO |
                               GPIA_ASSOC | GPIF_DEFAULT );
      /* take the input focus */
      WinFocusChange( HWND_DESKTOP, handle, 0L );
      LOG(( "screen_dc and screen_ps have been created\n" ));

      /* To permit F9, F10 and others to pass through to the application */
      if (TRUE != WinSetAccelTable (surface->anchor, 0, surface->frame_window))
      {
        printf( "Error - failed to clear accel table\n");
      }
      break;

    case WM_MINMAXFRAME:
      /* to update minimized if changed */
      swp = *((PSWP) parm1);
      if ( swp.fl & SWP_MINIMIZE )
        minimized = TRUE;
      if ( swp.fl & SWP_RESTORE )
        minimized = FALSE;
      return WinDefWindowProc( handle, mess, parm1, parm2 );
      break;

    case WM_ERASEBACKGROUND:
    case WM_PAINT:
      /* copy the memory image of the screen out to the real screen */
      LOCK( surface->image_lock );
      WinBeginPaint( handle, screen_ps, NULL );

      /* main image and magnified picture */
      GpiBitBlt( screen_ps,
                 surface->image_ps,
                 4L,
                 surface->blit_points,
                 ROP_SRCCOPY, BBO_AND );

      WinEndPaint( screen_ps );
      UNLOCK( surface->image_lock );
      break;

    case WM_HELP:  /* this really is a F1 Keypress !! */
      surface->event.key = grKeyF1;
      goto Do_Key_Event;

    case WM_CHAR:
      if ( CHARMSG( &mess )->fs & KC_KEYUP )
        break;

      /* look for a specific vkey */
      {
        int          count = sizeof( key_translators )/sizeof( key_translators[0] );
        Translator*  trans = key_translators;
        Translator*  limit = trans + count;

        for ( ; trans < limit; trans++ )
          if ( CHARMSG(&mess)->vkey == trans->os2key )
          {
            surface->event.key = trans->grkey;
            goto Do_Key_Event;
          }
      }

      /* otherwise, simply record the character code */
      if ( (CHARMSG( &mess )->fs & KC_CHAR) == 0 )
        break;

      surface->event.key = CHARMSG(&mess)->chr;

    Do_Key_Event:
      surface->event.type = gr_event_key;
      DosPostEventSem( surface->event_lock );
      break;

    default:
      return WinDefWindowProc( handle, mess, parm1, parm2 );
    }

    return (MRESULT) FALSE;
  }
コード例 #5
0
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;
}
コード例 #6
0
void        OpenObject( HWND hwnd)

{
    ULONG           rc = 0;
    HWND            hRtn;
    ULONG           ulHndl;
    ULONG           ulView;
    char *          ptr;
    PRWSHDR         pHdr = 0;
    PMINIRECORDCORE pRec;

do
{
    pRec = precMenu;
    precMenu = 0;

    // this should only be called if the single-object menu was used
    if (pRec == 0)
        ERRNBR( 1)

    // get the object's handle from the Key column,
    // then get the view this entry refers to
    ulHndl = strtoul( ((char**)&pRec[1])[eKEY], 0, 10);
    ptr = strchr( ((char**)&pRec[1])[eKEY], '@');
    if (ptr)
        ulView = strtoul( ++ptr, 0, 10) / 10;
    else
        ulView = 0;

    // RWSCMD_OPEN is similar to wpViewObject() except that it reliably
    // returns the hwnd of the target object;  it's also preferable in
    // RWS terms because it opens new windows on the WPS's primary (UI)
    // thread rather than on RwsServer's thread
    ERRRTN( RwsCall( &pHdr, RWSP_CMD,   RWSCMD_OPEN,
                            RWSR_ASIS,  0, 3,
                            RWSI_OHNDL, 0, ulHndl,      // object
                            RWSI_ASIS,  0, ulView,      // view
                            RWSI_ASIS,  0, 0))          // fNew = FALSE

    // if this isn't the active window, the focus is not ours to give away
    if (WinQueryActiveWindow( HWND_DESKTOP) != hwnd)
        break;

    // get the hwnd of the target window, then move the focus to it
    hRtn = RwsGetResult( pHdr, 0, 0);
    if (hRtn == 0 || hRtn == (ULONG)-1)
        ERRNBR( 2)

    WinFocusChange( HWND_DESKTOP, hRtn, 0);

} while (fFalse);

    if (rc)
    {
        RwsGetRcString( rc, sizeof( szError), szError);
        printf( "OpenObject:  rc= %d %s\n", rc, szError);
    }

    // free the server request block
    RwsFreeMem( pHdr);

    return;
}
コード例 #7
0
MRESULT EXPENTRY Dlg_OutputPage (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
{
     switch( msg )
     {
     case WM_INITDLG:
         {
             HWND path = WinWindowFromID(hwnd,OUT_PATH);
             HWND max  = WinWindowFromID(hwnd,OUT_MB);
             WinSendMsg(path,EM_SETTEXTLIMIT,MPFROM2SHORT(1024,TRUE),MPFROM2SHORT(0,TRUE));
             WinSendMsg(max,EM_SETTEXTLIMIT,MPFROM2SHORT(6,TRUE),MPFROM2SHORT(0,TRUE));
             
             WinSetWindowText(path,p_config->getBaseDir());
             char *num_str = new char[1024];
             sprintf(num_str,"%d",p_config->getMaxDownload());
             WinSetWindowText(max,num_str);
             delete[] num_str;
         }
         break;

     case WM_CLOSE:
         {
             char *buffer = new char[1024];
             WinQueryWindowText(WinWindowFromID(hwnd,OUT_PATH),1023,buffer);
             lrSpaceTrim(buffer);
             p_config->setBaseDir(buffer);
             
             WinQueryWindowText(WinWindowFromID(hwnd,OUT_MB),1023,buffer);
             ULONG value = atol(buffer);
             p_config->setMaxDownload(value);
             
             delete[] buffer;
         }

	 return 0;	// 06 Mar 01 SHL

     case WM_CONTROL:
         switch(SHORT2FROMMP(mp1))
         {
         case EN_CHANGE:
             {
                 switch (SHORT1FROMMP(mp1))
                 {
                     case OUT_MB:
                     {
                         if (done_already)
                         {
                             done_already = 0;
                             FILE *rego = fopen(szLicensePath,"r");
                             if (rego)
                                 fclose(rego);
                             else
                                 message("Unregistered News Harvest will finish after a random amount < 15 MB");
                         }
                         rego_file_found = 1;
                         char *number_str = new char[1024];
                         WinQueryWindowText(WinWindowFromID(hwnd,OUT_MB),1023,number_str);
                         if (makeDigitsOnly(number_str))
                             WinSetWindowText(WinWindowFromID(hwnd,OUT_MB),number_str);
                         delete[] number_str;
                     }
                 }
             }
         }
         break;
         
     //----------------------------------
     case WM_COMMAND:
          switch( SHORT1FROMMP( mp1 ) )
          {
               case PB_UNDO:
                    // The undo pushbutton has been pressed
                    // The entries should be reset to their last saved values
                    break;
                //----------------------------------
               case PB_DEFAULT:
                    // The default pushbutton has been pressed
                   // The entries should be reset to their default values
                   {
                        HWND path = WinWindowFromID(hwnd,OUT_PATH);
                        HWND max  = WinWindowFromID(hwnd,OUT_MB);
                        WinSetWindowText(path,"C:\\NHOutput\\");
                        WinSetWindowText(max,"0");
                   }

                    break;
                //----------------------------------
          }
          return 0;
     //----------------------------------
     case WM_VALIDATE:
          // Validate the entries
         {
             char *buffer = new char[1024];
             
             WinQueryWindowText(WinWindowFromID(hwnd,OUT_PATH),1023,buffer);
             lrSpaceTrim(buffer);
             if (*buffer != '\0');
             {
                 if (!checkDir(buffer))
                 {
                     message("Output path is not a vailid directory");
                     WinSetWindowText(WinWindowFromID(hwnd,OUT_PATH),buffer);
                     WinFocusChange(HWND_DESKTOP,WinWindowFromID(hwnd,OUT_PATH),0);
                     delete[] buffer;
                     return 0;
                 }
                 WinSetWindowText(WinWindowFromID(hwnd,OUT_PATH),buffer);
             }
             delete[] buffer;
          }
          return (MPARAM) 1; 
     }

     return WinDefDlgProc( hwnd, msg, mp1, mp2 );

}// Dlg_NbkpPage Dialog Procedure