Ejemplo n.º 1
0
/*
 * MaybeEnableAddButton: Enable/disable the "add spell" button
 *   depending on whether the currently selected spell in the available
 *   list box can be chosen.
 */
void MaybeEnableAddButton(HWND hDlg)
{
   int i;
   int school = 0;
   Spell *s;
   BOOL enable = TRUE;
   int index = ListBox_GetCurSel(hList1);
   if (index != LB_ERR)
   {
      // First find any chosen Qor/Shallile spells
      for (i = 0; i < ListBox_GetCount(hList2); ++i)
      {
         s = (Spell *) ListBox_GetItemData(hList2, i);
         if (s->school == SS_QOR || s->school == SS_SHALILLE)
            school = s->school;
      }
      
      // If school of selected spell conflicts, disable button
      s = (Spell *) ListBox_GetItemData(hList1, index);
      
      if (school == SS_QOR && s->school == SS_SHALILLE ||
          school == SS_SHALILLE && s->school == SS_QOR)
         enable = FALSE;
   }

   EnableWindow(GetDlgItem(hDlg, IDC_ADDSPELL), enable);
}
Ejemplo n.º 2
0
static void sttUpdateAccountInfo(HWND hwndDlg, struct TAccMgrData *dat)
{
	HWND hwndList = GetDlgItem(hwndDlg, IDC_ACCLIST);
	int curSel = ListBox_GetCurSel( hwndList );
	if ( curSel != LB_ERR ) {
		HWND hwnd;
		char svc[MAXMODULELABELLENGTH];

		PROTOACCOUNT *pa = (PROTOACCOUNT *)ListBox_GetItemData(hwndList, curSel);
		if ( pa ) {
			EnableWindow( GetDlgItem( hwndDlg, IDC_UPGRADE ), pa->bOldProto || pa->bDynDisabled );
			EnableWindow( GetDlgItem( hwndDlg, IDC_EDIT ), !pa->bOldProto && !pa->bDynDisabled );
			EnableWindow( GetDlgItem( hwndDlg, IDC_REMOVE ), TRUE );
			EnableWindow( GetDlgItem( hwndDlg, IDC_OPTIONS ), pa->ppro != 0 );

			if ( dat->iSelected >= 0 ) {
				PROTOACCOUNT *pa_old = (PROTOACCOUNT *)ListBox_GetItemData(hwndList, dat->iSelected);
				if (pa_old && pa_old != pa && pa_old->hwndAccMgrUI)
					ShowWindow(pa_old->hwndAccMgrUI, SW_HIDE);
			}

			if ( pa->hwndAccMgrUI ) {
				ShowWindow(GetDlgItem(hwndDlg, IDC_TXT_INFO), SW_HIDE);
				ShowWindow(pa->hwndAccMgrUI, SW_SHOW);
			}
			else if ( !pa->ppro ) {
				ShowWindow(GetDlgItem(hwndDlg, IDC_TXT_INFO), SW_SHOW);
				SetWindowText(GetDlgItem(hwndDlg, IDC_TXT_INFO), TranslateT("Account is disabled. Please activate it to access options."));
			}
			else {
				mir_snprintf(svc, SIZEOF(svc), "%s%s", pa->szModuleName, PS_CREATEACCMGRUI);
				hwnd = (HWND)CallService(svc, 0, (LPARAM)hwndDlg);
				if (hwnd && (hwnd != (HWND)CALLSERVICE_NOTFOUND)) {
					RECT rc;

					ShowWindow(GetDlgItem(hwndDlg, IDC_TXT_INFO), SW_HIDE);

					GetWindowRect(GetDlgItem(hwndDlg, IDC_TXT_INFO), &rc);
					MapWindowPoints(NULL, hwndDlg, (LPPOINT)&rc, 2);
					SetWindowPos(hwnd, hwndList, rc.left, rc.top, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW);

					pa->hwndAccMgrUI = hwnd;
				}
				else {
					ShowWindow(GetDlgItem(hwndDlg, IDC_TXT_INFO), SW_SHOW);
					SetWindowText(GetDlgItem(hwndDlg, IDC_TXT_INFO), TranslateT(legacyMsg));
			}	}
			return;
	}	}
	
	EnableWindow( GetDlgItem( hwndDlg, IDC_UPGRADE ), FALSE );
	EnableWindow( GetDlgItem( hwndDlg, IDC_EDIT ), FALSE );
	EnableWindow( GetDlgItem( hwndDlg, IDC_REMOVE ), FALSE );
	EnableWindow( GetDlgItem( hwndDlg, IDC_OPTIONS ), FALSE );

	ShowWindow(GetDlgItem(hwndDlg, IDC_TXT_INFO), SW_SHOW);
	SetWindowText(GetDlgItem(hwndDlg, IDC_TXT_INFO), TranslateT(welcomeMsg));
}
Ejemplo n.º 3
0
/////////////////////////////////////////////////////////////////////////
//Function:    AddItem
//Description: Add a item to Selected object list
/////////////////////////////////////////////////////////////////////////
void AddItem (HWND hDlg)
	{
	 int  		  nObjects ;
	 char   *lpszString ;
	 int       *SelectedIndexes ;
	 DWORD 	  	objectIndex ;
	 OBJECTID 	theObj ;
	 int		i ;

	 //nObjects = (int) SendDlgItemMessage (hDlg, IDD_OBJECTSLIST, LB_GETSELCOUNT, 0, 0L) ;
	 nObjects = ListBox_GetSelCount (GetDlgItem(hDlg, IDD_OBJECTSLIST)) ;
	 if (nObjects == 0) return ;

	 SelectedIndexes = new int[nObjects] ;
	 //SendDlgItemMessage (hDlg, IDD_OBJECTSLIST, LB_GETSELITEMS, (WPARAM)nObjects, (long)SelectedIndexes) ;
	 ListBox_GetSelItems (GetDlgItem (hDlg, IDD_OBJECTSLIST), nObjects, SelectedIndexes) ;
	 lpszString = new char[256] ;
	 for (i = 0; i < nObjects; i++)
		{
		 //SendDlgItemMessage (hDlg, IDD_OBJECTSLIST, LB_GETTEXT, SelectedIndexes[i], (long) lpszString) ;
		 //theObj =(OBJECTID)SendDlgItemMessage (hDlg, IDD_OBJECTSLIST, LB_GETITEMDATA, SelectedIndexes[i], 0) ;
		 //objectIndex = (DWORD)SendDlgItemMessage(hDlg, IDD_FIELDSLIST, LB_INSERTSTRING, -1, (long)lpszString) ;
		 //SendDlgItemMessage(hDlg, IDD_FIELDSLIST, LB_SETITEMDATA, (WPARAM)objectIndex, (long)theObj) ;
		 ListBox_GetText (GetDlgItem (hDlg, IDD_FIELDSLIST),SelectedIndexes[i], lpszString) ;
		 theObj = (OBJECTID)ListBox_GetItemData (GetDlgItem (hDlg, IDD_FIELDSLIST),SelectedIndexes[i]) ;
		 objectIndex = ListBox_InsertString (GetDlgItem (hDlg, IDD_FIELDSLIST), -1, lpszString) ;
		 ListBox_SetItemData (GetDlgItem(hDlg, IDD_FIELDSLIST), objectIndex, theObj) ;
		}
	 delete(SelectedIndexes) ;
	 delete(lpszString) ;
	 return ;
	}
