コード例 #1
0
ファイル: prc_keyfiles.c プロジェクト: hkerem/dcrypt
static
INT_PTR CALLBACK
_keyfiles_dlg_proc(
		HWND	hwnd,
		UINT	message,
		WPARAM	wparam,
		LPARAM	lparam
	)
{
	static int			key_list;
	static list_entry  *head;

	switch ( message )
	{
		case WM_CLOSE : 
		{
			EndDialog( hwnd, 0 );
			return 0L;
		}
		break;		

		case WM_NOTIFY : 
		{
			if( wparam == IDC_LIST_KEYFILES )
			{
				if ( ((NMHDR *)lparam)->code == LVN_ITEMCHANGED &&
					 (((NMLISTVIEW *)lparam)->uNewState & LVIS_FOCUSED ) )
				{
					HWND h_list = GetDlgItem( hwnd, IDC_LIST_KEYFILES );

					EnableWindow(GetDlgItem( hwnd, IDB_REMOVE_ITEM), ListView_GetSelectedCount( h_list ) );

					return 1L;
				}
				if ( ((NM_LISTVIEW *)lparam)->hdr.code == NM_CLICK )
				{
					HWND h_list = GetDlgItem( hwnd, IDC_LIST_KEYFILES );

					EnableWindow( GetDlgItem( hwnd, IDB_REMOVE_ITEM), ListView_GetSelectedCount( h_list ) );
				}
			}
		}
		case WM_COMMAND :
		{
			HWND h_list = GetDlgItem( hwnd, IDC_LIST_KEYFILES );

			int code = HIWORD(wparam);
			int id   = LOWORD(wparam);

			switch ( id )
			{
				case IDB_GENERATE_KEYFILE :
				{
					wchar_t s_file[MAX_PATH] = { L"keyfile" };

					byte keyfile[64];
					int rlt;					

					if ( _save_file_dialog(
							hwnd, s_file, countof(s_file), L"Save 64 bytes random keyfile as.."
						) )
					{
						if ( (rlt = dc_get_random(keyfile, sizeof(keyfile))) == ST_OK ) 
						{
							rlt = save_file(s_file, keyfile, sizeof(keyfile));
							burn(keyfile, sizeof(keyfile));
						}
						if ( rlt == ST_OK )
						{							
							if ( __msg_q(hwnd, 
								L"Keyfile \"%s\" successfully created\n\n"
								L"Add this file to the keyfiles list?", 
								s_file
								)	)
							{
								_ui_keys_list_refresh(hwnd);

								if ( key_list == KEYLIST_EMBEDDED ) 
								{
									ListView_DeleteAllItems( h_list );
								}
								_add_item( h_list, s_file );

								_ui_embedded( hwnd, key_list );
							}							
						} else {
							__error_s( hwnd, L"Error creating Keyfile", rlt );
						}
					}
				}
				break;
				case IDB_REMOVE_ITEM :
				{					
					ListView_DeleteItem( h_list, ListView_GetSelectionMark(h_list) );

					_ui_keys_list_refresh( hwnd );
					_ui_embedded( hwnd, key_list );
				}
				break;
				case IDB_REMOVE_ITEMS :
				{
					ListView_DeleteAllItems( h_list );

					_ui_keys_list_refresh( hwnd );
					_ui_embedded( hwnd, key_list );
				}
				break;
				case IDB_ADD_FOLDER :
				{
					wchar_t path[MAX_PATH];
					if ( _folder_choice(hwnd, path, L"Choice folder..") )
					{
						_ui_keys_list_refresh( hwnd );

						_set_trailing_slash( path );
						_add_item( h_list, path );
					}
				}
				break;
				case IDB_ADD_FILE :
				{
					wchar_t s_path[MAX_PATH] = { 0 };
					if ( _open_file_dialog(hwnd, s_path, countof(s_path), L"Select File..") )
					{					
						if ( key_list == KEYLIST_EMBEDDED )
						{
							HWND h_file = 
								CreateFile(
									s_path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL
									);

							if ( h_file != INVALID_HANDLE_VALUE )
							{
								if ( GetFileSize( h_file, NULL ) != 64 )
								{
									__error_s( hwnd, L"Embedded keyfile must be 64 byte size", ST_ERROR );
								} else 
								{
									_ui_keys_list_refresh( hwnd );
									_add_item( h_list, s_path );
								}
								CloseHandle( h_file );
							}
							_ui_embedded( hwnd, key_list );
						} else 
						{
							_ui_keys_list_refresh( hwnd );
							_add_item( h_list, s_path );
						}
					}
				}
				break;
			}
			if ( id == IDCANCEL )
			{
				EndDialog(hwnd, 0);
			}
			if ( id == IDOK )
			{
				int k = 0;

				_keyfiles_wipe(key_list);

				for ( ; k < ListView_GetItemCount( h_list ); k ++ )
				{
					wchar_t item[MAX_PATH];
					_get_item_text( h_list, k, 0, item, countof(item) );

					if ( wcscmp(item, IDS_EMPTY_LIST) != 0 )
					{
						_list_key_files *new_node;

						if ( (new_node = secure_alloc(sizeof(_list_key_files))) == NULL )
						{
							__error_s( hwnd, L"Can't allocate memory", ST_NOMEM );
							_keyfiles_wipe(key_list);
							break;
						}
						wcsncpy(new_node->path, item, countof(new_node->path));
						_insert_tail_list(head, &new_node->next);
					}
				}
				EndDialog(hwnd, 0);

			}
		}
		break;
		case WM_INITDIALOG : 
		{
			HWND h_list = GetDlgItem(hwnd, IDC_LIST_KEYFILES);
			
			_list_key_files *key_file;

			key_list = (int)lparam;
			head     = _KEYFILES_HEAD_( key_list );

			_init_list_headers( h_list, _keyfiles_headers );

			if ( key_file = _first_keyfile( key_list ) )
			{
				EnableWindow( GetDlgItem(hwnd, IDB_REMOVE_ITEMS), TRUE );
				do 
				{
					_list_insert_item( h_list, ListView_GetItemCount(h_list), 0, key_file->path, 0 );
					key_file = _next_keyfile( key_file, key_list );

				} while ( key_file != NULL );
			} 

			_ui_keys_list_refresh( hwnd );
			_ui_embedded( hwnd, key_list );

			ListView_SetBkColor( h_list, GetSysColor(COLOR_BTNFACE) );
			ListView_SetTextBkColor( h_list, GetSysColor(COLOR_BTNFACE) );
			ListView_SetExtendedListViewStyle( h_list, LVS_EX_FLATSB | LVS_EX_FULLROWSELECT );

			SetForegroundWindow(hwnd);
			return 1L;
		}
		break;
		case WM_CTLCOLOREDIT :
		{
			return _ctl_color(wparam, _cl(COLOR_BTNFACE, LGHT_CLR));
		}
		break;
		default:
		{
			int rlt = _draw_proc(message, lparam);
			if (rlt != -1) return rlt;
		}
	}
	return 0L;

}
コード例 #2
0
ファイル: SetupDlg.cpp プロジェクト: sunaoka/ygmail
BOOL OnEdit(HWND hWnd, BOOL bAdd) {

	char szEMail[256], szSound[256];
	int nLen;
	LV_ITEM	li;
	HWND hWndLV = GetDlgItem(hWnd, IDC_LIST);

	nLen = GetWindowText(GetDlgItem(hWnd, IDC_EMAIL), szEMail, sizeof(szEMail));
	if (nLen == 0) {
		MessageBox(hWnd, "メールアドレスを記入してください。", "エラー", MB_OK | MB_ICONEXCLAMATION);
		SetFocus(GetDlgItem(hWnd, IDC_MAIL));
		return FALSE;
	}
	
	nLen = GetWindowText(GetDlgItem(hWnd, IDC_SOUND), szSound, sizeof(szSound));
	if (nLen == 0) {
		MessageBox(hWnd, "wav ファイル名を記入してください。", "エラー", MB_OK | MB_ICONEXCLAMATION);
		SetFocus(GetDlgItem(hWnd, IDC_SOUND));
		return FALSE;
	}

	if (bAdd) {
		// 追加
		// メールアドレスが重複していないかチェック
		int nListCount = ListView_GetItemCount(hWndLV);
		for (int i = 0; i < nListCount; i++) {
			char buf[256];
			ListView_GetItemText(hWndLV, i, 0, buf, sizeof(buf));
			if (__stristr(buf, szEMail)) { // BkCommon.h
				MessageBox(hWnd, "指定したメールアドレスは、すでに登録されています。", "エラー", MB_OK | MB_ICONEXCLAMATION);
				SetFocus(GetDlgItem(hWnd, IDC_MAIL));
				return FALSE;
			}
		}
		
		li.mask = LVIF_TEXT;
		li.iItem = nListCount;

		li.pszText = szEMail;
		li.iSubItem = 0;
		ListView_InsertItem(hWndLV, &li);

		li.pszText = szSound;
		li.iSubItem = 1;
		ListView_SetItem(hWndLV, &li);
	} else {
		// 変更
		int nItem = ListView_GetNextItem(hWndLV, -1, LVNI_ALL | LVNI_SELECTED);
		if (nItem != -1) {
			li.mask = LVIF_TEXT;
			li.iItem = nItem;

			li.pszText = szEMail;
			li.iSubItem = 0;
			ListView_SetItem(hWndLV, &li);

			li.pszText = szSound;
			li.iSubItem = 1;
			ListView_SetItem(hWndLV, &li);
			// 選択状態を解除
			ListView_SetItemState(hWndLV, nItem, 0, LVIS_SELECTED);
		}
	}

	SetWindowText(GetDlgItem(hWnd, IDC_EMAIL), "");
	SetWindowText(GetDlgItem(hWnd, IDC_SOUND), "");
	
	return TRUE;
}
コード例 #3
0
BOOL CALLBACK VerticalFileSwitcher::run_dlgProc(UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
        case WM_INITDIALOG :
        {
			_fileListView.init(_hInst, _hSelf, _hImaLst);
			_fileListView.insertColumn(TEXT("Name"), 150, 0);
			_fileListView.insertColumn(TEXT("Ext."), 50, 1);
			_fileListView.initList();
			_fileListView.display();

            return TRUE;
        }

		case WM_NOTIFY:
		{
			switch (((LPNMHDR)lParam)->code)
			{
				case NM_DBLCLK:
				{
					LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam;
					int i = lpnmitem->iItem;
					if (i == -1)
					{
						::SendMessage(_hParent, WM_COMMAND, IDM_FILE_NEW, 0);
					}
					return TRUE;
				}

				case NM_CLICK:
				{
					LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam;
					int nbItem = ListView_GetItemCount(_fileListView.getHSelf());
					int i = lpnmitem->iItem;
					if (i == -1 || i >= nbItem)
						return TRUE;

					LVITEM item;
					item.mask = LVIF_PARAM;
					item.iItem = i;	
					ListView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item);
					TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam;

					activateDoc(tlfs);
					return TRUE;
				}

				case NM_RCLICK :
				{
					// Switch to the right document
					LPNMITEMACTIVATE lpnmitem = (LPNMITEMACTIVATE) lParam;
					int nbItem = ListView_GetItemCount(_fileListView.getHSelf());
					int i = lpnmitem->iItem;
					if (i == -1 || i >= nbItem)
 						return TRUE;

					LVITEM item;
					item.mask = LVIF_PARAM;
					item.iItem = i;	
					ListView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item);
					TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam;

					activateDoc(tlfs);

					// Redirect NM_RCLICK message to Notepad_plus handle
					NMHDR	nmhdr;
					nmhdr.code = NM_RCLICK;
					nmhdr.hwndFrom = _hSelf;
					nmhdr.idFrom = ::GetDlgCtrlID(nmhdr.hwndFrom);
					::SendMessage(_hParent, WM_NOTIFY, nmhdr.idFrom, (LPARAM)&nmhdr);
					return TRUE;
				}

				case LVN_GETINFOTIP:
				{
					LPNMLVGETINFOTIP pGetInfoTip = (LPNMLVGETINFOTIP)lParam;
					int i = pGetInfoTip->iItem;
					if (i == -1)
						return TRUE;
					generic_string fn = getFullFilePath((size_t)i);
					lstrcpyn(pGetInfoTip->pszText, fn.c_str(), pGetInfoTip->cchTextMax);
					return TRUE;
				}

				case LVN_COLUMNCLICK:
				{
					LPNMLISTVIEW pnmLV = (LPNMLISTVIEW)lParam;
					setHeaderOrder(pnmLV);
					ListView_SortItemsEx(pnmLV->hdr.hwndFrom, ListViewCompareProc,(LPARAM)pnmLV);
					return TRUE;
				}
				case LVN_KEYDOWN:
				{
					switch (((LPNMLVKEYDOWN)lParam)->wVKey)
					{
						case VK_RETURN:
						{
							int i = ListView_GetSelectionMark(_fileListView.getHSelf());
							if (i == -1)
								return TRUE;

							LVITEM item;
							item.mask = LVIF_PARAM;
							item.iItem = i;	
							ListView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item);
							TaskLstFnStatus *tlfs = (TaskLstFnStatus *)item.lParam;
							activateDoc(tlfs);
							return TRUE;
						}
						default:
							break;
					}
				}
				break;

				default:
					break;
			}
		}
		return TRUE;

        case WM_SIZE:
        {
            int width = LOWORD(lParam);
            int height = HIWORD(lParam);
			::MoveWindow(_fileListView.getHSelf(), 0, 0, width, height, TRUE);
            break;
        }
        
		case WM_DESTROY:
        {
			_fileListView.destroy();
            break;
        }

        default :
            return DockingDlgInterface::run_dlgProc(message, wParam, lParam);
    }
	return DockingDlgInterface::run_dlgProc(message, wParam, lParam);
}
コード例 #4
0
ファイル: alias.c プロジェクト: Tatsujinichi/Meridian59
/*
 * VerbAliasDialogProc:  Dialog procedure for command verb alias dialog.
 */
