Example #1
1
void Main_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{

    switch(id)
    {
        case IDC_BUTTON2:
		{
			OPENFILENAME ofn;
			char szFile[MAX_PATH];
			ZeroMemory(&ofn,sizeof(ofn));
			ofn.lStructSize = sizeof(ofn);
			ofn.lpstrFile = szFile;
			ofn.lpstrFile[0] = TEXT('\0');
			ofn.nMaxFile = sizeof(szFile);
			ofn.lpstrFilter = TEXT("ALL\0*.*\0Text\0*.txt\0C++\0*.cpp\0mp3\0*.mp3\0");
			ofn.nFilterIndex = 1;
			ofn.lpstrFileTitle = NULL;
			ofn.nMaxFileTitle = 0;
			ofn.lpstrInitialDir = NULL;
			ofn.hwndOwner = hwnd;
			ofn.Flags = OFN_EXPLORER|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST;
			if(GetOpenFileName(&ofn))
			{
				char songname[256];
				wsprintf(songname,"play %s repeat",szFile);
				mciSendString(songname,"",0,NULL);
				SetDlgItemText(hwnd,IDC_EDIT2,szFile);
			}
		}
        break;
		case IDC_BUTTON3:
		{
			OPENFILENAME ofn;
			char szFile[MAX_PATH];
			ZeroMemory(&ofn,sizeof(ofn));
			ofn.lStructSize = sizeof(ofn);
			ofn.lpstrFile = szFile;
			ofn.lpstrFile[0] = TEXT('\0');
			ofn.nMaxFile = sizeof(szFile);
			ofn.lpstrFilter = TEXT("mp3\0*.mp3\0AVI\0*.avi\0");
			ofn.nFilterIndex = 1;
			ofn.lpstrFileTitle = NULL;
			ofn.nMaxFileTitle = 0;
			ofn.lpstrInitialDir = NULL;
			ofn.hwndOwner = hwnd;
			ofn.Flags = OFN_EXPLORER|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_ALLOWMULTISELECT;
			if(GetOpenFileName(&ofn))
			{
				TCHAR songname[256];
				HWND Combo1 = GetDlgItem(hwnd,IDC_LIST1);
				int count = ListBox_GetCount(Combo1),loc,i=0;
				for(loc=0;loc<count;loc++)
				{
					ListBox_GetText(Combo1,loc,songname);
					if(strcmp(songname,szFile)==0){
						MessageBox(NULL,TEXT("此选项已经存在,请重新选择!"),TEXT("       重试"),MB_OK|MB_ICONEXCLAMATION);
						break;}
					i++;
				}
				if(i==count)
					ListBox_InsertString(Combo1,-1,szFile);
			}
		}
		break;
		case IDC_BUTTON4:
		{
			TCHAR EDIT[256],STOPSTR[256];
			GetDlgItemText(hwnd,IDC_EDIT2,EDIT,sizeof(EDIT));
			wsprintf(STOPSTR,"stop %s",EDIT);
			mciSendString(STOPSTR,"",0,NULL);
			TCHAR str1[256];
			HWND Combo1 = GetDlgItem(hwnd,IDC_LIST1);
			int cixu = ListBox_GetCurSel(Combo1);
			if(cixu==-1){
				MessageBox(NULL,TEXT("未选择播放歌曲"),TEXT("       重试"),MB_OK|MB_ICONEXCLAMATION);break;}
			ListBox_GetText(Combo1,cixu,str1);
			TCHAR songname[256];
			wsprintf(songname,"play %s repeat",str1);
			mciSendString(songname,"",0,NULL);
			SetDlgItemText(hwnd,IDC_EDIT2,str1);
			TCHAR leth[256],str2[256],str3[256];
			wsprintf(str2,"status %s length",str1);			
			mciSendString(str2,leth,sizeof(leth)/sizeof(char),NULL);
			int tminute,tsecond;
			int lll = atoi(leth);
			int totalsecond = atoi(leth)/1000;
			tminute = totalsecond/60;
			tsecond = totalsecond-tminute*60;
			wsprintf(str3,"%02d:%02d",tminute,tsecond);
			SetDlgItemText(hwnd,IDC_TIME,str3);
			SendDlgItemMessage(hwnd,IDC_SLIDER2,TBM_SETRANGEMAX,false,(LPARAM)(totalsecond-1));
			SendDlgItemMessage(hwnd,IDC_SLIDER2,TBM_SETRANGEMIN,false,(LPARAM)0);
			SetTimer(hwnd,1,1000,progressBar);			
		}
		break;
		case IDC_BUTTON1:
		{
			TCHAR str1[256];
			HWND Combo1 = GetDlgItem(hwnd,IDC_LIST1);
			int cixu = ListBox_GetCurSel(Combo1);
			if(cixu==-1){
				MessageBox(NULL,TEXT("未选择播放歌曲"),TEXT("       重试"),MB_OK|MB_ICONEXCLAMATION);break;}
			GetDlgItemText(hwnd,IDC_EDIT2,str1,sizeof(str1));
			TCHAR songname[256];
			wsprintf(songname,"pause %s",str1);
			mciSendString(songname,"",0,NULL);	
		}
		break;
		case IDC_BUTTON5:
		{
			
			HWND Combo1 = GetDlgItem(hwnd,IDC_LIST1);
			int cixu = ListBox_GetCurSel(Combo1);
			if(cixu==-1){
				MessageBox(NULL,TEXT("未选择歌曲"),TEXT("       重试"),MB_OK|MB_ICONEXCLAMATION);break;}			
			ListBox_DeleteString(Combo1,cixu);
		}
		break;
		case IDC_BUTTON6:
		{
			TCHAR str1[256];
			HWND Combo1 = GetDlgItem(hwnd,IDC_LIST1);
			int cixu = ListBox_GetCurSel(Combo1);
			if(cixu==-1){
				MessageBox(NULL,TEXT("未选择播放歌曲"),TEXT("       重试"),MB_OK|MB_ICONEXCLAMATION);break;}
			GetDlgItemText(hwnd,IDC_EDIT2,str1,sizeof(str1));
			TCHAR songname[256];
			wsprintf(songname,"play %s repeat",str1);
			mciSendString(songname,"",0,NULL);
			SetDlgItemText(hwnd,IDC_EDIT2,str1);
		}
		break;
		case IDC_BUTTON7:
		{
			TCHAR EDI[256],STOPS[256];
			HWND Combo1 = GetDlgItem(hwnd,IDC_LIST1);
			int cixu = ListBox_GetCurSel(Combo1);
			if(cixu==-1){
				MessageBox(NULL,TEXT("未选择歌曲"),TEXT("       重试"),MB_OK|MB_ICONEXCLAMATION);break;}
			GetDlgItemText(hwnd,IDC_EDIT2,EDI,sizeof(EDI));
			wsprintf(STOPS,"stop %s",EDI);
			mciSendString(STOPS,"",0,NULL);
			
			TCHAR str[256],str1[256],str2[256],str3[256];
			GetDlgItemText(hwnd,IDC_EDIT2,str,sizeof(str));
			int location;
			int count = ListBox_GetCount(Combo1);
			for(location=0;location<count;location++)
			{
				ListBox_GetText(Combo1,location,str2);
				if(strcmp(str,str2)==0)
				{
					if(location==0)
						location=count;
					location = location-1;
					ListBox_GetText(Combo1,location,str3);
					wsprintf(str1,"play %s repeat",str3);
					mciSendString(str1,"",0,NULL);
					SetDlgItemText(hwnd,IDC_EDIT2,str3);
					ListBox_SetCurSel(Combo1,location);
					break;
				}
			}
			TCHAR leth[256],str4[256],str5[256];
			wsprintf(str4,"status %s length",str3);			
			mciSendString(str4,leth,sizeof(leth)/sizeof(char),NULL);
			int tminute,tsecond;
			int lll = atoi(leth);
			int totalsecond = atoi(leth)/1000;
			tminute = totalsecond/60;
			tsecond = totalsecond-tminute*60;
			wsprintf(str5,"%02d:%02d",tminute,tsecond);
			SetDlgItemText(hwnd,IDC_TIME,str5);
			SendDlgItemMessage(hwnd,IDC_SLIDER2,TBM_SETRANGEMAX,false,(LPARAM)(totalsecond-1));
			SendDlgItemMessage(hwnd,IDC_SLIDER2,TBM_SETRANGEMIN,false,(LPARAM)0);
		}
		break;
		case IDC_BUTTON8:
		{	
			TCHAR EDIT[256],STOPSTR[256];
			HWND Combo1 = GetDlgItem(hwnd,IDC_LIST1);
			int cixu = ListBox_GetCurSel(Combo1);
			if(cixu==-1){
				MessageBox(NULL,TEXT("未选择播放歌曲"),TEXT("       重试"),MB_OK|MB_ICONEXCLAMATION);break;}
			GetDlgItemText(hwnd,IDC_EDIT2,EDIT,sizeof(EDIT));
			wsprintf(STOPSTR,"stop %s",EDIT);
			mciSendString(STOPSTR,"",0,NULL);
			
			TCHAR str[256],str1[256],str2[256],str3[256];
			GetDlgItemText(hwnd,IDC_EDIT2,str,sizeof(str));
			int location;
			int count = ListBox_GetCount(Combo1);
			for(location=0;location<count;location++)
			{
				ListBox_GetText(Combo1,location,str2);
				if(strcmp(str,str2)==0)
				{
					location++;
					if(location==count)
						location=0;
					ListBox_GetText(Combo1,location,str3);
					wsprintf(str1,"play %s repeat",str3);
					mciSendString(str1,"",0,NULL);
					SetDlgItemText(hwnd,IDC_EDIT2,str3);
					ListBox_SetCurSel(Combo1,location);
					break;
				}
			}
			TCHAR leth[256],str4[256],str5[256];
			wsprintf(str4,"status %s length",str3);			
			mciSendString(str4,leth,sizeof(leth)/sizeof(char),NULL);
			int tminute,tsecond;
			int totalsecond = atoi(leth)/1000;
			tminute = totalsecond/60;
			tsecond = totalsecond-tminute*60;
			wsprintf(str5,"%02d:%02d",tminute,tsecond);
			SetDlgItemText(hwnd,IDC_TIME,str5);
			SendDlgItemMessage(hwnd,IDC_SLIDER2,TBM_SETRANGEMAX,false,(LPARAM)(totalsecond-1));
			SendDlgItemMessage(hwnd,IDC_SLIDER2,TBM_SETRANGEMIN,false,(LPARAM)0);
		}
		case IDC_BUTTON9:
		{
			int loc;
			HWND Combo1 = GetDlgItem(hwnd,IDC_LIST1);
			int cixu = ListBox_GetCurSel(Combo1);
			if(cixu==-1){
				MessageBox(NULL,TEXT("无歌曲可保存"),TEXT("       重试"),MB_OK|MB_ICONEXCLAMATION);break;}
			OPENFILENAME ofn;
			char szFile[MAX_PATH];
			ZeroMemory(&ofn,sizeof(ofn));
			ofn.lStructSize = sizeof(ofn);
			ofn.lpstrFile = szFile;
			ofn.lpstrFile[0] = TEXT('\0');
			ofn.nMaxFile = sizeof(szFile);
			ofn.lpstrFilter = TEXT("mp3\0*.mp3\0AVI\0*.avi\0text\0*.txt\0");
			ofn.nFilterIndex = 3;
			ofn.lpstrFileTitle = NULL;
			ofn.nMaxFileTitle = 0;
			ofn.lpstrInitialDir = NULL;
			ofn.hwndOwner = hwnd;
			ofn.Flags = OFN_EXPLORER|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_ALLOWMULTISELECT;
			if(GetSaveFileName(&ofn))
			{
				
				
				FILE *fp;
				TCHAR EDI[256],str[256],str1[256];
				wsprintf(str1,"%s.txt",szFile);
				int count = ListBox_GetCount(Combo1);
				fp = fopen(str1,"w");
				for(loc=0;loc<count;loc++)
				{
					ListBox_GetText(Combo1,loc,EDI);
					wsprintf(str,"%s\n",EDI);								
					fputs(str,fp);				
				}
				fclose(fp);
			}
			
		}
		break;
		case IDC_GETLIST:
		{
			OPENFILENAME ofn;
			char szFile[MAX_PATH];
			ZeroMemory(&ofn,sizeof(ofn));
			ofn.lStructSize = sizeof(ofn);
			ofn.lpstrFile = szFile;
			ofn.lpstrFile[0] = TEXT('\0');
			ofn.nMaxFile = sizeof(szFile);
			ofn.lpstrFilter = TEXT("mp3\0*.mp3\0AVI\0*.avi\0text\0*.txt\0");
			ofn.nFilterIndex = 3;
			ofn.lpstrFileTitle = NULL;
			ofn.nMaxFileTitle = 0;
			ofn.lpstrInitialDir = NULL;
			ofn.hwndOwner = hwnd;
			ofn.Flags = OFN_EXPLORER|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST|OFN_ALLOWMULTISELECT;
			if(GetOpenFileName(&ofn))
			{
				FILE *fp;
				HWND ListBox = GetDlgItem(hwnd,IDC_LIST1);
				TCHAR songname[256];
				fp = fopen(szFile,"a+");
				int size=100,loc;
				while(fgets(songname,sizeof(songname),fp)!=0)
				{
					for(loc = 0;loc<size;loc++)
					{
						if(songname[loc]=='\n')
							songname[loc]='\0';
					}
					ListBox_InsertString(ListBox,-1,songname);		
				}
				fclose(fp);
			}
			
		}
		break;
		case IDC_LIST1:
		{
			TCHAR buf[256];
			if(LBN_DBLCLK==codeNotify)
			{
				TCHAR EDIT[256],STOPSTR[256],PLAYSTR[256];
				HWND Combo1 = GetDlgItem(hwnd,IDC_LIST1);				
				GetDlgItemText(hwnd,IDC_EDIT2,EDIT,sizeof(EDIT));
				wsprintf(STOPSTR,"stop %s",EDIT);
				mciSendString(STOPSTR,"",0,NULL);
				int index = SendDlgItemMessage(hwnd,IDC_LIST1,LB_GETCURSEL,0,0);
				SetTimer(hwnd,2,1000,progressBar);
				SendDlgItemMessage(hwnd,IDC_LIST1,LB_GETTEXT,index,(LPARAM)buf);
				wsprintf(PLAYSTR,"play %s repeat",buf);
				mciSendString(PLAYSTR,"",0,NULL);
				SetDlgItemText(hwnd,IDC_EDIT2,buf);//				ListBox_SetCurSel(Combo1,index);
				TCHAR leth[256],str4[256],str5[256];
				wsprintf(str4,"status %s length",buf);			
				mciSendString(str4,leth,sizeof(leth)/sizeof(char),NULL);
				int tminute,tsecond;
				int totalsecond = atoi(leth)/1000;
				tminute = totalsecond/60;
				tsecond = totalsecond-tminute*60;
				wsprintf(str5,"%02d:%02d",tminute,tsecond);
				SetDlgItemText(hwnd,IDC_TIME,str5);
				SendDlgItemMessage(hwnd,IDC_SLIDER2,TBM_SETRANGEMAX,false,(LPARAM)(totalsecond-1));
				SendDlgItemMessage(hwnd,IDC_SLIDER2,TBM_SETRANGEMIN,false,(LPARAM)0);
								
			}						
		}
		break;
		case IDC_MOVIE:
		{
			TCHAR buf[256],buf1[256],buf2[256];
			TCHAR EDIT[256],STOPSTR[256],PLAYSTR[256];
			GetDlgItemText(hwnd,IDC_EDIT2,EDIT,sizeof(EDIT));
			wsprintf(STOPSTR,"stop %s",EDIT);
			mciSendString(STOPSTR,"",0,NULL);
			HWND movie = GetDlgItem(hwnd,IDC_LIST1);
			int cur = SendDlgItemMessage(hwnd,IDC_LIST1,LB_GETCURSEL,false,0);
			ListBox_GetText(movie,cur,buf);
			wsprintf(buf1,"open %s type MPEGVideo",buf);
			wsprintf(buf2,"play %s",buf);
			mciSendString(buf1,0,0,NULL);
			mciSendString(buf2,0,0,NULL);
			SetDlgItemText(hwnd,IDC_EDIT2,buf);								
		}
        default:
		break;
    }
}
Example #2
0
void w32g_rotate_playlist(int dest)
{
    int i, i1, i2;
    HWND hListBox;
    PlayListEntry save;
	char temp[1024];

    if(playlist.nfiles == 0)
	return;
    if(!(hListBox = playlist_box()))
	return;

    i1 = ListBox_GetCurSel(hListBox);
    i2 = playlist.nfiles - 1;
    if(i1 >= i2)
	return;

#ifdef W32G_RANDOM_IS_SHUFFLE
	w32g_shuffle_playlist_rotate(dest,i1,i2);
#endif
    if(dest > 0)
    {
	save = playlist.list[i2];
	for(i = i2; i > i1; i--) /* i: i2 -> i1 */
	    playlist.list[i] = playlist.list[i - 1];
	playlist.list[i] = save;
	ListBox_GetText(hListBox,i2,temp);
    ListBox_DeleteString(hListBox,i2);
    ListBox_InsertString(hListBox,i1,temp);
	ListBox_SetCurSel(hListBox,i1);
	if(playlist.selected == i2){
	    playlist.selected = i1;
		w32g_update_playlist_pos(playlist.selected);
	} else if(i1 <= playlist.selected && playlist.selected < i2){
	    playlist.selected++;
		w32g_update_playlist_pos(playlist.selected);
	}
    }
    else
    {
	save = playlist.list[i1];
	for(i = i1; i < i2; i++) /* i: i1 -> i2 */
	    playlist.list[i] = playlist.list[i + 1];
	playlist.list[i] = save;
	ListBox_GetText(hListBox,i1,temp);
    ListBox_DeleteString(hListBox,i1);
    ListBox_InsertString(hListBox,-1,temp);
	ListBox_SetCurSel(hListBox,i1);
	if(playlist.selected == i1){
	    playlist.selected = i2;
		w32g_update_playlist_pos(playlist.selected);
	} else if(i1 < playlist.selected && playlist.selected <= i2){
	    playlist.selected--;    
		w32g_update_playlist_pos(playlist.selected);
	}
    }
}
Example #3
0
BOOL CALLBACK LOADDS 
ReadMailDlgProc(HWND hWndMail, UINT wMsg, WPARAM wParam, LPARAM lParam) 
{
  switch (wMsg) 
  {
  case WM_INITDIALOG: 
    {
      DWORD i;
      // Do everything we need to display the message pointed to by
      // mailPtr
      if (!mailPtr)
        break;

      // Start with the basics...
      SetDlgItemText(hWndMail, IDC_EDIT_SUBJECT, mailPtr->lpszSubject);
      SetDlgItemText(hWndMail, IDC_EDIT_DATETIME, mailPtr->lpszDateReceived);
      SetDlgItemText(hWndMail, IDC_EDIT_THREAD, mailPtr->lpszConversationID);
      SetDlgItemText(hWndMail, IDC_EDIT_BODYTEXT, mailPtr->lpszNoteText);

      char    buf[1024];
      wsprintf(buf, "%s (%s)", mailPtr->lpOriginator->lpszName, 
                              mailPtr->lpOriginator->lpszAddress);
      SetDlgItemText(hWndMail, IDC_EDIT_FROM, buf);

      for (i=0; i<mailPtr->nRecipCount; i++)
      {
          wsprintf(buf, "%s (%s)", mailPtr->lpRecips[i].lpszName, 
                                   mailPtr->lpRecips[i].lpszAddress);
          ListBox_InsertString(GetDlgItem(hWndMail, IDC_LIST_RECIPIENTS), 
                  ListBox_GetCount(GetDlgItem(hWndMail, IDC_LIST_RECIPIENTS)), 
                  buf);
      }

      for (i=0; i<mailPtr->nFileCount; i++)
      {
          ListBox_InsertString(GetDlgItem(hWndMail, IDC_LIST_ATTACHMENTS), 
                ListBox_GetCount(GetDlgItem(hWndMail, IDC_LIST_ATTACHMENTS)), 
                mailPtr->lpFiles[i].lpszPathName);
      }
    }
    break;

  case WM_COMMAND:
    HANDLE_WM_COMMAND(hWndMail, wParam, lParam, ProcessReadMailCommand);
    break;

  default:
    return FALSE;
  }
  
  return TRUE;
}
Example #4
0
/*
 * ReplaceItem() - 
 */