Ejemplo n.º 4
0
static void PASCAL PostMessageToMdi(HWND hDlg,WORD param)
{
  HWND hMdi=GetProp(hDlg,gsPropName);
  HCURSOR hOldCursor=SetCursor(LoadCursor(NULL,IDC_WAIT));
  switch (param)
    {
    case IDOK:  // show current window
      {
      HWND hwndList = GetDlgItem(hDlg, 100);
      int curSel = ListBox_GetCurSel(hwndList);
      if (curSel!=LB_ERR)
        {
        HWND hWnd = (HWND)ListBox_GetItemData(hwndList, curSel);
        if (IsIconic(hWnd))
          SendMessage(hMdi,WM_MDIRESTORE,(WPARAM)hWnd,0L);
        SendMessage(hMdi,WM_MDIACTIVATE,(WPARAM)hWnd,0L);
        }
      }
      break;

    case 13: // iconize all
      PostToAll(hDlg,hMdi,TRUE,SW_SHOWMINNOACTIVE);
      break;

    case 14: // restore all
      PostToAll(hDlg,hMdi,FALSE,WM_MDIRESTORE);
      break;

    case 15: // close all
      PostToAll(hDlg,hMdi,FALSE,WM_MDIDESTROY);
      break;
    }
  SetCursor(hOldCursor);
}
Ejemplo n.º 5
0
/* This function updates the out-basket status
 */
void FASTCALL UpdateOutBasketStatus( void )
{
   if( hwndOutBasket )
      {
      BOOL fIsEditable;
      BOOL fHasItem;
      BOOL fCanDelete;
      HWND hwndList;
      int nSelCount;

      hwndList = GetDlgItem( hwndOutBasket, IDD_LIST );
      fIsEditable = FALSE;
      fHasItem = ( ListBox_GetCount( hwndList ) > 0 );
      fCanDelete = FALSE;
      if( ( nSelCount = ListBox_GetSelCount( hwndList ) ) > 0 )
         {
         OBINFO obinfo;
         LPOB lpob;
         int nSel;

         ListBox_GetSelItems( hwndList, 1, &nSel );
         lpob = (LPOB)ListBox_GetItemData( hwndList, nSel );
         Amob_GetObInfo( lpob, &obinfo );
         SetWindowText( GetDlgItem( hwndOutBasket, IDD_HOLD ), ( obinfo.obHdr.wFlags & OBF_HOLD ) ? GS(IDS_STR282) : GS(IDS_STR281) );
         SetWindowText( GetDlgItem( hwndOutBasket, IDD_KEEP ), ( obinfo.obHdr.wFlags & OBF_KEEP ) ? GS(IDS_STR318) : GS(IDS_STR319) );
         fIsEditable = !fInitiatingBlink && Amob_IsEditable( obinfo.obHdr.clsid ) && !TestF(obinfo.obHdr.wFlags, OBF_PENDING ) && !TestF(obinfo.obHdr.wFlags, OBF_ACTIVE );
         fCanDelete = !fInitiatingBlink && !TestF(obinfo.obHdr.wFlags, OBF_PENDING ) && !TestF(obinfo.obHdr.wFlags, OBF_ACTIVE );
         }
      EnableControl( hwndOutBasket, IDOK, fIsEditable );
      EnableControl( hwndOutBasket, IDD_LIST, fHasItem );
      EnableControl( hwndOutBasket, IDD_DELETE, fCanDelete );
      EnableControl( hwndOutBasket, IDD_HOLD, fHasItem && fCanDelete );
      EnableControl( hwndOutBasket, IDD_KEEP, fHasItem && fCanDelete );
      }
}
Ejemplo n.º 6
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;
  }