BOOL CALLBACK VerbAliasDialogProc(HWND hDlg, UINT message, UINT wParam, LONG lParam)
{
   switch (message)
   {
   case WM_INITDIALOG:

      SendDlgItemMessage(hDlg, IDC_VERB, EM_LIMITTEXT, MAX_VERBLEN, 0L);
      SendDlgItemMessage(hDlg, IDC_EXPANSION, EM_LIMITTEXT, MAX_ALIASLEN, 0L);

      // Prepare list of aliases currently defined.
      {
	 LV_COLUMN lvcol;
	 HWND hList;
	 int i;

	 // Prepare list of aliases.
	 hList = GetDlgItem(hDlg, IDC_COMMAND_LIST);
	 SetWindowFont(hList, GetFont(FONT_LIST), FALSE);
	 SetWindowLong(hList, GWL_STYLE, GetWindowLong(hList, GWL_STYLE) | LVS_SHOWSELALWAYS);

	 // Add column headings
	 lvcol.mask = LVCF_TEXT | LVCF_WIDTH;
	 lvcol.pszText = GetString(hInst, IDS_AHEADER0);
	 lvcol.cx = 60;
	 ListView_InsertColumn(hList, 0, &lvcol);
	 lvcol.pszText = GetString(hInst, IDS_AHEADER1);
	 lvcol.cx = 220;
	 ListView_InsertColumn(hList, 1, &lvcol);

	 // Add aliases
	 for (i = 0; i < _nVerbAliases; i++)
	 {
	    if (_apVerbAliases[i].verb[0])
	    {
	       LV_ITEM lvitem;

	       // Add item for verb.
	       lvitem.mask = LVIF_TEXT;
	       lvitem.iItem = ListView_GetItemCount(hList);
	       lvitem.iSubItem = 0;
	       lvitem.pszText = _apVerbAliases[i].verb;
	       lvitem.iItem = ListView_InsertItem(hList, &lvitem);

	       // Add subitem for command.
	       lvitem.mask = LVIF_TEXT;
	       lvitem.iSubItem = 1;
	       lvitem.pszText = _apVerbAliases[i].text;
	       ListView_SetItem(hList, &lvitem);
	    }
	 }
      }

      // Dialog is up.
      hAliasDialog = hDlg;
      hAliasDialog2 = hDlg;
      if (hAliasDialog1)
	 DestroyWindow(GetDlgItem(hDlg, IDC_TUNNEL));

      CenterWindow(hDlg, GetParent(hDlg));
      return TRUE;

   case WM_NOTIFY:
      if (wParam != IDC_COMMAND_LIST)
      {
	 return TRUE;
      }
      else
      {
	 NM_LISTVIEW* pnm = (NM_LISTVIEW*)lParam;
	 LV_HITTESTINFO lvhit;
	 LV_KEYDOWN* plvkey;
	 HWND hList;
	 int i;

	 if (!pnm)
	    break;

	 // Prepare list of aliases.
	 hList = GetDlgItem(hDlg, IDC_COMMAND_LIST);

	 switch (pnm->hdr.code)
	 {
	 case NM_CLICK:
	    {
	       VerbAlias alias;
	       LV_ITEM lvitem;
	       HWND hList;

	       hList = GetDlgItem(hDlg, IDC_COMMAND_LIST);

	       // If you click anywhere on an item.
	       GetCursorPos(&lvhit.pt);
	       ScreenToClient(hList, &lvhit.pt);
	       lvhit.pt.x = 3;
	       i = ListView_HitTest(hList, &lvhit);
	       if (i < 0)
		  break;

	       // Get our current definition.
	       lvitem.mask = LVIF_TEXT;
	       lvitem.iItem = i;
	       lvitem.iSubItem = 0;
	       lvitem.pszText = alias.verb;
	       lvitem.cchTextMax = sizeof(alias.verb);
	       ListView_GetItem(hList, &lvitem);
	       lvitem.iSubItem = 1;
	       lvitem.pszText = alias.text;
	       lvitem.cchTextMax = sizeof(alias.text);
	       ListView_GetItem(hList, &lvitem);

	       // Put it up for editing.
	       SetDlgItemText(hDlg, IDC_VERB, alias.verb);
	       SetDlgItemText(hDlg, IDC_EXPANSION, alias.text);

	       // Select and focus the item in the list.
	       ListView_SetItemState(hList, i, 
				     LVIS_SELECTED | LVIS_FOCUSED,
				     LVIS_SELECTED | LVIS_FOCUSED);
	    }
	    break;

	 case LVN_KEYDOWN:
	    plvkey = (LV_KEYDOWN*)pnm;
	    if (plvkey->wVKey == VK_DELETE)
	    {
//	       for (i = 0; i < nItems; i++)
//		  if (is selected i)
//		     ListView_DeleteItem(hList, i);
	    }
	    break;
	 }
      }
      return TRUE;

   case WM_COMMAND:
      switch(GET_WM_COMMAND_ID(wParam, lParam))
      {
      case IDOK:
	 // Erase current set and redefine words in the dialog.
	 {
	    int i, nItems;
	    HWND hList;
	    hList = GetDlgItem(hDlg, IDC_COMMAND_LIST);

	    // Simulate a last click of 'Define' in case they forgot.
	    // Does no harm if they left the boxes empty after their
	    // last 'Define'.
	    //
	    ListView_ClearSelection(hList);
	    SendMessage(hDlg, WM_COMMAND,
	       (WPARAM)MAKELONG(IDC_DEFINE, BN_CLICKED),
	       (LPARAM)GetDlgItem(hDlg, IDC_DEFINE));

	    // Clear our real aliases and rebuild them from our listbox.
	    //
	    FreeVerbAliases();
	    nItems = ListView_GetItemCount(hList);
	    for (i = 0; i < nItems; i++)
	    {
	       VerbAlias alias;
	       LV_ITEM lvitem;

	       lvitem.mask = LVIF_TEXT;
	       lvitem.iItem = i;
	       lvitem.iSubItem = 0;
	       lvitem.pszText = alias.verb;
	       lvitem.cchTextMax = sizeof(alias.verb);
	       ListView_GetItem(hList, &lvitem);
	       lvitem.iSubItem = 1;
	       lvitem.pszText = alias.text;
	       lvitem.cchTextMax = sizeof(alias.text);
	       ListView_GetItem(hList, &lvitem);

	       AddVerbAlias(alias.verb, alias.text);
	    }
	 }
	 EndDialog(hDlg, IDOK);
	 return TRUE;

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

      case IDC_DEFINE:
	 {
	    VerbAlias alias;
	    LV_ITEM lvitem;
	    HWND hList;

	    hList = GetDlgItem(hDlg, IDC_COMMAND_LIST);

	    // Get our new definition.
	    GetDlgItemText(hDlg, IDC_VERB, alias.verb, sizeof(alias.verb));
	    GetDlgItemText(hDlg, IDC_EXPANSION, alias.text, sizeof(alias.text));
	    if (!alias.verb[0])
	    {
	       SetFocus(GetDlgItem(hDlg, IDC_VERB));
	       return TRUE;
	    }
	    if (!alias.text[0])
	    {
	       SetFocus(GetDlgItem(hDlg, IDC_EXPANSION));
	       return TRUE;
	    }

	    // Simulate a remove so we don't have to hunt and modify existing entry.
	    ListView_ClearSelection(hList);
	    SendMessage(hDlg, WM_COMMAND,
	       (WPARAM)MAKELONG(IDC_REMOVE, BN_CLICKED),
	       (LPARAM)GetDlgItem(hDlg, IDC_REMOVE));

	    // Add item for verb.
	    lvitem.mask = LVIF_TEXT;
	    lvitem.iItem = ListView_GetItemCount(hList);
	    lvitem.iSubItem = 0;
	    lvitem.pszText = alias.verb;
	    lvitem.iItem = ListView_InsertItem(hList, &lvitem);

	    // Add subitem for command.
	    lvitem.mask = LVIF_TEXT;
	    lvitem.iSubItem = 1;
	    lvitem.pszText = alias.text;
	    ListView_SetItem(hList, &lvitem);

	    // Clear the fields to try another.
	    SetDlgItemText(hDlg, IDC_VERB, "");
	    SetDlgItemText(hDlg, IDC_EXPANSION, "");
	    SetFocus(GetDlgItem(hDlg, IDC_VERB));
	 }
	 return TRUE;

      case IDC_REMOVE:
	 {
	    char verb[MAX_VERBLEN+1];
	    LV_FINDINFO lvfind;
	    HWND hList;
	    int i;

	    hList = GetDlgItem(hDlg, IDC_COMMAND_LIST);

	    // Get our new definition.
	    GetDlgItemText(hDlg, IDC_VERB, verb, sizeof(verb));
	    if (!verb[0])
	    {
	       LV_ITEM lvitem;

	       i = ListView_GetSelection(hList);
	       if (i < 0)
	       {
		  SetFocus(GetDlgItem(hDlg, IDC_VERB));
		  return TRUE;
	       }

	       lvitem.mask = LVIF_TEXT;
	       lvitem.iItem = i;
	       lvitem.iSubItem = 0;
	       lvitem.pszText = verb;
	       lvitem.cchTextMax = sizeof(verb);
	       ListView_GetItem(hList, &lvitem);
	       if (!verb[0])
	       {
		  SetFocus(GetDlgItem(hDlg, IDC_VERB));
		  return TRUE;
	       }
	    }

	    // Find item for verb.
	    lvfind.flags = LVFI_STRING | LVFI_WRAP; // not LVFI_PARTIAL
	    lvfind.psz = verb;
	    lvfind.lParam = 0;
	    i = ListView_FindItem(hList, -1, &lvfind);
	    if (i < 0)
	    {
	       SetFocus(GetDlgItem(hDlg, IDC_VERB));
	       Edit_SetSel(GetDlgItem(hDlg, IDC_VERB), 0, -1);
	       return TRUE;
	    }

	    // Remove item.
	    ListView_DeleteItem(hList, i);

	    // Clear the fields to try another.
	    SetDlgItemText(hDlg, IDC_VERB, "");
	    SetDlgItemText(hDlg, IDC_EXPANSION, "");
	    SetFocus(GetDlgItem(hDlg, IDC_VERB));
	 }
	 return TRUE;

      case IDC_TUNNEL:
	 if (!hAliasDialog1 &&
	     IDOK == DialogBox(hInst, MAKEINTRESOURCE(IDD_ALIAS), hDlg, AliasDialogProc))
	 {
	    AliasSave();
	    SetFocus(GetDlgItem(hDlg, IDOK));
	 }
	 return TRUE;
      }
      break;

   case WM_DESTROY:
      hAliasDialog = NULL;
      hAliasDialog2 = NULL;
      return TRUE;
   }
   
   return FALSE;
}
コード例 #5
0
ファイル: Directories.c プロジェクト: cdrr/MAME_hack
static BOOL Directories_OnEndLabelEdit(HWND hDlg, NMHDR* pNMHDR)
{
    BOOL          bResult = FALSE;
    NMLVDISPINFO* pDispInfo = (NMLVDISPINFO*)pNMHDR;
    LVITEM*       pItem = &pDispInfo->item;

    if (pItem->pszText != NULL)
    {
        struct stat file_stat;

        /* Don't allow empty entries. */
        if (!strcmp(pItem->pszText, ""))
        {
            return FALSE;
        }

        /* Check validity of edited directory. */
        if (stat(pItem->pszText, &file_stat) == 0
        &&  (file_stat.st_mode & S_IFDIR))
        {
            bResult = TRUE;
        }
        else
        {
            if (MessageBox(NULL, "Directory does not exist, continue anyway?", "MAME32", MB_OKCANCEL) == IDOK)
                bResult = TRUE;
        }
    }

    if (bResult == TRUE)
    {
        int nType;
        int i;

        nType = ComboBox_GetCurSel(GetDlgItem(hDlg, IDC_DIR_COMBO));
        switch (nType)
        {
        case ROM:
        case SAMPLE:

            /* Last item is placeholder for append */
            if (pItem->iItem == ListView_GetItemCount(GetDlgItem(hDlg, IDC_DIR_LIST)) - 1)
            {
                if (MAX_DIRS <= DirInfo_NumDir(pDirInfo, nType))
                    return FALSE;

                for (i = DirInfo_NumDir(pDirInfo, nType); pItem->iItem < i; i--)
                    strcpy(DirInfo_Path(pDirInfo, nType, i),
                           DirInfo_Path(pDirInfo, nType, i - 1));

                strcpy(DirInfo_Path(pDirInfo, nType, pItem->iItem), pItem->pszText);
                pDirInfo->m_Paths[nType].m_bModified = TRUE;

                DirInfo_NumDir(pDirInfo, nType)++;
            }
            else
                DirInfo_SetDir(pDirInfo, nType, pItem->iItem, pItem->pszText);


            break;

        case CFG:
        case HI:
        case IMG:
        case INP:
        case STATE:
        case ART:
		case MEMCARD:
		case FLYER:
		case CABINET:
		case NVRAM:
            DirInfo_SetDir(pDirInfo, nType, pItem->iItem, pItem->pszText);
            break;
        }

        UpdateDirectoryList(hDlg);
        ListView_SetItemState(GetDlgItem(hDlg, IDC_DIR_LIST), pItem->iItem,
                              LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);

    }

    return bResult;
}
コード例 #6
0
void NListView::ListView_HandleInsertionMark(HWND hListView,int iItemFocus,POINT *ppt)
{
	/* Remove the insertion mark. */
	if(ppt == NULL)
	{
		LVINSERTMARK lvim;
		lvim.cbSize		= sizeof(LVINSERTMARK);
		lvim.dwFlags	= 0;
		lvim.iItem		= -1;
		ListView_SetInsertMark(hListView,&lvim);

		return;
	}

	RECT ItemRect;
	DWORD dwFlags = 0;
	int iNext;

	LV_HITTESTINFO item;
	item.pt = *ppt;

	int iItem = ListView_HitTest(hListView,&item);

	if(iItem != -1 && item.flags & LVHT_ONITEM)
	{
		ListView_GetItemRect(hListView,item.iItem,&ItemRect,LVIR_BOUNDS);

		/* If the cursor is on the left side
		of this item, set the insertion before
		this item; if it is on the right side
		of this item, set the insertion mark
		after this item. */
		if((ppt->x - ItemRect.left) >
			((ItemRect.right - ItemRect.left)/2))
		{
			iNext = iItem;
			dwFlags = LVIM_AFTER;
		}
		else
		{
			iNext = iItem;
			dwFlags = 0;
		}
	}
	else
	{
		dwFlags = 0;

		/* VK_UP finds whichever item is "above" the cursor.
		This item may be in the same row as the cursor is in
		(e.g. an item in the next row won't be found until the
		cursor passes into that row). Appears to find the item
		on the right side. */
		LVFINDINFO lvfi;
		lvfi.flags			= LVFI_NEARESTXY;
		lvfi.pt				= *ppt;
		lvfi.vkDirection	= VK_UP;
		iNext = ListView_FindItem(hListView,-1,&lvfi);

		if(iNext == -1)
		{
			lvfi.flags			= LVFI_NEARESTXY;
			lvfi.pt				= *ppt;
			lvfi.vkDirection	= VK_LEFT;
			iNext = ListView_FindItem(hListView,-1,&lvfi);
		}

		ListView_GetItemRect(hListView,iNext,&ItemRect,LVIR_BOUNDS);

		/* This situation only occurs at the
		end of the row. Prior to this, it is
		always the item on the right side that
		is found, with the insertion mark been
		inserted before that item.
		Once the end of the row is reached, the
		item found will be on the left side of
		the cursor. */
		if(ppt->x > ItemRect.left +
			((ItemRect.right - ItemRect.left)/2))
		{
			/* At the end of a row, VK_UP appears to
			find the next item up. Therefore, if we're
			at the end of a row, and the cursor is
			completely below the "next" item, find the
			one under it instead (if there is an item
			under it), and anchor the insertion mark
			there. */
			if(ppt->y > ItemRect.bottom)
			{
				int iBelow;

				iBelow = ListView_GetNextItem(hListView,iNext,LVNI_BELOW);

				if(iBelow != -1)
					iNext = iBelow;
			}

			dwFlags = LVIM_AFTER;
		}

		int nItems = ListView_GetItemCount(hListView);

		/* Last item is at position nItems - 1. */
		ListView_GetItemRect(hListView,nItems - 1,&ItemRect,LVIR_BOUNDS);

		/* Special case needed for very last item. If cursor is within 0.5 to 1.5 width
		of last item, and is greater than it's y coordinate, snap the insertion mark to
		this item. */
		if((ppt->x > ItemRect.left + ((ItemRect.right - ItemRect.left)/2)) &&
			ppt->x < ItemRect.right + ((ItemRect.right - ItemRect.left)/2) + 2 &&
			ppt->y > ItemRect.top)
		{
			iNext = nItems - 1;
			dwFlags = LVIM_AFTER;
		}
	}

	LVINSERTMARK lvim;
	lvim.cbSize			= sizeof(LVINSERTMARK);
	lvim.dwFlags		= dwFlags;
	lvim.iItem			= iNext;
	ListView_SetInsertMark(hListView,&lvim);
}
コード例 #7
0
void CDebugTlb::RefreshTLBWindow (void) 
{
	if (m_hWnd == NULL) 
	{
		return; 
	}
	
	HWND hList = GetDlgItem(IDC_LIST);
	char Output[100], OldText[100];
	LV_ITEM item, OldItem;
	int count;

	CTLB::TLB_ENTRY * tlb = g_TLB->m_tlb;	
	for (count = 0; count < 32; count ++)
	{
		sprintf(Output,"0x%02X",count);
		item.mask      = LVIF_TEXT;
		item.iItem     = count;
		item.pszText   = Output;
		item.iSubItem  = 0;

		OldItem.mask       = LVIF_TEXT;
		OldItem.iItem      = count;
		OldItem.pszText    = OldText;
		OldItem.cchTextMax = sizeof( OldText )-1;
		OldItem.iSubItem   = 0;

		if (ListView_GetItemCount(hList) <= count)
		{
			ListView_InsertItem(hList,&item);
		}
		else
		{
			ListView_GetItem(hList,&OldItem);
			if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
			{
				ListView_SetItem(hList,&item);
			}
		}
		if (tlb[count].EntryDefined)
		{
			sprintf(Output,"0x%08X",tlb[count].PageMask.Value);
		}
		else
		{
			strcpy(Output,"................");
		}
		item.iSubItem  = 1;
		OldItem.iSubItem   = 1;
		ListView_GetItem(hList,&OldItem);
		if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
		{
			ListView_SetItem(hList,&item);
		}

		if (tlb[count].EntryDefined)
		{
			sprintf(Output,"0x%08X",tlb[count].EntryHi.Value);
		}
		else
		{
			strcpy(Output,"................");
		}
		item.iSubItem  = 2;
		OldItem.iSubItem   = 2;
		ListView_GetItem(hList,&OldItem);
		if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
		{
			ListView_SetItem(hList,&item);
		}

		if (tlb[count].EntryDefined)
		{
			sprintf(Output,"0x%08X",tlb[count].EntryLo0.Value);
		}
		else
		{
			strcpy(Output,"................");
		}
		item.iSubItem  = 3;
		OldItem.iSubItem   = 3;
		ListView_GetItem(hList,&OldItem);
		if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
		{
			ListView_SetItem(hList,&item);
		}

		if (tlb[count].EntryDefined)
		{
			sprintf(Output,"0x%08X",tlb[count].EntryLo1.Value);
		}
		else
		{
			strcpy(Output,"................");
		}
		item.iSubItem  = 4;
		OldItem.iSubItem   = 4;
		ListView_GetItem(hList,&OldItem);
		if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
		{
			ListView_SetItem(hList,&item);
		}
	}
	
	CTLB::FASTTLB   * FastTlb = g_TLB->m_FastTlb;
	hList = GetDlgItem(IDC_LIST2);	
	for (count = 0; count < 64; count ++)
	{
		sprintf(Output,"0x%02X",count);
		item.mask      = LVIF_TEXT;
		item.iItem     = count;
		item.pszText   = Output;
		item.iSubItem  = 0;

		OldItem.mask       = LVIF_TEXT;
		OldItem.iItem      = count;
		OldItem.pszText    = OldText;
		OldItem.cchTextMax = sizeof( OldText )-1;
		OldItem.iSubItem   = 0;

		if (ListView_GetItemCount(hList) <= count)
		{
			item.iItem = ListView_InsertItem(hList,&item);
		}
		else
		{
			ListView_GetItem(hList,&OldItem);
			if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
			{
				ListView_SetItem(hList,&item);
			}
		}

		if (FastTlb[count].ValidEntry)
		{
			sprintf(Output,"%s",FastTlb[count].VALID?"Yes":"No");
		}
		else
		{
			strcpy(Output,"................");
		}
		item.iSubItem  = 1;
		OldItem.iSubItem   = 1;
		ListView_GetItem(hList,&OldItem);
		if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
		{
			ListView_SetItem(hList,&item);
		}

		if (FastTlb[count].ValidEntry && FastTlb[count].VALID)
		{
			sprintf(Output,"%s",FastTlb[count].DIRTY?"Yes":"No");
		}
		else
		{
			strcpy(Output,"................");
		}
		item.iSubItem  = 2;
		OldItem.iSubItem   = 2;
		ListView_GetItem(hList,&OldItem);
		if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
		{
			ListView_SetItem(hList,&item);
		}

		if (FastTlb[count].ValidEntry && FastTlb[count].VALID)
		{
			sprintf(Output,"%08X:%08X -> %08X:%08X",FastTlb[count].VSTART,FastTlb[count].VEND,
				FastTlb[count].PHYSSTART,FastTlb[count].PHYSEND);
		}
		else
		{
			strcpy(Output,"................");
		}
		item.iSubItem  = 3;
		OldItem.iSubItem  = 3;
		ListView_GetItem(hList,&OldItem);
		if ( strcmp( item.pszText, OldItem.pszText ) != 0 )
		{
			ListView_SetItem(hList,&item);
		}
	}
}
コード例 #8
0
ファイル: mir_options.cpp プロジェクト: kmdtukl/miranda-ng
INT_PTR CALLBACK SaveOptsDlgProc(OptPageControl *controls, int controlsSize, char *module, HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
	TCHAR tmp[1024];

	switch (msg) {
	case WM_INITDIALOG:
		TranslateDialogDefault(hwndDlg);

		for (int i = 0; i < controlsSize; i++) {
			OptPageControl *ctrl = &controls[i];

			if (GetDlgItem(hwndDlg, ctrl->nID) == NULL)
				continue;

			switch (ctrl->type) {
			case CONTROL_CHECKBOX:
				CheckDlgButton(hwndDlg, ctrl->nID, db_get_b(NULL, module, ctrl->setting, ctrl->dwDefValue) == 1 ? BST_CHECKED : BST_UNCHECKED);
				break;

			case CONTROL_SPIN:
				SendDlgItemMessage(hwndDlg, ctrl->nIDSpin, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwndDlg, ctrl->nID), 0);
				SendDlgItemMessage(hwndDlg, ctrl->nIDSpin, UDM_SETRANGE, 0, MAKELONG(ctrl->max, ctrl->min));
				SendDlgItemMessage(hwndDlg, ctrl->nIDSpin, UDM_SETPOS, 0, MAKELONG(db_get_w(NULL, module, ctrl->setting, ctrl->dwDefValue), 0));
				break;

			case CONTROL_COLOR:
				SendDlgItemMessage(hwndDlg, ctrl->nID, CPM_SETCOLOUR, 0, (COLORREF)db_get_dw(NULL, module, ctrl->setting, ctrl->dwDefValue));
				break;

			case CONTROL_RADIO:
				CheckDlgButton(hwndDlg, ctrl->nID, db_get_w(NULL, module, ctrl->setting, ctrl->dwDefValue) == ctrl->value ? BST_CHECKED : BST_UNCHECKED);
				break;

			case CONTROL_COMBO:
				SendDlgItemMessage(hwndDlg, ctrl->nID, CB_SETCURSEL, db_get_w(NULL, module, ctrl->setting, ctrl->dwDefValue), 0);
				break;

			case CONTROL_PROTOCOL_LIST:
			{
				// Fill list view
				HWND hwndProtocols = GetDlgItem(hwndDlg, ctrl->nID);
				LVCOLUMN lvc;
				LVITEM lvi;

				ListView_SetExtendedListViewStyle(hwndProtocols, LVS_EX_CHECKBOXES);

				memset(&lvc, 0, sizeof(lvc));
				lvc.mask = LVCF_FMT;
				lvc.fmt = LVCFMT_IMAGE | LVCFMT_LEFT;
				ListView_InsertColumn(hwndProtocols, 0, &lvc);

				memset(&lvi, 0, sizeof(lvi));
				lvi.mask = LVIF_TEXT | LVIF_PARAM;
				lvi.iSubItem = 0;
				lvi.iItem = 1000;

				int count;
				PROTOACCOUNT **protos;
				Proto_EnumAccounts(&count, &protos);

				for (int i = 0; i < count; i++) {
					PROTOACCOUNT *p = protos[i];
					if (p->szModuleName == NULL || p->szModuleName[0] == '\0')
						continue;

					if (ctrl->allowProtocol != NULL && !ctrl->allowProtocol(p->szModuleName))
						continue;

					char *setting = (char *)mir_alloc(128 * sizeof(char));
					mir_snprintf(setting, 128, ctrl->setting, p->szModuleName);

					BOOL show = (BOOL)db_get_b(NULL, module, setting, ctrl->dwDefValue);

					lvi.lParam = (LPARAM)setting;
					lvi.pszText = p->tszAccountName;
					lvi.iItem = ListView_InsertItem(hwndProtocols, &lvi);
					ListView_SetItemState(hwndProtocols, lvi.iItem, INDEXTOSTATEIMAGEMASK(show ? 2 : 1), LVIS_STATEIMAGEMASK);
				}

				ListView_SetColumnWidth(hwndProtocols, 0, LVSCW_AUTOSIZE);
				ListView_Arrange(hwndProtocols, LVA_ALIGNLEFT | LVA_ALIGNTOP);
			}
			break;

			case CONTROL_TEXT:
				SetDlgItemText(hwndDlg, ctrl->nID, MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == NULL ? NULL : TranslateTS(ctrl->tszDefValue)));
				SendDlgItemMessage(hwndDlg, ctrl->nID, EM_LIMITTEXT, min(ctrl->max <= 0 ? 1024 : ctrl->max, 1024), 0);
				break;

			case CONTROL_INT:
				SetDlgItemInt(hwndDlg, ctrl->nID, db_get_dw(NULL, module, ctrl->setting, ctrl->dwDefValue), ctrl->min <= 0);
				SendDlgItemMessage(hwndDlg, ctrl->nID, EM_LIMITTEXT, 9, 0);
				break;

			case CONTROL_FILE:
				MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == NULL ? NULL : ctrl->tszDefValue);
				{
					TCHAR abs[1024];
					PathToAbsolute(abs, 1024, tmp);
					SetDlgItemText(hwndDlg, ctrl->nID, abs);
				}
				SendDlgItemMessage(hwndDlg, ctrl->nID, EM_LIMITTEXT, min(ctrl->max <= 0 ? 1024 : ctrl->max, 1024), 0);
				break;

			case CONTROL_COMBO_TEXT:
				MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == NULL ? NULL : TranslateTS(ctrl->tszDefValue));
				SendDlgItemMessage(hwndDlg, ctrl->nID, CB_SELECTSTRING, 0, (WPARAM)tmp);
				break;

			case CONTROL_COMBO_ITEMDATA:
				MyDBGetContactSettingTString(NULL, module, ctrl->setting, tmp, 1024, ctrl->tszDefValue == NULL ? NULL : TranslateTS(ctrl->tszDefValue));
				{
					int count = SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETCOUNT, 0, 0);
					int i;
					for (i = 0; i < count; i++) {
						TCHAR *id = (TCHAR *)SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETITEMDATA, (WPARAM)i, 0);
						if (mir_tstrcmp(id, tmp) == 0)
							break;
					}
					if (i < count)
						SendDlgItemMessage(hwndDlg, ctrl->nID, CB_SETCURSEL, i, 0);
				}
				break;
			}
		}
		break;

	case WM_COMMAND:
		for (int i = 0; i < controlsSize; i++) {
			OptPageControl *ctrl = &controls[i];

			if (LOWORD(wParam) == ctrl->nID) {
				switch (ctrl->type) {
				case CONTROL_TEXT:
				case CONTROL_SPIN:
				case CONTROL_INT:
					// Don't make apply enabled during buddy set
					if (HIWORD(wParam) != EN_CHANGE || (HWND)lParam != GetFocus())
						return 0;

					break;

				case CONTROL_COMBO_ITEMDATA:
				case CONTROL_COMBO_TEXT:
				case CONTROL_COMBO:
					if (HIWORD(wParam) != CBN_SELCHANGE || (HWND)lParam != GetFocus())
						return 0;
					break;
				}

				SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
			}
		}
		break;

	case WM_NOTIFY:
	{
		LPNMHDR lpnmhdr = (LPNMHDR)lParam;
		if (lpnmhdr->idFrom == 0 && lpnmhdr->code == PSN_APPLY) {
			for (int i = 0; i < controlsSize; i++) {
				OptPageControl *ctrl = &controls[i];

				if (GetDlgItem(hwndDlg, ctrl->nID) == NULL)
					continue;

				switch (ctrl->type) {
				case CONTROL_CHECKBOX:
					db_set_b(NULL, module, ctrl->setting, (BYTE)IsDlgButtonChecked(hwndDlg, ctrl->nID));
					break;

				case CONTROL_SPIN:
					db_set_w(NULL, module, ctrl->setting, (WORD)SendDlgItemMessage(hwndDlg, ctrl->nIDSpin, UDM_GETPOS, 0, 0));
					break;

				case CONTROL_COLOR:
					db_set_dw(NULL, module, ctrl->setting, (DWORD)SendDlgItemMessage(hwndDlg, ctrl->nID, CPM_GETCOLOUR, 0, 0));
					break;

				case CONTROL_RADIO:
					if (IsDlgButtonChecked(hwndDlg, ctrl->nID))
						db_set_w(NULL, module, ctrl->setting, (BYTE)ctrl->value);
					break;

				case CONTROL_COMBO:
					db_set_w(NULL, module, ctrl->setting, (WORD)SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETCURSEL, 0, 0));
					break;

				case CONTROL_PROTOCOL_LIST:
				{
					LVITEM lvi = { 0 };
					HWND hwndProtocols = GetDlgItem(hwndDlg, ctrl->nID);
					int i;

					lvi.mask = (UINT)LVIF_PARAM;

					for (i = 0; i < ListView_GetItemCount(hwndProtocols); i++) {
						lvi.iItem = i;
						ListView_GetItem(hwndProtocols, &lvi);

						char *setting = (char *)lvi.lParam;
						db_set_b(NULL, module, setting, (BYTE)ListView_GetCheckState(hwndProtocols, i));
					}
				}
				break;

				case CONTROL_TEXT:
				{
					TCHAR tmp[1024];
					GetDlgItemText(hwndDlg, ctrl->nID, tmp, _countof(tmp));
					db_set_ts(NULL, module, ctrl->setting, tmp);
				}
				break;

				case CONTROL_INT:
				{
					BOOL trans;
					int val = GetDlgItemInt(hwndDlg, ctrl->nID, &trans, ctrl->min <= 0);
					if (!trans)
						val = ctrl->dwDefValue;
					if (ctrl->max != 0)
						val = min(val, ctrl->max);
					if (ctrl->min != 0)
						val = max(val, ctrl->min);
					db_set_dw(NULL, module, ctrl->setting, val);
				}
				break;
				case CONTROL_FILE:
				{
					TCHAR tmp[1024];
					GetDlgItemText(hwndDlg, ctrl->nID, tmp, _countof(tmp));
					TCHAR rel[1024];
					PathToRelative(rel, 1024, tmp);
					db_set_ts(NULL, module, ctrl->setting, rel);
				}
				break;
				case CONTROL_COMBO_TEXT:
				{
					TCHAR tmp[1024];
					GetDlgItemText(hwndDlg, ctrl->nID, tmp, _countof(tmp));
					db_set_ts(NULL, module, ctrl->setting, tmp);
				}
				break;
				case CONTROL_COMBO_ITEMDATA:
				{
					int sel = SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETCURSEL, 0, 0);
					db_set_ts(NULL, module, ctrl->setting, (TCHAR *)SendDlgItemMessage(hwndDlg, ctrl->nID, CB_GETITEMDATA, (WPARAM)sel, 0));
				}
				break;
				}

				LoadOpt(ctrl, module);
			}

			return TRUE;
		}
		else if (lpnmhdr->idFrom != 0 && lpnmhdr->code == LVN_ITEMCHANGED) {
			// Changed for protocols
			for (int i = 0; i < controlsSize; i++) {
				OptPageControl *ctrl = &controls[i];

				if (ctrl->type == CONTROL_PROTOCOL_LIST && ctrl->nID == lpnmhdr->idFrom) {
					NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam;

					if (IsWindowVisible(GetDlgItem(hwndDlg, ctrl->nID)) && ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK))
						SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);

					break;
				}
			}
		}
	}
	break;

	case WM_DESTROY:
		for (int i = 0; i < controlsSize; i++) {
			OptPageControl *ctrl = &controls[i];

			if (GetDlgItem(hwndDlg, ctrl->nID) == NULL)
				continue;

			switch (ctrl->type) {
			case CONTROL_PROTOCOL_LIST:
				LVITEM lvi = { 0 };
				HWND hwndProtocols = GetDlgItem(hwndDlg, ctrl->nID);
				int i;

				lvi.mask = (UINT)LVIF_PARAM;

				for (i = 0; i < ListView_GetItemCount(hwndProtocols); i++) {
					lvi.iItem = i;
					ListView_GetItem(hwndProtocols, &lvi);
					mir_free((char *)lvi.lParam);
				}
				break;
			}
		}
		break;
	}

	return 0;
}
コード例 #9
0
ファイル: cdlgfileassoc.cpp プロジェクト: dps123/nitrogenS100
LRESULT CDlgFileAssoc::DlgProc(UINT uMsg, WPARAM wParam, LPARAM lParam) {

	switch (uMsg) {
		
		case WM_INITDIALOG: {

#ifdef SHELL_AYGSHELL
			// Initializes menubar		
			SHMENUBARINFO mbi;
			memset(&mbi, 0, sizeof(SHMENUBARINFO));
			mbi.cbSize = sizeof(SHMENUBARINFO);
			mbi.hwndParent = hWnd;
			mbi.nToolBarId = MNU_OKCANCEL;
			mbi.hInstRes = player()->hInstance;
			mbi.nBmpId = 0;
			mbi.cBmpImages = 0;
			if (SHCreateMenuBar(&mbi)) {
				hWndMenuBar = mbi.hwndMB;
				SetSoftkeyText(hWndMenuBar, 0, _str(STR_CANCEL));
				SetSoftkeyText(hWndMenuBar, 1, _str(STR_OK));
			} else {
				hWndMenuBar = NULL;
			}
#else
            hWndMenuBar = NULL;
#endif

#ifdef SHELL_AYGSHELL
			// Initializes fullscreen dialog
			SHINITDLGINFO shidi;
			shidi.dwMask = SHIDIM_FLAGS;
			shidi.dwFlags = SHIDIF_SIZEDLGFULLSCREEN|SHIDIF_DONEBUTTON|SHIDIF_WANTSCROLLBAR;
			shidi.hDlg = hWnd;
			SHInitDialog(&shidi);
#endif

			SetWindowText(hWnd, _str(STR_FILEASSOCIATIONS));
			SetDlgItemText(hWnd, LBL_USETOOPEN, _str(STR_USENITROGENTOOPE));
			SetDlgItemText(hWnd, BTN_SELALL, _str(STR_SELECTALL));
			SetDlgItemText(hWnd, BTN_SELNONE, _str(STR_SELECTNONE));
			SetDlgItemText(hWnd, LBL_NOTRUNNING, _str(STR_IFTHEPLAYERISNOT));
			SetDlgItemText(hWnd, LBL_RUNNING, _str(STR_IFTHEPLAYERISALR));

			int rActions[3] = {STR_SETFILEASPLAYLIS, STR_ADDFILETOPLAYLIS, STR_SETFOLDERASPLAYL};
			for (int i = 0; i < 3; i++) {
				SendDlgItemMessage(hWnd, CBB_NOTRUNNING, CB_ADDSTRING, 0, (LPARAM)_str(rActions[i]));
				SendDlgItemMessage(hWnd, CBB_RUNNING, CB_ADDSTRING, 0, (LPARAM)_str(rActions[i]));
			}

			SendDlgItemMessage(hWnd, CBB_NOTRUNNING, CB_SETCURSEL, (WPARAM)player()->lpConfig->cf.FileAssNotRunning, 0);
			SendDlgItemMessage(hWnd, CBB_RUNNING, CB_SETCURSEL, (WPARAM)player()->lpConfig->cf.FileAssRunning, 0);

			ListView_SetExtendedListViewStyle(GetDlgItem(hWnd, LST_EXTENSIONS), LVS_EX_CHECKBOXES|LVS_EX_FULLROWSELECT);
		
			LVCOLUMN nCol;
			memset(&nCol, 0, sizeof(LVCOLUMN));
			nCol.mask = LVCF_TEXT;
			nCol.pszText = NULL;
			ListView_InsertColumn(GetDlgItem(hWnd, LST_EXTENSIONS), 0, &nCol);

			LPWSTR assc[4] = {L"Skin files (*.sk2)", L"MPEG Layer-3 files (*.mp3)", L"Ogg Vorbis files (*.ogg)", L"Wave Audio files (*.wav)"};
			LPWSTR exts[4] = {L"sk2", L"mp3", L"ogg", L"wav"};

			int y = 0;

			for (int i = 0; i < 4; i++) {
				LVITEM nItem;
				memset(&nItem, 0, sizeof(LVITEM));
				nItem.mask = LVIF_TEXT;
				nItem.iSubItem = 0;
				nItem.pszText = assc[i];
				nItem.iItem = y;
				ListView_InsertItem(GetDlgItem(hWnd, LST_EXTENSIONS), &nItem);
				PrevAssoc[y] = IsExtAssignedDyn(exts[i]);
				if (PrevAssoc[y]) {
					ListView_SetCheckState(GetDlgItem(hWnd, LST_EXTENSIONS), y, true);
				}
				y++;
			}
			for (int i = 0; i < MAP_GetDecoderPlugInCount(player()->MAP); i++) {

				MAP_DEC_PLUGIN * mplug = MAP_GetDecoderPlugIn(player()->MAP, i);
				
				for (int x = 0; x < mplug->GetFileExtCount(); x++) {

					TCHAR ExtName[MAX_PATH];
					TCHAR ExtDesc[MAX_PATH];
					mplug->GetFileExt(x, ExtName, ExtDesc);
					LVITEM nItem;
					memset(&nItem, 0, sizeof(LVITEM));
					nItem.mask = LVIF_TEXT;
					nItem.iSubItem = 0;
					nItem.pszText = ExtDesc;
					nItem.iItem = y;
					
					ListView_InsertItem(GetDlgItem(hWnd, LST_EXTENSIONS), &nItem);	
					PrevAssoc[y] = IsExtAssignedDyn(ExtName);
					if (PrevAssoc[y]) {
						ListView_SetCheckState(GetDlgItem(hWnd, LST_EXTENSIONS), y, true);
					}

					y++;
				}
			}

			RECT rc;
			GetClientRect(GetDlgItem(hWnd, LST_EXTENSIONS), &rc);
			ListView_SetColumnWidth(GetDlgItem(hWnd, LST_EXTENSIONS), 0, rc.right-rc.left);

			break;

		}

 		case WM_COMMAND: {

			int wmId = LOWORD(wParam); 
			if ((wmId == IDM_OK) || (wmId == IDOK)) {

				player()->lpConfig->cf.FileAssNotRunning = SendDlgItemMessage(hWnd, CBB_NOTRUNNING, CB_GETCURSEL, 0, 0);
				player()->lpConfig->cf.FileAssRunning = SendDlgItemMessage(hWnd, CBB_RUNNING, CB_GETCURSEL, 0, 0);
				
				LPWSTR exts[4] = {L"sk2", L"mp3", L"ogg", L"wav"};
				for (int i = 0; i < 4; i++) {
					
					bool NewAssoc = ListView_GetCheckState(GetDlgItem(hWnd, LST_EXTENSIONS), i);

					if (NewAssoc && !PrevAssoc[i]) {
						ExtAssignDyn(exts[i], L"\"%1\"", 102+(int)(i == 0));
					}

					if (!NewAssoc && PrevAssoc[i]) {
						ExtUnassignDyn(exts[i]);
					}

				}

				int y = 4;

				for (int i = 0; i < MAP_GetDecoderPlugInCount(player()->MAP); i++) {
		
					MAP_DEC_PLUGIN * mplug = MAP_GetDecoderPlugIn(player()->MAP, i);
				
					for (int x = 0; x < mplug->GetFileExtCount(); x++) {

						bool NewAssoc = ListView_GetCheckState(GetDlgItem(hWnd, LST_EXTENSIONS), y);
	
						TCHAR ExtName[MAX_PATH];
						TCHAR ExtDesc[MAX_PATH];
						mplug->GetFileExt(x, ExtName, ExtDesc);
						
						if (NewAssoc && !PrevAssoc[y]) {
							ExtAssignDyn(ExtName, L"\"%1\"", 102);
						}

						if (!NewAssoc && PrevAssoc[y]) {
							ExtUnassignDyn(ExtName);
						}

						y++;
					}
				}

				EndDialog(hWnd, 0);

			} else if (wmId == BTN_SELALL) {
		
				HWND ls = GetDlgItem(hWnd, LST_EXTENSIONS);
				for (int i = 0; i < ListView_GetItemCount(ls); i++) {
					ListView_SetCheckState(ls, i, true);
				}

			} else if (wmId == BTN_SELNONE) {
		
				HWND ls = GetDlgItem(hWnd, LST_EXTENSIONS);
				for (int i = 0; i < ListView_GetItemCount(ls); i++) {
					ListView_SetCheckState(ls, i, false);
				}

			} else if (wmId == IDM_CANCEL) {
			
				EndDialog(hWnd, 0);
			
			}

			break;
		}

		case WM_DESTROY:
			CommandBar_Destroy(hWndMenuBar);
			break;

		case WM_ACTIVATE:
			
			if ((wParam == WA_INACTIVE) && ((HWND)lParam == player()->lpWndMain->hWnd)) {
				EndDialog(hWnd, 0);
			} else {
				return DefWindowProc(hWnd, uMsg, wParam, lParam);
			}
			break;

		default:
			DefWindowProc(hWnd, uMsg, wParam, lParam);
	}

	return 0;
}
コード例 #10
0
ファイル: ctrl.cpp プロジェクト: danieljiang0415/gh
//ListView
DWORD LvGetItemCount(HWND hLv)
{
	return ListView_GetItemCount( hLv );
}