void TxLbx_ReplaceItem(HWND listBox, int idx, const _TUCHAR *text, DWORD itemData
        , TXLBX_ATTR attr)
{
    ListBox_DeleteString(listBox, idx);
    ListBox_InsertString(listBox, idx, text);
    ListBox_SetItemData(listBox, idx, attr | (itemData & 0x00FFFFFF));
}
Example #5
0
void
wxListBox::DoInsertItems(const wxArrayString& items, unsigned int pos)
{
    wxCHECK_RET( IsValidInsert(pos),
                 wxT("invalid index in wxListBox::InsertItems") );

    unsigned int nItems = items.GetCount();
    for ( unsigned int i = 0; i < nItems; i++ )
    {
        int idx = ListBox_InsertString(GetHwnd(), i + pos, items[i]);

#if wxUSE_OWNER_DRAWN
        if ( m_windowStyle & wxLB_OWNERDRAW )
        {
            wxOwnerDrawn *pNewItem = CreateLboxItem(idx);
            pNewItem->SetName(items[i]);
            pNewItem->SetFont(GetFont());
            m_aItems.Insert(pNewItem, idx);

            ListBox_SetItemData(GetHwnd(), idx, pNewItem);
        }
#else
        wxUnusedVar(idx);
#endif // wxUSE_OWNER_DRAWN
    }

    m_noItems += nItems;

    SetHorizontalExtent();
}
Example #6
0
void AppendLog(char* str) {
	HWND list = GetDlgItem(ghWndOutput, IDC_LST_OUTPUT);

	ListBox_InsertString(list, -1,str);
	ListBox_SetCurSel(list, ListBox_GetCount(list) - 1);
	SetFocus(list);
}
Example #7
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);
}
Example #8
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 ;
	}