Ejemplo n.º 7
0
// forward the message to the appropriate item
bool wxListBox::MSWOnDraw(WXDRAWITEMSTRUCT *item)
{
    // only owner-drawn control should receive this message
    wxCHECK( ((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), false );

    DRAWITEMSTRUCT *pStruct = (DRAWITEMSTRUCT *)item;
    UINT itemID = pStruct->itemID;

    // the item may be -1 for an empty listbox
    if ( itemID == (UINT)-1 )
        return false;

    long data = ListBox_GetItemData(GetHwnd(), pStruct->itemID);

    wxCHECK( data && (data != LB_ERR), false );

    wxListBoxItem *pItem = (wxListBoxItem *)data;

    wxDCTemp dc((WXHDC)pStruct->hDC);
    wxPoint pt1(pStruct->rcItem.left, pStruct->rcItem.top);
    wxPoint pt2(pStruct->rcItem.right, pStruct->rcItem.bottom);
    wxRect rect(pt1, pt2);

    return pItem->OnDrawItem(dc, rect,
                             (wxOwnerDrawn::wxODAction)pStruct->itemAction,
                             (wxOwnerDrawn::wxODStatus)pStruct->itemState);
}
Ejemplo n.º 8
0
/* This function draws one item in the out-basket list.
 */
void FASTCALL OutBasket_OnDrawItem( HWND hwnd, const DRAWITEMSTRUCT FAR * lpDrawItem )
{
   if( lpDrawItem->itemID != -1 )
      if( lpDrawItem->itemAction == ODA_FOCUS )
         DrawFocusRect( lpDrawItem->hDC, (LPRECT)&lpDrawItem->rcItem );
      else {
         HFONT hOldFont;
         HWND hwndList;
         OBINFO obinfo;
         TEXTMETRIC tm;
         COLORREF tmpT;
         COLORREF tmpB;
         COLORREF T;
         COLORREF B;
         HBRUSH hbr;
         LPOB lpob;
         RECT rc;

         hwndList = GetDlgItem( hwnd, IDD_LIST );
         lpob = (LPOB)ListBox_GetItemData( hwndList, lpDrawItem->itemID );
         Amob_GetObInfo( lpob, &obinfo );
         rc = lpDrawItem->rcItem;
         hOldFont = SelectFont( lpDrawItem->hDC, hOutBasketFont );
         if( lpDrawItem->itemState & ODS_SELECTED )
            {
            T = crHighlightText;
            B = crHighlight;
            }
         else
            {
            T = (obinfo.obHdr.wFlags & OBF_OPEN) ? crIgnoredTopic : crOutBaskText;
            B = crOutBaskWnd;
            }
         hbr = CreateSolidBrush( B );
         tmpT = SetTextColor( lpDrawItem->hDC, T );
         tmpB = SetBkColor( lpDrawItem->hDC, B );
         rc.left = 0;
         rc.right = 32;
         FillRect( lpDrawItem->hDC, &rc, hbr );
         if( obinfo.obHdr.wFlags & OBF_KEEP )
            Amuser_DrawBitmap( lpDrawItem->hDC, rc.left, rc.top, 16, 16, hbmpOutBasket, 1 );
         if( obinfo.obHdr.wFlags & OBF_HOLD )
            Amuser_DrawBitmap( lpDrawItem->hDC, rc.left + 16, rc.top, 16, 16, hbmpOutBasket, 0 );
         if( obinfo.obHdr.wFlags & OBF_ACTIVE )
            Amuser_DrawBitmap( lpDrawItem->hDC, rc.left + 16, rc.top, 16, 16, hbmpOutBasket, 2 );
         if( obinfo.obHdr.wFlags & OBF_SCRIPT )
            Amuser_DrawBitmap( lpDrawItem->hDC, rc.left + 16, rc.top, 16, 16, hbmpOutBasket, 4 );
         if( obinfo.obHdr.wFlags & OBF_ERROR )
            Amuser_DrawBitmap( lpDrawItem->hDC, rc.left + 16, rc.top, 16, 16, hbmpOutBasket, 3 );
         rc.left = rc.right;
         rc.right = lpDrawItem->rcItem.right;
         Amob_Describe( lpob, lpTmpBuf );
         GetTextMetrics( lpDrawItem->hDC, &tm );
         ExtTextOut( lpDrawItem->hDC, rc.left, rc.top, ETO_OPAQUE, &rc, lpTmpBuf, strlen( lpTmpBuf ), NULL );
         SelectFont( lpDrawItem->hDC, hOldFont );
         SetTextColor( lpDrawItem->hDC, tmpT );
         SetBkColor( lpDrawItem->hDC, tmpB );
         DeleteBrush( hbr );
         }
}
Ejemplo n.º 9
0
static void
DisconnectDialogDone(HWND hDlg, BOOL bResult)
{
    int i,Count;
    NETRESOURCE *pNetRes;
    HWND hListBoxWnd = GetDlgItem(hDlg,IDC_NETUI_DISCONLIST);

    // Free all the NETRESOURCE structs
    if ((Count = ListBox_GetCount(hListBoxWnd)) == LB_ERR)
        DEBUGMSG(ZONE_ERROR,(DBGTEXT("!DisconnectDlgDone: LB_GETCOUNT failed")));
    else {
        for (i=0; i<Count; i++) {
            pNetRes = (NETRESOURCE *)ListBox_GetItemData(hListBoxWnd,i);
            if ((LRESULT)pNetRes == LB_ERR) {
                DEBUGMSG(ZONE_ERROR,(DBGTEXT("!DisconnectDlgDone: LB_GETITEMDATA returned err %d"),
                                     GetLastError()));
            }
            else if (pNetRes == NULL) {
                DEBUGMSG(ZONE_ERROR,(DBGTEXT("!DisconnectDlgDone: LB_GETITEMDATA %d returned NULL"),i));
            }
            else
                LocalFree(pNetRes);
        }
    }

    if (!EndDialog(hDlg, bResult))
        DEBUGMSG(ZONE_ERROR,(DBGTEXT("!DisconnectDlgDone: Error in EndDialog(%X): %u"),
                             hDlg,GetLastError()));
}
Ejemplo n.º 10
0
/* This function removes an item from the outbasket.
 */
void FASTCALL DeleteFromOutBasket( LPOB lpob )
{
   /* Now closes down the window if there is one
    * YH 03/05/96
    */
   HWND hwndSay;

   if( hwndSay = Amob_GetEditWindow( lpob ) )
      SendDlgCommand( hwndSay, IDCANCEL, BN_CLICKED );
   if( NULL != hwndOutBasket && !fIgnoreDeleteEvent )
      {
      HWND hwndList;

      hwndList = GetDlgItem( hwndOutBasket, IDD_LIST );
      if( hwndList )
         {
         int wCount;
         int nSel;

         wCount = ListBox_GetCount( hwndList );
         for( nSel = 0; nSel < wCount; ++nSel )
            if( (LPOB)ListBox_GetItemData( hwndList, nSel ) == lpob )
               {
               if( ListBox_DeleteString( hwndList, nSel ) == nSel )
                  --nSel;
               if( ListBox_GetSelCount( hwndList ) == 0 )
                  ListBox_SetSel( hwndList, TRUE, nSel );
               break;
               }
         }
      UpdateOutBasketStatus();
      }
}
Ejemplo n.º 11
0
CUserControlListElement* CUserControlList::GetSelectedElement()
{
	//получить индекс выделенного элемента
	UINT ElementIndex=ListBox_GetCurSel(mhWindow);
	if(ElementIndex==LB_ERR) return NULL;
	return (CUserControlListElement*)ListBox_GetItemData(mhWindow,ElementIndex);
}
Ejemplo n.º 12
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;
}
Ejemplo n.º 13
0
int ListBox_MoveString(HWND hwndListBox, int iIndex, int iNewIndex, BOOL bRelativeToOld)
{
    int iCount = ListBox_GetCount(hwndListBox);
    int nExactNewIndex;

    if (iIndex == 0 && iNewIndex < 0)
        iNewIndex = 0;

    nExactNewIndex = bRelativeToOld ? (iIndex + iNewIndex) : iNewIndex;

    if ((bRelativeToOld && (iIndex + iNewIndex) >= iCount) ||
        (iNewIndex >= iCount))
    {
        return (LB_ERR);
    }
    else
    {
        LPTSTR pszBuffer = (LPTSTR)Mem_AllocStr(ListBox_GetTextLen(hwndListBox, iIndex) + SZ);
        LPVOID lpVoid = (LPVOID)ListBox_GetItemData(hwndListBox, iIndex);

        ListBox_GetText(hwndListBox, iIndex, pszBuffer);
        ListBox_DeleteString(hwndListBox, iIndex);
        ListBox_InsertString(hwndListBox, nExactNewIndex, pszBuffer);
        ListBox_SetItemData(hwndListBox, nExactNewIndex, lpVoid);
    
        Mem_Free(pszBuffer);
    }

    return (nExactNewIndex);
}
Ejemplo n.º 14
0
void Cls_OnAdvCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
//WM_COMMAND handler
{
	int     index;
	DWORD   dwItem;
	
	switch(codeNotify)
	{
		case LBN_SELCHANGE:
			index = ListBox_GetCurSel(hSettingsListbox);
			dwItem = ListBox_GetItemData(hSettingsListbox, index);
			
			if ( hCurrentDlg )
				ShowWindow(hCurrentDlg, SW_HIDE);
				
			if ( dwItem IS IDI_ERROR_LOG )
				hCurrentDlg = hErrLogDlg;
			else if ( dwItem IS IDI_ERROR_HANDLING )
				hCurrentDlg = hErrorsDlg;
			else if ( dwItem IS IDI_MEMORY )
				hCurrentDlg = hMemoryDlg;
			else if ( dwItem IS IDI_SECURITY )
				hCurrentDlg = hSecurityDlg;
			else if ( dwItem IS IDI_SETUP )
				hCurrentDlg = hSetupDlg;
			else if ( dwItem IS IDI_OUTPUT )
				hCurrentDlg = hOutputDlg;
			ShowWindow(hCurrentDlg, SW_SHOW);
			break;

			default:
				;
	}
}
Ejemplo n.º 15
0
/*
 * SetItemAttr()
 */
