Beispiel #1
0
  static char raise_killed_monster(HWND hDlg)
  {
    HWND listdlg = PrepareListWindow(hDlg);
    HWND list = GetDlgItem(listdlg,IDC_LIST);
    char buff[256];
    int i;
    int res;

    for (i = 0;i<MAX_MOBS;i++) if (~mobs[i].vlajky & MOB_LIVE && mobs[i].cislo_vzoru != 0) 
    {
      int p;
      _snprintf(buff,sizeof(buff),"%4d. %s (sector: %d home %d)",i,mobs[i].name,mobs[i].sector,mobs[i].home_pos);
      kamenik2windows(buff,strlen(buff),buff);
      p = ListBox_AddString(list,buff);
      ListBox_SetItemData(list,p,i);
    }
    res = PumpDialogMessages(listdlg);
    while (res == IDOK)
    {
      int cnt;
      for (i = 0,cnt = ListBox_GetCount(list);i<cnt;i++) if (ListBox_GetSel(list,i))
      {
        int idx = ListBox_GetItemData(list,i);
        mobs[idx].vlajky |= MOB_LIVE;
        mobs[idx].lives = mobs[idx].vlastnosti[VLS_MAXHIT];
        wzprintf("%s znovu povstal(a)\r\n",mobs[idx].name);
        SEND_LOG("(WIZARD) '%s' has been raised",mobs[idx].name,0);
      }
      res = PumpDialogMessages(listdlg);
    }
    CloseListWindow(listdlg);
    return 1;
  }
Beispiel #2
0
/*
 * LookSelChange:  We received a LBN_SELCHANGE message for the list box; see
 *   if a number item is being selected, and thus we should prompt for an amount.
 */
void LookSelChange(HWND hList)
{
   int i, count;
   Bool selected;
   
   count = ListBox_GetCount(hList);
   for (i=0; i < count; i++)
   {
      selected = (ListBox_GetSel(hList, i) > 0);
      
      if (info->flags & LD_AMOUNTS && !info->selected[i] && selected)
      {
         // Selecting item
         if (!GetAmountListBox(hList, i))
         {
            ListBox_SetSel(hList, FALSE, i);
            info->selected[i] = False;
            continue;
         }
      }
      
      info->selected[i] = selected;
   }
   
}
Beispiel #3
0
bool plMtlEventProc::IUserCommand(HWND hWnd, IParamBlock2* pb, int cmd, int resID)
{
    if (cmd == LBN_SELCHANGE && resID == IDC_EVENT_LIST)
    {
        HWND hList = GetDlgItem(hWnd, IDC_EVENT_LIST);
        int idx = ListBox_GetCurSel(hList);
        BOOL selected = ListBox_GetSel(hList, idx);
        int eventType = ListBox_GetItemData(hList, idx);

        if (eventType == kAnimEventBegin)
            pb->SetValue(kMtlBegin, 0, selected);
        else if (eventType == kAnimEventEnd)
            pb->SetValue(kMtlEnd, 0, selected);
        else if (eventType == kAnimEventMarker)
        {
            char buf[256];
            ListBox_GetText(hList, idx, buf);
            ST::string text = ST::string::from_utf8(buf);
            if (selected)
            {
                if (!IsMarkerSelected(pb, kMtlMarkers, text))
                {
                    TCHAR* name = buf;
                    pb->Append(kMtlMarkers, 1, &name);
                }
            }
            else
                IsMarkerSelected(pb, kMtlMarkers, text, true);
        }

        return true;
    }

    return false;
}
UINT UninstallerShortcutsListbox::eraseSelected()
{
	UINT itemCount = ListBox_GetCount(m_listbox);
	TCHAR buffer[MAX_PATH];
	for (UINT i = 0; i < itemCount; ++i)
	{
		if (ListBox_GetSel(m_listbox, i) > 0)
		{
			ListBox_GetText(m_listbox, i, buffer);
			erase(buffer);
		}
	}
	UINT diff = itemCount - (UINT) m_files.size();
	if (diff > 0)
		updateListbox();
	return diff;
}
Beispiel #5
0
/* This function processes the WM_COMMAND message.
 */