Example #9
0
/*
 * InsertItem() - Inserts an item into the list box at a specific index.
 */
int TxLbx_InsertItem(HWND listBox, int idx, const _TUCHAR *text, DWORD itemData
        , TXLBX_ATTR attr)
{
    idx = ListBox_InsertString(listBox, idx, text);
    ListBox_SetItemData(listBox, idx, attr | (itemData & 0x00FFFFFF));

    return idx;
}
Example #10
0
LOCAL void DragEnd(HWND hWindow)
/***********************************************************************/
{
// get the listbox data pointer, if we don't have one, get out
LPLISTBOXDATA lpData = ListBox_GetData(hWindow);
if (!lpData)
	return;

// see if we ever started dragging
if (lpData->fDragging)
	{
	// if we had a cursor, reset it
	if (lpData->hCursor)
		SetCursor(lpData->hOldCursor);
    // do the move if we successfully dragged
    if (lpData->fSuccess) 
    	{
        int nItem, iTopItem;       
        TCHAR szString[256];  
        
		// save the top index, so we can reset it
		iTopItem = ListBox_GetTopIndex(hWindow);
        // turn of painting while working with list
		SetWindowRedraw(hWindow, FALSE);
        // save text of item
		ListBox_GetText(hWindow, lpData->iOldPos, szString);
        
        // delete the item
		ListBox_DeleteString(hWindow, lpData->iOldPos);
             
		// adjust index because of DeleteString
		int iNewPos = lpData->iNewPos;
        if (iNewPos > lpData->iOldPos)
        	iNewPos--;
      	// add the new string at the right spot                       
		nItem = ListBox_InsertString(hWindow, iNewPos, szString);

		// select the item we moved
		DWORD dwStyle = GetWindowLong(hWindow, GWL_STYLE);
		if (dwStyle & (LBS_MULTIPLESEL, LBS_EXTENDEDSEL))
	        ListBox_SetSel(hWindow, TRUE, nItem);
		else
	        ListBox_SetCurSel(hWindow, nItem);

		// reset the top index
		ListBox_SetTopIndex(hWindow, iTopItem);
		// turn drawing back on
		SetWindowRedraw(hWindow, TRUE);
		// inform the dialog of the move
		FORWARD_WM_COMMAND(GetParent(hWindow), GetDlgCtrlID(hWindow),
							hWindow, LBN_MOVEITEM, SendMessage);
       	}
   	}
// turn off dragging
lpData->fDragging = FALSE;    
KillTimer(hWindow, lpData->idTimer);    
}
Example #11
0
/* This function simply inserts the pointer to the out-basket object into the
 * list box for the out-basket then updates the total of out-basket items. It
 * does not check to ascertain whether the object already appears in the list,
 * so this function should only be called for new out-basket items.
 */