void TxLbx_SetItemAttr(HWND listBox, int lbxItem, TXLBX_ATTR attr)
{
    DWORD data = ListBox_GetItemData(listBox, lbxItem) & 0x00FFFFFF;

    data |= attr;
    ListBox_SetItemData(listBox, lbxItem, data);
}
Ejemplo n.º 16
0
void CSetDlgNetwork::OnBnClickedButtonDelUdp()
{
	// TODO: ここにコントロール通知ハンドラー コードを追加します。
	HWND hItem = GetDlgItem(IDC_LIST_IP_UDP);
	int sel = ListBox_GetCurSel(hItem);
	if( sel != LB_ERR ){
		int index = (int)ListBox_GetItemData(hItem, sel);

		vector<NW_SEND_INFO>::iterator itr;
		itr = udpSendList.begin();
		advance(itr, index);
		udpSendList.erase(itr);

		ListBox_ResetContent(hItem);

		for( int i=0; i<(int)udpSendList.size(); i++ ){
			wstring add = L"";
			Format(add, L"%s:%d",udpSendList[i].ipString.c_str(), udpSendList[i].port);
			if( udpSendList[i].broadcastFlag == TRUE ){
				add+= L" ブロードキャスト";
			}
			index = ListBox_AddString(hItem, add.c_str());
			ListBox_SetItemData(hItem, index, i);
		}
	}
}
Ejemplo n.º 17
0
/*
    A font is currently selected at index.
    Get the string associated with that index.
    Enumerate the fonts again.
    Find the same string in the newly enumerated list, if it exists.
    If all goes well return the new index and font handle.
    If the font disappeared return RetryNotFound and
    the index and font handle are garbage.
    If something else goes wrong, return RetryFailure and
    the index and font handle are garbage.

*/
enum RetryStati RetryAndSelectString(HWND hwnd,
                                            int  *lpIndex,
                                            HCOMPONENT *lphFontHandle)
{
	LPTSTR lpszSelectedString;
	int   length;

	// Save away the name of the selected
	// font so we can find it in the new list.
	// It is possible for the name to be good
	// but the handle to be bad.

	if ((length = ListBox_GetTextLen(hwnd, *lpIndex)) IS LB_ERR)
		// length contains the length of the string in characters
	{
		return RetryFailure;
	}

	lpszSelectedString = (LPTSTR) HP_GLOBAL_ALLOC_DLL((length + 1) * sizeof(TCHAR));
	if (lpszSelectedString IS NULL)
	{
		return RetryFailure;
	}

	if (LB_ERR IS ListBox_GetText(hwnd, *lpIndex, lpszSelectedString))
	{
		HP_GLOBAL_FREE(lpszSelectedString);
		return RetryFailure;
	}

	// Enumerate again

	GetFontListAndDisplay(hDisk);

	// Try to find the previously selected string
	// in the new enumeration.

	*lpIndex = ListBox_FindStringExact(hwnd, 0, lpszSelectedString);
	if (*lpIndex IS LB_ERR)
	{
		HP_GLOBAL_FREE(lpszSelectedString);
		return RetryNotFound;
	} // *lpIndex = ListBox_FindStringExact

	// Select the new item
	// and get the new handle for the selected item.

	ListBox_SetCurSel(hwnd, *lpIndex);
 	if (!(*lphFontHandle =
	     (HCOMPONENT)ListBox_GetItemData(hwnd, *lpIndex)))
	{
		HP_GLOBAL_FREE(lpszSelectedString);
		return RetryFailure;
	}

	HP_GLOBAL_FREE(lpszSelectedString);
	return RetrySuccess;

} // RetryAndSelectString
Ejemplo n.º 18
0
static void DispInfoExt(HWND hDlg,CShellExt *lpcs)
{
	//クリア
	long items = ListBox_GetCount(GetDlgItem(hDlg,IDC_LIST_VALUE));
	if(items != LB_ERR)
	{
		for(int i=0; i<items; i++)
		{
			COggExt *oggExt = (COggExt *)ListBox_GetItemData(GetDlgItem(hDlg,IDC_LIST_VALUE),0);
			if(oggExt)
			{
				delete oggExt;
			}
			ListBox_DeleteString(GetDlgItem(hDlg,IDC_LIST_VALUE),0);
		}
	}

	CString strDisp;
	CStringArray strArray;
	lpcs->m_Ogg.GetCommentNames(strArray);
	items = 0;
	for(int i=0; i<strArray.GetSize(); i++)
	{
		CString strName = strArray.GetAt(i);
		CString strValue;
		CString _strValue;
		int j = 0;
		while(1)
		{
			if(!lpcs->m_Ogg.GetComment(strName,j++,strValue))
			{
				break;
			}

			//標準名は除外
			if((j == 1) &&
				(
				!strName.Compare(_T("TITLE")) ||
				!strName.Compare(_T("TRACKNUMBER")) ||
				!strName.Compare(_T("ARTIST")) ||
				!strName.Compare(_T("ALBUM")) ||
				!strName.Compare(_T("ALBUMARTIST")) ||
				!strName.Compare(_T("DISCNUMBER")) ||
				!strName.Compare(_T("DATE")) ||
				!strName.Compare(_T("GENRE")) ||
				!strName.Compare(_T("COMMENT")))
				)
			{
				continue;
			}
//			TRACE(_T("OGG %s %s\n"),strName,strValue);
			COggExt *oggExt = new COggExt(strName,strValue);
			ListBox_AddString(GetDlgItem(hDlg,IDC_LIST_VALUE),oggExt->Get1LineDisp());
			ListBox_SetItemData(GetDlgItem(hDlg,IDC_LIST_VALUE),items,oggExt);
			items++;
		}
	}
}
Ejemplo n.º 19
0
/* 
 * StatsListDrawStat:  Draw info about stat in stat list box.
 *   selected is True iff the item is currently selected.
 */