void FASTCALL OutBasket_OnCommand( HWND hwnd, int id, HWND hwndCtl, UINT codeNotify )
{
   switch( id )
      {
      case IDM_QUICKPRINT:
      case IDM_PRINT:
         CmdPrintOutbasket( hwnd );
         break;

      case IDD_HELP:
         HtmlHelp( hwnd, szHelpFile, HH_HELP_CONTEXT, idsOUTBASKET );
         break;

      case IDCANCEL:
         SendMessage( hwnd, WM_CLOSE, 0, 0L );
         break;

      case IDD_DELETE: {
         HWND hwndList;

         hwndList = GetDlgItem( hwnd, IDD_LIST );
         if( IsWindowEnabled( GetDlgItem( hwnd, id ) ) )
            if( fMessageBox( hwnd, 0, GS(IDS_STR253), MB_YESNO|MB_ICONINFORMATION ) == IDYES )
               {
               int cDeleted;
               int nCount;
               int nSel;
               int c;

               /* Set fIgnoreDeleteEvent because we could be
                * deleting lots of items, and we don't want each
                * deletion from the out-basket to be individual.
                */
               nCount = ListBox_GetCount( hwndList );
               SetWindowRedraw( hwndList, FALSE );
               cDeleted = c = 0;
               nSel = -1;
               fIgnoreDeleteEvent = TRUE;
               while( c < nCount )
                  {
                  if( ListBox_GetSel( hwndList, c ) > 0 )
                     {
                     OBINFO obinfo;
                     LPOB lpob;
         
                     lpob = (LPOB)ListBox_GetItemData( hwndList, c );
                     Amob_GetObInfo( lpob, &obinfo );
                     if( !( obinfo.obHdr.wFlags & OBF_ACTIVE ) && !( obinfo.obHdr.wFlags & OBF_PENDING ) )
                        {
                        ListBox_DeleteString( hwndList, c );
                        nSel = c;
                        Amob_RemoveObject( lpob, FALSE );
                        ++cDeleted;
                        --nCount;
                        }
                     else
                        ++c;
                     }
                  else
                      ++c;
                  }
               if( nSel >= nCount )
                  nSel = nCount - 1;
               SetWindowRedraw( hwndList, TRUE );
               if( cDeleted )
                  {
                  InvalidateRect( hwndList, NULL, TRUE );
                  UpdateWindow( hwndList );
                  if( nSel > -1 )
                     ListBox_SetSel( hwndList, TRUE, nSel );
                  Amob_SaveOutBasket( FALSE );
                  UpdateOutBasketStatus();
                  ShowOutBasketTotal( hwndOutBasket );
                  }
               fIgnoreDeleteEvent = FALSE;
               OutBasket_OnSetFocus( hwnd, NULL );
               }
         SetFocus( hwndList );
         break;
         }

      case IDD_HOLD: {
         HWND hwndList;
         int nCount;
         BOOL fFirst;
         BOOL fHold;
         int c;

         hwndList = GetDlgItem( hwnd, IDD_LIST );
         nCount = ListBox_GetCount( hwndList );
         fFirst = TRUE;                        
         fHold = FALSE;
         for( c = 0; c < nCount; ++c )
            if( ListBox_GetSel( hwndList, c ) )
               {
               OBINFO obinfo;
               LPOB lpob;
               RECT rc;

               lpob = (LPOB)ListBox_GetItemData( hwndList, c );
               Amob_GetObInfo( lpob, &obinfo );
               if( !( obinfo.obHdr.wFlags & OBF_ACTIVE ) && !( obinfo.obHdr.wFlags & OBF_PENDING ) )
                  {
                  if( fFirst )
                     {
                     if( obinfo.obHdr.wFlags & OBF_HOLD )
                        {
                        SetWindowText( GetDlgItem( hwnd, IDD_HOLD ), GS(IDS_STR281) );
                        fHold = FALSE;
                        }
                     else
                        {
                        SetWindowText( GetDlgItem( hwnd, IDD_HOLD ), GS(IDS_STR282) );
                        fHold = TRUE;
                        }
                     fFirst = FALSE;
                     }
                  obinfo.obHdr.wFlags &= ~OBF_ERROR;
                  if( fHold )
                     obinfo.obHdr.wFlags |= OBF_HOLD;
                  else
                     obinfo.obHdr.wFlags &= ~OBF_HOLD;
                  Amob_SetObInfo( lpob, &obinfo );
                  ListBox_GetItemRect( hwndList, c, &rc );
                  if( !IsRectEmpty( &rc ) )
                     InvalidateRect( hwndList, &rc, FALSE );
                  }
               }
         // !!SM!! 2.55.2035
         Amob_SaveOutBasket( FALSE );
         UpdateOutBasketStatus();
         ShowOutBasketTotal( hwndOutBasket );
         // !!SM!! 2.55.2035

         UpdateWindow( hwndList );
         SetFocus( hwndList );
         break;
         }

      case IDD_KEEP: {
         HWND hwndList;
         int nCount;
         BOOL fFirst;
         BOOL fKeep;
         int c;

         hwndList = GetDlgItem( hwnd, IDD_LIST );
         nCount = ListBox_GetCount( hwndList );
         fFirst = TRUE;
         fKeep = FALSE;
         for( c = 0; c < nCount; ++c )
            {
            if( ListBox_GetSel( hwndList, c ) )
               {
               OBINFO obinfo;
               LPOB lpob;
               RECT rc;

               lpob = (LPOB)ListBox_GetItemData( hwndList, c );
               Amob_GetObInfo( lpob, &obinfo );
               if( fFirst )
                  {
                  if( obinfo.obHdr.wFlags & OBF_KEEP )
                     {
                     fKeep = FALSE;
                     SetWindowText( GetDlgItem( hwnd, IDD_KEEP ), GS(IDS_STR319) );
                     }
                  else
                     {
                     fKeep = TRUE;
                     SetWindowText( GetDlgItem( hwnd, IDD_KEEP ), GS(IDS_STR318) );
                     }
                  fFirst = FALSE;
                  }
               obinfo.obHdr.wFlags &= ~OBF_ERROR;
               if( fKeep )
                  obinfo.obHdr.wFlags |= OBF_KEEP;
               else
                  obinfo.obHdr.wFlags &= ~OBF_KEEP;
               Amob_SetObInfo( lpob, &obinfo );
               ListBox_GetItemRect( hwndList, c, &rc );
               if( !IsRectEmpty( &rc ) )
                  InvalidateRect( hwndList, &rc, FALSE );
               }
            }
         // !!SM!! 2.55.2035
         Amob_SaveOutBasket( FALSE );
         UpdateOutBasketStatus();
         ShowOutBasketTotal( hwndOutBasket );
         // !!SM!! 2.55.2035

         UpdateWindow( hwndList );
         SetFocus( hwndList );
         break;
         }

      case IDD_LIST:
         if( codeNotify == LBN_SELCHANGE )
            {
            UpdateOutBasketStatus();
            break;
            }
         else if( codeNotify != LBN_DBLCLK )
            break;
         if( !IsWindowEnabled( GetDlgItem( hwnd, IDOK ) ) )
            break;

      case IDOK: {
         HWND hwndList;
         int nCount;
         int c;

         hwndList = GetDlgItem( hwnd, IDD_LIST );
         nCount = ListBox_GetCount( hwndList );
         for( c = 0; c < nCount; ++c )
            if( ListBox_GetSel( hwndList, c ) > 0 )
               {
               OBINFO obinfo;
               LPOB lpob;

               lpob = (LPOB)ListBox_GetItemData( hwndList, c );
               Amob_GetObInfo( lpob, &obinfo );
               if( Amob_IsEditable( obinfo.obHdr.clsid ) && !( obinfo.obHdr.wFlags & OBF_ACTIVE ) && !( obinfo.obHdr.wFlags & OBF_PENDING ) )
                  Amob_Edit( lpob );
               }
         break;
         }
      }
}
Beispiel #6
0
/* This function intercepts messages for the out-basket list box window
 * so that we can handle the right mouse button.
 */