void FASTCALL AddStringToOutBasket( HWND hwnd, LPOB lpob )
{
   HWND hwndList;

   hwndList = GetDlgItem( hwnd, IDD_LIST );
   if( hwndList )
      {
      ListBox_InsertString( hwndList, -1, lpob );
      if( ListBox_GetSelCount( hwndList ) == 0 )
         ListBox_SetSel( hwndList, TRUE, 0 );
      ShowOutBasketTotal( hwnd );
      }
}
Example #12
0
void wxListBox::SetString(int N, const wxString& s)
{
    wxCHECK_RET( N >= 0 && N < m_noItems,
                 wxT("invalid index in wxListBox::SetString") );

    // remember the state of the item
    bool wasSelected = IsSelected(N);

    void *oldData = NULL;
    wxClientData *oldObjData = NULL;
    if ( m_clientDataItemsType == wxClientData_Void )
        oldData = GetClientData(N);
    else if ( m_clientDataItemsType == wxClientData_Object )
        oldObjData = GetClientObject(N);

    // delete and recreate it
    SendMessage(GetHwnd(), LB_DELETESTRING, N, 0);

    int newN = N;
    if ( N == m_noItems - 1 )
        newN = -1;

    ListBox_InsertString(GetHwnd(), newN, s);

    // restore the client data
    if ( oldData )
        SetClientData(N, oldData);
    else if ( oldObjData )
        SetClientObject(N, oldObjData);

#if wxUSE_OWNER_DRAWN
    if ( m_windowStyle & wxLB_OWNERDRAW )
    {
        // update item's text
        m_aItems[N]->SetName(s);

        // reassign the item's data
        ListBox_SetItemData(GetHwnd(), N, m_aItems[N]);
    }
#endif  //USE_OWNER_DRAWN

    // we may have lost the selection
    if ( wasSelected )
        Select(N);

    InvalidateBestSize();
}
Example #13
0
void wxListBox::SetString(unsigned int n, const wxString& s)
{
    wxCHECK_RET( IsValid(n),
                 wxT("invalid index in wxListBox::SetString") );

    // remember the state of the item
    bool wasSelected = IsSelected(n);

    void *oldData = NULL;
    wxClientData *oldObjData = NULL;
    if ( m_clientDataItemsType == wxClientData_Void )
        oldData = GetClientData(n);
    else if ( m_clientDataItemsType == wxClientData_Object )
        oldObjData = GetClientObject(n);

    // delete and recreate it
    SendMessage(GetHwnd(), LB_DELETESTRING, n, 0);

    int newN = n;
    if ( n == (m_noItems - 1) )
        newN = -1;

    ListBox_InsertString(GetHwnd(), newN, s);

    // restore the client data
    if ( oldData )
        SetClientData(n, oldData);
    else if ( oldObjData )
        SetClientObject(n, oldObjData);

#if wxUSE_OWNER_DRAWN
    if ( m_windowStyle & wxLB_OWNERDRAW )
    {
        // update item's text
        m_aItems[n]->SetName(s);

        // reassign the item's data
        ListBox_SetItemData(GetHwnd(), n, m_aItems[n]);
    }
#endif  //USE_OWNER_DRAWN

    // we may have lost the selection
    if ( wasSelected )
        Select(n);

    SetHorizontalExtent();
}
void plResponderProc::ICmdRightClick(HWND hCmdList)
{
    // Get the position of the cursor in screen and tree client coords
    POINT point, localPoint;
    GetCursorPos(&point);
    localPoint = point;
    ScreenToClient(hCmdList, &localPoint);

    LRESULT res = SendMessage(hCmdList, LB_ITEMFROMPOINT, 0, MAKELPARAM(localPoint.x, localPoint.y));
    WORD index = LOWORD(res);
    if (index == WORD(LB_ERR))
        return;

    RECT rect;
    SendMessage(hCmdList, LB_GETITEMRECT, index, (LPARAM)&rect);

    // Make sure we're actually ON an item, LB_ITEMFROMPOINT get the closest instead of exact
    if (localPoint.y >= rect.top && localPoint.y <= rect.bottom)
    {
        BOOL enabled = fStatePB->GetInt(kStateCmdEnabled, 0, index);

        HMENU hMenu = CreatePopupMenu();
        AppendMenu(hMenu, MF_STRING, 1, enabled ? "Disable" : "Enable");

        SetForegroundWindow(fhDlg);
        int sel = TrackPopupMenu(hMenu, TPM_NONOTIFY | TPM_RETURNCMD, point.x, point.y, 0, fhDlg, NULL);
        if (sel == 1)
        {
            fStatePB->SetValue(kStateCmdEnabled, 0, !enabled, index);

            ListBox_DeleteString(hCmdList, index);
            ListBox_InsertString(hCmdList, index, GetCommandName(index));
        }

        DestroyMenu(hMenu);
    }
}
Example #15
0
void wxListBox::SetString(unsigned int n, const wxString& s)
{
    wxCHECK_RET( IsValid(n),
                 wxT("invalid index in wxListBox::SetString") );

    // remember the state of the item
    bool wasSelected = IsSelected(n);

    void *oldData = NULL;
    wxClientData *oldObjData = NULL;
    if ( HasClientUntypedData() )
        oldData = GetClientData(n);
    else if ( HasClientObjectData() )
        oldObjData = GetClientObject(n);

    // delete and recreate it
    SendMessage(GetHwnd(), LB_DELETESTRING, n, 0);

    int newN = n;
    if ( n == (m_noItems - 1) )
        newN = -1;

    ListBox_InsertString(GetHwnd(), newN, s.wx_str());

    // restore the client data
    if ( oldData )
        SetClientData(n, oldData);
    else if ( oldObjData )
        SetClientObject(n, oldObjData);

    // we may have lost the selection
    if ( wasSelected )
        Select(n);

    MSWOnItemsChanged();
}
Example #16
0
INT_PTR CALLBACK PhpColumnsDlgProc(
    __in HWND hwndDlg,
    __in UINT uMsg,
    __in WPARAM wParam,
    __in LPARAM lParam
    )
{
    PCOLUMNS_DIALOG_CONTEXT context = NULL;

    if (uMsg == WM_INITDIALOG)
    {
        context = (PCOLUMNS_DIALOG_CONTEXT)lParam;
        SetProp(hwndDlg, PhMakeContextAtom(), (HANDLE)context);
    }
    else
    {
        context = (PCOLUMNS_DIALOG_CONTEXT)GetProp(hwndDlg, PhMakeContextAtom());
    }

    if (!context)
        return FALSE;

    switch (uMsg)
    {
    case WM_INITDIALOG:
        {
            ULONG count;
            ULONG total;
            ULONG i;
            PPH_LIST displayOrderList;

            context->InactiveList = GetDlgItem(hwndDlg, IDC_INACTIVE);
            context->ActiveList = GetDlgItem(hwndDlg, IDC_ACTIVE);

            if (context->Type == PH_CONTROL_TYPE_TREE_NEW)
            {
                PH_TREENEW_COLUMN column;

                count = 0;
                total = TreeNew_GetColumnCount(context->ControlHandle);
                i = 0;

                displayOrderList = PhCreateList(total);

                while (count < total)
                {
                    if (TreeNew_GetColumn(context->ControlHandle, i, &column))
                    {
                        PPH_TREENEW_COLUMN copy;

                        if (column.Fixed)
                        {
                            i++;
                            total--;
                            continue;
                        }

                        copy = PhAllocateCopy(&column, sizeof(PH_TREENEW_COLUMN));
                        PhAddItemList(context->Columns, copy);
                        count++;

                        if (column.Visible)
                        {
                            PhAddItemList(displayOrderList, copy);
                        }
                        else
                        {
                            ListBox_AddString(context->InactiveList, column.Text);
                        }
                    }

                    i++;
                }

                qsort(displayOrderList->Items, displayOrderList->Count, sizeof(PVOID), PhpColumnsCompareDisplayIndexTn);
            }

            for (i = 0; i < displayOrderList->Count; i++)
            {
                if (context->Type == PH_CONTROL_TYPE_TREE_NEW)
                {
                    PPH_TREENEW_COLUMN copy = displayOrderList->Items[i];

                    ListBox_AddString(context->ActiveList, copy->Text);
                }
            }

            PhDereferenceObject(displayOrderList);

            SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_INACTIVE, LBN_SELCHANGE), (LPARAM)context->InactiveList);
            SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_ACTIVE, LBN_SELCHANGE), (LPARAM)context->ActiveList);
        }
        break;
    case WM_DESTROY:
        {
            ULONG i;

            for (i = 0; i < context->Columns->Count; i++)
                PhFree(context->Columns->Items[i]);

            RemoveProp(hwndDlg, PhMakeContextAtom());
        }
        break;
    case WM_COMMAND:
        {
            switch (LOWORD(wParam))
            {
            case IDCANCEL:
                EndDialog(hwndDlg, IDCANCEL);
                break;
            case IDOK:
                {
#define ORDER_LIMIT 100
                    PPH_LIST activeList;
                    ULONG activeCount;
                    ULONG i;
                    INT orderArray[ORDER_LIMIT];
                    INT maxOrder;

                    memset(orderArray, 0, sizeof(orderArray));
                    maxOrder = 0;

                    activeCount = ListBox_GetCount(context->ActiveList);
                    activeList = PhCreateList(activeCount);

                    for (i = 0; i < activeCount; i++)
                        PhAddItemList(activeList, PhGetListBoxString(context->ActiveList, i));

                    if (context->Type == PH_CONTROL_TYPE_TREE_NEW)
                    {
                        // Apply visiblity settings.

                        TreeNew_SetRedraw(context->ControlHandle, FALSE);

                        for (i = 0; i < context->Columns->Count; i++)
                        {
                            PPH_TREENEW_COLUMN column = context->Columns->Items[i];
                            ULONG index;

                            index = IndexOfStringInList(activeList, column->Text);
                            column->Visible = index != -1;
                            column->DisplayIndex = index; // the active list box order is the actual display order

                            TreeNew_SetColumn(context->ControlHandle, TN_COLUMN_FLAG_VISIBLE, column);
                        }

                        // Do a second pass to create the order array. This is because the ViewIndex of each column
                        // were unstable in the previous pass since we were both adding and removing columns.
                        for (i = 0; i < context->Columns->Count; i++)
                        {
                            PPH_TREENEW_COLUMN column = context->Columns->Items[i];
                            PH_TREENEW_COLUMN tempColumn;

                            if (column->Visible)
                            {
                                if (column->DisplayIndex < ORDER_LIMIT)
                                {
                                    TreeNew_GetColumn(context->ControlHandle, column->Id, &tempColumn);

                                    orderArray[column->DisplayIndex] = tempColumn.s.ViewIndex;

                                    if ((ULONG)maxOrder < column->DisplayIndex + 1)
                                        maxOrder = column->DisplayIndex + 1;
                                }
                            }
                        }

                        // Apply display order.
                        TreeNew_SetColumnOrderArray(context->ControlHandle, maxOrder, orderArray);

                        TreeNew_SetRedraw(context->ControlHandle, TRUE);

                        PhDereferenceObject(activeList);

                        InvalidateRect(context->ControlHandle, NULL, FALSE);
                    }

                    EndDialog(hwndDlg, IDOK);
                }
                break;
            case IDC_INACTIVE:
                {
                    switch (HIWORD(wParam))
                    {
                    case LBN_DBLCLK:
                        {
                            SendMessage(hwndDlg, WM_COMMAND, IDC_SHOW, 0);
                        }
                        break;
                    case LBN_SELCHANGE:
                        {
                            INT sel = ListBox_GetCurSel(context->InactiveList);

                            EnableWindow(GetDlgItem(hwndDlg, IDC_SHOW), sel != -1);
                        }
                        break;
                    }
                }
                break;
            case IDC_ACTIVE:
                {
                    switch (HIWORD(wParam))
                    {
                    case LBN_DBLCLK:
                        {
                            SendMessage(hwndDlg, WM_COMMAND, IDC_HIDE, 0);
                        }
                        break;
                    case LBN_SELCHANGE:
                        {
                            INT sel = ListBox_GetCurSel(context->ActiveList);
                            INT count = ListBox_GetCount(context->ActiveList);

                            EnableWindow(GetDlgItem(hwndDlg, IDC_HIDE), sel != -1 && count != 1);
                            EnableWindow(GetDlgItem(hwndDlg, IDC_MOVEUP), sel != 0 && sel != -1);
                            EnableWindow(GetDlgItem(hwndDlg, IDC_MOVEDOWN), sel != count - 1 && sel != -1);
                        }
                        break;
                    }
                }
                break;
            case IDC_SHOW:
                {
                    INT sel;
                    INT count;
                    PPH_STRING string;

                    sel = ListBox_GetCurSel(context->InactiveList);
                    count = ListBox_GetCount(context->InactiveList);

                    if (string = PhGetListBoxString(context->InactiveList, sel))
                    {
                        ListBox_DeleteString(context->InactiveList, sel);
                        ListBox_AddString(context->ActiveList, string->Buffer);
                        PhDereferenceObject(string);

                        count--;

                        if (sel >= count - 1)
                            sel = count - 1;

                        ListBox_SetCurSel(context->InactiveList, sel);

                        SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_INACTIVE, LBN_SELCHANGE), (LPARAM)context->InactiveList);
                        SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_ACTIVE, LBN_SELCHANGE), (LPARAM)context->ActiveList);
                    }
                }
                break;
            case IDC_HIDE:
                {
                    INT sel;
                    INT count;
                    PPH_STRING string;

                    sel = ListBox_GetCurSel(context->ActiveList);
                    count = ListBox_GetCount(context->ActiveList);

                    if (count != 1)
                    {
                        if (string = PhGetListBoxString(context->ActiveList, sel))
                        {
                            ListBox_DeleteString(context->ActiveList, sel);
                            ListBox_AddString(context->InactiveList, string->Buffer);
                            PhDereferenceObject(string);

                            count--;

                            if (sel >= count - 1)
                                sel = count - 1;

                            ListBox_SetCurSel(context->ActiveList, sel);

                            SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_INACTIVE, LBN_SELCHANGE), (LPARAM)context->InactiveList);
                            SendMessage(hwndDlg, WM_COMMAND, MAKEWPARAM(IDC_ACTIVE, LBN_SELCHANGE), (LPARAM)context->ActiveList);
                        }
                    }
                }
                break;
            case IDC_MOVEUP:
                {
                    INT sel;
                    INT count;
                    PPH_STRING string;

                    sel = ListBox_GetCurSel(context->ActiveList);
                    count = ListBox_GetCount(context->ActiveList);

                    if (sel != 0)
                    {
                        if (string = PhGetListBoxString(context->ActiveList, sel))
                        {
                            ListBox_DeleteString(context->ActiveList, sel);
                            ListBox_InsertString(context->ActiveList, sel - 1, string->Buffer);
                            PhDereferenceObject(string);

                            sel -= 1;
                            ListBox_SetCurSel(context->ActiveList, sel);
                            EnableWindow(GetDlgItem(hwndDlg, IDC_MOVEUP), sel != 0);
                            EnableWindow(GetDlgItem(hwndDlg, IDC_MOVEDOWN), sel != count - 1);
                        }
                    }
                }
                break;
            case IDC_MOVEDOWN:
                {
                    INT sel;
                    INT count;
                    PPH_STRING string;

                    sel = ListBox_GetCurSel(context->ActiveList);
                    count = ListBox_GetCount(context->ActiveList);

                    if (sel != count - 1)
                    {
                        if (string = PhGetListBoxString(context->ActiveList, sel))
                        {
                            ListBox_DeleteString(context->ActiveList, sel);
                            ListBox_InsertString(context->ActiveList, sel + 1, string->Buffer);
                            PhDereferenceObject(string);

                            sel += 1;
                            ListBox_SetCurSel(context->ActiveList, sel);
                            EnableWindow(GetDlgItem(hwndDlg, IDC_MOVEUP), sel != 0);
                            EnableWindow(GetDlgItem(hwndDlg, IDC_MOVEDOWN), sel != count - 1);
                        }
                    }
                }
                break;
            }
        }
        break;
    }

    return FALSE;
}
Example #17
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;
   }
}
Example #18
0
LRESULT CALLBACK CartDBFilesDlg(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	char *p,*tmp,*str = (char*)(LONG_PTR)GetWindowLongPtr(hwnd,GWLP_USERDATA);
	int n,i;

	switch(message) {
		case WM_INITDIALOG:
			SetWindowLongPtr(hwnd,GWLP_USERDATA,(LONG)(LONG_PTR)lParam);
			str = strdup((char*)lParam);
			p = strtok(str,";");
			while(p) {
				tmp = strdup(p);
				ListBox_AddString(GetDlgItem(hwnd,IDC_FILELIST),str_eatwhitespace(tmp));
				free(tmp);
				p = strtok(0,";");
			}
			free(str);
			EnableWindow(GetDlgItem(hwnd,IDC_DELETEBUTTON),FALSE);
			return(TRUE);

		case WM_COMMAND:
		    switch(LOWORD(wParam)) {
				case IDC_FILELIST:
					switch(HIWORD(wParam)) {
						case LBN_DBLCLK:
							tmp = (char*)mem_alloc(1024);
							n = ListBox_GetCurSel(GetDlgItem(hwnd,IDC_FILELIST));
							ListBox_GetText(GetDlgItem(hwnd,IDC_FILELIST),n,tmp);
							tmp = (char*)DialogBoxParam(hInst,(LPCTSTR)IDD_FILEEDIT,hwnd,(DLGPROC)FileEditDlg,(LPARAM)(char*)tmp);
							if(tmp) {
								ListBox_DeleteString(GetDlgItem(hwnd,IDC_FILELIST),n);
								ListBox_InsertString(GetDlgItem(hwnd,IDC_FILELIST),n,tmp);
								mem_free(tmp);
							}
							return(TRUE);
						case LBN_SELCHANGE:
							EnableWindow(GetDlgItem(hwnd,IDC_DELETEBUTTON),TRUE);
							return(TRUE);
						case LBN_SELCANCEL:
							EnableWindow(GetDlgItem(hwnd,IDC_DELETEBUTTON),FALSE);
							return(TRUE);
					}
					break;
				case IDC_ADDBUTTON:
					tmp = (char*)DialogBoxParam(hInst,(LPCTSTR)IDD_FILEEDIT,hwnd,(DLGPROC)FileEditDlg,0);
					if(tmp) {
						ListBox_AddString(GetDlgItem(hwnd,IDC_FILELIST),tmp);
						mem_free(tmp);
					}
					return(TRUE);
				case IDC_DELETEBUTTON:
					n = ListBox_GetCurSel(GetDlgItem(hwnd,IDC_FILELIST));
					if(n != LB_ERR)
						ListBox_DeleteString(GetDlgItem(hwnd,IDC_FILELIST),n);
					return(TRUE);
				case IDOK:
					n = ListBox_GetCount(GetDlgItem(hwnd,IDC_FILELIST));
					strcpy(str,"");
					tmp = (char*)mem_alloc(1024);
					for(i=0;i<n;i++) {
						if(i)
							strcat(str," ; ");
						ListBox_GetText(GetDlgItem(hwnd,IDC_FILELIST),i,tmp);
						strcat(str,tmp);
					}
					mem_free(tmp);
					EndDialog(hwnd,(INT_PTR)str);
					return(TRUE);
				case IDCANCEL:
					EndDialog(hwnd,(INT_PTR)NULL);
					return(TRUE);
			 }
			break;

		case WM_DESTROY:
			break;

	}
	return(FALSE);
}
Example #19
0
BOOL Main_Apply_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
	HWND hList = GetDlgItem(hwnd,IDC_LIST_SEGMEN);

	CheckedListBox_SetFlatStyleChecks(hList, TRUE);
	
	

	char szFilePath[256 * 2] = {0};
	strncpy(szFilePath, database_idb, 256);
	char *lpTmpBuf = strrchr(szFilePath, '\\') + 1;
	if(lpTmpBuf == (char*)1)
	{
		return FALSE;
	}
	*lpTmpBuf = 0;
	get_root_filename(lpTmpBuf, 256);
	HANDLE hFile=CreateFile(szFilePath, GENERIC_WRITE | GENERIC_READ, 0, 
		NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);   //获得文件句柄
	if(hFile == INVALID_HANDLE_VALUE)
	{
		msg("Apply Path:%s\n", szFilePath);
		msg("失败!目标%s文件不存在 或 文件无法打开    ErrorCode:%d\n", szFilePath, GetLastError());
		MoveWindowCenter(g_hwndMain, hwnd);
		return FALSE;
	}
	CloseHandle(hFile);
	int i;
	segment_t *curseg;
	int seg_qty = get_segm_qty();
	netnode n("$ Apply SegMen");
	if(BADNODE == (nodeidx_t)n)
	{
		netnode n("$ Apply SegMen", 0, true);
		for(i=0 ; i < seg_qty; i++)
		{
			BOOL bStats = FALSE;
			char segname[0x100] = {0};
			curseg = getnseg(i);
			get_true_segm_name(curseg, segname, 255);
			ListBox_InsertString(hList, -1, segname);
			bStats = !IsFilterTable(segname);
			if(bStats)
			{
				msg("segname:%s, type:%d\n", segname, curseg->type);
				bStats = curseg->type == SEG_CODE;
			}
			if(get_fileregion_offset(curseg->startEA) > 0)
			{
				CheckedListBox_SetCheckState(hList, i, bStats);
				n.altset(i, bStats);
			}

		}
		n.altset(CHECK_BACKFILE_INDEX, 1);
		CheckDlgButton( hwnd,IDC_APPLY_CHECK_BACK,   BST_CHECKED   );
	}
	else
	{
		for(i=0 ; i < seg_qty; i++)
		{
			char segname[0x100] = {0};
			curseg = getnseg(i);
			get_true_segm_name(curseg, segname, 255);
			ListBox_InsertString(hList, -1, segname);
			if(get_fileregion_offset(curseg->startEA) > 0)
			{
				CheckedListBox_SetCheckState(hList, i, n.altval(i));
			}
		}
		if(n.altval(CHECK_BACKFILE_INDEX))
		{
			CheckDlgButton( hwnd, IDC_APPLY_CHECK_BACK,  BST_CHECKED  );
		}
	}
	
	MoveWindowCenter(g_hwndMain, hwnd);
	return FALSE;
}
Example #20
0
BOOL CALLBACK CShellExt::PageDlgProc_ogg(HWND hDlg,UINT uMessage,WPARAM wParam,LPARAM lParam)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());

	LPCSHELLEXT	lpcs = (CShellExt *)GetWindowLongPtr(hDlg,DWLP_USER);

	switch(uMessage){
	case WM_INITDIALOG:
		{
			lpcs = (LPCSHELLEXT )((LPPROPSHEETPAGE )lParam)->lParam;
			lpcs->m_hwndPage = hDlg;
			SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)lpcs);
			lpcs->m_bApply = FALSE;

			//Ver情報
			SetDlgItemText(hDlg,IDC_STATIC_VER_INFO,SOFT_NAME);
			//タイトル
			SetDlgItemText(hDlg,IDC_EDIT_FILENAME,getFileName(lpcs->m_strSelectFile));
			//アイコンを表示
			SHFILEINFO sfi;
			if(SHGetFileInfo(lpcs->m_strSelectFile,0,&sfi,sizeof(sfi),SHGFI_ICON))
			{
				Static_SetImage_Icon(GetDlgItem(hDlg,IDC_ICON1),sfi.hIcon);
			}

			//コンボボックスの初期化
			ComboBox_AddString(GetDlgItem(hDlg,IDC_EDIT_GNR), _T(""));
			for(int i=0; i<256; i++)
			{
				if(lpcs->m_Id3tagv1.GenreNum2String((unsigned char)i).GetLength())
					ComboBox_AddString(GetDlgItem(hDlg,IDC_EDIT_GNR),
							lpcs->m_Id3tagv1.GenreNum2String((unsigned char)i));
			}
			//オーナードローボタンの初期化