void StatsListDrawStat(const DRAWITEMSTRUCT *lpdis, Bool selected, Bool bShowSpellIcon )
{
   HFONT hOldFont;
   Statistic *s;
   char str[MAXRSCSTRING + 10];
   RECT r;
   int lastItem = ListBox_GetCount(lpdis->hwndItem) - 1;
   RECT rcWnd;

   GetClientRect(lpdis->hwndItem,&rcWnd);
   if (lpdis->rcItem.bottom > rcWnd.bottom)
      return;

   hOldFont = (HFONT) SelectObject(lpdis->hDC, GetFont(FONT_STATS));

   s = (Statistic *) ListBox_GetItemData(hList, lpdis->itemID);
   if (s == NULL)
      return;

   sprintf(str, "%s %d%%", LookupNameRsc(s->name_res), s->list.value);

   SetBkMode(lpdis->hDC, TRANSPARENT);

   memcpy(&r, &lpdis->rcItem, sizeof(RECT));
   r.left += ENCHANT_SIZE + 2;
   // Draw text with drop shadow
   SetTextColor(lpdis->hDC, GetColor(COLOR_STATSBGD));
   //DrawText(lpdis->hDC, str, strlen(str), &r,  DT_CENTER);
   DrawText( lpdis->hDC, str, strlen(str), &r, DT_LEFT );
   OffsetRect(&r, 1, 1);
   SetTextColor(lpdis->hDC, selected ? GetColor(COLOR_HIGHLITE) : GetColor(COLOR_STATSFGD));
   //DrawText(lpdis->hDC, str, strlen(str), &r,  DT_CENTER);
   DrawText( lpdis->hDC, str, strlen(str), &r, DT_LEFT );

   SelectObject(lpdis->hDC, hOldFont);

   switch (StatsGetCurrentGroup())
   {
   AREA areaIcon;
   case STATS_SPELLS:
   case STATS_SKILLS:
      areaIcon.x = lpdis->rcItem.left;
      areaIcon.y = lpdis->rcItem.top;
      areaIcon.cx = ENCHANT_SIZE;		//xxx
      areaIcon.cy = ENCHANT_SIZE;
      DrawObjectIcon(lpdis->hDC, s->list.icon, 0, True, &areaIcon, NULL, 0, 0, True);
      break;
   }
   if (lastItem == (int)lpdis->itemID)
   {
      RECT rcWnd;
      GetClientRect(lpdis->hwndItem,&rcWnd);
      rcWnd.top = lpdis->rcItem.bottom;
      if (rcWnd.top < rcWnd.bottom)
	 InvalidateRect(lpdis->hwndItem,&rcWnd,TRUE);
   }
}
Ejemplo n.º 20
0
LRESULT CALLBACK SelectDlgProc( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	switch( uMsg ) {
	case WM_INITDIALOG : {
		char szLocalePath[256], szDisplayName[256];
		for(int i=0; gs_stLocaleData[i].szServiceName; i++ ) {
			sprintf(szLocalePath, "locale/%s/item_proto", gs_stLocaleData[i].szLocaleName);
			if( CEterPackManager::Instance().isExist(szLocalePath)) {
				sprintf(szDisplayName, "%s (%s, %d)", gs_stLocaleData[i].szLocaleName, gs_stLocaleData[i].szServiceName, gs_stLocaleData[i].wCodePage);
				int iIndex = ListBox_AddString(GetDlgItem(hDlg, IDC_LOCALE_LIST), szDisplayName);
				ListBox_SetItemData(GetDlgItem(hDlg, IDC_LOCALE_LIST), iIndex, i);
			}
		}
		return TRUE;
		}
	case WM_COMMAND :
		switch( LOWORD( wParam ) ) {
		case IDC_LOCALE_LIST: {
			int iSelected = ListBox_GetCurSel(GetDlgItem(hDlg, IDC_LOCALE_LIST));
			switch(HIWORD(wParam)) {
			case LBN_SELCHANGE :
				gs_iLocale = ListBox_GetItemData(GetDlgItem(hDlg, IDC_LOCALE_LIST), iSelected);
				break;
			case LBN_DBLCLK :
				gs_iLocale = ListBox_GetItemData(GetDlgItem(hDlg, IDC_LOCALE_LIST), iSelected);
				::EndDialog(hDlg, 0);
				break;
			} 
			break;
			}
		case IDC_START: {
			::EndDialog(hDlg, 0);
			break;
			}
		case IDC_EXIT: {
			gs_iLocale = -1;
			::EndDialog(hDlg, 0);
			break;
			}
		}
		return FALSE;
	}
	return FALSE;
}
Ejemplo n.º 21
0
VOID CUserControlList::Clear()
{
	//удалить все элементы в списке
	while(ListBox_GetCount(mhWindow))
	{
		//удалить элемент
		delete (CUserControlListElement*)ListBox_GetItemData(mhWindow,0);
		ListBox_DeleteString(mhWindow,0);
	}
}
Ejemplo n.º 22
0
int CCreateLightNodeWindow::GetSelectedItemId()
{
	int itemIndex = ListBox_GetCurSel(mLightNodesList);
	if (itemIndex != LB_ERR)
	{
		u32 id = ListBox_GetItemData(mLightNodesList, itemIndex);
		return id;
	}
	return -1;
}
Ejemplo n.º 23
0
VOID CUserControlList::DeleteSelectedElement()
{
	//получить выделенный элемент
	UINT ElementIndex=ListBox_GetCurSel(mhWindow);
	if(ElementIndex!=LB_ERR)
	{
		//удалить элемент
		delete (CUserControlListElement*)ListBox_GetItemData(mhWindow,ElementIndex);
		ListBox_DeleteString(mhWindow,ElementIndex);
	}
}
Ejemplo n.º 24
0
void plAgeDescInterface::ISaveCurAge( const plFileName &path, bool checkSeqNum )
{
    hsUNIXStream s;
    if( !s.Open( path, "wt" ) )
    {
        hsMessageBox("Unable to open the Age Description file for writing. Updates not saved.", "Error", hsMessageBoxNormal);
        return;
    }

    plAgeDescription aged;
    aged.SetAgeNameFromPath( path );

    // set the date and time
    HWND hDate = GetDlgItem(fhDlg, IDC_DATE);
    SYSTEMTIME dst = {0};
    DateTime_GetSystemtime(hDate, &dst);
    HWND hTime = GetDlgItem(fhDlg, IDC_TIME);
    SYSTEMTIME tst = {0};
    DateTime_GetSystemtime(hTime, &tst);
    aged.SetStart(dst.wYear,dst.wMonth,dst.wDay,tst.wHour,tst.wMinute,tst.wSecond);
    aged.SetDayLength(fSpin->GetFVal());
    aged.SetMaxCapacity(fCapSpin->GetIVal());
    if( checkSeqNum )
    {
        ICheckSequenceNumber( aged );
    }
    else if( IsDlgButtonChecked( fhDlg, IDC_RSVDCHECK ) )
    {
        // Store reserved sequence prefix
        aged.SetSequencePrefix( -fSeqPrefixSpin->GetIVal() );
    }
    else
    {
        aged.SetSequencePrefix( fSeqPrefixSpin->GetIVal() );
    }

    // gather pages
    HWND hPages = GetDlgItem(fhDlg, IDC_PAGE_LIST);
    int count = ListBox_GetCount(hPages);
    if (count != LB_ERR)
    {
        for (int i = 0; i < count; i++)
        {
            char pageName[256];
            ListBox_GetText(hPages, i, pageName);
            plAgePage *page = (plAgePage *)ListBox_GetItemData( hPages, i );
            aged.AppendPage( pageName, page->GetSeqSuffix(), page->GetFlags() );
        }
    }

    // write it all out
    aged.Write(&s);
    s.Close();
}
Ejemplo n.º 25
0
static bool GetPickedMtl(HWND hDlg, Mtl** mtl)
{
    HWND hList = GetDlgItem(hDlg, IDC_MTL_LIST);
    int sel = ListBox_GetCurSel(hList);
    if (sel != LB_ERR)
    {
        *mtl = (Mtl*)ListBox_GetItemData(hList, sel);
        return true;
    }

    return false;
}
Ejemplo n.º 26
0
void FASTCALL CmdPrintOutbasket( HWND hwnd )
{
   HPRINT hPr;
   BOOL fOk = TRUE;
   LPSTR lpOBPrintBuf;

   /* Show and get the print terminal dialog box.
    */
   if( !Adm_Dialog( hRscLib, hwnd, MAKEINTRESOURCE(IDDLG_PRINTOUTBASKET), PrintOutbasketDlg, 0L ) )
      return;

   fNewMemory( &lpOBPrintBuf, LEN_TEMPBUF );
   GetWindowText( hwnd, lpOBPrintBuf, LEN_TEMPBUF );
   if(   NULL != ( hPr = BeginPrint( hwnd, lpOBPrintBuf, &lfFixedFont ) ) )
      {
      register int cCount;

      for( cCount = 0; fOk && cCount < cCopies; ++cCount )
         {

      int nCount;
      int c;
      HWND hwndList;

      ResetPageNumber( hPr );
      fOk = BeginPrintPage( hPr );

      hwndList = GetDlgItem( hwnd, IDD_LIST );

      nCount = ListBox_GetCount( hwndList );
      for( c = 0; c != nCount; c++ )
         {
         OBINFO obinfo;
         LPOB lpob;

         lpob = (LPOB)ListBox_GetItemData( hwndList, c );
         Amob_GetObInfo( lpob, &obinfo );
         Amob_Describe( lpob, lpOBPrintBuf );
         if( TestF(obinfo.obHdr.wFlags, OBF_HOLD) )
            wsprintf( lpOBPrintBuf, "%s (H)", lpOBPrintBuf );
         if( TestF(obinfo.obHdr.wFlags, OBF_KEEP) )
            wsprintf( lpOBPrintBuf, "%s (K)", lpOBPrintBuf );
         if( fOk )
            fOk = PrintLine( hPr, lpOBPrintBuf );
         }
      if( fOk )
         EndPrintPage( hPr );
      }
      }
   EndPrint( hPr );
   if( NULL != lpOBPrintBuf )
      FreeMemory( &lpOBPrintBuf );
}
Ejemplo n.º 27
0
// Respond to a change in the function list selection.
static void onFunctionListSelChange(HWND win) {
	int idx = ListBox_GetCurSel(GetDlgItem(win, IDC_FUNCTION_LST));
	int id;
	int i;

	if (LB_ERR == idx) {
		return;
	}

	// Locate the function table entry corresponding to the selection.
	id = (int)ListBox_GetItemData(GetDlgItem(win, IDC_FUNCTION_LST), idx);
	for (i = 0; i < sizeof(functions) / sizeof(functions[0]); ++i) {
		if (functions[i].id == id) {
			break;
		}
	}
	if (i >= sizeof(functions) / sizeof(functions[0])) {
		// Shouldn't happen, but just in case...
		return;
	}

	// Clear the parameters.
	SetDlgItemText(win, IDC_PARAM1_EDT, "");
	SetDlgItemText(win, IDC_PARAM2_EDT, "");
	SetDlgItemText(win, IDC_PARAM3_EDT, "");
	SetDlgItemText(win, IDC_PARAM4_EDT, "");

	// Set the parameter labels as specified in the table.
	SetDlgItemText(win, IDC_PARAM1_LBL, functions[i].param1Lbl != NULL ?
	  functions[i].param1Lbl : "");
	SetDlgItemText(win, IDC_PARAM2_LBL, functions[i].param2Lbl != NULL ?
	  functions[i].param2Lbl : "");
	SetDlgItemText(win, IDC_PARAM3_LBL, functions[i].param3Lbl != NULL ?
	  functions[i].param3Lbl : "");
	SetDlgItemText(win, IDC_PARAM4_LBL, functions[i].param4Lbl != NULL ?
	  functions[i].param4Lbl : "");
	EnableWindow(GetDlgItem(win, IDC_PARAM1_EDT),
	  functions[i].param1Lbl != NULL);
	EnableWindow(GetDlgItem(win, IDC_PARAM2_EDT),
	  functions[i].param2Lbl != NULL);
	EnableWindow(GetDlgItem(win, IDC_PARAM3_EDT),
	  functions[i].param3Lbl != NULL);
	EnableWindow(GetDlgItem(win, IDC_PARAM4_EDT),
	  functions[i].param4Lbl != NULL);

	// Enable the session, lexicon, block id and text fields as required.
	EnableWindow(GetDlgItem(win, IDC_SESSION_ID_EDT), functions[i].sidEnabled);
	EnableWindow(GetDlgItem(win, IDC_LEXICON_ID_EDT),
	  functions[i].lexIdEnabled);
	EnableWindow(GetDlgItem(win, IDC_BLOCK_ID_EDT), functions[i].blkIdEnabled);
	EnableWindow(GetDlgItem(win, IDC_TEXT_EDT), functions[i].textEnabled);
}
Ejemplo n.º 28
0
void CInstanceInfoWindow::SelectListItem(u32 id)
{
	u32 count = ListBox_GetCount(mInstancesListBox);
	for (u32 i = 0; i < count; i++)
	{
		u32 data = ListBox_GetItemData(mInstancesListBox, i);
		if (data == id)
		{
			ListBox_SetCurSel(mInstancesListBox, i);
			return;
		}
	}
}
Ejemplo n.º 29
0
/*
 * MailFindIndex:  Return index in list box of message with given number.
 *   Returns -1 if message not found.
 */
int MailFindIndex(int number)
{
   int i, msgnum, num_msgs;

   num_msgs = ListBox_GetCount(hMsgList);
   for (i=0; i < num_msgs; i++)
   {
      msgnum = ListBox_GetItemData(hMsgList, i);
      if (msgnum == number)
	 return i;
   }
   return -1;
}
Ejemplo n.º 30
0
void CCreateLightNodeWindow::SelectListItem(u32 id)
{
	u32 count = ListBox_GetCount(mLightNodesList);
	for (u32 i = 0; i < count; i++)
	{
		u32 data = ListBox_GetItemData(mLightNodesList, i);
		if (data == id)
		{
			ListBox_SetCurSel(mLightNodesList, i);
			return;
		}
	}
}