LRESULT EXPORT FAR PASCAL OutBaskListProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
   switch( msg )
      {
      case WM_ERASEBKGND: {
         RECT rc;

         GetClientRect( hwnd, &rc );
         FillRect( (HDC)wParam, &rc, hbrOutBaskWnd );
         return( TRUE );
         }

      case WM_CONTEXTMENU: /*!!SM!!*/
      case WM_RBUTTONDOWN:
         {
         POINT pt;
         LPOB lpob;
         HWND hwndOpen;
         HMENU hPopupMenu;
         int index;
         AEPOPUP aep;

         /* Make sure this window is active and select the item
          * at the cursor.
          */
         if( hwndActive != GetParent( hwnd ) )
            SendMessage( hwndMDIClient, WM_MDIACTIVATE, (WPARAM)hwndOutBasket, 0L );

         /* Select the item under the cursor only if nothing is
          * currently selected.
          */
         index = ItemFromPoint( hwnd, (short)LOWORD(lParam), (short)HIWORD(lParam) );
         if( ListBox_GetSel( hwnd, index ) == 0 )
            {
            CallWindowProc( lpProcListCtl, hwnd, WM_LBUTTONDOWN, wParam, lParam );
            CallWindowProc( lpProcListCtl, hwnd, WM_LBUTTONUP, wParam, lParam );
            }

         /* Get the out-basket menu.
          */
         hPopupMenu = GetSubMenu( hPopupMenus, IPOP_OBASKWINDOW );
         hwndOpen = GetDlgItem( GetParent( hwnd ), IDOK );
         MenuEnable( hPopupMenu, IDOK, IsWindowEnabled( hwndOpen ) );

         /* If we have any selected items, use the attributes
          * of the first item to determine the menu items.
          */
         if( ListBox_GetSelCount( hwnd ) > 0 )
            {
            OBINFO obinfo;

            ListBox_GetSelItems( hwnd, 1, &index );
            lpob = (LPOB)ListBox_GetItemData( hwnd, index );
            Amob_GetObInfo( lpob, &obinfo );
            if( TestF(obinfo.obHdr.wFlags, OBF_HOLD) )
               MenuString( hPopupMenu, IDD_HOLD, GS(IDS_STR275) );
            else
               MenuString( hPopupMenu, IDD_HOLD, GS(IDS_STR277) );
            if( TestF(obinfo.obHdr.wFlags, OBF_KEEP) )
               MenuString( hPopupMenu, IDD_KEEP, GS(IDS_STR440) );
            else
               MenuString( hPopupMenu, IDD_KEEP, GS(IDS_STR439) );
            MenuEnable( hPopupMenu, IDOK, !fInitiatingBlink && Amob_IsEditable( obinfo.obHdr.clsid ) && !TestF(obinfo.obHdr.wFlags, OBF_PENDING) && !TestF(obinfo.obHdr.wFlags, OBF_ACTIVE ) );
            MenuEnable( hPopupMenu, IDD_DELETE, !fInitiatingBlink && !TestF(obinfo.obHdr.wFlags, OBF_PENDING ) && !TestF(obinfo.obHdr.wFlags, OBF_ACTIVE ) );
            MenuEnable( hPopupMenu, IDD_KEEP, !fInitiatingBlink && !TestF(obinfo.obHdr.wFlags, OBF_PENDING ) && !TestF(obinfo.obHdr.wFlags, OBF_ACTIVE ) );
            MenuEnable( hPopupMenu, IDD_HOLD, !fInitiatingBlink && !TestF(obinfo.obHdr.wFlags, OBF_PENDING ) && !TestF(obinfo.obHdr.wFlags, OBF_ACTIVE ) );
            }
         else
            {
            MenuEnable( hPopupMenu, IDOK, FALSE );
            MenuEnable( hPopupMenu, IDD_KEEP, FALSE );
            MenuEnable( hPopupMenu, IDD_HOLD, FALSE );
            MenuEnable( hPopupMenu, IDD_DELETE, FALSE );
            }
            /* Call the AE_POPUP event.
             */
         aep.wType = WIN_OUTBASK;
         aep.pFolder = NULL;
         aep.pSelectedText = NULL;
         aep.cchSelectedText = 0;
         aep.hMenu = hPopupMenu;
         aep.nInsertPos = 2;
         Amuser_CallRegistered( AE_POPUP, (LPARAM)(LPSTR)&aep, 0L );

         GetCursorPos( &pt );
         TrackPopupMenu( hPopupMenu, TPM_LEFTALIGN|TPM_RIGHTBUTTON, pt.x, pt.y, 0, hwndFrame, NULL );
         return( 0 );
         }

      case WM_KEYDOWN:
         /* Trap the Delete and Shift+Delete key in the outbasket
          * list box to handle the Delete command.
          */
         if( wParam == VK_DELETE ) 
            {
            PostDlgCommand( GetParent( hwnd ), IDD_DELETE, 0 );
            return( 0 );
            }

         /* Trap the Pause and Shift+Pause key in the outbasket
          * list box to handle the Hold command.
          */
         if( wParam == VK_PAUSE )
            {
            PostDlgCommand( GetParent( hwnd ), IDD_HOLD, 1 );
            return( 0 );
            }
         break;
      }
   return( CallWindowProc( lpProcListCtl, hwnd, msg, wParam, lParam ) );
}
Beispiel #7
0
static LRESULT WizardDlgProc(HWND hDlg,UINT msg, WPARAM wParam,LPARAM lParam)
  {
  int i;
  switch (msg)
	{
	case WM_INITDIALOG:
	  hWizardDlg = hDlg;
	  hWizardText = GetDlgItem(hDlg,IDC_OUTPUT);
	  SendMessage(hWizardText,WM_SETFONT,(WPARAM)hfCourier,1);
	  display_game_status();
	  SetTimer(hDlg,10,20,NULL);
	  return 0;	
	case WM_TIMER: do_events();return 1;
	case WM_COMMAND:
	  switch (LOWORD(wParam))
		{
	 case IDCANCEL: EndDialog(hDlg,0);return 0;
     case IDC_CLEARMAP:
       {
          HWND listwnd = PrepareListWindow(hDlg);
          HWND list = GetDlgItem(listwnd,IDC_LIST);
          int res;
          ListBox_AddString(list,"Clear Monsters");
          ListBox_AddString(list,"Clear Items");
          res = PumpDialogMessages(listwnd);
          if (res == IDOK)
          {
            if (ListBox_GetSel(list,0))
            {
              for(i = 0;i<MAX_MOBS;i++)
                          if (mobs[i].vlajky & MOB_LIVE)
                            {
                            vybrana_zbran = -1;
                            select_player = -1;
                            mob_hit(mobs+i,mobs[i].lives);
                            }
            }
            if (ListBox_GetSel(list,1))
            {
              for(i = 0;i<mapsize*4;i++)
                              {
                              destroy_items(map_items[i]);
                              free(map_items[i]);
                              map_items[i] = NULL;
                              }
                           for(i = 0;i<vyk_max;i++)
                              {
                              destroy_items(map_vyk[i].items);
                              map_vyk[i].items[0] = 0;
                              }
            }
          }
          CloseListWindow(listwnd);          
       }
       break;
       
     case IDC_ADVENCE:
              {
              int i,j,c;
              if (!wzscanf("Advence to level <postava -1= vsichni><uroven>:","%d %d",&i,&j)) return 0;
              c = MessageBox(GetActiveWindow(),"Automaticky?","?",MB_YESNO|MB_ICONQUESTION);
              if (i>0) advence_player(i-1,j,c == IDYES);else
                 for(i = 0;i<POCET_POSTAV;i++) if (postavy[i].used) advence_player(i,j,c == IDYES);              
              return 0;
              }
     case IDC_GOTO:
			  {
			  char prompt[50];
              sprintf(prompt,"Goto sector <1-%d>:",mapsize-1);
			  if (!wzscanf(prompt,"%d",&viewsector)) return 0;
              chod_s_postavama(1);              
              SEND_LOG("(WIZARD) Goto %d",viewsector,0);
              return 0;
			  }
     case IDC_LOADMAP:
              if (!wzscanf("Load Map <filename><sector>","%s %hd",loadlevel.name,&loadlevel.start_pos)) return 0;
              for(i = 0;i<POCET_POSTAV;i++)postavy[i].sektor = loadlevel.start_pos;
              SEND_LOG("(WIZARD) Load map '%s' %d",loadlevel.name,loadlevel.start_pos);
			  EndDialog(hDlg,0);
              send_message(E_CLOSE_MAP);
              return 0;
     case IDC_OPENDOOR:if (map_sectors[viewsector].step_next[viewdir])
                delay_action(3,viewsector,viewdir,0x2000000,0,0);
              else
                delay_action(3,viewsector,viewdir,0,0,0);
              return 0;
     case IDC_TAKEMONEY:if (take_money()) return 0;break;
     case IDC_PURGE:if (purge_map()) return 0;break;
     case IDC_HEAL:if (heal_meditate()) return 0;break;
     case IDC_RAISEDEATH:if (raise_death()) return 0;break;
     case IDC_RAISEMONSTER:if (raise_killed_monster(hDlg)) return 0;break;
     case IDC_IMMORTAL:set_immortality();break;
     case IDC_NETECNOST:set_nohassle();break;
     case IDC_UNAFFECT :unaffect();break;
     case IDC_WEAPONSKILL:if (advance_weapon()) return 0;break;
     case IDC_REFRESH:display_game_status();break;
     case IDC_RELOADMOBILES:
			  i = MessageBox(hDlg,"Tato funkce precte znova parametry vsech existujicich nestvur. "
                      "Pouzivej jen v pripade, ze se tyto parametry zmenili a nesouhlasi tak "
                      "obsah ulozene pozice. Pokracovat? ","??",MB_YESNO|MB_ICONQUESTION);
              if (i == IDYES) reload_mobs();
              return 0;
     case IDC_LOADITEM:
                       {
                         HWND listdlg = PrepareListWindow(hDlg);
                         HWND list = GetDlgItem(listdlg,IDC_LIST);
                         char buff[256];
                         int i;
                         int res;

                         for (i = 0;i<item_count;i++)
                         {
                           _snprintf(buff,sizeof(buff),"%d. %s",i,glob_items[i].jmeno);
                           kamenik2windows(buff,strlen(buff),buff);
                           ListBox_AddString(list,buff);
                         }
                         res = PumpDialogMessages(listdlg);
                         while (res == IDOK)
                         {
                           int cnt;
                           for (i = 0,cnt = ListBox_GetCount(list);i<cnt;i++) if (ListBox_GetSel(list,i))
                           {
                             SEND_LOG("(WIZARD) Load Item %d (%s)",i,glob_items[i].jmeno);
                             macro_drop_item(viewsector,viewdir,i);                             
                             wzprintf("Dropped item: %d\r\n",i);
                           }
                           res = PumpDialogMessages(listdlg);
                         }
                         CloseListWindow(listdlg);
                       }
                       return 0;
		}
			
	 default: return 0;
     }
return 1;
}
Beispiel #8
0
void Dlg_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify) {

   // Obtain the user's settings from the dialog box controls.
   TCHAR szExpression[100];
   ComboBox_GetText(GetDlgItem(hwnd, IDC_EXPRESSION), szExpression,
      sizeof(szExpression) / sizeof(szExpression[0]));

   int nObjects = GetDlgItemInt(hwnd, IDC_NUMOBJS, NULL, FALSE);

   switch (id) {
   case IDCANCEL:
      EndDialog(hwnd, id);
      break;

   case IDC_OBJLIST:
      switch (codeNotify) {
      case LBN_SELCHANGE:
         // An item changed state, reset all items and set the selected ones.
         for (int n = 0; n < nObjects; n++)
            ResetEvent(g_ahObjs[n]);

         for (n = 0; n < nObjects; n++) {
            if (ListBox_GetSel(GetDlgItem(hwnd, IDC_OBJLIST), n)) 
               SetEvent(g_ahObjs[n]);
         }
         break;
      }
      break;

   case IDOK:
      // Prevent the user from changing values while the test is running
      SetFocus(GetDlgItem(hwnd, IDC_OBJLIST));
      EnableWindow(GetDlgItem(hwnd, IDC_NUMOBJS),    FALSE);
      EnableWindow(GetDlgItem(hwnd, IDC_TIMEOUT),    FALSE);
      EnableWindow(GetDlgItem(hwnd, IDC_EXPRESSION), FALSE);
      EnableWindow(GetDlgItem(hwnd, IDOK),           FALSE);

      // Notify the user that the test is running
      SetDlgItemText(hwnd, IDC_RESULT, TEXT("Waiting..."));

      // Create all of the desired kernel objects
      ZeroMemory(g_ahObjs, sizeof(g_ahObjs));
      g_awfme.m_nExpObjects = 0;
      ZeroMemory(g_awfme.m_ahExpObjs, sizeof(g_awfme.m_ahExpObjs));
      g_awfme.m_hwnd = hwnd;
      g_awfme.m_dwMilliseconds = GetDlgItemInt(hwnd, IDC_TIMEOUT, NULL, FALSE);

      ListBox_ResetContent(GetDlgItem(hwnd, IDC_OBJLIST));
      for (int n = 0; n < nObjects; n++) {
         TCHAR szBuf[20];
         g_ahObjs[n] = CreateEvent(NULL, FALSE, FALSE, NULL);

         wsprintf(szBuf, TEXT("  %d"), n + 1);
         ListBox_AddString(GetDlgItem(hwnd, IDC_OBJLIST), 
            &szBuf[lstrlen(szBuf) - 3]);
      }

      PTSTR p = _tcstok(szExpression, TEXT(" "));
      while (p != NULL) {
         g_awfme.m_ahExpObjs[g_awfme.m_nExpObjects++] = 
            (*p == TEXT('|')) ? NULL : g_ahObjs[_ttoi(p) - 1];
         p = _tcstok(NULL, TEXT(" "));
      }

      DWORD dwThreadId;
      CloseHandle(chBEGINTHREADEX(NULL, 0, 
         AsyncWaitForMultipleExpressions, &g_awfme, 
         0, &dwThreadId));
      break;
   }   
}
Beispiel #9
0
/*
 * LookCommand:  Handle WM_COMMAND messages.
 */ 