/*			RECT rect;
			SetRect(&rect,145,208,145,75);//ボタン位置の基準
			MapDialogRect(hDlg,&rect);
			SetWindowPos(GetDlgItem(hDlg,IDC_BUTTON_REW),NULL,rect.left+25*0,rect.top,23,23,SWP_NOZORDER | SWP_SHOWWINDOW);
			SetWindowPos(GetDlgItem(hDlg,IDC_BUTTON_PLAY),NULL,rect.left+25*1,rect.top,23,23,SWP_NOZORDER | SWP_SHOWWINDOW);
			SetWindowPos(GetDlgItem(hDlg,IDC_BUTTON_PAUSE),NULL,rect.left+25*2,rect.top,23,23,SWP_NOZORDER | SWP_SHOWWINDOW);
			SetWindowPos(GetDlgItem(hDlg,IDC_BUTTON_STOP),NULL,rect.left+25*3,rect.top,23,23,SWP_NOZORDER | SWP_SHOWWINDOW);
			SetWindowPos(GetDlgItem(hDlg,IDC_BUTTON_FFW),NULL,rect.left+25*4,rect.top,23,23,SWP_NOZORDER | SWP_SHOWWINDOW);
*/			
			//情報を表示
			DispInfo(hDlg,lpcs);
			DispInfoExt(hDlg,lpcs);
			
			return FALSE;
		}
		break;

	case WM_TIMER:
		switch(wParam){
		case REW_TIMER:
			SendMessage(hDlg,WM_COMMAND,
				MAKEWPARAM((UINT )IDC_BUTTON_REW,(UINT )BN_CLICKED),
				0);
			break;
		case FFW_TIMER:
			SendMessage(hDlg,WM_COMMAND,
				MAKEWPARAM((UINT )IDC_BUTTON_FFW,(UINT )BN_CLICKED),
				0);
			break;
		}
		break;
	// オーナー描画コントロール
	case WM_DRAWITEM:
		DrawControl(hDlg,(LPDRAWITEMSTRUCT )lParam);
		break;
	case WM_COMMAND:
	switch(LOWORD(wParam)){
		case IDC_BUTTON_ADD_VALUE:
			//値追加
			{
				CDlg_ogg_exttag dlg;
				if(dlg.DoModal() == IDOK)
				{
					COggExt *oggExt = new COggExt(dlg.m_strName,dlg.m_strValue);
					long index = ListBox_AddString(GetDlgItem(hDlg,IDC_LIST_VALUE),oggExt->Get1LineDisp());
					if(index == LB_ERR)
					{
						delete oggExt;
					}
					else
					{
						ListBox_SetItemData(GetDlgItem(hDlg,IDC_LIST_VALUE),index,oggExt);
					}
				
					PropSheet_Changed(GetParent(hDlg),hDlg);
					lpcs->m_bApply = TRUE;
				}
			}
			break;
		case IDC_BUTTON_DEL_VALUE:
			//値削除
			{
				long item = ListBox_GetCurSel(GetDlgItem(hDlg,IDC_LIST_VALUE));
				if(item == LB_ERR)
					break;
				
				COggExt *oggExt = (COggExt *)ListBox_GetItemData(GetDlgItem(hDlg,IDC_LIST_VALUE),item);
				if(oggExt)
				{
					delete oggExt;
				}
				ListBox_DeleteString(GetDlgItem(hDlg,IDC_LIST_VALUE),item);
				
				PropSheet_Changed(GetParent(hDlg),hDlg);
				lpcs->m_bApply = TRUE;
			}
			break;
		case IDC_LIST_VALUE:
			if(HIWORD(wParam) == LBN_DBLCLK)
			{
				//ダブルクリック - 編集
				long item = ListBox_GetCurSel(GetDlgItem(hDlg,IDC_LIST_VALUE));
				if(item == LB_ERR)
					break;
				
				COggExt *oggExt = (COggExt *)ListBox_GetItemData(GetDlgItem(hDlg,IDC_LIST_VALUE),item);
				if(oggExt == NULL)
					break;
				
				CDlg_ogg_exttag dlg;

				dlg.m_strName = oggExt->GetName();
				dlg.m_strValue = oggExt->GetValue();
				if(dlg.DoModal() == IDOK)
				{
					oggExt->SetName(dlg.m_strName);
					oggExt->SetValue(dlg.m_strValue);
					ListBox_DeleteString(GetDlgItem(hDlg,IDC_LIST_VALUE),item);
					ListBox_InsertString(GetDlgItem(hDlg,IDC_LIST_VALUE),item,oggExt->Get1LineDisp());
					ListBox_SetItemData(GetDlgItem(hDlg,IDC_LIST_VALUE),item,oggExt);
					
					PropSheet_Changed(GetParent(hDlg),hDlg);
					lpcs->m_bApply = TRUE;
				}
			}
			break;
		case IDC_EDIT_SBJ:
		case IDC_EDIT_TRK:
		case IDC_EDIT_ART:
		case IDC_EDIT_PRD:
		case IDC_EDIT_AART:
		case IDC_EDIT_DISC:
		case IDC_EDIT_CRD:
		case IDC_EDIT_CMT:
			if((HIWORD(wParam) == EN_CHANGE) &&
				(IsWindowEnabled((HWND )lParam)) )
			{
				PropSheet_Changed(GetParent(hDlg),hDlg);
				lpcs->m_bApply = TRUE;
			}
			break;
		case IDC_EDIT_GNR:
			if( ((HIWORD(wParam) == CBN_SELENDOK) || (HIWORD(wParam) == CBN_EDITCHANGE)) &&
				(IsWindowEnabled((HWND )lParam)) )
			{
				PropSheet_Changed(GetParent(hDlg),hDlg);
				lpcs->m_bApply = TRUE;
			}
			break;
		case IDC_BUTTON_PLAY:
			{
				PlayWinamp(hDlg,lpcs->m_strSelectFile);
				break;
			}
		case IDC_BUTTON_PAUSE:
			{
				PauseWinamp();
				break;
			}
		case IDC_BUTTON_STOP:
			{
				StopWinamp();
				break;
			}
		case IDC_BUTTON_REW:
			{
				Rew5Winamp();
				break;
			}
		case IDC_BUTTON_FFW:
			{
				Ffw5Winamp();
				break;
			}
		case IDC_CHECK_AOT:
			if(IsDlgButtonChecked(hDlg,IDC_CHECK_AOT) == BST_CHECKED)
			{
				lpcs->m_bPropAOT = TRUE;
				SetWindowPos(GetParent(hDlg),HWND_TOPMOST,0,0,0,0,
					SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOSIZE);
			}
			else
			{
				lpcs->m_bPropAOT = FALSE;
				SetWindowPos(GetParent(hDlg),HWND_NOTOPMOST,0,0,0,0,
					SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOSIZE);
			}
			regSetDword(HKEY_CURRENT_USER,MP3INFP_REG_ENTRY,_T("PropAOT"),(DWORD )lpcs->m_bPropAOT);
			break;
		case IDC_SETUP:
			OpenConfigPage(hDlg,8);
			break;
		case IDC_HELPVIEW:
			lpcs->OpenHtmlHelp(hDlg,_T("extension.htm"));
			break;
		DLG_CLIPBOARD_MACRO(lpcs->m_strSelectFile);
		}
		break;
	case WM_DESTROY:
		{
			//後始末
			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),i);
					if(oggExt)
					{
						delete oggExt;
					}
				}
			}
		}
		return TRUE;
	// コンテキストメニュー
	case WM_CONTEXTMENU:
		DlgContextMenu(hDlg,lParam,lpcs->m_Ogg.IsEnable());
		break;
	//状況依存ヘルプ
	case WM_HELP:
		OpenAboutDlg(hDlg);
		break;

	case WM_NOTIFY:
		switch(((NMHDR FAR *)lParam)->code){
//		case PSN_SETACTIVE:
//			break;
		case PSN_APPLY:
			//保存
			if(lpcs->m_bApply)
			{
				TRACE(_T("WM_NOTIFY(PSN_APPLY) - 保存\n"));
				//ファイルが書き込み可能か調べる
				if(GetFileAttributes(lpcs->m_strSelectFile) & (FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_READONLY))
				{
					//「このファイルは「読み込み専用」です」
					AfxMessageBox(IDS_PAGE_THIS_READONLY,MB_ICONINFORMATION);
					//適用ボタンは引き続き有効
					SetWindowLongPtr(hDlg,DWLP_MSGRESULT,PSNRET_INVALID);
					break;
				}
				lpcs->m_bApply = FALSE;

				CString strTmp;
				CWnd wnd;
				//いったんリセット
				lpcs->m_Ogg.Release();

				wnd.Attach(hDlg);

				wnd.GetDlgItemText(IDC_EDIT_SBJ,strTmp);
				lpcs->m_Ogg.AddComment(_T("TITLE"),strTmp);

				wnd.GetDlgItemText(IDC_EDIT_TRK,strTmp);
				lpcs->m_Ogg.AddComment(_T("TRACKNUMBER"),strTmp);

				wnd.GetDlgItemText(IDC_EDIT_ART,strTmp);
				lpcs->m_Ogg.AddComment(_T("ARTIST"),strTmp);

				wnd.GetDlgItemText(IDC_EDIT_PRD,strTmp);
				lpcs->m_Ogg.AddComment(_T("ALBUM"),strTmp);

				wnd.GetDlgItemText(IDC_EDIT_AART,strTmp);
				lpcs->m_Ogg.AddComment(_T("ALBUMARTIST"),strTmp);

				wnd.GetDlgItemText(IDC_EDIT_DISC,strTmp);
				lpcs->m_Ogg.AddComment(_T("DISCNUMBER"),strTmp);

				wnd.GetDlgItemText(IDC_EDIT_CRD,strTmp);
				lpcs->m_Ogg.AddComment(_T("DATE"),strTmp);

				wnd.GetDlgItemText(IDC_EDIT_GNR,strTmp);
				lpcs->m_Ogg.AddComment(_T("GENRE"),strTmp);

				wnd.GetDlgItemText(IDC_EDIT_CMT,strTmp);
				lpcs->m_Ogg.AddComment(_T("COMMENT"),strTmp);

				wnd.Detach();

				//その他分を保存
				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),i);
						if(oggExt)
						{
							lpcs->m_Ogg.AddComment(oggExt->GetName(),oggExt->GetValue());
						}
					}
				}

				//タイムスタンプを保存
				lpcs->PushTimeStamp(lpcs->m_strSelectFile);

				DWORD dwRet = lpcs->m_Ogg.Save(lpcs->m_strSelectFile);
				if(dwRet != ERROR_SUCCESS)
				{
					lpcs->m_bApply = TRUE;
					if(dwRet == -1)
						//「ファイルを正しく更新できませんでした。」
						AfxMessageBox(IDS_PAGE_BROKEN,MB_ICONINFORMATION);
					else
						//システムエラーを表示
						errMessageBox(hDlg,dwRet);
					//適用ボタンは引き続き有効
					SetWindowLongPtr(hDlg,DWLP_MSGRESULT,PSNRET_INVALID);
					break;
				}

				//タイムスタンプを復元
				if(lpcs->m_bSaveTimeStamp)
				{
					lpcs->PopTimeStamp(lpcs->m_strSelectFile);
				}

				//情報を表示
				lpcs->m_Ogg.Load(lpcs->m_strSelectFile);
				DispInfo(hDlg,lpcs);
				DispInfoExt(hDlg,lpcs);

				SetWindowLongPtr(hDlg,DWLP_MSGRESULT,PSNRET_NOERROR);

				//シェルに変更を通知
				SHChangeNotify(SHCNE_UPDATEITEM,SHCNF_PATH,lpcs->m_strSelectFile,NULL);
			}
			break;
		default:
			break;
		}
		break;

	default:
		return FALSE;
	
	}

	return TRUE;
}
Example #21
0
BOOL CALLBACK CQuickLaunch::QuickLaunchProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) 
{
	static HWND hwndList;
	static HKEY g_hKey = NULL;
	static list<LaunchItem*> launchItems;

	TEXTMETRIC tm;

	static CDlgAnchor g_dlgAnchor;

    switch (message) 
    { 
		case WM_SIZE :
		{
			g_dlgAnchor.OnSize();
		}
		break;
		case WM_MEASUREITEM :
			{
				LPMEASUREITEMSTRUCT lpmis;
				lpmis = (MEASUREITEMSTRUCT FAR*) lParam;
				if (GetTextMetricsW(GetDC(hwndDlg), &tm))
				{
					lpmis->itemHeight = (UINT)(tm.tmHeight * 2.5);
				}
				else
				{
					lpmis->itemHeight = 50;
				}
			}
			break;
		case WM_DRAWITEM :
			{
				WCHAR tchBuffer[256] = {0};
				int y = 0;
				LPDRAWITEMSTRUCT lpdis = (DRAWITEMSTRUCT FAR*) lParam;

				LaunchItem* pRecord = (LaunchItem*)lpdis->itemData;
				GetTextMetrics(lpdis->hDC, &tm);

				HBRUSH hBrush = NULL;
				SetBkMode(lpdis->hDC, TRANSPARENT);
				if ((lpdis->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)))
				{
					if ((lpdis->itemState & ODS_SELECTED))
					{
						hBrush = GetSysColorBrush(COLOR_HIGHLIGHT);
						SetTextColor(lpdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT));
					}
					else
					{
						hBrush = GetSysColorBrush(COLOR_WINDOW);
						SetTextColor(lpdis->hDC, GetSysColor(COLOR_WINDOWTEXT));
					}
				}
				if (hBrush)
				{
					int desiredHeight = (lpdis->rcItem.bottom - lpdis->rcItem.top) - 2;

					RECT rect;
					memcpy(&rect, &(lpdis->rcItem), sizeof(RECT));
					rect.top += 1;
					rect.bottom -= 1;
					rect.left += 1;
					rect.right -= 1;
					rect.left += desiredHeight;

					FillRect(lpdis->hDC, &rect, hBrush);

					rect.left += 5;
					rect.right -= 5;
					rect.bottom -= 5;
					rect.top += 5;

					WCHAR wzFullPath[MAX_PATH];
					WCHAR wzName[MAX_PATH];
					StringCchCopy(wzFullPath, ARRAYSIZE(wzFullPath), pRecord->wzPath);
					StringCchCopy(wzName, ARRAYSIZE(wzName), pRecord->wzPath);

					WCHAR* wzFile = wcsrchr(wzName, L'\\');

					if (!wzFile)
					{
						wzFile = wzName;
					}
					else
					{
						wzFile++;
					}
					WCHAR* wzExt = wcsrchr(wzFile, L'.');
					if (wzExt)
					{
						wzExt[0] = 0;
					}

					WCHAR* wzDir = wcsrchr(wzFullPath, L'\\');
					if (wzDir)
					{
						wzDir[0] = 0;
					}

					// todo - trim of .lnk
					DrawText(lpdis->hDC, wzFile, wcslen(wzFile), &rect, DT_TOP);
					
					LOGFONT lf;
					ZeroMemory(&lf, sizeof(lf));
					lf.lfHeight = -((rect.bottom - rect.top) / 4);
					lf.lfWeight = FW_BOLD;
					lf.lfCharSet = DEFAULT_CHARSET;
					HFONT hFont = CreateFontIndirect(&lf);
					HGDIOBJ hOldFont = SelectObject(lpdis->hDC, hFont);
					DrawText(lpdis->hDC, wzFullPath, wcslen(wzFullPath), &rect, DT_BOTTOM);
					SelectObject(lpdis->hDC, hOldFont);

					if (pRecord->hIcon)
					{
						DrawIcon(lpdis->hDC, 0, rect.top, pRecord->hIcon);
					}
				}
			}
			break;
        case WM_INITDIALOG:
        {
			g_dlgAnchor.Init(hwndDlg);
			g_dlgAnchor.Add(IDC_LIST_SPEEDDIAL, ANCHOR_ALL);
			g_dlgAnchor.Add(IDC_BUTTON_ADD, ANCHOR_RIGHT | ANCHOR_BOTTOM);
			g_dlgAnchor.Add(IDC_BUTTON_REMOVE, ANCHOR_RIGHT | ANCHOR_TOP);
			g_dlgAnchor.Add(IDC_BUTTON_MOVEDOWN, ANCHOR_RIGHT | ANCHOR_TOP);
			g_dlgAnchor.Add(IDC_BUTTON_MOVEUP, ANCHOR_RIGHT | ANCHOR_TOP);

			hwndList = GetDlgItem(hwndDlg, IDC_LIST_SPEEDDIAL);

            SHINITDLGINFO shidi;
            // Create a Done button and size it.
            shidi.dwMask = SHIDIM_FLAGS;
            shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN;
            shidi.hDlg = hwndDlg;
            SHInitDialog(&shidi);

            SHMENUBARINFO mbi;
            memset(&mbi, 0, sizeof(SHMENUBARINFO));
            mbi.cbSize = sizeof(SHMENUBARINFO);
            mbi.hwndParent = hwndDlg;
            mbi.nToolBarId = IDR_Flipper_SET_MENUBAR;
			mbi.hInstRes = CQuickLaunch::g_hInstance;
            mbi.nBmpId = 0;
            mbi.cBmpImages = 0;    

            SHCreateMenuBar(&mbi);

			RECT rect;
			GetWindowRect(hwndList, &rect);
			
			LV_COLUMN lvC;
			lvC.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
			lvC.fmt = LVCFMT_LEFT;  // left-align column
			lvC.cx = rect.right - rect.left - 2;
			lvC.pszText = L"Name";

			HKEY hKey = (HKEY)lParam;
			g_hKey = hKey;

			CQuickLaunch::LoadLaunchItems(hKey, &launchItems);

			list<LaunchItem*>::iterator iter = launchItems.begin();

			while (iter != launchItems.end())
			{
				LaunchItem* pRecord = *iter;
				int index = ListBox_InsertString(hwndList, -1, pRecord->wzPath);
				ListBox_SetItemData(hwndList, index, pRecord);
				iter++;
			}
			SetFocus(hwndList);

            return 0;
        }
        break;
        case WM_COMMAND: 
			{
				if (HIWORD(wParam) == LBN_SELCHANGE)
				{
					int index = ListBox_GetCurSel(hwndList);
					int count = ListBox_GetCount(hwndList);

					bool bMoveUp = (index > 0);
					bool bMoveDown = (index < (count - 1));

					if (index < 0)
					{
						bMoveUp = bMoveDown = false;
					}

					EnableWindow(GetDlgItem(hwndDlg, IDC_BUTTON_REMOVE), index >= 0);
					EnableWindow(GetDlgItem(hwndDlg, IDC_BUTTON_MOVEUP), bMoveUp);
					EnableWindow(GetDlgItem(hwndDlg, IDC_BUTTON_MOVEDOWN), bMoveDown);
				}
				else if (HIWORD(wParam) == BN_CLICKED)
				{
					switch (LOWORD(wParam)) 
					{
						case IDC_BUTTON_ADD :
						{
							LaunchItem* pRecord = new LaunchItem();
							SetCursor(LoadCursor(NULL, IDC_WAIT));

							CApplicationSelector* appSelector = new CApplicationSelector();
							// TODO
							if (appSelector->ShowDialog(CQuickLaunch::g_hInstance, hwndDlg, pRecord->wzPath, false))
							{
								pRecord->hIcon = GetApplicationIcon(pRecord->wzPath, false, NULL, NULL, NULL);
								int index = ListBox_InsertString(hwndList, -1, pRecord->wzPath);
								ListBox_SetItemData(hwndList, index, pRecord);
								ListBox_SetCurSel(hwndList, index);
								PostMessage(hwndDlg, WM_COMMAND, MAKELONG(0, LBN_SELCHANGE), 0);
							}
							else
							{
								delete pRecord;
							}
							delete appSelector;
							SetCursor(NULL);
						}
						break;
						case IDC_BUTTON_REMOVE :
						{
							int index = ListBox_GetCurSel(hwndList);

							if (index >= 0)
							{
								LaunchItem* pRecord = (LaunchItem*)ListBox_GetItemData(hwndList, index);
								ListBox_DeleteString(hwndList, index);
								delete pRecord;
							}
							int count = ListBox_GetCount(hwndList);
							ListBox_SetCurSel(hwndList, min(count-1, index));
							PostMessage(hwndDlg, WM_COMMAND, MAKELONG(0, LBN_SELCHANGE), 0);
						}
						break;
						case IDC_BUTTON_MOVEUP :
						{
							int index = ListBox_GetCurSel(hwndList);
							if (index > 0)
							{
								LaunchItem* pRecord = (LaunchItem*)ListBox_GetItemData(hwndList, index);
								ListBox_DeleteString(hwndList, index);
								ListBox_InsertString(hwndList, index-1, pRecord->wzPath);
								ListBox_SetItemData(hwndList, index-1, pRecord);
								ListBox_SetCurSel(hwndList, index-1);
								PostMessage(hwndDlg, WM_COMMAND, MAKELONG(0, LBN_SELCHANGE), 0);
							}
						}
						break;
						case IDC_BUTTON_MOVEDOWN :
						{
							int index = ListBox_GetCurSel(hwndList);
							int count = ListBox_GetCount(hwndList);
							if (index < count - 1)
							{
								LaunchItem* pRecord = (LaunchItem*)ListBox_GetItemData(hwndList, index);
								ListBox_DeleteString(hwndList, index);
								ListBox_InsertString(hwndList, index+1, pRecord->wzPath);
								ListBox_SetItemData(hwndList, index+1, pRecord);
								ListBox_SetCurSel(hwndList, index+1);
								PostMessage(hwndDlg, WM_COMMAND, MAKELONG(0, LBN_SELCHANGE), 0);
							}
						}
						break;
					}
				}
				switch (LOWORD(wParam))
				{
					case IDM_Flipper_SET_ACCEPT :
					case IDOK:
						{
							int index = 0;

							list<LaunchItem*> launchItems;
							int count = ListBox_GetCount(hwndList);

							for (int i = 0; i < count; ++i)
							{
								WCHAR wzPath[10], wzCount[5];
								DWORD dwSize = 0;
								_itow(i, wzCount, 10);

								StringCchCopy(wzPath, ARRAYSIZE(wzPath), wzCount);
								StringCchCat(wzPath, ARRAYSIZE(wzPath), L"_Path");

								LaunchItem* pRecord = (LaunchItem*)ListBox_GetItemData(hwndList, i);
								launchItems.push_back(pRecord);
							}

							CQuickLaunch::SaveLaunchItems(g_hKey, &launchItems);

							EndDialog(hwndDlg, IDOK);
						}
						break;
					case IDM_Flipper_SET_CANCEL:
						{
							EndDialog(hwndDlg, IDOK);
						}
						break;
				}
            }
            break;
        case WM_DESTROY:
            {
				CQuickLaunch::DestroyLaunchItems(&launchItems);
                Sleep(0);
            }
            break;
    } 
    return FALSE; 
}
Example #22
0
/*
 * AdminValueDialogProc:  Dialog procedure for editing a property's value.
 *   lParam of INITDIALOG message is index of property in object list box.
 */
BOOL CALLBACK AdminValueDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
   static int index;
   int type, i;
   char *value, line[MAX_PROPERTYLEN], *str, property[MAX_PROPERTYLEN];
   static HWND hEdit;

   switch (message)
   {
   case WM_INITDIALOG:
      index = lParam;
      hEdit = GetDlgItem(hDlg, IDC_EDITVALUE);
      Edit_LimitText(hEdit, MAX_PROPERTYLEN - 1);

      ListBox_GetText(hObjectList, index, line);

      value = AdminPropertyValue(line, &type);
      if (value != NULL)
      {
	 // Initialize dialog with current value
	 for (i = 0; type_table[i].word != NULL; i++)
	    if (type == type_table[i].type)
	       CheckDlgButton(hDlg, type_table[i].control, 1);

	 Edit_SetText(hEdit, value);
	 Edit_SetSel(hEdit, 0, -1);

	 strcpy(property, AdminNthToken(line, 1));
	 str = strchr(property, ' ');
	 if (str != NULL)
	    *str = 0;
	 SetDlgItemText(hDlg, IDC_PROPERTY, property);
      }

      sprintf(line, "%d", current_obj);
      SetDlgItemText(hDlg, IDC_OBJECTNUM, line);

      CenterWindow(hDlg, GetParent(hDlg));
      SetWindowFont(hEdit, GetFont(FONT_INPUT), TRUE);
      SetFocus(hEdit);
      return FALSE;

   case WM_COMMAND:
      switch (GET_WM_COMMAND_ID(wParam, lParam))
      {
      case IDOK:
	 // Get type and value
	 str = NULL;
	 for (i = 0; type_table[i].word != NULL; i++)
	    if (IsDlgButtonChecked(hDlg, type_table[i].control))
	    {
	       str = type_table[i].word;
	       break;
	    }
	 if (str != NULL)
	 {
	    Edit_GetText(hEdit, line, MAX_PROPERTYLEN);
	    GetDlgItemText(hDlg, IDC_PROPERTY, property, MAX_PROPERTYLEN);
	    
	    // Special case for NIL:  value must be zero
	    if (type_table[i].type == TAG_NIL)
	       strcpy(line, "0");
	    
	    sprintf(command, "set object %d %s %s %s", current_obj, property, str, line);
	    
	    SendMessage(hAdminDlg, BK_SENDCMD, 0, (LPARAM) command);
	    
	    // Change value in object list box
	    sprintf(command, "%s = %s %s", property, str, line);
	    WindowBeginUpdate(hObjectList);
	    ListBox_DeleteString(hObjectList, index);
	    ListBox_InsertString(hObjectList, index, command);
	    WindowEndUpdate(hObjectList);
	 }
	    
	 EndDialog(hDlg, IDOK);
	 return TRUE;

      case IDCANCEL:
	 EndDialog(hDlg, IDCANCEL);
	 return TRUE;
      }
      break;
   }

   return FALSE;
}
Example #23
0
void w32g_update_playlist(void)
{
#if 0
    int i, cur, modified;
    HWND hListBox;

    if(!(hListBox = playlist_box()))
	return;

    cur = ListBox_GetCurSel(hListBox);
    modified = 0;
    for(i = 0; i < playlist.nfiles; i++)
    {
	char *filename, *title, *item1, *item2;
	int maxlen, item2_len;

	filename = playlist.list[i].filename;
	title = playlist.list[i].title;
	if(title == NULL || title[0] == '\0')
	{
	    if(playlist.list[i].info->file_type == IS_ERROR_FILE)
		title = " --SKIP-- ";
	    else
		title = " -------- ";
	}
	maxlen = strlen(filename) + strlen(title) + 32;
	item1 = (char *)new_segment(&tmpbuffer, maxlen);
	if(i == playlist.selected)
	    snprintf(item1, maxlen, "==>%04d %s (%s)", i + 1, title, filename);
	else
	    snprintf(item1, maxlen, "   %04d %s (%s)", i + 1, title, filename);
	item2_len = ListBox_GetTextLen(hListBox, i);
	item2 = (char *)new_segment(&tmpbuffer, item2_len + 1);
	ListBox_GetText(hListBox, i, item2);
	if(strcmp(item1, item2) != 0)
	{
	    ListBox_DeleteString(hListBox, i);
	    ListBox_InsertString(hListBox, i, item1);
	    modified = 1;
	}
	reuse_mblock(&tmpbuffer);
    }

    if(modified)
    {
	if(cur < 0)
	    cur = playlist.selected;
	else if(cur >= playlist.nfiles - 1)
	    cur = playlist.nfiles - 1;
	ListBox_SetCurSel(hListBox, cur);
	SetNumListWnd(cur,playlist.nfiles);
    }
#else
    int i, cur, modified;
    HWND hListBox;

    if(!(hListBox = playlist_box()))
	return;

    cur = ListBox_GetCurSel(hListBox);
    modified = 0;
    for(i = 0; i < playlist.nfiles; i++)
    {
		w32g_update_playlist_pos(i);
    }

    if(modified)
    {
	if(cur < 0)
	    cur = playlist.selected;
	else if(cur >= playlist.nfiles - 1)
	    cur = playlist.nfiles - 1;
	ListBox_SetCurSel(hListBox, cur);
	SetNumListWnd(cur,playlist.nfiles);
    }
#endif
}
Example #24
0
INT_PTR HandleCommonMessages(
    _In_ HWND hwndDlg,
    _In_ UINT uMsg,
    _In_ WPARAM wParam,
    _In_ LPARAM lParam,
    _In_ HWND ListBox,
    _In_ PPH_LIST FilterList
    )
{
    switch (uMsg)
    {
    case WM_INITDIALOG:
        {
            SetWindowSubclass(GetDlgItem(hwndDlg, IDC_TEXT), TextBoxSubclassProc, 0, 0);

            Button_SetCheck(GetDlgItem(hwndDlg, IDC_INCLUDE), BST_CHECKED);

            FixControlStates(hwndDlg, ListBox);
        }
        break;
    case WM_COMMAND:
        {
            switch (GET_WM_COMMAND_ID(wParam, lParam))
            {
            case IDC_LIST:
                {
                    if (GET_WM_COMMAND_CMD(wParam, lParam) == LBN_SELCHANGE)
                    {
                        ULONG i;

                        i = ListBox_GetCurSel(ListBox);

                        if (i != LB_ERR)
                        {
                            PFILTER_ENTRY entry;

                            entry = FilterList->Items[i];
                            SetDlgItemText(hwndDlg, IDC_TEXT, entry->Filter->Buffer);
                            Button_SetCheck(GetDlgItem(hwndDlg, IDC_INCLUDE),
                                entry->Type == FilterInclude ? BST_CHECKED : BST_UNCHECKED);
                            Button_SetCheck(GetDlgItem(hwndDlg, IDC_EXCLUDE),
                                entry->Type == FilterExclude ? BST_CHECKED : BST_UNCHECKED);
                        }

                        FixControlStates(hwndDlg, ListBox);
                    }
                }
                break;
            case IDC_ADD:
            case IDC_TEXT_RETURN:
                {
                    ULONG i;
                    PPH_STRING string;
                    PFILTER_ENTRY entry = NULL;
                    FILTER_TYPE type;
                    PPH_STRING entryString;

                    string = PhGetWindowText(GetDlgItem(hwndDlg, IDC_TEXT));

                    if (string->Length == 0)
                    {
                        PhDereferenceObject(string);
                        return FALSE;
                    }

                    for (i = 0; i < FilterList->Count; i++)
                    {
                        entry = FilterList->Items[i];

                        if (PhEqualString(entry->Filter, string, TRUE))
                            break;
                    }

                    type = Button_GetCheck(GetDlgItem(hwndDlg, IDC_INCLUDE)) == BST_CHECKED ? FilterInclude : FilterExclude;

                    if (i == FilterList->Count)
                    {
                        // No existing entry, so add a new one.

                        entry = PhAllocate(sizeof(FILTER_ENTRY));
                        entry->Type = type;
                        entry->Filter = string;
                        PhInsertItemList(FilterList, 0, entry);

                        entryString = FormatFilterEntry(entry);
                        ListBox_InsertString(ListBox, 0, entryString->Buffer);
                        PhDereferenceObject(entryString);

                        ListBox_SetCurSel(ListBox, 0);
                    }
                    else
                    {
                        entry->Type = type;
                        PhDereferenceObject(entry->Filter);
                        entry->Filter = string;

                        ListBox_DeleteString(ListBox, i);
                        entryString = FormatFilterEntry(entry);
                        ListBox_InsertString(ListBox, i, entryString->Buffer);
                        PhDereferenceObject(entryString);

                        ListBox_SetCurSel(ListBox, i);
                    }

                    SendMessage(hwndDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hwndDlg, IDC_TEXT), TRUE);
                    Edit_SetSel(GetDlgItem(hwndDlg, IDC_TEXT), 0, -1);

                    FixControlStates(hwndDlg, ListBox);
                }
                break;
            case IDC_REMOVE:
                {
                    ULONG i;
                    PFILTER_ENTRY entry;

                    i = ListBox_GetCurSel(ListBox);

                    if (i != LB_ERR)
                    {
                        entry = FilterList->Items[i];
                        FreeFilterEntry(entry);
                        PhRemoveItemList(FilterList, i);
                        ListBox_DeleteString(ListBox, i);

                        if (i >= FilterList->Count)
                            i = FilterList->Count - 1;

                        ListBox_SetCurSel(ListBox, i);

                        FixControlStates(hwndDlg, ListBox);
                    }
                }
                break;
            case IDC_MOVEUP:
                {
                    ULONG i;
                    PFILTER_ENTRY entry;
                    PPH_STRING entryString;

                    i = ListBox_GetCurSel(ListBox);

                    if (i != LB_ERR && i != 0)
                    {
                        entry = FilterList->Items[i];

                        PhRemoveItemList(FilterList, i);
                        PhInsertItemList(FilterList, i - 1, entry);

                        ListBox_DeleteString(ListBox, i);
                        entryString = FormatFilterEntry(entry);
                        ListBox_InsertString(ListBox, i - 1, entryString->Buffer);
                        PhDereferenceObject(entryString);

                        i--;
                        ListBox_SetCurSel(ListBox, i);

                        FixControlStates(hwndDlg, ListBox);
                    }
                }
                break;
            case IDC_MOVEDOWN:
                {
                    ULONG i;
                    PFILTER_ENTRY entry;
                    PPH_STRING entryString;

                    i = ListBox_GetCurSel(ListBox);

                    if (i != LB_ERR && i != FilterList->Count - 1)
                    {
                        entry = FilterList->Items[i];

                        PhRemoveItemList(FilterList, i);
                        PhInsertItemList(FilterList, i + 1, entry);

                        ListBox_DeleteString(ListBox, i);
                        entryString = FormatFilterEntry(entry);
                        ListBox_InsertString(ListBox, i + 1, entryString->Buffer);
                        PhDereferenceObject(entryString);

                        i++;
                        ListBox_SetCurSel(ListBox, i);

                        FixControlStates(hwndDlg, ListBox);
                    }
                }
                break;
            }
        }
        break;
    }

    return FALSE;
}
Example #25
0
INT_PTR CALLBACK DlgProc_Options( HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	switch( uMsg )
	{
	case WM_INITDIALOG:
		{
			updateLB1( hDlg );
			updateLB2( hDlg );
			initCBAction( hDlg );
			updateCBAction( hDlg );
			lParam = 0;
		} break;
	case WM_COMMAND:
		{
			int ctrl_id = LOWORD(wParam);
			HWND hWndLB1 = GetDlgItem( hDlg, IDC_LIST1 );
			HWND hWndLB2 = GetDlgItem( hDlg, IDC_LIST2 );
			switch( ctrl_id )
			{
			case IDC_ADD:
				{
					int nSel = ListBox_GetCurSel( hWndLB2 );
					if( nSel >= 0 )
					{
						TCHAR buffer[1024];
						ListBox_GetText( hWndLB2, nSel, buffer );
						ListBox_AddString( hWndLB1, buffer );
						ListBox_DeleteString( hWndLB2, nSel );
					}
				} break;
			case IDC_DEL:
				{
					int nSel = ListBox_GetCurSel( hWndLB1 );
					if( nSel >= 0 )
					{
						TCHAR buffer[1024];
						ListBox_GetText( hWndLB1, nSel, buffer );
						ListBox_AddString( hWndLB2, buffer );
						ListBox_DeleteString( hWndLB1, nSel );
					}
				} break;
			case IDC_MOVEUP:
				{
					int nSel = ListBox_GetCurSel( hWndLB1 );
					if( nSel >= 0 )
					{
						if( nSel >= 1 )
						{
							TCHAR buffer[1024];
							ListBox_GetText( hWndLB1, nSel, buffer );
							ListBox_DeleteString( hWndLB1, nSel );
							ListBox_InsertString( hWndLB1, nSel-1, buffer );
							ListBox_SetCurSel( hWndLB1, nSel-1 );
						}
					}
				} break;
			case IDC_MOVEDOWN:
				{
					int nSel = ListBox_GetCurSel( hWndLB1 );
					if( nSel >= 0 )
					{
						if( nSel < PLAYERS_COUNT-1 )
						{
							TCHAR buffer[1024];
							ListBox_GetText( hWndLB1, nSel, buffer );
							ListBox_DeleteString( hWndLB1, nSel );
							ListBox_InsertString( hWndLB1, nSel+1, buffer );
							ListBox_SetCurSel( hWndLB1, nSel+1 );
						}
					}
				} break;
			case IDC_CBACTION:
				{
					updateCBAction( hDlg );
				} break;
			case IDOK:
				{
					int i;
					int cnt = ListBox_GetCount( hWndLB1 );
					// zero orders in config
					if( g_cfg )
						for( i=0; i<PLAYERS_COUNT; i++ )
							g_cfg->order[i] = 0;
					// save players order
					for( i=0; i<cnt; i++ )
					{
						TCHAR buffer[1024];
						ListBox_GetText( hWndLB1, i, buffer );
						if( g_cfg )
							g_cfg->order[i] = GetPlayerID( buffer );
					}
					// save action & text
					int cur_sel = ComboBox_GetCurSel( GetDlgItem( hDlg, IDC_CBACTION ) );
					if( g_cfg ) g_cfg->action_player_not_found = cur_sel;
					if( g_cfg )
					{
						if( g_cfg->action_player_not_found == ACT_SHOW_USER_TEXT )
							GetDlgItemText( hDlg, IDC_ETEXT, g_cfg->text_PlayerNotFound, sizeof(g_cfg->text_PlayerNotFound)/sizeof(g_cfg->text_PlayerNotFound[0]) );
					}
					EndDialog( hDlg, IDOK );
				} break;
			case IDCANCEL:
				EndDialog( hDlg, IDCANCEL );
				break;
			}
		} break;
	default: return FALSE; break;
	}
	return TRUE;
}