void LookCommand(HWND hDlg, int ctrl_id, HWND hwndCtl, UINT codeNotify) 
{
   int index, num_entries, i, amount, currentAmount;
   list_type selection;
   object_node *obj;
   char buf[MAXNAME + 1], temp[16];

   switch(ctrl_id)
   {
   case IDC_ITEMFIND:
      if (codeNotify == EN_UPDATE)
      {
	 /* Go to object in list that user has named */
	 Edit_GetText(info->hwndFind, buf, MAXNAME);
	 index = ListBox_FindString(info->hwndListBox, -1, buf);

	 if (index != LB_ERR)
	    if (info->flags & LD_MULTIPLESEL)
	       ListBox_SetCaretIndex(info->hwndListBox, index);
	    else ListBox_SetCurSel(info->hwndListBox, index);
      }
      break;

   case IDC_ALL:
      /* In multiple selection box only, select all objects.  If we require that
       * user give amounts, don't select amount objects */
      num_entries = ListBox_GetCount(info->hwndListBox);

      ListBox_SetSel(info->hwndListBox, TRUE, -1);

      WindowBeginUpdate(info->hwndQuanList);
      // Select all for number items
      for (i=0; i < num_entries; i++)
      {
	 info->selected[i] = True;
	 obj = (object_node *) ListBox_GetItemData(info->hwndListBox, i);
	 if (IsNumberObj(obj->id))
	    amount = obj->amount;
	 else
	    amount = 1;
	 obj->temp_amount = amount;
	 ListBox_DeleteString(info->hwndQuanList,i);
	 sprintf(temp, "%d", amount);
	 ListBox_InsertString(info->hwndQuanList,i,temp);
	 ListBox_SetItemData(info->hwndQuanList,i,amount);
      }
      WindowEndUpdate(info->hwndQuanList);
      break;

   case IDC_ITEMLIST:
      switch (codeNotify)
      {
      case LBN_DBLCLK:
	 /* Look at item */
	 index = ListBox_GetCaretIndex(info->hwndListBox);
	 if (index != LB_ERR)
	 {
	    obj = (object_node *) ListBox_GetItemData(info->hwndListBox, index);
	    RequestLook(obj->id);
	    SetDescParams(hDlg, DESC_NONE);
	    ListBox_SetSel(info->hwndListBox, FALSE, index);
	    info->selected[index] = False;
	 }
	 break;

      case LBN_SELCHANGE:
#if 0
	 LookSelChange(hwndCtl);
#else
	 index = ListBox_GetCurSel(info->hwndListBox);
	 obj = (object_node *) ListBox_GetItemData(info->hwndListBox, index);
	 WindowBeginUpdate(info->hwndQuanList);
	 ListBox_DeleteString(info->hwndQuanList,index);
	 if (ListBox_GetSel(info->hwndListBox,index))
	 {
	    if (IsNumberObj(obj->id))
	       amount = obj->amount;
	    else
	       amount = 1;
	    sprintf(temp, "%d", amount);
	 }
	 else
	 {
	    amount = 0;
	    strcpy(temp," ");
	 }
	 ListBox_InsertString(info->hwndQuanList,index,temp);
	 ListBox_SetItemData(info->hwndQuanList,index,amount);
	 ListBox_SetSel(info->hwndListBox,amount > 0,index);
	 info->selected[index] = (amount > 0);
	 obj->temp_amount = amount;
	 ListBox_SetSel(info->hwndQuanList,FALSE,index);
	 WindowEndUpdate(info->hwndQuanList);

#endif
	 break;
      }
      break;

   case IDC_QUANLIST:
      if (codeNotify == LBN_SELCHANGE)
      {
	 char temp[16];
	 index = (int)ListBox_GetCurSel(info->hwndQuanList);
	 obj = (object_node *) ListBox_GetItemData(info->hwndListBox, index);
	 currentAmount = (int)ListBox_GetItemData(info->hwndQuanList, index);
	 amount = currentAmount;
	 if (ListBox_GetItemData(info->hwndQuanList, index) > 0)
	 {
	    if (IsNumberObj(obj->id))
	    {
	       MEASUREITEMSTRUCT m;
	       int startAmount = currentAmount;
	       if (currentAmount == 0)
		  startAmount = obj->amount;
	       /* Place amount dialog just beneath selected item */
	       ItemListMeasureItem(info->hwndQuanList, &m);
	       // Force highlight on (we are editing it)
	       ListBox_SetSel(info->hwndListBox,TRUE,index);
	       if(InputNumber(hDlg,info->hwndQuanList,
		  0,(index - ListBox_GetTopIndex(info->hwndQuanList) + 1) * (m.itemHeight - 1),
		  &amount,startAmount,1,obj->amount))
	       {
		  ListBox_DeleteString(info->hwndQuanList,index);
		  if (amount > 0)
		  {
		     sprintf(temp, "%d", amount);
		     ListBox_InsertString(info->hwndQuanList, index, temp);
		  }
		  else
		  {
		     ListBox_InsertString(info->hwndQuanList,index," ");
		  }
		  ListBox_SetItemData(info->hwndQuanList, index, amount);
	       }
	       else
		  amount = currentAmount;
	       // reset highlight based on quantity - off if zero, on otherwise
	       ListBox_SetSel(info->hwndListBox,
		  (ListBox_GetItemData(info->hwndQuanList,index) > 0),
		  index);
	    }
	    else
	    {
	       ListBox_DeleteString(info->hwndQuanList,index);
	       if (currentAmount == 0)
	       {
		  amount = 1;
		  strcpy(temp,"1");
	       }
	       else
	       {
		  amount = 0;
		  strcpy(temp," ");
	       }
	       ListBox_InsertString(info->hwndQuanList,index,temp);
	       ListBox_SetItemData(info->hwndQuanList,index,amount);
	    }
	 }
	 ListBox_SetSel(info->hwndListBox,amount > 0,index);
	 info->selected[index] = (amount > 0);
	 obj->temp_amount = amount;
	 ListBox_SetCurSel(info->hwndQuanList,-1);
      }
      break;

   case IDOK:
      /* Get user's selection(s) */
      num_entries = ListBox_GetCount(info->hwndListBox);
      selection = NULL;
      
      for (i = 0; i < num_entries; i++)
      {
	 /* If item is selected, add to selection list, else free */
	 obj = (object_node *) ListBox_GetItemData(info->hwndListBox, i);
	 if (ListBox_GetSel(info->hwndListBox, i) > 0)
	    selection = list_add_item(selection, obj);
	 else 
	    ObjectDestroyAndFree(obj);
      }

      LookDialogRetval = selection;
      EndDialog(hDlg, IDOK);
      break;
      
   case IDCANCEL:
      LookListFreeContents(info->hwndListBox);
      
      LookDialogRetval = NULL;
      EndDialog(hDlg, IDCANCEL);
      break;
   }
}