void PropertyPageHandler_TLS::OnInitDialog() { // Fill them with data vector<TextAndData> TLSItemsInfo; PEReadWrite::PEType PEType = m_PEReaderWriter.getPEType(); union { PIMAGE_TLS_DIRECTORY32 pTLSData32; PIMAGE_TLS_DIRECTORY64 pTLSData64; }; int err; switch (PEType) { case PEReadWrite::PEType::PE32: { err = m_PEReaderWriter.getTLSDirectory(std::ref(pTLSData32)); if (err) { LogError(L"ERROR: Couldn't read 'IMAGE_TLS_DIRECTORY32' header. File is not valid.", true); return; } TLSItemsInfo = { { L"Raw Data Start (VA)", DWORD_toString(pTLSData32->StartAddressOfRawData, Hexadecimal) }, { L"Raw Data End (VA)", DWORD_toString(pTLSData32->EndAddressOfRawData, Hexadecimal) }, { L"Addr of Index (VA)", DWORD_toString(pTLSData32->AddressOfIndex, Hexadecimal) }, { L"Addr of Callbacks (VA)", DWORD_toString(pTLSData32->AddressOfCallBacks, Hexadecimal) }, { L"Size of Zero Fill", DWORD_toString(pTLSData32->SizeOfZeroFill), FormattedBytesSize(pTLSData32->SizeOfZeroFill) }, { L"Characteristics", DWORD_toString(pTLSData32->Characteristics), L"Reserved, must be zero" } }; } break; case PEReadWrite::PEType::PE64: { err = m_PEReaderWriter.getTLSDirectory(std::ref(pTLSData64)); if (err) { LogError(L"ERROR: Couldn't read 'IMAGE_TLS_DIRECTORY64' header. File is not valid.", true); return; } TLSItemsInfo = { { L"Raw Data Start (VA)", QWORD_toString(pTLSData64->StartAddressOfRawData, Hexadecimal) }, { L"Raw Data End (VA)", QWORD_toString(pTLSData64->EndAddressOfRawData, Hexadecimal) }, { L"Addr of Index (VA)", QWORD_toString(pTLSData64->AddressOfIndex, Hexadecimal) }, { L"Addr of Callbacks (VA)", QWORD_toString(pTLSData64->AddressOfCallBacks, Hexadecimal) }, { L"Size of Zero Fill", DWORD_toString(pTLSData64->SizeOfZeroFill), FormattedBytesSize(pTLSData64->SizeOfZeroFill) }, { L"Characteristics", DWORD_toString(pTLSData64->Characteristics), L"Reserved, must be zero" } }; } break; default: LogError(L"ERROR: This type of Portable Executable doesn't have any Thread Local Storage data.", true); return; } // Insert ListView columns for 'hListViewTLSData' LV_COLUMN column; ZeroMemory(&column, sizeof(column)); for (size_t i = 0; i < ARRAYSIZE(szGenericColumnText); ++i) { column.mask = LVCF_TEXT; column.pszText = szGenericColumnText[i]; ListView_InsertColumn(m_hListViewTLSData, i, &column); } // Insert ListView columns for 'hListViewCallbacks' static LPWSTR szCallbacksColumnText[] = { L"Index", L"RVA" }; for (size_t i = 0; i < ARRAYSIZE(szCallbacksColumnText); ++i) { column.mask = LVCF_TEXT; column.pszText = szCallbacksColumnText[i]; ListView_InsertColumn(m_hListViewCallbacks, i, &column); } // Insert ListView items for 'hListViewTLSData' LV_ITEM item; ZeroMemory(&item, sizeof(item)); for (size_t i = 0; i < TLSItemsInfo.size(); ++i) { item.iItem = int(i); item.iSubItem = 0; item.mask = LVIF_TEXT; item.pszText = LPWSTR(_wcsdup(TLSItemsInfo[i].Text.c_str())); ListView_InsertItem(m_hListViewTLSData, &item); free(item.pszText); item.iSubItem = 1; item.pszText = LPWSTR(_wcsdup(TLSItemsInfo[i].Data.c_str())); ListView_SetItem(m_hListViewTLSData, &item); free(item.pszText); item.iSubItem = 2; item.pszText = LPWSTR(_wcsdup(TLSItemsInfo[i].Comments.c_str())); ListView_SetItem(m_hListViewTLSData, &item); free(item.pszText); } // Insert ListView items for 'hListViewCallbacks' int i = 0; ZeroMemory(&item, sizeof(item)); switch (PEType) { case PEReadWrite::PEType::PE32: { DWORD Callback = m_PEReaderWriter.getTLSCallbackByIndex(pTLSData32, i); while (Callback) { item.iItem = i; item.iSubItem = 0; item.mask = LVIF_TEXT; item.pszText = LPWSTR(_wcsdup(DWORD_toString(i).c_str())); ListView_InsertItem(m_hListViewCallbacks, &item); free(item.pszText); item.iSubItem = 1; item.pszText = LPWSTR(_wcsdup(DWORD_toString(Callback, Hexadecimal).c_str())); ListView_SetItem(m_hListViewCallbacks, &item); free(item.pszText); Callback = m_PEReaderWriter.getTLSCallbackByIndex(pTLSData32, ++i); } } break; case PEReadWrite::PEType::PE64: { ULONGLONG Callback = m_PEReaderWriter.getTLSCallbackByIndex(pTLSData64, i); while (Callback) { item.iItem = i; item.iSubItem = 0; item.mask = LVIF_TEXT; item.pszText = LPWSTR(_wcsdup(QWORD_toString(i).c_str())); ListView_InsertItem(m_hListViewCallbacks, &item); free(item.pszText); item.iSubItem = 1; item.pszText = LPWSTR(_wcsdup(QWORD_toString(Callback, Hexadecimal).c_str())); ListView_SetItem(m_hListViewCallbacks, &item); free(item.pszText); Callback = m_PEReaderWriter.getTLSCallbackByIndex(pTLSData64, ++i); } } break; } // Resize columns for 'hListViewTLSData' for (size_t i = 0; i < ARRAYSIZE(szGenericColumnText); ++i) ListView_SetColumnWidth(m_hListViewTLSData, i, (i == ARRAYSIZE(szGenericColumnText) - 1 ? LVSCW_AUTOSIZE_USEHEADER : LVSCW_AUTOSIZE)); // Resize columns for 'hListViewCallbacks' for (size_t i = 0; i < ARRAYSIZE(szCallbacksColumnText); ++i) ListView_SetColumnWidth(m_hListViewCallbacks, i, LVSCW_AUTOSIZE_USEHEADER); }
/* * MainWindowHandleWMNotify * * Purpose: * * Main window WM_NOTIFY handler. * */ LRESULT MainWindowHandleWMNotify( _In_ HWND hwnd, _In_ WPARAM wParam, _In_ LPARAM lParam ) { INT c, k; LPNMHDR hdr = (LPNMHDR)lParam; LPTOOLTIPTEXT lpttt; LPNMLISTVIEW lvn; LPNMTREEVIEW lpnmTreeView; LPWSTR str; SIZE_T lcp; LVITEMW lvitem; LVCOLUMNW col; TVHITTESTINFO hti; POINT pt; WCHAR item_string[MAX_PATH + 1]; UNREFERENCED_PARAMETER(wParam); if (hdr) { if (hdr->hwndFrom == ObjectTree) { switch (hdr->code) { case TVN_ITEMEXPANDED: case TVN_SELCHANGED: SetFocus(ObjectTree); supSetWaitCursor(TRUE); MainWindowTreeViewSelChanged((LPNMTREEVIEWW)lParam); SendMessageW(StatusBar, WM_SETTEXT, 0, (LPARAM)CurrentObjectPath); g_enumParams.lpSubDirName = CurrentObjectPath; ListObjectsInDirectory(&g_enumParams); ListView_SortItemsEx(ObjectList, &MainWindowObjectListCompareFunc, SortColumn); supSetWaitCursor(FALSE); lpnmTreeView = (LPNMTREEVIEW)lParam; if (lpnmTreeView) { SelectedTreeItem = lpnmTreeView->itemNew.hItem; } break; case NM_RCLICK: GetCursorPos(&pt); hti.pt = pt; ScreenToClient(hdr->hwndFrom, &hti.pt); if (TreeView_HitTest(hdr->hwndFrom, &hti) && (hti.flags & (TVHT_ONITEM | TVHT_ONITEMRIGHT))) { SelectedTreeItem = hti.hItem; if (hdr->code == NM_RCLICK) { TreeView_SelectItem(ObjectTree, SelectedTreeItem); SendMessageW(StatusBar, WM_SETTEXT, 0, (LPARAM)CurrentObjectPath); supHandleTreePopupMenu(hwnd, &pt); } } break; } } if (hdr->hwndFrom == ObjectList) { switch (hdr->code) { case NM_SETFOCUS: if (ListView_GetSelectionMark(ObjectList) == -1) { lvitem.mask = LVIF_STATE; lvitem.iItem = 0; lvitem.state = LVIS_SELECTED | LVIS_FOCUSED; lvitem.stateMask = LVIS_SELECTED | LVIS_FOCUSED; ListView_SetItem(ObjectList, &lvitem); } break; case LVN_ITEMCHANGED: lvn = (LPNMLISTVIEW)lParam; RtlSecureZeroMemory(&item_string, sizeof(item_string)); ListView_GetItemText(ObjectList, lvn->iItem, 0, item_string, MAX_PATH); lcp = _strlen(CurrentObjectPath); str = HeapAlloc(GetProcessHeap(), 0, (lcp + _strlen(item_string) + 4) * sizeof(WCHAR)); if (str == NULL) break; _strcpy(str, CurrentObjectPath); if ((str[0] == '\\') && (str[1] == 0)) { _strcpy(str + lcp, item_string); } else { str[lcp] = '\\'; _strcpy(str + lcp + 1, item_string); } SendMessageW(StatusBar, WM_SETTEXT, 0, (LPARAM)str); HeapFree(GetProcessHeap(), 0, str); break; //handle sort by column case LVN_COLUMNCLICK: bSortInverse = !bSortInverse; SortColumn = ((NMLISTVIEW *)lParam)->iSubItem; ListView_SortItemsEx(ObjectList, &MainWindowObjectListCompareFunc, SortColumn); RtlSecureZeroMemory(&col, sizeof(col)); col.mask = LVCF_IMAGE; col.iImage = -1; for (c = 0; c < 3; c++) ListView_SetColumn(ObjectList, c, &col); k = ImageList_GetImageCount(ListViewImages); if (bSortInverse) col.iImage = k - 2; else col.iImage = k - 1; ListView_SetColumn(ObjectList, ((NMLISTVIEW *)lParam)->iSubItem, &col); break; case NM_CLICK: c = ((LPNMITEMACTIVATE)lParam)->iItem; EnableMenuItem(GetSubMenu(GetMenu(hwnd), 2), ID_OBJECT_GOTOLINKTARGET, (supIsSymlink(c)) ? MF_BYCOMMAND : MF_BYCOMMAND | MF_GRAYED); break; case NM_DBLCLK: MainWindowHandleObjectListProp(hwnd); break; default: break; } } //handle tooltip if (hdr->code == TTN_GETDISPINFO) { lpttt = (LPTOOLTIPTEXT)lParam; switch (lpttt->hdr.idFrom) { case ID_OBJECT_PROPERTIES: case ID_VIEW_REFRESH: case ID_FIND_FINDOBJECT: lpttt->hinst = g_hInstance; lpttt->lpszText = MAKEINTRESOURCE(lpttt->hdr.idFrom); lpttt->uFlags |= TTF_DI_SETITEM; break; default: break; } } } return FALSE; }
/* * SdtListTable * * Purpose: * * KiServiceTable query and list routine. * */ VOID SdtListTable( VOID ) { BOOL cond = FALSE; PUTable Dump = NULL; PRTL_PROCESS_MODULES pModules = NULL; PVOID Module = NULL; PIMAGE_EXPORT_DIRECTORY pexp = NULL; PIMAGE_NT_HEADERS NtHeaders = NULL; DWORD ETableVA; PDWORD names, functions; PWORD ordinals; LVITEMW lvitem; WCHAR szBuffer[MAX_PATH + 1]; char *name; void *addr; ULONG number, i; INT index; __try { do { pModules = (PRTL_PROCESS_MODULES)supGetSystemInfo(SystemModuleInformation); if (pModules == NULL) break; //if table empty, dump and prepare table if (g_SdtTable == NULL) { if (g_NtdllModule == NULL) { Module = GetModuleHandle(TEXT("ntdll.dll")); } else { Module = g_NtdllModule; } if (Module == NULL) break; g_SdtTable = (PSERVICETABLEENTRY)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SERVICETABLEENTRY) * g_kdctx.KiServiceLimit); if (g_SdtTable == NULL) break; if (!supDumpSyscallTableConverted(&g_kdctx, &Dump)) break; NtHeaders = RtlImageNtHeader(Module); if (NtHeaders == NULL) break; ETableVA = NtHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress; pexp = (PIMAGE_EXPORT_DIRECTORY)((PBYTE)Module + ETableVA); names = (PDWORD)((PBYTE)Module + pexp->AddressOfNames), functions = (PDWORD)((PBYTE)Module + pexp->AddressOfFunctions); ordinals = (PWORD)((PBYTE)Module + pexp->AddressOfNameOrdinals); //walk for Nt stubs g_cSdtTable = 0; for (i = 0; i < pexp->NumberOfNames; i++) { name = ((CHAR *)Module + names[i]); addr = (PVOID *)((CHAR *)Module + functions[ordinals[i]]); if (*(USHORT*)name == 'tN') { number = *(ULONG*)((UCHAR*)addr + 4); if (number < g_kdctx.KiServiceLimit) { MultiByteToWideChar(CP_ACP, 0, name, (INT)_strlen_a(name), g_SdtTable[g_cSdtTable].Name, MAX_PATH); g_SdtTable[g_cSdtTable].ServiceId = number; g_SdtTable[g_cSdtTable].Address = Dump[number]; g_cSdtTable++; } }//tN }//for HeapFree(GetProcessHeap(), 0, Dump); Dump = NULL; } //list table for (i = 0; i < g_cSdtTable; i++) { //ServiceId RtlSecureZeroMemory(&lvitem, sizeof(lvitem)); lvitem.mask = LVIF_TEXT | LVIF_IMAGE; lvitem.iSubItem = 0; lvitem.iItem = MAXINT; lvitem.iImage = 0; RtlSecureZeroMemory(szBuffer, sizeof(szBuffer)); wsprintf(szBuffer, L"%d", g_SdtTable[i].ServiceId); lvitem.pszText = szBuffer; index = ListView_InsertItem(SdtDlgContext.ListView, &lvitem); //Name lvitem.mask = LVIF_TEXT; lvitem.iSubItem = 1; lvitem.pszText = (LPWSTR)g_SdtTable[i].Name; lvitem.iItem = index; ListView_SetItem(SdtDlgContext.ListView, &lvitem); //Address lvitem.mask = LVIF_TEXT; lvitem.iSubItem = 2; RtlSecureZeroMemory(szBuffer, sizeof(szBuffer)); wsprintf(szBuffer, L"0x%p", (PVOID)g_SdtTable[i].Address); lvitem.pszText = szBuffer; lvitem.iItem = index; ListView_SetItem(SdtDlgContext.ListView, &lvitem); //Module lvitem.mask = LVIF_TEXT; lvitem.iSubItem = 3; RtlSecureZeroMemory(szBuffer, sizeof(szBuffer)); number = supFindModuleEntryByAddress(pModules, (PVOID)g_SdtTable[i].Address); if (number == (ULONG)-1) { _strcpy(szBuffer, TEXT("Unknown Module")); } else { MultiByteToWideChar(CP_ACP, 0, (LPCSTR)&pModules->Modules[number].FullPathName, (INT)_strlen_a((char*)pModules->Modules[number].FullPathName), szBuffer, MAX_PATH); } lvitem.pszText = szBuffer; lvitem.iItem = index; ListView_SetItem(SdtDlgContext.ListView, &lvitem); } } while (cond); } __except (exceptFilter(GetExceptionCode(), GetExceptionInformation())) { return; } if (pModules) { HeapFree(GetProcessHeap(), 0, pModules); } if (Dump) { HeapFree(GetProcessHeap(), 0, Dump); } }
//----------------------------------------------------------------------------- // Name: DisplayPlayersInChat() // Desc: Displays the active players in the listview //----------------------------------------------------------------------------- HRESULT DisplayPlayersInChat( HWND hDlg ) { if( hDlg == NULL ) return S_OK; LVITEM lvItem; HWND hListView = GetDlgItem( hDlg, IDC_PEOPLE_LIST ); TCHAR strStatus[32]; TCHAR strNumberPlayers[32]; DWORD dwNumPlayers = 0; // Remove all the players and re-add them in the player enum callback ListView_DeleteAllItems( hListView ); PLAYER_LOCK(); // enter player context CS APP_PLAYER_INFO* pCurPlayer = g_playerHead.pNext; while ( pCurPlayer != &g_playerHead ) { ZeroMemory( &lvItem, sizeof(lvItem) ); // Add the item, saving the player's name and dpnid in the listview lvItem.mask = LVIF_TEXT | LVIF_PARAM; lvItem.iItem = 0; lvItem.iSubItem = 0; lvItem.pszText = pCurPlayer->strPlayerName; lvItem.lParam = (LONG) pCurPlayer->dpnidPlayer; lvItem.cchTextMax = _tcslen( pCurPlayer->strPlayerName ); int nIndex = ListView_InsertItem( hListView, &lvItem ); if( pCurPlayer->bHalfDuplex ) { _tcscpy( strStatus, TEXT("Can't talk") ); } else { if( g_bMixingSessionType ) { // With mixing servers, you can't tell which // client is talking. _tcscpy( strStatus, TEXT("n/a") ); } else { if( pCurPlayer->bTalking ) _tcscpy( strStatus, TEXT("Talking") ); else _tcscpy( strStatus, TEXT("Silent") ); } } // Start the player's status off as silent. lvItem.mask = LVIF_TEXT; lvItem.iItem = nIndex; lvItem.iSubItem = 1; lvItem.pszText = strStatus; lvItem.cchTextMax = _tcslen( strStatus ); ListView_SetItem( hListView, &lvItem ); dwNumPlayers++; pCurPlayer = pCurPlayer->pNext; } PLAYER_UNLOCK(); // leave player context CS wsprintf( strNumberPlayers, TEXT("%d"), dwNumPlayers ); SetDlgItemText( hDlg, IDC_NUM_PLAYERS, strNumberPlayers ); return S_OK; }
static BOOL CALLBACK JabberGroupchatDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam ) { HWND lv; LVCOLUMN lvCol; LVITEM lvItem; JABBER_LIST_ITEM *item; switch ( msg ) { case WM_INITDIALOG: // lParam is the initial conference server ( if any ) SendMessage( hwndDlg, WM_SETICON, ICON_BIG, ( LPARAM )iconBigList[0] ); TranslateDialogDefault( hwndDlg ); sortColumn = -1; // Add columns lv = GetDlgItem( hwndDlg, IDC_ROOM ); lvCol.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM; lvCol.pszText = TranslateT( "JID" ); lvCol.cx = 210; lvCol.iSubItem = 0; ListView_InsertColumn( lv, 0, &lvCol ); lvCol.pszText = TranslateT( "Name" ); lvCol.cx = 150; lvCol.iSubItem = 1; ListView_InsertColumn( lv, 1, &lvCol ); lvCol.pszText = TranslateT( "Type" ); lvCol.cx = 60; lvCol.iSubItem = 2; ListView_InsertColumn( lv, 2, &lvCol ); if ( jabberOnline ) { if (( TCHAR* )lParam != NULL ) { SetDlgItemText( hwndDlg, IDC_SERVER, ( TCHAR* )lParam ); int iqId = JabberSerialNext(); JabberIqAdd( iqId, IQ_PROC_DISCOROOMSERVER, JabberIqResultDiscoRoomItems ); XmlNodeIq iq( "get", iqId, ( TCHAR* )lParam ); XmlNode* query = iq.addQuery( "http://jabber.org/protocol/disco#items" ); JabberSend( jabberThreadInfo->s, iq ); } else { for ( int i=0; i < GC_SERVER_LIST_SIZE; i++ ) { char text[100]; mir_snprintf( text, sizeof( text ), "GcServerLast%d", i ); DBVARIANT dbv; if ( !JGetStringT( NULL, text, &dbv )) { SendDlgItemMessage( hwndDlg, IDC_SERVER, CB_ADDSTRING, 0, ( LPARAM )dbv.ptszVal ); JFreeVariant( &dbv ); } } } } else EnableWindow( GetDlgItem( hwndDlg, IDC_JOIN ), FALSE ); return TRUE; case WM_JABBER_ACTIVATE: // lParam = server from which agent information is obtained if ( lParam ) SetDlgItemText( hwndDlg, IDC_SERVER, ( TCHAR* )lParam ); ListView_DeleteAllItems( GetDlgItem( hwndDlg, IDC_ROOM )); EnableWindow( GetDlgItem( hwndDlg, IDC_BROWSE ), FALSE ); return TRUE; case WM_JABBER_REFRESH: // lParam = server from which agent information is obtained { int i; TCHAR szBuffer[256]; char text[128]; if ( lParam ){ _tcsncpy( szBuffer, ( TCHAR* )lParam, SIZEOF( szBuffer )); for ( i=0; i<GC_SERVER_LIST_SIZE; i++ ) { mir_snprintf( text, SIZEOF( text ), "GcServerLast%d", i ); DBVARIANT dbv; if ( !JGetStringT( NULL, text, &dbv )) { JSetStringT( NULL, text, szBuffer ); if ( !_tcsicmp( dbv.ptszVal, ( TCHAR* )lParam )) { JFreeVariant( &dbv ); break; } _tcsncpy( szBuffer, dbv.ptszVal, SIZEOF( szBuffer )); JFreeVariant( &dbv ); } else { JSetStringT( NULL, text, szBuffer ); break; } } SendDlgItemMessage( hwndDlg, IDC_SERVER, CB_RESETCONTENT, 0, 0 ); for ( i=0; i<GC_SERVER_LIST_SIZE; i++ ) { mir_snprintf( text, SIZEOF( text ), "GcServerLast%d", i ); DBVARIANT dbv; if ( !JGetStringT( NULL, text, &dbv )) { SendDlgItemMessage( hwndDlg, IDC_SERVER, CB_ADDSTRING, 0, ( LPARAM )dbv.ptszVal ); JFreeVariant( &dbv ); } } SetDlgItemText( hwndDlg, IDC_SERVER, ( TCHAR* )lParam ); } i = 0; lv = GetDlgItem( hwndDlg, IDC_ROOM ); ListView_DeleteAllItems( lv ); LVITEM lvItem; lvItem.iItem = 0; while (( i=JabberListFindNext( LIST_ROOM, i )) >= 0 ) { if (( item=JabberListGetItemPtrFromIndex( i )) != NULL ) { lvItem.mask = LVIF_PARAM | LVIF_TEXT; lvItem.iSubItem = 0; _tcsncpy( szBuffer, item->jid, SIZEOF(szBuffer)); szBuffer[ SIZEOF(szBuffer)-1 ] = 0; lvItem.lParam = ( LPARAM )item->jid; lvItem.pszText = szBuffer; ListView_InsertItem( lv, &lvItem ); lvItem.mask = LVIF_TEXT; lvItem.iSubItem = 1; lvItem.pszText = item->name; ListView_SetItem( lv, &lvItem ); lvItem.iSubItem = 2; lvItem.pszText = item->type; ListView_SetItem( lv, &lvItem ); lvItem.iItem++; } i++; } EnableWindow( GetDlgItem( hwndDlg, IDC_BROWSE ), TRUE ); } return TRUE; case WM_JABBER_CHECK_ONLINE: { TCHAR text[128]; if ( jabberOnline ) { EnableWindow( GetDlgItem( hwndDlg, IDC_JOIN ), TRUE ); GetDlgItemText( hwndDlg, IDC_SERVER, text, SIZEOF( text )); EnableWindow( GetDlgItem( hwndDlg, IDC_BROWSE ), ( text[0]!='\0' )); } else { EnableWindow( GetDlgItem( hwndDlg, IDC_JOIN ), FALSE ); EnableWindow( GetDlgItem( hwndDlg, IDC_BROWSE ), FALSE ); SetDlgItemTextA( hwndDlg, IDC_SERVER, "" ); lv = GetDlgItem( hwndDlg, IDC_ROOM ); ListView_DeleteAllItems( lv ); } break; } case WM_NOTIFY: switch ( wParam ) { case IDC_ROOM: switch (( ( LPNMHDR )lParam )->code ) { case LVN_COLUMNCLICK: { LPNMLISTVIEW pnmlv = ( LPNMLISTVIEW ) lParam; if ( pnmlv->iSubItem>=0 && pnmlv->iSubItem<=1 ) { if ( pnmlv->iSubItem == sortColumn ) sortAscending = !sortAscending; else { sortAscending = TRUE; sortColumn = pnmlv->iSubItem; } ListView_SortItems( GetDlgItem( hwndDlg, IDC_ROOM ), GroupchatCompare, sortColumn ); } } break; } break; } break; case WM_COMMAND: switch ( LOWORD( wParam )) { case WM_JABBER_JOIN: if ( jabberChatDllPresent ) { lv = GetDlgItem( hwndDlg, IDC_ROOM ); if (( lvItem.iItem=ListView_GetNextItem( lv, -1, LVNI_SELECTED )) >= 0 ) { lvItem.iSubItem = 0; lvItem.mask = LVIF_PARAM; ListView_GetItem( lv, &lvItem ); ListView_SetItemState( lv, lvItem.iItem, 0, LVIS_SELECTED ); // Unselect the item DialogBoxParam( hInst, MAKEINTRESOURCE( IDD_GROUPCHAT_JOIN ), hwndDlg, JabberGroupchatJoinDlgProc, ( LPARAM )lvItem.lParam ); } else { TCHAR text[128]; GetDlgItemText( hwndDlg, IDC_SERVER, text, SIZEOF( text )); DialogBoxParam( hInst, MAKEINTRESOURCE( IDD_GROUPCHAT_JOIN ), hwndDlg, JabberGroupchatJoinDlgProc, ( LPARAM )text ); } } else JabberChatDllError(); return TRUE; case WM_JABBER_ADD_TO_ROSTER: lv = GetDlgItem( hwndDlg, IDC_ROOM ); if (( lvItem.iItem=ListView_GetNextItem( lv, -1, LVNI_SELECTED )) >= 0 ) { lvItem.iSubItem = 0; lvItem.mask = LVIF_PARAM; ListView_GetItem( lv, &lvItem ); TCHAR* jid = ( TCHAR* )lvItem.lParam; { GCSESSION gcw = {0}; gcw.cbSize = sizeof(GCSESSION); gcw.iType = GCW_CHATROOM; gcw.pszID = t2a(jid); gcw.pszModule = jabberProtoName; gcw.pszName = NEWSTR_ALLOCA(gcw.pszID); char* p = ( char* )strchr( gcw.pszName, '@' ); if ( p != NULL ) *p = 0; CallService( MS_GC_NEWSESSION, 0, ( LPARAM )&gcw ); mir_free((void*)gcw.pszID); } { XmlNodeIq iq( "set" ); XmlNode* query = iq.addQuery( "jabber:iq:roster" ); XmlNode* item = query->addChild( "item" ); item->addAttr( "jid", jid ); JabberSend( jabberThreadInfo->s, iq ); } { XmlNode p( "presence" ); p.addAttr( "to", jid ); p.addAttr( "type", "subscribe" ); JabberSend( jabberThreadInfo->s, p ); } } break; case WM_JABBER_ADD_TO_BOOKMARKS: lv = GetDlgItem( hwndDlg, IDC_ROOM ); if (( lvItem.iItem=ListView_GetNextItem( lv, -1, LVNI_SELECTED )) >= 0 ) { lvItem.iSubItem = 0; lvItem.mask = LVIF_PARAM; ListView_GetItem( lv, &lvItem ); JABBER_LIST_ITEM* item = JabberListGetItemPtr( LIST_BOOKMARK, ( TCHAR* )lvItem.lParam ); if ( item == NULL ) { item = JabberListGetItemPtr( LIST_ROOM, ( TCHAR* )lvItem.lParam ); if (item != NULL) { item->type = _T("conference"); JabberAddEditBookmark(NULL, (LPARAM) item); } } } break; case IDC_SERVER: { TCHAR text[ 128 ]; GetDlgItemText( hwndDlg, IDC_SERVER, text, SIZEOF( text )); if ( jabberOnline && ( text[0] || HIWORD( wParam )==CBN_SELCHANGE )) EnableWindow( GetDlgItem( hwndDlg, IDC_BROWSE ), TRUE ); break; } case IDC_BROWSE: { TCHAR text[ 128 ]; GetDlgItemText( hwndDlg, IDC_SERVER, text, SIZEOF( text )); if ( jabberOnline && text[0] ) { EnableWindow( GetDlgItem( hwndDlg, IDC_BROWSE ), FALSE ); ListView_DeleteAllItems( GetDlgItem( hwndDlg, IDC_ROOM )); GetDlgItemText( hwndDlg, IDC_SERVER, text, SIZEOF( text )); int iqId = JabberSerialNext(); JabberIqAdd( iqId, IQ_PROC_DISCOROOMSERVER, JabberIqResultDiscoRoomItems ); XmlNodeIq iq( "get", iqId, text ); XmlNode* query = iq.addQuery( "http://jabber.org/protocol/disco#items" ); JabberSend( jabberThreadInfo->s, iq ); } return TRUE; } case IDCLOSE: DestroyWindow( hwndDlg ); return TRUE; } break; case WM_CONTEXTMENU: if (( HWND )wParam == GetDlgItem( hwndDlg, IDC_ROOM )) { HMENU hMenu = CreatePopupMenu(); AppendMenu( hMenu, MF_STRING, WM_JABBER_JOIN, TranslateT( "Join" )); AppendMenu( hMenu, MF_STRING, WM_JABBER_ADD_TO_ROSTER, TranslateT( "Add to roster" )); if ( jabberThreadInfo->caps & CAPS_BOOKMARK ) AppendMenu( hMenu, MF_STRING, WM_JABBER_ADD_TO_BOOKMARKS, TranslateT( "Add to Bookmarks" )); TrackPopupMenu( hMenu, TPM_LEFTALIGN | TPM_NONOTIFY, LOWORD(lParam), HIWORD(lParam), 0, hwndDlg, 0 ); ::DestroyMenu( hMenu ); return TRUE; } break; case WM_CLOSE: DestroyWindow( hwndDlg ); break; case WM_DESTROY: hwndJabberGroupchat = NULL; break; } return FALSE; }
/* ** Updates the list of measures and values. ** */ void CDialogAbout::CTabSkins::UpdateMeasureList(CMeterWindow* meterWindow) { if (!meterWindow) { // Find selected skin HWND item = GetDlgItem(m_Window, IDC_ABOUTSKINS_ITEMS_LISTBOX); int selected = (int)SendMessage(item, LB_GETCURSEL, NULL, NULL); const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows(); std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin(); while (selected && iter != windows.end()) { ++iter; --selected; } m_SkinWindow = (*iter).second; } else if (meterWindow != m_SkinWindow) { // Called by a skin other than currently visible one, so return return; } HWND item = GetDlgItem(m_Window, IDC_ABOUTSKINS_ITEMS_LISTVIEW); SendMessage(item, WM_SETREDRAW, FALSE, 0); int count = ListView_GetItemCount(item); LVITEM lvi; lvi.mask = LVIF_TEXT | LVIF_GROUPID | LVIF_PARAM; lvi.iSubItem = 0; lvi.iItem = 0; lvi.lParam = 0; lvi.iGroupId = 0; const std::list<CMeasure*>& measures = m_SkinWindow->GetMeasures(); std::list<CMeasure*>::const_iterator j = measures.begin(); for ( ; j != measures.end(); ++j) { lvi.pszText = (WCHAR*)(*j)->GetName(); if (lvi.iItem < count) { ListView_SetItem(item, &lvi); } else { ListView_InsertItem(item, &lvi); } WCHAR buffer[256]; CMeasure::GetScaledValue(AUTOSCALE_ON, 1, (*j)->GetMinValue(), buffer, _countof(buffer)); std::wstring range = buffer; range += L" - "; CMeasure::GetScaledValue(AUTOSCALE_ON, 1, (*j)->GetMaxValue(), buffer, _countof(buffer)); range += buffer; ListView_SetItemText(item, lvi.iItem, 1, (WCHAR*)range.c_str()); ListView_SetItemText(item, lvi.iItem, 2, (WCHAR*)(*j)->GetStringValue(AUTOSCALE_OFF, 1, -1, false)); ++lvi.iItem; } lvi.iGroupId = 1; const auto& variables = m_SkinWindow->GetParser().GetVariables(); for (auto iter = variables.cbegin(); iter != variables.cend(); ++iter) { const WCHAR* name = (*iter).first.c_str(); lvi.lParam = (LPARAM)name; if (wcscmp(name, L"@") == 0) { // Ignore reserved variables continue; } std::wstring tmpStr = (*iter).first; wcslwr(&tmpStr[0]); lvi.pszText = (WCHAR*)tmpStr.c_str(); if (lvi.iItem < count) { ListView_SetItem(item, &lvi); } else { ListView_InsertItem(item, &lvi); } ListView_SetItemText(item, lvi.iItem, 1, L""); ListView_SetItemText(item, lvi.iItem, 2, (WCHAR*)(*iter).second.c_str()); ++lvi.iItem; } // Delete unnecessary items while (count > lvi.iItem) { ListView_DeleteItem(item, lvi.iItem); --count; } int selIndex = ListView_GetNextItem(item, -1, LVNI_FOCUSED | LVNI_SELECTED); ListView_SortItems(item, ListSortProc, 0); if (selIndex != -1) { // Re-select previously selected item ListView_SetItemState(item, selIndex, LVIS_FOCUSED | LVNI_SELECTED, LVIS_FOCUSED | LVNI_SELECTED); } SendMessage(item, WM_SETREDRAW, TRUE, 0); }
INT_PTR CALLBACK DlgPluginOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); timerID = 0; { HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); mir_subclassWindow(hwndList, PluginListWndProc); HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 4, 0); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_UNICODE); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_ANSI); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_LOADED); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_NOTLOADED); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_LOADEDGRAY); ImageList_AddIcon_IconLibLoaded(hIml, SKINICON_OTHER_NOTLOADEDGRAY); ListView_SetImageList(hwndList, hIml, LVSIL_SMALL); LVCOLUMN col; col.mask = LVCF_TEXT | LVCF_WIDTH; col.pszText = _T(""); col.cx = 40; ListView_InsertColumn(hwndList, 0, &col); col.pszText = TranslateT("Plugin"); col.cx = 180; ListView_InsertColumn(hwndList, 1, &col); col.pszText = TranslateT("Name"); col.cx = 180;//max = 220; ListView_InsertColumn(hwndList, 2, &col); col.pszText = TranslateT("Version"); col.cx = 75; ListView_InsertColumn(hwndList, 3, &col); ListView_SetExtendedListViewStyleEx(hwndList, 0, LVS_EX_SUBITEMIMAGES | LVS_EX_CHECKBOXES | LVS_EX_LABELTIP | LVS_EX_FULLROWSELECT); // scan the plugin dir for plugins, cos arPluginList.destroy(); szFilter.Empty(); enumPlugins(dialogListPlugins, (WPARAM)hwndDlg, (LPARAM)hwndList); // sort out the headers ListView_SetColumnWidth(hwndList, 1, LVSCW_AUTOSIZE); // dll name int w = ListView_GetColumnWidth(hwndList, 1); if (w > 110) { ListView_SetColumnWidth(hwndList, 1, w = 110); } int max = w < 110 ? 189 + 110 - w : 189; ListView_SetColumnWidth(hwndList, 3, LVSCW_AUTOSIZE); // short name w = ListView_GetColumnWidth(hwndList, 2); if (w > max) ListView_SetColumnWidth(hwndList, 2, max); ListView_SortItems(hwndList, SortPlugins, (LPARAM)hwndDlg); } return TRUE; case WM_NOTIFY: if (lParam) { NMLISTVIEW *hdr = (NMLISTVIEW *)lParam; if (hdr->hdr.code == LVN_ITEMCHANGED && IsWindowVisible(hdr->hdr.hwndFrom)) { if (hdr->uOldState != 0 && (hdr->uNewState == 0x1000 || hdr->uNewState == 0x2000)) { HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); LVITEM it; it.mask = LVIF_PARAM | LVIF_STATE; it.iItem = hdr->iItem; if (!ListView_GetItem(hwndList, &it)) break; PluginListItemData *dat = (PluginListItemData*)it.lParam; if (dat->flags & STATIC_PLUGIN) { ListView_SetItemState(hwndList, hdr->iItem, 0x3000, LVIS_STATEIMAGEMASK); return FALSE; } // find all another standard plugins by mask and disable them if ((hdr->uNewState == 0x2000) && dat->stdPlugin != 0) { for (int iRow = 0; iRow != -1; iRow = ListView_GetNextItem(hwndList, iRow, LVNI_ALL)) { if (iRow != hdr->iItem) { // skip the plugin we're standing on LVITEM dt; dt.mask = LVIF_PARAM; dt.iItem = iRow; if (ListView_GetItem(hwndList, &dt)) { PluginListItemData *dat2 = (PluginListItemData*)dt.lParam; if (dat2->stdPlugin & dat->stdPlugin) {// mask differs // the lParam is unset, so when the check is unset the clist block doesnt trigger int iSave = dat2->stdPlugin; dat2->stdPlugin = 0; ListView_SetItemState(hwndList, iRow, 0x1000, LVIS_STATEIMAGEMASK); dat2->stdPlugin = iSave; } } } } } if (bOldMode) ShowWindow(GetDlgItem(hwndDlg, IDC_RESTART), TRUE); // this here only in "ghazan mode" SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); break; } if (hdr->iItem != -1) { int sel = hdr->uNewState & LVIS_SELECTED; HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); LVITEM lvi = { 0 }; lvi.mask = LVIF_PARAM; lvi.iItem = hdr->iItem; if (ListView_GetItem(hwndList, &lvi)) { PluginListItemData *dat = (PluginListItemData*)lvi.lParam; TCHAR buf[1024]; ListView_GetItemText(hwndList, hdr->iItem, 2, buf, _countof(buf)); SetDlgItemText(hwndDlg, IDC_PLUGININFOFRAME, sel ? buf : _T("")); ptrT tszAuthor(latin2t(sel ? dat->author : NULL)); SetDlgItemText(hwndDlg, IDC_PLUGINAUTHOR, tszAuthor); ptrT tszEmail(latin2t(sel ? dat->authorEmail : NULL)); SetDlgItemText(hwndDlg, IDC_PLUGINEMAIL, tszEmail); ptrT p(Langpack_PcharToTchar(dat->description)); SetDlgItemText(hwndDlg, IDC_PLUGINLONGINFO, sel ? p : _T("")); ptrT tszCopyright(latin2t(sel ? dat->copyright : NULL)); SetDlgItemText(hwndDlg, IDC_PLUGINCPYR, tszCopyright); ptrT tszUrl(latin2t(sel ? dat->homepage : NULL)); SetDlgItemText(hwndDlg, IDC_PLUGINURL, tszUrl); if (!equalUUID(miid_last, dat->uuid)) { char szUID[128]; uuidToString(dat->uuid, szUID, sizeof(szUID)); SetDlgItemTextA(hwndDlg, IDC_PLUGINPID, sel ? szUID : ""); } else SetDlgItemText(hwndDlg, IDC_PLUGINPID, sel ? TranslateT("<none>") : _T("")); } } } if (hdr->hdr.code == PSN_APPLY) { bool needRestart = false; TCHAR bufRestart[1024]; int bufLen = mir_sntprintf(bufRestart, _T("%s\n"), TranslateT("Miranda NG must be restarted to apply changes for these plugins:")); HWND hwndList = GetDlgItem(hwndDlg, IDC_PLUGLIST); for (int iRow = 0; iRow != -1;) { TCHAR buf[1024]; ListView_GetItemText(hwndList, iRow, 1, buf, _countof(buf)); int iState = ListView_GetItemState(hwndList, iRow, LVIS_STATEIMAGEMASK); SetPluginOnWhiteList(buf, (iState & 0x2000) ? 1 : 0); if (!bOldMode && iState != 0x3000) { LVITEM lvi = { 0 }; lvi.mask = LVIF_IMAGE | LVIF_PARAM; lvi.stateMask = -1; lvi.iItem = iRow; lvi.iSubItem = 0; if (ListView_GetItem(hwndList, &lvi)) { lvi.mask = LVIF_IMAGE; PluginListItemData *dat = (PluginListItemData*)lvi.lParam; if (iState == 0x2000) { // enabling plugin if (lvi.iImage == 3 || lvi.iImage == 5) { if (lvi.iImage == 3 && LoadPluginDynamically(dat)) { lvi.iImage = 2; ListView_SetItem(hwndList, &lvi); } else { bufLen += mir_sntprintf(bufRestart + bufLen, _countof(bufRestart) - bufLen, _T(" - %s\n"), buf); needRestart = true; } } } else { // disabling plugin if (lvi.iImage == 2 || lvi.iImage == 4) { if (lvi.iImage == 2 && UnloadPluginDynamically(dat)) { lvi.iImage = 3; ListView_SetItem(hwndList, &lvi); } else { bufLen += mir_sntprintf(bufRestart + bufLen, _countof(bufRestart) - bufLen, _T(" - %s\n"), buf); needRestart = true; } } } } } iRow = ListView_GetNextItem(hwndList, iRow, LVNI_ALL); } LoadStdPlugins(); ShowWindow(GetDlgItem(hwndDlg, IDC_RESTART), needRestart); if (needRestart) { mir_sntprintf(bufRestart + bufLen, _countof(bufRestart) - bufLen, _T("\n%s"), TranslateT("Do you want to restart it now?")); if (MessageBox(NULL, bufRestart, _T("Miranda NG"), MB_ICONWARNING | MB_YESNO) == IDYES) CallService(MS_SYSTEM_RESTART, 1, 0); } } } break; case WM_COMMAND: if (HIWORD(wParam) == STN_CLICKED) { switch (LOWORD(wParam)) { case IDC_GETMOREPLUGINS: Utils_OpenUrl("http://miranda-ng.org/downloads/"); break; case IDC_PLUGINEMAIL: case IDC_PLUGINURL: char buf[512]; char *p = &buf[7]; mir_strcpy(buf, "mailto:"); if (GetDlgItemTextA(hwndDlg, LOWORD(wParam), p, _countof(buf) - 7)) Utils_OpenUrl(LOWORD(wParam) == IDC_PLUGINEMAIL ? buf : p); break; } } break; case WM_DESTROY: arPluginList.destroy(); RemoveAllItems(GetDlgItem(hwndDlg, IDC_PLUGLIST)); break; } return FALSE; }
static BOOL CALLBACK processTokenListMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { /* hwndDlg must be a child of the help dialog */ switch(msg) { case WM_INITDIALOG: { TOKENREGISTEREX *tr; TCHAR *tszTokenDesc, *tszHelpDesc, *last, *cat, *text; // token list things HWND hList = GetDlgItem(hwndDlg, IDC_TOKENLIST); LVCOLUMN lvCol = { 0 }; lvCol.mask = LVCF_TEXT; lvCol.pszText = TranslateT("Token"); ListView_InsertColumn(hList, 0, &lvCol); lvCol.pszText = TranslateT("Description"); ListView_InsertColumn(hList, 1, &lvCol); HELPDLGDATA *hdd = (HELPDLGDATA *)GetWindowLongPtr(GetParent(hwndDlg), GWLP_USERDATA); int i = -1; do { i += 1; tszHelpDesc = tszTokenDesc = NULL; tr = getTokenRegister(i); if ((tr == NULL) || (tr->tszTokenString == NULL)) continue; else if (hdd != NULL) { if (!_tcscmp(tr->tszTokenString, SUBJECT)) { if (hdd->vhs->flags&VHF_HIDESUBJECTTOKEN) continue; if (hdd->vhs->szSubjectDesc != NULL) tszHelpDesc = mir_a2t(hdd->vhs->szSubjectDesc); } if (!_tcscmp(tr->tszTokenString, MIR_EXTRATEXT)) { if (hdd->vhs->flags & VHF_HIDEEXTRATEXTTOKEN) continue; if (hdd->vhs->szExtraTextDesc != NULL) tszHelpDesc = mir_a2t(hdd->vhs->szExtraTextDesc); } } LVITEM lvItem = { 0 }; lvItem.mask = LVIF_TEXT | LVIF_PARAM; lvItem.iItem = ListView_GetItemCount(hList); lvItem.lParam = (LPARAM)tr; tszTokenDesc = getTokenDescription(tr); if (tszTokenDesc == NULL) continue; lvItem.pszText = tszTokenDesc; ListView_InsertItem(hList, &lvItem); mir_free(tszTokenDesc); lvItem.mask = LVIF_TEXT; if (tszHelpDesc == NULL) tszHelpDesc = getHelpDescription(tr); if (tszHelpDesc == NULL) tszHelpDesc = mir_tstrdup(_T("unknown")); lvItem.iSubItem = 1; lvItem.pszText = TranslateTS(tszHelpDesc); ListView_SetItem(hList, &lvItem); mir_free(tszHelpDesc); } while (tr != NULL); ListView_SetColumnWidth(hList, 0, LVSCW_AUTOSIZE); ListView_SetColumnWidth(hList, 1, LVSCW_AUTOSIZE); ListView_SortItems(hList, compareTokenHelp, 0); last = text = NULL; for (i = 0; i < ListView_GetItemCount(hList); i++) { LVITEM lvItem = { 0 }; lvItem.mask = LVIF_PARAM; lvItem.iItem = i; if (ListView_GetItem(hList, &lvItem) == FALSE) continue; cat = getTokenCategory((TOKENREGISTEREX *)lvItem.lParam); if (cat != NULL) { text = mir_tstrdup(TranslateTS(cat)); mir_free(cat); } else text = NULL; if (text != NULL && (last == NULL || _tcsicmp(last, text))) { lvItem.mask = LVIF_TEXT; lvItem.pszText = text; ListView_InsertItem(hList, &lvItem); if (last != NULL) { mir_free(last); lvItem.iSubItem = 0; lvItem.pszText = _T(""); ListView_InsertItem(hList, &lvItem); } last = text; } else mir_free(text); } mir_free(last); } break; case WM_NOTIFY: if ((((NMHDR*)lParam)->idFrom == IDC_TOKENLIST) && (((NMHDR*)lParam)->code == NM_DBLCLK)) { HWND hwndInputDlg = (HWND)SendMessage(GetParent(hwndDlg), VARM_GETDIALOG, (WPARAM)VHF_INPUT, 0); if (hwndInputDlg == NULL) break; HWND hList = GetDlgItem(hwndDlg, IDC_TOKENLIST); int item = ListView_GetNextItem(hList, -1, LVNI_SELECTED|LVNI_FOCUSED); LVITEM lvItem = { 0 }; lvItem.mask = LVIF_PARAM; lvItem.iItem = item; if (ListView_GetItem(hList, &lvItem) == FALSE) break; TOKENREGISTER *tr = (TOKENREGISTER *)lvItem.lParam; if (tr == NULL) break; size_t len = _tcslen(tr->tszTokenString) + 2; if (len < 0) break; TCHAR *tokenString = (TCHAR*)mir_alloc((len+1)*sizeof(TCHAR)); if (tokenString == NULL) break; memset(tokenString, 0, ((len + 1) * sizeof(TCHAR))); mir_sntprintf(tokenString, len + 1, _T("%c%s%c"), (tr->flags & TRF_FIELD) ? FIELD_CHAR : FUNC_CHAR, tr->tszTokenString, (tr->flags & TRF_FIELD) ? FIELD_CHAR : '('); SendDlgItemMessage(hwndInputDlg, IDC_TESTSTRING, EM_REPLACESEL, TRUE, (LPARAM)tokenString); mir_free(tokenString); SetFocus(GetDlgItem(hwndInputDlg, IDC_TESTSTRING)); } break; } return FALSE; }
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); } } }
INT_PTR CLogger::DlgProc(HWND hDlg,UINT uMsg,WPARAM wParam,LPARAM lParam) { switch (uMsg) { case WM_INITDIALOG: { HWND hwndList=GetDlgItem(hDlg,IDC_LOG_LIST); LVCOLUMN lvc; LVITEM lvi; ListView_SetExtendedListViewStyle(hwndList,LVS_EX_FULLROWSELECT | LVS_EX_LABELTIP); lvc.mask=LVCF_FMT | LVCF_WIDTH | LVCF_TEXT; lvc.fmt=LVCFMT_LEFT; lvc.cx=80; lvc.pszText=TEXT("日時"); ListView_InsertColumn(hwndList,0,&lvc); lvc.pszText=TEXT("内容"); ListView_InsertColumn(hwndList,1,&lvc); lvi.iItem=0; lvi.mask=LVIF_TEXT; m_Lock.Lock(); ListView_SetItemCount(hwndList,(int)m_LogList.size()); for (auto itr=m_LogList.begin();itr!=m_LogList.end();++itr) { const CLogItem *pLogItem=*itr; TCHAR szTime[64]; lvi.iSubItem=0; pLogItem->FormatTime(szTime,lengthof(szTime)); lvi.pszText=szTime; ListView_InsertItem(hwndList,&lvi); lvi.iSubItem=1; lvi.pszText=const_cast<LPTSTR>(pLogItem->GetText()); ListView_SetItem(hwndList,&lvi); lvi.iItem++; } for (int i=0;i<2;i++) ListView_SetColumnWidth(hwndList,i,LVSCW_AUTOSIZE_USEHEADER); if (!m_LogList.empty()) ListView_EnsureVisible(hwndList,(int)m_LogList.size()-1,FALSE); m_Lock.Unlock(); DlgCheckBox_Check(hDlg,IDC_LOG_OUTPUTTOFILE,m_fOutputToFile); } return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_LOG_CLEAR: ListView_DeleteAllItems(GetDlgItem(hDlg,IDC_LOG_LIST)); Clear(); return TRUE; case IDC_LOG_COPY: CopyToClipboard(GetAppClass().GetUICore()->GetMainWindow()); return TRUE; case IDC_LOG_SAVE: { TCHAR szFileName[MAX_PATH]; GetDefaultLogFileName(szFileName); if (!SaveToFile(szFileName,false)) { ::MessageBox(hDlg,TEXT("保存ができません。"),NULL,MB_OK | MB_ICONEXCLAMATION); } else { TCHAR szMessage[MAX_PATH+64]; StdUtil::snprintf(szMessage,lengthof(szMessage), TEXT("ログを \"%s\" に保存しました。"),szFileName); ::MessageBox(hDlg,szMessage,TEXT("ログ保存"),MB_OK | MB_ICONINFORMATION); } } return TRUE; } return TRUE; case WM_NOTIFY: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: { bool fOutput=DlgCheckBox_IsChecked(hDlg,IDC_LOG_OUTPUTTOFILE); if (fOutput!=m_fOutputToFile) { CBlockLock Lock(&m_Lock); if (fOutput && m_LogList.size()>0) { TCHAR szFileName[MAX_PATH]; GetDefaultLogFileName(szFileName); SaveToFile(szFileName,true); } m_fOutputToFile=fOutput; m_fChanged=true; } } return TRUE; } break; } return FALSE; }
static int SetStatusList(HWND hwndDlg) { if (confirmSettings->getCount() == 0) return -1; HWND hList = GetDlgItem(hwndDlg, IDC_STARTUPLIST); TCHAR buf[100]; // create items LVITEM lvItem = { 0 }; lvItem.mask = LVIF_TEXT | LVIF_PARAM; for (int i = 0; i < confirmSettings->getCount(); i++) { lvItem.pszText = (*confirmSettings)[i].tszAccName; if (ListView_GetItemCount(hList) < confirmSettings->getCount()) ListView_InsertItem(hList, &lvItem); int actualStatus; switch ((*confirmSettings)[i].status) { case ID_STATUS_LAST: actualStatus = (*confirmSettings)[i].lastStatus; break; case ID_STATUS_CURRENT: actualStatus = CallProtoService((*confirmSettings)[i].szName, PS_GETSTATUS, 0, 0); break; default: actualStatus = (*confirmSettings)[i].status; } TCHAR* status = pcli->pfnGetStatusModeDescription(actualStatus, 0); switch ((*confirmSettings)[i].status) { case ID_STATUS_LAST: mir_sntprintf(buf, _T("%s (%s)"), TranslateT("<last>"), status); ListView_SetItemText(hList, lvItem.iItem, 1, buf); break; case ID_STATUS_CURRENT: mir_sntprintf(buf, _T("%s (%s)"), TranslateT("<current>"), status); ListView_SetItemText(hList, lvItem.iItem, 1, buf); break; default: ListView_SetItemText(hList, lvItem.iItem, 1, status); } // status message if (!((!((CallProtoService((*confirmSettings)[i].szName, PS_GETCAPS, (WPARAM)PFLAGNUM_1, 0)&PF1_MODEMSGSEND)&~PF1_INDIVMODEMSG)) || (!(CallProtoService((*confirmSettings)[i].szName, PS_GETCAPS, (WPARAM)PFLAGNUM_3, 0)&Proto_Status2Flag(actualStatus))))) { TCHAR *msg = GetDefaultStatusMessage(&(*confirmSettings)[i], actualStatus); if (msg != NULL) { TCHAR* fMsg = variables_parsedup(msg, (*confirmSettings)[i].tszAccName, NULL); ListView_SetItemText(hList, lvItem.iItem, 2, fMsg); mir_free(fMsg); mir_free(msg); } else ListView_SetItemText(hList, lvItem.iItem, 2, TranslateT("<n/a>")); } else ListView_SetItemText(hList, lvItem.iItem, 2, TranslateT("<n/a>")); ListView_SetColumnWidth(hList, 0, LVSCW_AUTOSIZE); ListView_SetColumnWidth(hList, 2, LVSCW_AUTOSIZE); lvItem.lParam = (LPARAM)&(*confirmSettings)[i]; ListView_SetItem(hList, &lvItem); lvItem.iItem++; } // grey out status box EnableWindow(GetDlgItem(hwndDlg, IDC_STATUS), (ListView_GetNextItem(GetDlgItem(hwndDlg, IDC_STARTUPLIST), -1, LVNI_SELECTED) >= 0)); return 0; }
LRESULT CALLBACK FileConnectProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam) { FBIPACKET DL; //mystruct MS; char FileName [100] = ""; int i = 0; int j = 0; int Select = 0; char FilePathA[256] = ""; HMODULE getmodh; //LVBKIMAGE IBBkImg; LV_ITEM item; char Name [50] = ""; char Buffer [512] = ""; RECT rc; WORD FEvent; HANDLE hFile; LPSTR pszFileText; switch(message) { //////////////////////////////////////////////////////////////////////////////// case WM_INITDIALOG: if(InitiliseSocket(hwnd)) { } else { // MessageBox(NULL, "FAIL InitiliseSocket", "InitiliseSocket", MB_OK); }/* getmodh = GetModuleHandle(NULL); GetModuleFileName(getmodh,me,sizeof(me)); */ DLSize = sizeof(FBIPACKET); break; case RATMSG_SOCKET: FEvent=WSAGETSELECTEVENT(lParam); switch(FEvent) { case FD_CLOSE: break; ///////////////////////////////////////////////////////////////////////////////////////////// case FD_ACCEPT: while(FClient[F] != NULL) { F++; } FClient[F]=accept(wParam,(LPSOCKADDR)&ServAdr,&AdrLen); break; ///////////////////////////////////////////////////////////////////////////////////////////// case FD_READ: ZeroMemory(&DL, sizeof(FBIPACKET)); recv(wParam,(char*)&DL,DLSize,0); switch(DL.PacketType) { case PACKET_FILE_MANAGER_FILE_RECV: if(DOWN[DL.ID2] == NULL) { //MessageBox(NULL, "cant find file", "FRecv.Data", MB_OK); break; } fwrite(DL.Data, DL.ID3, 1, DOWN[DL.ID2]); break; case PACKET_FILE_MANAGER_FILE_C: if(DOWN[DL.ID2] == NULL) { MessageBox(NULL, "cant find file", "FRecv.Data", MB_OK); break; } fclose(DOWN[DL.ID2]); break; case PACKET_FILE_MANAGER_FILE_UPDATE_WIN: item.mask=TVIF_TEXT; item.iItem=DL.ID3; item.iSubItem=2; item.pszText=DL.Data; ListView_SetItem(GetDlgItem(File[DL.ID],IDC_TRANSFER),&item); break; case SCREEN_SHOT_OPEN: SCREENDOWN[DL.ID] = fopen(DL.Data, "wb"); SendMessage(GetDlgItem(Screen[DL.ID],IDC_PROGRESS1), PBM_SETRANGE32 , 0, DL.ID2); break; case SCREEN_SHOT_RECV: if(SCREENDOWN[DL.ID] == NULL) { //MessageBox(NULL, "cant find file", "FRecv.Data", MB_OK); break; } fwrite(DL.Data, DL.ID3, 1, SCREENDOWN[DL.ID]); SendMessage(GetDlgItem(Screen[DL.ID],IDC_PROGRESS1), PBM_SETPOS , (WPARAM)DL.ID2, 0); break; case SCREEN_SHOT_CLOSE: fclose(SCREENDOWN[DL.ID]); if(Screen[DL.ID] == NULL) { break; } SendMessage(GetDlgItem(Screen[DL.ID],IDC_PROGRESS1), PBM_SETPOS , (WPARAM)0, 0); GetClientRect(Screen[DL.ID], &rc); ScreenA[DL.ID] = LoadJPEG(DL.Data); SetFocus (Screen[DL.ID]); InvalidateRect (Screen[DL.ID], NULL, FALSE); GetWindowText(GetDlgItem(Screen[DL.ID], IDC_SINGLESHOT), Buffer, 12); if(atoi(Buffer) == 1) { break; } else { GetWindowText(GetDlgItem(Screen[DL.ID], IDC_EDIT1), Buffer, 12); Sleep(atoi(Buffer)); FBISend(Server[DL.ID], "", SendMessage(GetDlgItem(Screen[DL.ID], IDC_SLIDER1), TBM_GETPOS,NULL,NULL), rc.right - 20, rc.bottom - 20, SCREEN_CAPTURE); } DeleteFile(DL.Data); break; case WEBCAM_SHOT_OPEN: WEBDOWN[DL.ID] = fopen(DL.Data, "wb"); SendMessage(GetDlgItem(Web[DL.ID],IDC_PROGRESS1), PBM_SETRANGE32 , 0, DL.ID2); break; case WEBCAM_SHOT_RECV: if(WEBDOWN[DL.ID] == NULL) { //MessageBox(NULL, "cant find file", "FRecv.Data", MB_OK); break; } fwrite(DL.Data, DL.ID3, 1, WEBDOWN[DL.ID]); SendMessage(GetDlgItem(Web[DL.ID],IDC_PROGRESS1), PBM_SETPOS , (WPARAM)DL.ID2, 0); break; case WEBCAM_SHOT_CLOSE: fclose(WEBDOWN[DL.ID]); if(Web[DL.ID] == NULL) { break; } SendMessage(GetDlgItem(Web[DL.ID],IDC_PROGRESS1), PBM_SETPOS , (WPARAM)0, 0); GetClientRect(Web[DL.ID], &rc); WebA[DL.ID] = LoadJPEG(DL.Data); SetFocus (Web[DL.ID]); InvalidateRect (Web[DL.ID], NULL, FALSE); GetWindowText(GetDlgItem(Web[DL.ID], IDC_SINGLESHOT), Buffer, 12); if(atoi(Buffer) == 1) { break; } else { GetWindowText(GetDlgItem(Screen[DL.ID], IDC_EDIT1), Buffer, 12); Sleep(atoi(Buffer)); FBISend(Server[DL.ID], "", 0, rc.right, rc.bottom - 20, WEBCAM_CAPTURE); } GetWindowText(GetDlgItem(Web[DL.ID], IDC_ID), Buffer, 12); Sleep(atoi(Buffer)); DeleteFile(DL.Data); break; case PACKET_KEYLOG_OPEN: Logs[DL.ID] = fopen(DL.Data, "wb"); SendMessage(GetDlgItem(KeyHwnd[DL.ID],IDC_PROGRESSA), PBM_SETRANGE32 , 0, DL.ID2); SendMessage(GetDlgItem(KeyHwnd[DL.ID],IDC_PROGRESSA), PBM_SETPOS , (WPARAM)0, 0); //MessageBox(NULL, "CLIENT OPENED LOGS!", "LOLS", MB_OK); break; case PACKET_KEYLOG_OFFLINE: fclose(Logs[DL.ID]); SendMessage(GetDlgItem(Screen[DL.ID],IDC_PROGRESSA), PBM_SETPOS , (WPARAM)DL.ID2, 0); // Set character formatting and background color SendMessage(GetDlgItem(KeyHwnd[DL.ID],IDC_MAIN_STATUS), SB_SETTEXT, 0, (LPARAM)"Logs Downloaded ."); hFile = CreateFile(DL.Data, GENERIC_READ, FILE_SHARE_READ, NULL,OPEN_EXISTING, 0, NULL); if(hFile != INVALID_HANDLE_VALUE) { DWORD dwFileSize; dwFileSize = GetFileSize(hFile, NULL); if(dwFileSize != 0xFFFFFFFF) { pszFileText = (char *)GlobalAlloc(GPTR, dwFileSize + 1); if(pszFileText != NULL) { DWORD dwRead; if(ReadFile(hFile, pszFileText, dwFileSize, &dwRead, NULL)) { pszFileText[dwFileSize] = 0; // Add null terminator if(SetWindowText(GetDlgItem(KeyHwnd[DL.ID],IDC_OFFLINE), pszFileText)) { } else { // MessageBox(NULL, "It did not work!", "Fail", MB_OK); } } GlobalFree(pszFileText); } } CloseHandle(hFile); } break; case PACKET_KEYLOG_DOWNLOAD: fwrite(DL.Data, DL.ID3, 1, Logs[DL.ID]); SendMessage(GetDlgItem(Screen[DL.ID],IDC_PROGRESSA), PBM_SETPOS , (WPARAM)DL.ID2, 0); //sprintf(Buffer, "%d", Recv.ID2); //MessageBox(NULL, Buffer, "Buffer", MB_OK); break; } break; } break; case WM_COMMAND: Select=LOWORD(wParam); switch(Select) { case IDCANCEL: EndDialog(hwnd,Select); break; } return TRUE; } return 0; }
void * ehzListViewSort(struct OBJ *objCalled,SINT cmd,LONG info,void *ptr) { EH_DISPEXT *psExt=ptr; static SINT HdbMovi=-1; static INT16 iSend; DWORD dwExStyle; SINT iLVIndex; if (fReset) { if (cmd!=WS_START) win_infoarg("Inizializzare EhListView()"); memset(&_arsLv,0,sizeof(EH_LVLIST)*LVMAX); EhListInizialize(); fReset=FALSE; return 0; } if (objCalled==NULL) ehExit("ELV: NULL %d",cmd); // Cerco una cella in LVLIST iLVIndex=LVFind(LV_FINDOBJ,objCalled); if (iLVIndex<0) iLVIndex=LVAlloc(objCalled); switch(cmd) { case WS_INF: return &_arsLv[iLVIndex]; case WS_OPEN: // Creazione objCalled->hWnd=CreateListViewSort(objCalled->nome,sys.EhWinInstance,WindowNow()); //_arsLv[iLVIndex].hWndList=objCalled->hWnd; _arsLv[iLVIndex].hWndList=objCalled->hWnd; _arsLv[iLVIndex].hWndHeader=GetWindow(objCalled->hWnd, GW_CHILD); _arsLv[iLVIndex].fLeftClick=TRUE; _arsLv[iLVIndex].fRightClick=TRUE; _arsLv[iLVIndex].fDoubleClick=FALSE; break; case WS_EXTNOTIFY: switch (info) { case 0: _arsLv[iLVIndex].subListNotify=ptr; break; case 1: _arsLv[iLVIndex].subMessage=ptr; break; case 2: _arsLv[iLVIndex].subHeaderNotify=ptr; break; } break; case WS_SETFLAG: if (!strcmp(ptr,"STYLE")) // Setta lo stile della finestra { DWORD dwStyle; dwStyle=GetWindowLong(objCalled->hWnd, GWL_STYLE); dwStyle|=info; SetWindowLong(objCalled->hWnd, GWL_STYLE, (DWORD) dwStyle); } if (!strcmp(ptr,"!STYLE")) // Setta lo stile della finestra { LONG lStyle; lStyle=GetWindowLong(objCalled->hWnd, GWL_STYLE); lStyle&=~info; SetWindowLong(objCalled->hWnd, GWL_STYLE, lStyle); } if (!strcmp(ptr,"STYLEMASK")) // Setta lo stile della finestra { DWORD dwStyle; dwStyle=GetWindowLong(objCalled->hWnd, GWL_STYLE); //win_infoarg("%08x",~LVS_TYPESTYLEMASK); dwStyle=dwStyle&~LVS_TYPESTYLEMASK|info; SetWindowLong(objCalled->hWnd, GWL_STYLE, (DWORD) dwStyle); } if (!strcmp(ptr,"EXSTYLE")) // Setta lo stile della finestra { dwExStyle=ListView_GetExtendedListViewStyle(objCalled->hWnd); dwExStyle|=info; ListView_SetExtendedListViewStyle(objCalled->hWnd,dwExStyle); } if (!strcmp(ptr,"!EXSTYLE")) // Setta lo stile della finestra { dwExStyle=ListView_GetExtendedListViewStyle(objCalled->hWnd); dwExStyle&=~info; ListView_SetExtendedListViewStyle(objCalled->hWnd,dwExStyle); } if (!strcmp(ptr,"DCLK")) // Setta il Double Click { _arsLv[iLVIndex].fDoubleClick=info; } break; case WS_CLOSE: // Distruzione DestroyWindow(objCalled->hWnd); // _arsLv[iLVIndex].lpObj=NULL; break; case WS_ADD: // Aggiungi una colonna ListView_InsertColumn(objCalled->hWnd, info, (LV_COLUMN *) ptr); break; case WS_LINK: // Aggiunge un Item // if (ListView_SetItem(objCalled->hWnd,(LPLVITEM) ptr)==FALSE) {ListView_InsertItem(objCalled->hWnd,(LPLVITEM) ptr);} break; case WS_DO: // Spostamento / Ridimensionamento MoveWindow(objCalled->hWnd,psExt->px,psExt->py,psExt->lx,psExt->ly,TRUE); break; case WS_DISPLAY: InvalidateRect(objCalled->hWnd,NULL,FALSE); break; } return NULL; }
UINT AlsongLyricLinkDialog::DialogProc(UINT iMessage, WPARAM wParam, LPARAM lParam) { switch(iMessage) { case WM_CLOSE: EndDialog(m_hWnd, 0); return TRUE; case WM_DESTROY: return TRUE; case WM_INITDIALOG: { uSetWindowText(m_hWnd, m_track->get_path()); //set artist, title field service_ptr_t<titleformat_object> to; pfc::string8 artist; pfc::string8 title; static_api_ptr_t<titleformat_compiler>()->compile_safe(to, "%artist%"); m_track->format_title(NULL, artist, to, NULL); static_api_ptr_t<titleformat_compiler>()->compile_safe(to, "%title%"); m_track->format_title(NULL, title, to, NULL); uSetDlgItemText(m_hWnd, IDC_ARTIST, artist.get_ptr()); uSetDlgItemText(m_hWnd, IDC_TITLE, title.get_ptr()); //perform listview initialization. LVCOLUMN lv; lv.mask = LVCF_WIDTH | LVCF_TEXT; lv.cx = 150; lv.pszText = TEXT("아티스트"); ListView_InsertColumn(GetDlgItem(m_hWnd, IDC_LYRICLIST), 0, &lv); lv.pszText = TEXT("제목"); ListView_InsertColumn(GetDlgItem(m_hWnd, IDC_LYRICLIST), 1, &lv); SetWindowLong(GetDlgItem(m_hWnd, IDC_NEXT), GWL_STYLE, GetWindowLong(GetDlgItem(m_hWnd, IDC_NEXT), GWL_STYLE) | WS_DISABLED); //disable next, prev button SetWindowLong(GetDlgItem(m_hWnd, IDC_PREV), GWL_STYLE, GetWindowLong(GetDlgItem(m_hWnd, IDC_NEXT), GWL_STYLE) | WS_DISABLED); } return TRUE; case WM_NOTIFY: { NMHDR *hdr = (NMHDR *)lParam; if(hdr->code == LVN_ITEMCHANGED && hdr->idFrom == IDC_LYRICLIST) { int nSel; NMLISTVIEW *nlv = (NMLISTVIEW *)lParam; nSel = nlv->iItem; LVITEM litem; litem.mask = LVIF_PARAM; litem.iItem = nSel; litem.iSubItem = 0; ListView_GetItem(GetDlgItem(m_hWnd, IDC_LYRICLIST), &litem); Lyric *res = m_searchresult->Get((int)litem.lParam); std::string lyric = res->GetRawLyric(); boost::replace_all(lyric, "<br>", "\r\n"); uSetDlgItemText(m_hWnd, IDC_LYRIC, lyric.c_str()); } } return TRUE; case WM_COMMAND: if(HIWORD(wParam) == BN_CLICKED) { switch(LOWORD(wParam)) { case IDC_SEARCH: { pfc::string8 artist; uGetDlgItemText(m_hWnd, IDC_ARTIST, artist); pfc::string8 title; uGetDlgItemText(m_hWnd, IDC_TITLE, title); if(artist.get_length() == 0) { MessageBox(m_hWnd, TEXT("아티스트를 입력해 주세요"), TEXT("에러"), MB_OK); return TRUE; } if(title.get_length() == 0) { MessageBox(m_hWnd, TEXT("제목을 입력해 주세요"), TEXT("에러"), MB_OK); return TRUE; } m_page = 0; m_lyriccount = LyricSourceAlsong().SearchLyricGetCount(artist.toString(), title.toString()); std::stringstream str; str << m_page * 100 + 1 << "~" << min(m_lyriccount, (m_page + 1) * 100) << "/" << m_lyriccount; uSetDlgItemText(m_hWnd, IDC_STATUS, str.str().c_str()); LVITEM item; HWND hListView = GetDlgItem(m_hWnd, IDC_LYRICLIST); item.mask = LVIF_TEXT; item.iItem = 0; item.iSubItem = 0; item.pszText = L""; ListView_InsertItem(hListView, &item); item.iSubItem = 1; item.mask = LVIF_TEXT; item.pszText = L"잠시 기다려 주세요"; ListView_SetItem(hListView, &item); m_searchresult = LyricSourceAlsong().SearchLyric(artist.toString(), title.toString(), 0); PopulateListView(); SetWindowLong(GetDlgItem(m_hWnd, IDC_PREV), GWL_STYLE, GetWindowLong(GetDlgItem(m_hWnd, IDC_PREV), GWL_STYLE) | WS_DISABLED); if(m_lyriccount > 100) SetWindowLong(GetDlgItem(m_hWnd, IDC_NEXT), GWL_STYLE, GetWindowLong(GetDlgItem(m_hWnd, IDC_NEXT), GWL_STYLE) & ~WS_DISABLED); else SetWindowLong(GetDlgItem(m_hWnd, IDC_NEXT), GWL_STYLE, GetWindowLong(GetDlgItem(m_hWnd, IDC_NEXT), GWL_STYLE) | WS_DISABLED); } break; case IDC_RESET: SetDlgItemText(m_hWnd, IDC_ARTIST, TEXT("")); SetDlgItemText(m_hWnd, IDC_TITLE, TEXT("")); SetDlgItemText(m_hWnd, IDC_STATUS, TEXT("")); ListView_DeleteAllItems(GetDlgItem(m_hWnd, IDC_LYRICLIST)); SetDlgItemText(m_hWnd, IDC_LYRIC, TEXT("")); SetFocus(GetDlgItem(m_hWnd, IDC_ARTIST)); SetWindowLong(GetDlgItem(m_hWnd, IDC_NEXT), GWL_STYLE, GetWindowLong(GetDlgItem(m_hWnd, IDC_NEXT), GWL_STYLE) | WS_DISABLED); SetWindowLong(GetDlgItem(m_hWnd, IDC_PREV), GWL_STYLE, GetWindowLong(GetDlgItem(m_hWnd, IDC_NEXT), GWL_STYLE) | WS_DISABLED); SetWindowLong(GetDlgItem(m_hWnd, IDC_ARTIST), GWL_STYLE, GetWindowLong(GetDlgItem(m_hWnd, IDC_ARTIST), GWL_STYLE) & ~WS_DISABLED); SetWindowLong(GetDlgItem(m_hWnd, IDC_TITLE), GWL_STYLE, GetWindowLong(GetDlgItem(m_hWnd, IDC_ARTIST), GWL_STYLE) & ~WS_DISABLED); //reset; break; case IDC_NEWLYRIC: //something break; case IDC_PREV: { if(m_page == 0) return TRUE; m_page --; pfc::string8 artist; uGetDlgItemText(m_hWnd, IDC_ARTIST, artist); pfc::string8 title; uGetDlgItemText(m_hWnd, IDC_TITLE, title); std::stringstream str; str << m_page * 100 + 1 << "~" << min(m_lyriccount, (m_page + 1) * 100) << "/" << m_lyriccount; uSetDlgItemText(m_hWnd, IDC_STATUS, str.str().c_str()); m_searchresult = LyricSourceAlsong().SearchLyric(artist.toString(), title.toString(), 0); PopulateListView(); if(m_page != 0) SetWindowLong(GetDlgItem(m_hWnd, IDC_PREV), GWL_STYLE, GetWindowLong(GetDlgItem(m_hWnd, IDC_PREV), GWL_STYLE) & ~WS_DISABLED); else SetWindowLong(GetDlgItem(m_hWnd, IDC_PREV), GWL_STYLE, GetWindowLong(GetDlgItem(m_hWnd, IDC_PREV), GWL_STYLE) | WS_DISABLED); if(m_lyriccount / 100 != m_page) SetWindowLong(GetDlgItem(m_hWnd, IDC_NEXT), GWL_STYLE, GetWindowLong(GetDlgItem(m_hWnd, IDC_NEXT), GWL_STYLE) & ~WS_DISABLED); else SetWindowLong(GetDlgItem(m_hWnd, IDC_NEXT), GWL_STYLE, GetWindowLong(GetDlgItem(m_hWnd, IDC_NEXT), GWL_STYLE) | WS_DISABLED); } break; case IDC_NEXT: { if(m_page == m_lyriccount / 100) return TRUE; m_page ++; pfc::string8 artist; uGetDlgItemText(m_hWnd, IDC_ARTIST, artist); pfc::string8 title; uGetDlgItemText(m_hWnd, IDC_TITLE, title); std::stringstream str; str << m_page * 100 + 1 << "~" << min(m_lyriccount, (m_page + 1) * 100) << "/" << m_lyriccount; uSetDlgItemText(m_hWnd, IDC_STATUS, str.str().c_str()); m_searchresult = LyricSourceAlsong().SearchLyric(artist.toString(), title.toString(), 0); PopulateListView(); if(m_page != 0) SetWindowLong(GetDlgItem(m_hWnd, IDC_PREV), GWL_STYLE, GetWindowLong(GetDlgItem(m_hWnd, IDC_PREV), GWL_STYLE) & ~WS_DISABLED); else SetWindowLong(GetDlgItem(m_hWnd, IDC_PREV), GWL_STYLE, GetWindowLong(GetDlgItem(m_hWnd, IDC_PREV), GWL_STYLE) | WS_DISABLED); if(m_lyriccount / 100 != m_page) SetWindowLong(GetDlgItem(m_hWnd, IDC_NEXT), GWL_STYLE, GetWindowLong(GetDlgItem(m_hWnd, IDC_NEXT), GWL_STYLE) & ~WS_DISABLED); else SetWindowLong(GetDlgItem(m_hWnd, IDC_NEXT), GWL_STYLE, GetWindowLong(GetDlgItem(m_hWnd, IDC_NEXT), GWL_STYLE) | WS_DISABLED); } break; case IDC_SYNCEDIT: break; case IDC_REGISTER: { int nSel; nSel = SendMessage(GetDlgItem(m_hWnd, IDC_LYRICLIST), LVM_GETSELECTIONMARK, 0, 0); LVITEM litem; litem.mask = LVIF_PARAM; litem.iItem = nSel; litem.iSubItem = 0; ListView_GetItem(GetDlgItem(m_hWnd, IDC_LYRICLIST), &litem); if(LyricSourceAlsong().Save(m_track, *m_searchresult->Get(litem.lParam))) { MessageBox(m_hWnd, TEXT("등록 성공"), TEXT("안내"), MB_OK); static_api_ptr_t<play_control> pc; metadb_handle_ptr p_track; pc->get_now_playing(p_track); if(p_track == m_track) LyricManager::Reload(p_track); EndDialog(m_hWnd, 0); return TRUE; } MessageBox(m_hWnd, TEXT("등록 실패"), TEXT("안내"), MB_OK); } break; case IDC_CANCEL: EndDialog(m_hWnd, 0); break; } } return TRUE; } return FALSE; }
/* TODO: This code should be coalesced with the code that adds items as well as the code that finds their icons. ALL changes to an items name/internal properties/icon/overlay icon should go through a central function. */ void CFolderView::RenameItem(int iItemInternal,TCHAR *szNewFileName) { IShellFolder *pShellFolder = NULL; LPITEMIDLIST pidlFull = NULL; LPITEMIDLIST pidlRelative = NULL; SHFILEINFO shfi; LVFINDINFO lvfi; TCHAR szDisplayName[MAX_PATH]; LVITEM lvItem; TCHAR szFullFileName[MAX_PATH]; DWORD_PTR res; HRESULT hr; int iItem; if(iItemInternal == -1) return; StringCchCopy(szFullFileName,MAX_PATH,m_CurDir); PathAppend(szFullFileName,szNewFileName); hr = GetIdlFromParsingName(szFullFileName,&pidlFull); if(SUCCEEDED(hr)) { hr = SHBindToParent(pidlFull,IID_IShellFolder,(void **)&pShellFolder,(LPCITEMIDLIST *)&pidlRelative); if(SUCCEEDED(hr)) { hr = GetDisplayName(szFullFileName,szDisplayName,SHGDN_INFOLDER|SHGDN_FORPARSING); if(SUCCEEDED(hr)) { m_pExtraItemInfo[iItemInternal].pridl = ILClone(pidlRelative); StringCchCopy(m_pExtraItemInfo[iItemInternal].szDisplayName, SIZEOF_ARRAY(m_pExtraItemInfo[iItemInternal].szDisplayName), szDisplayName); /* Need to update internal storage for the item, since it's name has now changed. */ StringCchCopy(m_pwfdFiles[iItemInternal].cFileName, SIZEOF_ARRAY(m_pwfdFiles[iItemInternal].cFileName), szNewFileName); /* The files' type may have changed, so retrieve the files' icon again. */ res = SHGetFileInfo((LPTSTR)pidlFull,0,&shfi, sizeof(SHFILEINFO),SHGFI_PIDL|SHGFI_ICON| SHGFI_OVERLAYINDEX); if(res != 0) { /* Locate the item within the listview. */ lvfi.flags = LVFI_PARAM; lvfi.lParam = iItemInternal; iItem = ListView_FindItem(m_hListView,-1,&lvfi); if(iItem != -1) { lvItem.mask = LVIF_TEXT|LVIF_IMAGE|LVIF_STATE; lvItem.iItem = iItem; lvItem.iSubItem = 0; lvItem.iImage = shfi.iIcon; lvItem.pszText = ProcessItemFileName(iItemInternal); lvItem.stateMask = LVIS_OVERLAYMASK; /* As well as resetting the items icon, we'll also set it's overlay again (the overlay could change, for example, if the file is changed to a shortcut). */ lvItem.state = INDEXTOOVERLAYMASK(shfi.iIcon >> 24); /* Update the item in the listview. */ ListView_SetItem(m_hListView,&lvItem); /* TODO: Does the file need to be filtered out? */ if(IsFileFiltered(iItemInternal)) { RemoveFilteredItem(iItem,iItemInternal); } } DestroyIcon(shfi.hIcon); } } pShellFolder->Release(); }
INT_PTR CALLBACK about_dlg_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg) { case WM_INITDIALOG: { HANDLE hsnap; HWND hw; SetDlgItemText(hwnd, IDC_PRODUCT, TEXT(KH_VERSTR_PRODUCT_1033)); /* retain the original copyright strings */ #ifdef OVERRIDE_COPYRIGHT SetDlgItemText(hwnd, IDC_COPYRIGHT, TEXT(KH_VERSTR_COPYRIGHT_1033)); #endif SetDlgItemText(hwnd, IDC_BUILDINFO, TEXT(KH_VERSTR_BUILDINFO_1033)); hsnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, 0); if (hsnap != INVALID_HANDLE_VALUE) { LVCOLUMN lvc; MODULEENTRY32 mod; RECT r; hw = GetDlgItem(hwnd, IDC_MODULES); #ifdef DEBUG assert(hw != NULL); #endif GetWindowRect(hw, &r); OffsetRect(&r, -r.left, -r.top); ZeroMemory(&lvc, sizeof(lvc)); lvc.mask = LVCF_TEXT | LVCF_WIDTH; lvc.pszText = L"Name"; lvc.cx = r.right / 4; ListView_InsertColumn(hw, 0, &lvc); lvc.pszText = L"Path"; lvc.cx = (r.right * 3) / 4; ListView_InsertColumn(hw, 1, &lvc); ZeroMemory(&mod, sizeof(mod)); mod.dwSize = sizeof(mod); /* done with columns, now for the actual data */ if (!Module32First(hsnap, &mod)) goto _done_with_modules; do { LVITEM lvi; int idx; ZeroMemory(&lvi, sizeof(lvi)); lvi.mask = LVIF_TEXT; lvi.pszText = mod.szModule; idx = ListView_InsertItem(hw, &lvi); lvi.mask = LVIF_TEXT; lvi.iItem = idx; lvi.iSubItem = 1; lvi.pszText = mod.szExePath; ListView_SetItem(hw, &lvi); ZeroMemory(&mod, sizeof(mod)); mod.dwSize = sizeof(mod); } while(Module32Next(hsnap, &mod)); _done_with_modules: CloseHandle(hsnap); } } return FALSE; case WM_DESTROY: return TRUE; case WM_CLOSE: EndDialog(hwnd, 0); return TRUE; case WM_COMMAND: if (wParam == MAKEWPARAM(IDOK, BN_CLICKED)) { EndDialog(hwnd, 0); } return TRUE; } return FALSE; }
LRESULT CALLBACK StackProc(HWND hwnd, UINT iMessage, WPARAM wParam, LPARAM lParam) { LV_ITEM item; LV_COLUMN lvC; RECT r; LPNMHDR nmh; char module[256]; SCOPE *sl; int i, lines; switch (iMessage) { case WM_CTLCOLORSTATIC: return (HBRUSH)(COLOR_WINDOW + 1); case WM_TIMER: KillTimer(hwnd, 100); ListView_SetItemState(hwndLV, curSel, 0, LVIS_SELECTED); break; case WM_NOTIFY: nmh = (LPNMHDR)lParam; if (nmh->code == NM_SETFOCUS) { PostMessage(hwndFrame, WM_REDRAWTOOLBAR, 0, 0); SendMessage(GetParent(hwnd), WM_ACTIVATEME, 0, 0); } else if (nmh->code == LVN_GETDISPINFO) { LV_DISPINFO *p = (LV_DISPINFO *)lParam; SCOPE *x = (SCOPE *)p->item.lParam; char addr[256]; p->item.mask |= LVIF_TEXT | LVIF_DI_SETITEM; p->item.mask &= ~LVIF_STATE; if (p->item.iSubItem == 2) { p->item.pszText = x->name; } else { sprintf(addr,"%8X", x->address); p->item.pszText = addr; } } else if (nmh->code == LVN_ITEMCHANGED) { LPNMLISTVIEW p = (LPNMHDR)lParam; if (p->uChanged & LVIF_STATE) { if (p->uNewState & LVIS_SELECTED) { i = 0; PostMessage(hwnd, WM_USER, p->iItem, 0); SetTimer(hwnd, 100, 400, 0); } } } else if (nmh->code == LVN_KEYDOWN) { switch (((LPNMLVKEYDOWN)lParam)->wVKey) { case 'C': if (GetKeyState(VK_CONTROL) &0x80000000) { CopyText(hwnd); } break; case VK_UP: if (curSel > 0) SendMessage(hwnd, WM_USER, curSel-1, 0); break; case VK_DOWN: if (curSel < ListView_GetItemCount(hwndLV) - 1) SendMessage(hwnd, WM_USER, curSel + 1, 0); break; } } break; case WM_COMMAND: switch(LOWORD(wParam)) { case ID_TBPROCEDURE: if (HIWORD(wParam) == CBN_SELENDOK) { int i = SendMessage(hwndTbProcedure, CB_GETCURSEL, 0 , 0); if (i != CB_ERR) { SendMessage(hwnd, WM_USER, i, 0); } } break; } break; case WM_USER: { memset(&item, 0, sizeof(item)); if (curSel != 0) { item.iItem = curSel; item.iSubItem = 0; item.mask = LVIF_IMAGE; item.iImage = IML_BLANK; ListView_SetItem(hwndLV, &item); } curSel = wParam; if (curSel != 0) { item.iItem = curSel; item.mask = LVIF_IMAGE; item.iImage = IML_CONTINUATION; ListView_SetItem(hwndLV, &item); } sl = StackList; lines = curSel; while (sl && lines) { sl = sl->next; lines--; } if (sl) { if (GetBreakpointLine(sl->address, module, &lines, curSel != 0)) { char *p; static DWINFO x; strcpy(x.dwName, sl->fileName); p = strrchr(module, '\\'); if (p) strcpy(x.dwTitle, p + 1); else strcpy(x.dwTitle, module); x.dwLineNo = sl->lineno; x.logMRU = FALSE; x.newFile = FALSE; SetScope(sl); CreateDrawWindow(&x, TRUE); } } } break; case WM_CREATE: hwndStack = hwnd; GetClientRect(hwnd, &r); hwndLV = CreateWindowEx(0, WC_LISTVIEW, "", LVS_REPORT | LVS_SINGLESEL | WS_CHILD | WS_VISIBLE | WS_BORDER, 0,0,r.right-r.left, r.bottom - r.top, hwnd, 0, hInstance, 0); ListView_SetExtendedListViewStyle(hwndLV, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES); StackFont = CreateFontIndirect(&fontdata); SendMessage(hwndLV, WM_SETFONT, (WPARAM)StackFont, 0); lvC.mask = LVCF_WIDTH | LVCF_SUBITEM ; lvC.cx = 20; lvC.iSubItem = 0; ListView_InsertColumn(hwndLV, 0, &lvC); lvC.mask = LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT; lvC.cx = 80; lvC.iSubItem = 1; lvC.pszText = "Address"; ListView_InsertColumn(hwndLV, 1, &lvC); lvC.mask = LVCF_WIDTH | LVCF_SUBITEM | LVCF_TEXT; lvC.cx = 200; lvC.iSubItem = 2; lvC.pszText = "Location"; ListView_InsertColumn(hwndLV, 2, &lvC); ListView_SetImageList(hwndLV, tagImageList, LVSIL_SMALL); break; case WM_SIZE: r.left = r.top = 0; r.right = LOWORD(lParam); r.bottom = HIWORD(lParam); MoveWindow(hwndLV, r.left, r.top, r.right - r.left, r.bottom - r.top, 1); break; // fall through case WM_RESTACK: SetScope(NULL); ClearStackArea(hwnd); EnableWindow(hwndLV, uState != notDebugging && wParam); EnableWindow(hwndTbProcedure, uState != notDebugging && wParam); if (uState != notDebugging && wParam) { int i = 0; char buf[256]; SCOPE *list; SetStackArea(hwnd); list = StackList; ListView_DeleteAllItems(hwndLV); memset(&item, 0, sizeof(item)); SendMessage(hwndTbProcedure, CB_RESETCONTENT, 0, 0); while (list) { item.iItem = i; item.iSubItem = 0; item.mask = LVIF_IMAGE | LVIF_PARAM; if (i == 0) { if (activeThread == stoppedThread) item.iImage = IML_STOPBP; else item.iImage = IML_STOP; if (i == curSel) SetScope(list); } else if (i == curSel) { item.iImage = IML_CONTINUATION; SetScope(list); } else { item.iImage = IML_BLANK; } item.lParam = (LPARAM)list; ListView_InsertItem(hwndLV, &item); item.iSubItem = 1; item.mask = LVIF_PARAM | LVIF_TEXT; item.lParam = (LPARAM)list; item.pszText = ""; ListView_InsertItem(hwndLV, &item); i++; sprintf(buf, "%08x %s", list->address, list->name); SendMessage(hwndTbProcedure, CB_ADDSTRING, 0, (LPARAM)buf); list = list->next; } SendMessage(hwndTbProcedure, CB_SETCURSEL, curSel, 0); } break; case WM_DESTROY: ClearStackArea(hwnd); hwndStack = 0; DeleteObject(StackFont); break; case WM_SETFOCUS: SendMessage(GetParent(hwnd), WM_ACTIVATEME, 0, 0); break; case WM_KILLFOCUS: break; } return DefWindowProc(hwnd, iMessage, wParam, lParam); }
void ShortcutMapper::populateShortCuts() { TCHAR filter1[40]={0},filter2[40]={0}; NppParameters *nppParam = NppParameters::getInstance(); size_t nrItems = 0; switch(_currentState) { case STATE_MENU: { nrItems = nppParam->getUserShortcuts().size(); break; } case STATE_MACRO: { nrItems = nppParam->getMacroList().size(); break; } case STATE_USER: { nrItems = nppParam->getUserCommandList().size(); break; } case STATE_PLUGIN: { nrItems = nppParam->getPluginCommandList().size(); break; } case STATE_SCINTILLA: { nrItems = nppParam->getScintillaKeyList().size(); break; } } ListView_DeleteAllItems(hlistview); if(nrItems==0){ ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), false); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DISABLE), false); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), false); return; } else ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DISABLE), true); switch(_currentState) { case STATE_MENU: { ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), true); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), false); break; } case STATE_MACRO: { bool shouldBeEnabled = nrItems > 0; ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), shouldBeEnabled); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), shouldBeEnabled); break; } case STATE_USER: { bool shouldBeEnabled = nrItems > 0; ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), shouldBeEnabled); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), shouldBeEnabled); break; } case STATE_PLUGIN: { bool shouldBeEnabled = nrItems > 0; ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), shouldBeEnabled); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), false); break; } case STATE_SCINTILLA: { ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), true); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), false); break; } } int index=0; int widths[3]; widths[0]=gettextwidth(hlistview,L"Index"); widths[1]=gettextwidth(hlistview,L"Name"); widths[2]=gettextwidth(hlistview,L"Shortcut"); GetWindowText(GetDlgItem(_hSelf,IDC_SHORTCUT_FILTER1),filter1,sizeof(filter2)/sizeof(TCHAR)); GetWindowText(GetDlgItem(_hSelf,IDC_SHORTCUT_FILTER2),filter2,sizeof(filter2)/sizeof(TCHAR)); _tcslwr(filter1); _tcslwr(filter2); for(size_t i = 0; i < nrItems; i++) { TCHAR keys[40]={0}; const TCHAR *name=GetShortcutName(_currentState,i,nppParam); GetShortcutKeys(_currentState,i,nppParam,keys,sizeof(keys)/sizeof(TCHAR)); if((filter1[0]==L'\0' && filter2[0]==L'\0') || (filter1[0]!=L'\0' && CheckFilter(name,filter1)) || (filter2[0]!=L'\0' && CheckFilter(keys,filter2))){ TCHAR str[10]={0}; LV_ITEM lvitem={0}; int w; _sntprintf_s(str,sizeof(str)/sizeof(TCHAR),_TRUNCATE,L"%i",i); w=gettextwidth(hlistview,str); if(w>widths[0]) widths[0]=w; w=gettextwidth(hlistview,name); if(w>widths[1]) widths[1]=w; w=gettextwidth(hlistview,keys); if(w>widths[2]) widths[2]=w; lvitem.mask=LVIF_TEXT|LVIF_PARAM; lvitem.iItem=index; lvitem.pszText=(LPWSTR)str; lvitem.lParam=i; ListView_InsertItem(hlistview,&lvitem); lvitem.mask=LVIF_TEXT; lvitem.iSubItem=1; lvitem.pszText=(LPWSTR)name; ListView_SetItem(hlistview,&lvitem); lvitem.iSubItem=2; lvitem.pszText=(LPWSTR)keys; ListView_SetItem(hlistview,&lvitem); index++; } } ListView_SetColumnWidth(hlistview,0,widths[0]); ListView_SetColumnWidth(hlistview,1,widths[1]); ListView_SetColumnWidth(hlistview,2,widths[2]); ListView_SetItemState(hlistview,0,LVIS_SELECTED,LVIS_SELECTED); if(index==0){ ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_MODIFY), false); ::EnableWindow(::GetDlgItem(_hSelf, IDC_SHORTCUT_DELETE), false); } }
static LRESULT CALLBACK PluginListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_CHAR: if (wParam == '\b') { if (szFilter.GetLength() > 0) szFilter.Truncate(szFilter.GetLength() - 1); } else { szFilter.AppendChar(wParam); for (int i = 0; i < arPluginList.getCount(); i++) { PluginListItemData *p = arPluginList[i]; if (!_tcsnicmp(szFilter, p->fileName, szFilter.GetLength())) { LVFINDINFO lvfi; lvfi.flags = LVFI_PARAM; lvfi.lParam = (LPARAM)p; int idx = ListView_FindItem(hwnd, 0, &lvfi); if (idx != -1) { ListView_SetItemState(hwnd, idx, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); ListView_EnsureVisible(hwnd, idx, FALSE); if (timerID != 0) KillTimer(hwnd, timerID); timerID = SetTimer(hwnd, 1, 1500, 0); return TRUE; } } } szFilter.Truncate(szFilter.GetLength() - 1); MessageBeep((UINT)-1); } return TRUE; case WM_TIMER: if (wParam == 1) { KillTimer(hwnd, timerID); timerID = 0; szFilter.Empty(); } break; case WM_LBUTTONDOWN: LVHITTESTINFO hi; hi.pt.x = LOWORD(lParam); hi.pt.y = HIWORD(lParam); ListView_SubItemHitTest(hwnd, &hi); // Dynamically load/unload a plugin if ((hi.iSubItem == 0) && (hi.flags & LVHT_ONITEMICON)) { LVITEM lvi = { 0 }; lvi.mask = LVIF_IMAGE | LVIF_PARAM; lvi.stateMask = -1; lvi.iItem = hi.iItem; lvi.iSubItem = 0; if (ListView_GetItem(hwnd, &lvi)) { lvi.mask = LVIF_IMAGE; PluginListItemData *dat = (PluginListItemData*)lvi.lParam; if (lvi.iImage == 3) { // load plugin if (LoadPluginDynamically(dat)) { lvi.iImage = 2; ListView_SetItem(hwnd, &lvi); } } else if (lvi.iImage == 2) { // unload plugin if (UnloadPluginDynamically(dat)) { lvi.iImage = 3; ListView_SetItem(hwnd, &lvi); } } LoadStdPlugins(); } } } return mir_callNextSubclass(hwnd, PluginListWndProc, msg, wParam, lParam); }
DWORD WINAPI ApplicationPageRefreshThread(void *lpParameter) { MSG msg; INT i; BOOL bItemRemoved = FALSE; LV_ITEM item; LPAPPLICATION_PAGE_LIST_ITEM pAPLI = NULL; HIMAGELIST hImageListLarge; HIMAGELIST hImageListSmall; /* If we couldn't create the event then exit the thread */ while (1) { /* Wait for an the event or application close */ if (GetMessage(&msg, NULL, 0, 0) <= 0) return 0; if (msg.message == WM_TIMER) { /* * FIXME: * * Should this be EnumDesktopWindows() instead? */ noApps = TRUE; EnumWindows(EnumWindowsProc, 0); if (noApps) { (void)ListView_DeleteAllItems(hApplicationPageListCtrl); bApplicationPageSelectionMade = FALSE; } /* Get the image lists */ hImageListLarge = ListView_GetImageList(hApplicationPageListCtrl, LVSIL_NORMAL); hImageListSmall = ListView_GetImageList(hApplicationPageListCtrl, LVSIL_SMALL); /* Check to see if we need to remove any items from the list */ for (i=ListView_GetItemCount(hApplicationPageListCtrl)-1; i>=0; i--) { memset(&item, 0, sizeof(LV_ITEM)); item.mask = LVIF_IMAGE|LVIF_PARAM; item.iItem = i; (void)ListView_GetItem(hApplicationPageListCtrl, &item); pAPLI = (LPAPPLICATION_PAGE_LIST_ITEM)item.lParam; if (!IsWindow(pAPLI->hWnd)|| (wcslen(pAPLI->szTitle) <= 0) || !IsWindowVisible(pAPLI->hWnd) || (GetParent(pAPLI->hWnd) != NULL) || (GetWindow(pAPLI->hWnd, GW_OWNER) != NULL) || (GetWindowLongPtr(pAPLI->hWnd, GWL_EXSTYLE) & WS_EX_TOOLWINDOW)) { ImageList_Remove(hImageListLarge, item.iItem); ImageList_Remove(hImageListSmall, item.iItem); (void)ListView_DeleteItem(hApplicationPageListCtrl, item.iItem); HeapFree(GetProcessHeap(), 0, pAPLI); bItemRemoved = TRUE; } } /* * If an item was removed from the list then * we need to resync all the items with the * image list */ if (bItemRemoved) { for (i=0; i<ListView_GetItemCount(hApplicationPageListCtrl); i++) { memset(&item, 0, sizeof(LV_ITEM)); item.mask = LVIF_IMAGE; item.iItem = i; item.iImage = i; (void)ListView_SetItem(hApplicationPageListCtrl, &item); } bItemRemoved = FALSE; } ApplicationPageUpdate(); } } }
static BOOL dialogListPlugins(WIN32_FIND_DATA *fd, TCHAR *path, WPARAM, LPARAM lParam) { TCHAR buf[MAX_PATH]; mir_sntprintf(buf, _T("%s\\Plugins\\%s"), path, fd->cFileName); HINSTANCE hInst = GetModuleHandle(buf); BASIC_PLUGIN_INFO pi; if (checkAPI(buf, &pi, MIRANDA_VERSION_CORE, CHECKAPI_NONE) == 0) return TRUE; PluginListItemData *dat = (PluginListItemData*)mir_alloc(sizeof(PluginListItemData)); dat->hInst = hInst; dat->flags = pi.pluginInfo->flags; dat->stdPlugin = 0; if (pi.Interfaces) { MUUID *piface = pi.Interfaces; for (int i = 0; !equalUUID(miid_last, piface[i]); i++) { int idx = getDefaultPluginIdx(piface[i]); if (idx != -1) { dat->stdPlugin |= (1 << idx); break; } } } CharLower(fd->cFileName); _tcsncpy_s(dat->fileName, fd->cFileName, _TRUNCATE); HWND hwndList = (HWND)lParam; LVITEM it = { 0 }; // column 1: Checkbox + Enable/disabled icons it.mask = LVIF_PARAM | LVIF_IMAGE; it.iImage = (hInst != NULL) ? 2 : 3; bool bNoCheckbox = (dat->flags & STATIC_PLUGIN) != 0; if (bNoCheckbox || hasMuuid(pi, miid_clist) || hasMuuid(pi, miid_protocol)) it.iImage += 2; it.lParam = (LPARAM)dat; int iRow = ListView_InsertItem(hwndList, &it); if (isPluginOnWhiteList(fd->cFileName)) ListView_SetItemState(hwndList, iRow, bNoCheckbox ? 0x3000 : 0x2000, LVIS_STATEIMAGEMASK); if (iRow != -1) { // column 2: Unicode/ANSI icon + filename it.mask = LVIF_IMAGE | LVIF_TEXT; it.iItem = iRow; it.iSubItem = 1; it.iImage = (dat->flags & UNICODE_AWARE) ? 0 : 1; it.pszText = fd->cFileName; ListView_SetItem(hwndList, &it); dat->author = mir_strdup(pi.pluginInfo->author); dat->authorEmail = mir_strdup(pi.pluginInfo->authorEmail); dat->copyright = mir_strdup(pi.pluginInfo->copyright); dat->description = mir_strdup(pi.pluginInfo->description); dat->homepage = mir_strdup(pi.pluginInfo->homepage); if (pi.pluginInfo->cbSize == sizeof(PLUGININFOEX)) dat->uuid = pi.pluginInfo->uuid; else memset(&dat->uuid, 0, sizeof(dat->uuid)); TCHAR *shortNameT = mir_a2t(pi.pluginInfo->shortName); // column 3: plugin short name if (shortNameT) { ListView_SetItemText(hwndList, iRow, 2, shortNameT); mir_free(shortNameT); } // column4: version number DWORD unused, verInfoSize = GetFileVersionInfoSize(buf, &unused); if (verInfoSize != 0) { UINT blockSize; VS_FIXEDFILEINFO *fi; void *pVerInfo = mir_alloc(verInfoSize); GetFileVersionInfo(buf, 0, verInfoSize, pVerInfo); VerQueryValue(pVerInfo, _T("\\"), (LPVOID*)&fi, &blockSize); mir_sntprintf(buf, _T("%d.%d.%d.%d"), HIWORD(fi->dwProductVersionMS), LOWORD(fi->dwProductVersionMS), HIWORD(fi->dwProductVersionLS), LOWORD(fi->dwProductVersionLS)); mir_free(pVerInfo); } else mir_sntprintf(buf, _T("%d.%d.%d.%d"), HIBYTE(HIWORD(pi.pluginInfo->version)), LOBYTE(HIWORD(pi.pluginInfo->version)), HIBYTE(LOWORD(pi.pluginInfo->version)), LOBYTE(LOWORD(pi.pluginInfo->version))); ListView_SetItemText(hwndList, iRow, 3, buf); arPluginList.insert(dat); } else mir_free(dat); FreeLibrary(pi.hInst); return TRUE; }
void CreateListView (HWND hWnd) { HICON hIcon; LV_ITEM item; LV_COLUMN col; TCHAR szBuffer[30]; INT i, iItem; HIMAGELIST hImageList; RECT rc; // // Create an image list to work with. // hImageList=ImageList_Create(16, 16, ILC_MASK, 1, 0); if (hImageList==NULL) { return; } // // Add some icons to it. // hIcon = LoadImage(hInst, MAKEINTRESOURCE(1), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR); ImageList_AddIcon(hImageList, hIcon); DestroyIcon(hIcon); GetClientRect (hWnd, &rc); hLV = CreateWindow (WC_LISTVIEW, NULL, LVS_REPORT | LVS_EDITLABELS| WS_CHILD | WS_VISIBLE | WS_EX_CLIENTEDGE | WS_BORDER, 0, 0, rc.right, rc.bottom, hWnd, (HMENU) 1, hInst, NULL); if (!hLV) { GetLastError(); return; } ListView_SetImageList(hLV, hImageList, LVSIL_SMALL); // // Insert Columns // col.mask = LVCF_FMT | LVCF_TEXT | LVCF_SUBITEM | LVCF_WIDTH; col.fmt = LVCFMT_LEFT; col.cx = rc.right / 3; col.pszText = TEXT("Column 0"); col.iSubItem = 0; ListView_InsertColumn (hLV, 0, &col); col.pszText = TEXT("Column 1"); col.iSubItem = 1; ListView_InsertColumn (hLV, 1, &col); col.pszText = TEXT("Column 2"); col.iSubItem = 2; ListView_InsertColumn (hLV, 2, &col); // // Insert Items // for (i=0; i < 18; i++) { wsprintf (szBuffer, TEXT("Item %d"), i+1); item.mask = LVIF_TEXT | LVIF_IMAGE; item.iItem = i; item.iSubItem = 0; item.pszText = szBuffer; item.cchTextMax = 30; item.iImage = 0; iItem = ListView_InsertItem (hLV, &item); wsprintf (szBuffer, TEXT("SubItem (1,%d)"), iItem+1); item.mask = LVIF_TEXT; item.iItem = iItem; item.iSubItem = 1; item.pszText = szBuffer; ListView_SetItem (hLV, &item); wsprintf (szBuffer, TEXT("SubItem (2,%d)"), iItem+1); item.mask = LVIF_TEXT; item.iItem = iItem; item.iSubItem = 2; item.pszText = szBuffer; ListView_SetItem (hLV, &item); } }
/* * Modifies the attributes of an item currently in the listview. */ void CShellBrowser::ModifyItemInternal(const TCHAR *FileName) { HANDLE hFirstFile; ULARGE_INTEGER ulFileSize; LVITEM lvItem; TCHAR FullFileName[MAX_PATH]; BOOL bFolder; BOOL res; int iItem; int iItemInternal = -1; iItem = LocateFileItemIndex(FileName); /* Although an item may not have been added to the listview yet, it is critical that its' size still be updated if necessary. It is possible (and quite likely) that the file add and modified messages will be sent in the same group, meaning that when the modification message is processed, the item is not in the listview, but it still needs to be updated. Therefore, instead of searching for items solely in the listview, also look through the list of pending file additions. */ if(iItem == -1) { /* The item doesn't exist in the listview. This can happen when a file has been created with a non-zero size, but an item has not yet been inserted into the listview. Search through the list of items waiting to be inserted, so that files the have just been created can be updated without them residing within the listview. */ std::list<AwaitingAdd_t>::iterator itr; for(itr = m_AwaitingAddList.begin();itr!= m_AwaitingAddList.end();itr++) { if(lstrcmp(m_pwfdFiles[itr->iItemInternal].cFileName,FileName) == 0) { iItemInternal = itr->iItemInternal; break; } } } else { /* The item exists in the listview. Determine its internal index from its listview information. */ lvItem.mask = LVIF_PARAM; lvItem.iItem = iItem; lvItem.iSubItem = 0; res = ListView_GetItem(m_hListView,&lvItem); if(res != FALSE) iItemInternal = (int)lvItem.lParam; TCHAR szFullFileName[MAX_PATH]; StringCchCopy(szFullFileName,SIZEOF_ARRAY(szFullFileName),m_CurDir); PathAppend(szFullFileName,FileName); /* When a file is modified, its icon overlay may change. This is the case when modifying a file managed by TortoiseSVN, for example. */ SHFILEINFO shfi; DWORD_PTR dwRes = SHGetFileInfo(szFullFileName,0,&shfi,sizeof(SHFILEINFO),SHGFI_ICON|SHGFI_OVERLAYINDEX); if(dwRes != 0) { lvItem.mask = LVIF_STATE; lvItem.iItem = iItem; lvItem.iSubItem = 0; lvItem.stateMask = LVIS_OVERLAYMASK; lvItem.state = INDEXTOOVERLAYMASK(shfi.iIcon >> 24); ListView_SetItem(m_hListView,&lvItem); DestroyIcon(shfi.hIcon); } }
/* ダイアログデータの設定 */ void CDlgCtrlCode::SetData( void ) { HWND hwndWork; int i, count; long lngStyle; LV_ITEM lvi; /* リスト */ hwndWork = ::GetDlgItem( GetHwnd(), IDC_LIST_CTRLCODE ); ListView_DeleteAllItems( hwndWork ); /* リストを空にする */ /* 行選択 */ lngStyle = ListView_GetExtendedListViewStyle( hwndWork ); lngStyle |= LVS_EX_FULLROWSELECT; ListView_SetExtendedListViewStyle( hwndWork, lngStyle ); /* データ表示 */ TCHAR tmp[10]; count = 0; for( i = 0; i < _countof(p_ctrl_list); i++ ) { if( p_ctrl_list[i].jname == NULL ) continue; // 2011.06.01 nasukoji 元のjnameがNULLのものはそのまま残す if( p_ctrl_list[i].jname ){ // LMP: Added, nasukoji changed p_ctrl_list[i].jname = (LPTSTR)cLabel_jname[i].LoadString(STR_ERR_DLGCTL5 + i); } auto_sprintf( tmp, _T("0x%02X"), p_ctrl_list[i].code ); lvi.mask = LVIF_TEXT | LVIF_PARAM; lvi.pszText = tmp; lvi.iItem = count; lvi.iSubItem = 0; lvi.lParam = 0; ListView_InsertItem( hwndWork, &lvi ); if( p_ctrl_list[i].code <= 0x1f ) auto_sprintf( tmp, _T("^%tc"), _T('@') + p_ctrl_list[i].code ); else if( p_ctrl_list[i].code == 0x7f ) _tcscpy( tmp, _T("^?") ); else _tcscpy( tmp, _T("・") ); lvi.mask = LVIF_TEXT; lvi.iItem = count; lvi.iSubItem = 1; lvi.pszText = tmp; ListView_SetItem( hwndWork, &lvi ); lvi.mask = LVIF_TEXT; lvi.iItem = count; lvi.iSubItem = 2; lvi.pszText = const_cast<TCHAR*>(p_ctrl_list[i].name); ListView_SetItem( hwndWork, &lvi ); lvi.mask = LVIF_TEXT; lvi.iItem = count; lvi.iSubItem = 3; lvi.pszText = const_cast<TCHAR*>(p_ctrl_list[i].jname); ListView_SetItem( hwndWork, &lvi ); count++; } ListView_SetItemState( hwndWork, 0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED ); return; }
LRESULT CVideoMarkup::OnButtonUp( UINT, WPARAM, LPARAM lParam, BOOL&) { POINT p; p.x = LOWORD(lParam); p.y = HIWORD(lParam); if (draggingIcon) { // we just completed an icon drag // End the drag-and-drop process draggingIcon = FALSE; ImageList_DragLeave(m_sampleListView); ImageList_EndDrag(); ImageList_Destroy(hDragImageList); SetCursor(LoadCursor(NULL, IDC_ARROW)); ReleaseCapture(); // Determine the position of the drop point LVHITTESTINFO lvhti; lvhti.pt = p; ClientToScreen(&lvhti.pt); ::ScreenToClient(m_sampleListView, &lvhti.pt); ListView_HitTestEx(m_sampleListView, &lvhti); CRect posRect, negRect, motionRect, rangeRect; ListView_GetGroupRect(m_sampleListView, GROUPID_POSSAMPLES, LVGGR_GROUP, &posRect); ListView_GetGroupRect(m_sampleListView, GROUPID_NEGSAMPLES, LVGGR_GROUP, &negRect); ListView_GetGroupRect(m_sampleListView, GROUPID_MOTIONSAMPLES, LVGGR_GROUP, &motionRect); ListView_GetGroupRect(m_sampleListView, GROUPID_RANGESAMPLES, LVGGR_GROUP, &rangeRect); int newGroupId; if (posRect.PtInRect(lvhti.pt)) newGroupId = GROUPID_POSSAMPLES; else if (negRect.PtInRect(lvhti.pt)) newGroupId = GROUPID_NEGSAMPLES; else if (motionRect.PtInRect(lvhti.pt)) newGroupId = GROUPID_MOTIONSAMPLES; else if (rangeRect.PtInRect(lvhti.pt)) newGroupId = GROUPID_RANGESAMPLES; else newGroupId = GROUPID_TRASH; // update group membership of selected items based on drop location int numSelected = ListView_GetSelectedCount(m_sampleListView); int iSelection = -1; for (int iIndex=0; iIndex<numSelected; iIndex++) { // retrieve the selected item LVITEM lvi; iSelection = ListView_GetNextItem(m_sampleListView, iSelection, LVNI_SELECTED); lvi.mask = LVIF_IMAGE | LVIF_STATE | LVIF_GROUPID; lvi.state = 0; lvi.stateMask = 0; lvi.iItem = iSelection; lvi.iSubItem = 0; ListView_GetItem(m_sampleListView, &lvi); // Get the ID of this selected item UINT sampleId = ListView_MapIndexToID(m_sampleListView, iSelection); // test if this is an allowable group membership change int origGroupId = sampleSet.GetOriginalSampleGroup(sampleId); if (!GroupTransitionIsAllowed(origGroupId, newGroupId)) { // this is not a valid change so we'll move to the next item continue; } // update sample group in training set sampleSet.SetSampleGroup(sampleId, newGroupId); // Update item in list view with new group id lvi.iGroupId = newGroupId; ListView_SetItem(m_sampleListView, &lvi); } m_sampleListView.Invalidate(FALSE); } else if (m_videoLoader.videoLoaded && selectingRegion) { // we just finished drawing a selection ClipCursor(NULL); // restore full cursor movement if (!m_videoRect.PtInRect(p)) { InvalidateRect(&m_videoRect,FALSE); return 0; } selectingRegion = false; Rect selectRect; selectRect.X = (INT) min(selectStart.X, selectCurrent.X); selectRect.Y = (INT) min(selectStart.Y, selectCurrent.Y); selectRect.Width = (INT) abs(selectStart.X - selectCurrent.X); selectRect.Height = (INT) abs(selectStart.Y - selectCurrent.Y); Rect drawBounds(0,0,VIDEO_X,VIDEO_Y); selectRect.Intersect(drawBounds); double scaleX = ((double)m_videoLoader.videoX) / ((double)VIDEO_X); double scaleY = ((double)m_videoLoader.videoY) / ((double)VIDEO_Y); selectRect.X = (INT) (scaleX * selectRect.X); selectRect.Y = (INT) (scaleY * selectRect.Y); selectRect.Width = (INT) (scaleX * selectRect.Width); selectRect.Height = (INT) (scaleY * selectRect.Height); // discard tiny samples since they won't help if ((selectRect.Width > 10) && (selectRect.Height > 10)) { TrainingSample *sample; // if we're in motion mode, the behavior is a little special if (recognizerMode == MOTION_FILTER) { sample = new TrainingSample(m_videoLoader.copyFrame, m_videoLoader.GetMotionHistory(), m_sampleListView, m_hImageList, selectRect, GROUPID_MOTIONSAMPLES); } else { sample = new TrainingSample(m_videoLoader.copyFrame, m_sampleListView, m_hImageList, selectRect, currentGroupId); } sampleSet.AddSample(sample); } InvalidateRect(&m_videoRect, FALSE); } return 0; }
static void write_entries_to_window(HWND window, char *filename){ int num_of_entries, entry, row_num = 0; char numstr[6]; filetype type; LVITEMA row; FILE *fd; struct program_block program; HWND preview = GetDlgItem(window, IDC_PREVIEW); HWND text = GetDlgItem(window, IDC_FILE_TYPE); HWND c64name = GetDlgItem(window, IDC_C64_NAME); fd = fopen(filename, "rb"); if (fd == NULL) return; switch (type = detect_type(fd)) { case not_a_valid_file: EnableWindow(preview, FALSE); EnableWindow(c64name, FALSE); SetWindowTextA(text, ""); SetWindowTextA(c64name, ""); fclose(fd); return; case t64: { char message[1000]; char tape_name[25]; int num_of_used_entries; num_of_entries = get_total_entries(fd); num_of_used_entries = get_used_entries(fd); get_tape_name(tape_name, fd); _snprintf(message, 1000, "T64 file with %u total entr%s, %u used entr%s, name %s", num_of_entries, num_of_entries == 1 ? "y" : "ies", num_of_used_entries, num_of_used_entries == 1 ? "y" : "ies", tape_name); SetWindowTextA(text, message); EnableWindow(preview, num_of_used_entries > 1); } EnableWindow(c64name, FALSE); break; case p00: EnableWindow(preview, FALSE); num_of_entries = 1; SetWindowTextA(text, "P00 file"); EnableWindow(c64name, TRUE); break; case prg: EnableWindow(preview, FALSE); num_of_entries = 1; SetWindowTextA(text, "PRG file"); EnableWindow(c64name, TRUE); break; } for (entry = 1; entry <= num_of_entries; entry++) { if (get_entry(entry, fd, &program)) { row.mask = LVIF_TEXT; row.iItem = row_num++; row.iSubItem = 0; row.pszText = numstr; sprintf(numstr, "%u", entry); ListView_InsertItem(preview, &row); row.iSubItem = 1; row.pszText = program.info.name; ListView_SetItem(preview, &row); row.iSubItem = 2; row.pszText = numstr; sprintf(numstr, "%u", program.info.start); ListView_SetItem(preview, &row); row.iSubItem = 3; sprintf(numstr, "%u", program.info.end); ListView_SetItem(preview, &row); } } if (row_num == 1) { ListView_SetItemState(preview, 0, LVIS_SELECTED, LVIS_SELECTED); SetWindowTextA(c64name, program.info.name); } else { SetWindowTextA(c64name, ""); if (IsWindowEnabled(preview)) ListView_SetItemState(preview, 0, LVIS_FOCUSED, LVIS_FOCUSED); } fclose(fd); }
//============================================================================= // // DirList_IconThread() // // Thread to extract file icons in the background // DWORD WINAPI DirList_IconThread(LPVOID lpParam) { HWND hwnd; LPDLDATA lpdl; LV_ITEM lvi; LPLV_ITEMDATA lplvid; IShellIcon* lpshi; int iItem = 0; int iMaxItem; lpdl = (LPDLDATA)lpParam; ResetEvent(lpdl->hTerminatedThread); // Exit immediately if DirList_Fill() hasn't been called if (!lpdl->lpsf) { SetEvent(lpdl->hTerminatedThread); ExitThread(0); return(0); } hwnd = lpdl->hwnd; iMaxItem = ListView_GetItemCount(hwnd); CoInitialize(NULL); // Get IShellIcon lpdl->lpsf->lpVtbl->QueryInterface(lpdl->lpsf,&IID_IShellIcon,&lpshi); while (iItem < iMaxItem && WaitForSingleObject(lpdl->hExitThread,0) != WAIT_OBJECT_0) { lvi.iItem = iItem; lvi.mask = LVIF_PARAM; if (ListView_GetItem(hwnd,&lvi)) { SHFILEINFO shfi; LPITEMIDLIST pidl; DWORD dwAttributes = SFGAO_LINK | SFGAO_SHARE; lplvid = (LPLV_ITEMDATA)lvi.lParam; lvi.mask = LVIF_IMAGE; if (!lpshi || NOERROR != lpshi->lpVtbl->GetIconOf(lpshi,lplvid->pidl,GIL_FORSHELL,&lvi.iImage)) { pidl = IL_Create(lpdl->pidl,lpdl->cbidl,lplvid->pidl,0); SHGetFileInfo((LPCWSTR)pidl,0,&shfi,sizeof(SHFILEINFO),SHGFI_PIDL | SHGFI_SYSICONINDEX | SHGFI_SMALLICON); CoTaskMemFree(pidl); lvi.iImage = shfi.iIcon; } // It proved necessary to reset the state bits... lvi.stateMask = 0; lvi.state = 0; // Link and Share Overlay lplvid->lpsf->lpVtbl->GetAttributesOf( lplvid->lpsf, 1,&lplvid->pidl, &dwAttributes); if (dwAttributes & SFGAO_LINK) { lvi.mask |= LVIF_STATE; lvi.stateMask |= LVIS_OVERLAYMASK; lvi.state |= INDEXTOOVERLAYMASK(2); } if (dwAttributes & SFGAO_SHARE) { lvi.mask |= LVIF_STATE; lvi.stateMask |= LVIS_OVERLAYMASK; lvi.state |= INDEXTOOVERLAYMASK(1); } // Fade hidden/system files if (!lpdl->bNoFadeHidden) { WIN32_FIND_DATA fd; if (NOERROR == SHGetDataFromIDList(lplvid->lpsf,lplvid->pidl, SHGDFIL_FINDDATA,&fd,sizeof(WIN32_FIND_DATA))) { if ((fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) || (fd.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM)) { lvi.mask |= LVIF_STATE; lvi.stateMask |= LVIS_CUT; lvi.state |= LVIS_CUT; } } } lvi.iSubItem = 0; ListView_SetItem(hwnd,&lvi); } //Sleep(1000); iItem++; } if (lpshi) lpshi->lpVtbl->Release(lpshi); CoUninitialize(); SetEvent(lpdl->hTerminatedThread); ExitThread(0); return(0); }
BOOL InsertItemFromStream(HWND hWndListView, t_stream* pt_stream) { LVITEM lvI; int index=ListView_GetItemCount(hWndListView); TCHAR info[128]; t_ether_packet *pt_eth_hdr = (void *)pt_stream->data; // Initialize LVITEM members that are different for each item. { lvI.iItem = index; lvI.iSubItem = 0; lvI.mask = LVIF_TEXT|LVIF_IMAGE; lvI.pszText = TEXT(" "); lvI.iImage = -1; /* 若不要图片,就设置为-1 */ // Insert items into the list. if (ListView_InsertItem(hWndListView, &lvI) == -1) return FALSE; if (pt_stream->selected) ListView_SetCheckState(hwnd_lv, index, 1); lvI.iItem = index; lvI.iSubItem = 1; lvI.mask = LVIF_TEXT|LVIF_IMAGE; lvI.pszText = TEXT(" "); //lvI.pszText = NULL; lvI.iImage = -1; /* 若不要图片,就设置为-1 */ ListView_SetItem(hWndListView, &lvI); #if 0 lvI.iItem = index; lvI.iSubItem = 2; lvI.mask = LVIF_TEXT|LVIF_IMAGE; lvI.pszText = TEXT(" "); //lvI.pszText = NULL; lvI.iImage = -1; /* 若不要图片,就设置为-1 */ ListView_SetItem(hWndListView, &lvI); #else sprintf(info, "%d", index+1); ListView_SetItemText(hWndListView, index, 2, info); #endif ListView_SetItemText(hWndListView, index, 3, pt_stream->name); get_src_addr(info, pt_eth_hdr); ListView_SetItemText(hWndListView, index, 4, info); get_dst_addr(info, pt_eth_hdr); ListView_SetItemText(hWndListView, index, 5, info); get_proto_name(info, pt_eth_hdr); ListView_SetItemText(hWndListView, index, 6, info); sprintf(info, "%d", pt_stream->len); ListView_SetItemText(hWndListView, index, 7, info); get_pkt_desc_info(info, pt_stream->data, pt_stream->err_flags); ListView_SetItemText(hWndListView, index, 8, info); } return TRUE; }
BOOL CALLBACK ReadMailDialogProc(HWND hDlg, UINT message, UINT wParam, LONG lParam) { static HWND hEdit, hList; static int mail_index; /* Number of currently displayed message, -1 if none */ MailHeader *header; int index, msg_num, count; char str[MAX_HEADERLINE], msg[MAXMAIL]; MINMAXINFO *lpmmi; LV_COLUMN lvcol; LV_ITEM lvitem; LV_HITTESTINFO lvhit; NM_LISTVIEW *nm; switch (message) { case WM_INITDIALOG: CenterWindow(hDlg, cinfo->hMain); hReadMailDlg = hDlg; hEdit = GetDlgItem(hDlg, IDC_MAILEDIT); hList = GetDlgItem(hDlg, IDC_MAILLIST); SendMessage(hDlg, BK_SETDLGFONTS, 0, 0); ListView_SetExtendedListViewStyleEx(hList, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT); /* Store dialog rectangle in case of resize */ GetWindowRect(hDlg, &dlg_rect); // Add column headings lvcol.mask = LVCF_TEXT | LVCF_WIDTH; lvcol.pszText = GetString(hInst, IDS_MHEADER1); lvcol.cx = 25; ListView_InsertColumn(hList, 0, &lvcol); lvcol.pszText = GetString(hInst, IDS_MHEADER2); lvcol.cx = 80; ListView_InsertColumn(hList, 1, &lvcol); lvcol.pszText = GetString(hInst, IDS_MHEADER3); lvcol.cx = 150; ListView_InsertColumn(hList, 2, &lvcol); lvcol.pszText = GetString(hInst, IDS_MHEADER4); lvcol.cx = 135; ListView_InsertColumn(hList, 3, &lvcol); mail_index = -1; SetFocus(hReadMailDlg); MailGetMessageList(); RequestReadMail(); return TRUE; case WM_SIZE: ResizeDialog(hDlg, &dlg_rect, mailread_controls); return TRUE; case WM_GETMINMAXINFO: lpmmi = (MINMAXINFO *) lParam; lpmmi->ptMinTrackSize.x = 200; lpmmi->ptMinTrackSize.y = 300; return 0; case WM_ACTIVATE: if (wParam == 0) *cinfo->hCurrentDlg = NULL; else *cinfo->hCurrentDlg = hDlg; return TRUE; case BK_SETDLGFONTS: SetWindowFont(hEdit, GetFont(FONT_MAIL), TRUE); SetWindowFont(hList, GetFont(FONT_MAIL), TRUE); return TRUE; case BK_SETDLGCOLORS: ListView_SetTextColor(hList, GetColor(COLOR_LISTFGD)); ListView_SetBkColor(hList, GetColor(COLOR_LISTBGD)); InvalidateRect(hDlg, NULL, TRUE); return TRUE; case EN_SETFOCUS: /* By default, whole message becomes selected for some reason */ Edit_SetSel(hEdit, -1, 0); break; case BK_NEWMAIL: /* wParam = message number, lParam = message header string */ msg_num = wParam; header = (MailHeader *) lParam; // Add message to list view sprintf(str, "%d", msg_num); lvitem.mask = LVIF_TEXT | LVIF_PARAM; lvitem.iItem = 0; lvitem.iSubItem = 0; lvitem.pszText = str; lvitem.lParam = msg_num; ListView_InsertItem(hList, &lvitem); // Add subitems lvitem.mask = LVIF_TEXT; lvitem.iSubItem = 1; lvitem.pszText = header->sender; ListView_SetItem(hList, &lvitem); lvitem.iSubItem = 2; lvitem.pszText = header->subject; ListView_SetItem(hList, &lvitem); lvitem.iSubItem = 3; lvitem.pszText = header->date; ListView_SetItem(hList, &lvitem); // Erase message in status area SetDlgItemText(hDlg, IDC_MAILINFO, ""); return TRUE; case BK_NONEWMAIL: SetDlgItemText(hDlg, IDC_MAILINFO, GetString(hInst, IDS_NONEWMAIL)); return TRUE; HANDLE_MSG(hDlg, WM_CTLCOLOREDIT, MailCtlColor); HANDLE_MSG(hDlg, WM_CTLCOLORLISTBOX, MailCtlColor); HANDLE_MSG(hDlg, WM_CTLCOLORSTATIC, MailCtlColor); HANDLE_MSG(hDlg, WM_CTLCOLORDLG, MailCtlColor); HANDLE_MSG(hDlg, WM_INITMENUPOPUP, InitMenuPopupHandler); case WM_CLOSE: SendMessage(hDlg, WM_COMMAND, IDCANCEL, 0); return TRUE; case WM_DESTROY: hReadMailDlg = NULL; if (exiting) PostMessage(cinfo->hMain, BK_MODULEUNLOAD, 0, MODULE_ID); return TRUE; case WM_NOTIFY: if (wParam != IDC_MAILLIST) return TRUE; nm = (NM_LISTVIEW *) lParam; switch (nm->hdr.code) { case NM_CLICK: // If you click on an item, select it--why doesn't control work this way by default? GetCursorPos(&lvhit.pt); ScreenToClient(hList, &lvhit.pt); lvhit.pt.x = 10; index = ListView_HitTest(hList, &lvhit); if (index == -1) break; ListView_SetItemState(hList, index, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED); break; case LVN_ITEMCHANGED: // New item selected; get its message number lvitem.mask = LVIF_STATE | LVIF_PARAM; lvitem.stateMask = LVIS_SELECTED; lvitem.iItem = nm->iItem; lvitem.iSubItem = 0; ListView_GetItem(hList, &lvitem); if (!(lvitem.state & LVIS_SELECTED)) break; msg_num = lvitem.lParam; if (msg_num == mail_index) break; if (MailLoadMessage(msg_num, MAXMAIL, msg) == False) { ClientError(hInst, hReadMailDlg, IDS_CANTLOADMSG); break; } mail_index = msg_num; Edit_SetText(hEdit, msg); break; } return TRUE; case WM_COMMAND: UserDidSomething(); switch(GET_WM_COMMAND_ID(wParam, lParam)) { case IDC_DELETEMSG: if (!ListViewGetCurrentData(hList, &index, &msg_num)) return TRUE; if (MailDeleteMessage(msg_num) == True) { /* Display new current message, if any */ Edit_SetText(hEdit, ""); ListView_DeleteItem(hList, index); count = ListView_GetItemCount(hList); if (count == 0) return TRUE; index = min(index, count - 1); // in case last message deleted ListView_SetItemState(hList, index, LVIS_SELECTED, LVIS_SELECTED); } return TRUE; case IDC_RESCAN: SetDlgItemText(hDlg, IDC_MAILINFO, GetString(hInst, IDS_GETTINGMSGS)); RequestReadMail(); return TRUE; case IDC_SEND: UserSendMail(); return TRUE; case IDC_REPLY: case IDC_REPLYALL: /* Find message number for currently selected message */ if (!ListViewGetCurrentData(hList, &index, &msg_num)) return TRUE; UserMailReply(msg_num, (Bool) (GET_WM_COMMAND_ID(wParam, lParam) == IDC_REPLYALL)); return TRUE; case IDCANCEL: /* Note: This code is also used by the WM_CLOSE message */ MailDeleteMessageList(); DestroyWindow(hDlg); return TRUE; } break; } return FALSE; }
INT_PTR CALLBACK DlgList(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { HWND hwndList = GetDlgItem(hDlg, IDC_LIST_UPDATES); switch (message) { case WM_INITDIALOG: hwndDialog = hDlg; TranslateDialogDefault( hDlg ); oldWndProc = (WNDPROC)SetWindowLongPtr(hwndList, GWLP_WNDPROC, (LONG_PTR)PluginListWndProc); SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIcon("plg_list", 1)); SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIcon("plg_list")); { HIMAGELIST hIml = ImageList_Create(16, 16, ILC_MASK | ILC_COLOR32, 4, 0); ImageList_AddIconFromIconLib(hIml, "info"); ListView_SetImageList(hwndList, hIml, LVSIL_SMALL); OSVERSIONINFO osver = { sizeof(osver) }; if (GetVersionEx(&osver) && osver.dwMajorVersion >= 6) { wchar_t szPath[MAX_PATH]; GetModuleFileName(NULL, szPath, SIZEOF(szPath)); TCHAR *ext = _tcsrchr(szPath, '.'); if (ext != NULL) *ext = '\0'; _tcscat(szPath, _T(".test")); HANDLE hFile = CreateFile(szPath, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) // Running Windows Vista or later (major version >= 6). Button_SetElevationRequiredState(GetDlgItem(hDlg, IDOK), !IsProcessElevated()); else { CloseHandle(hFile); DeleteFile(szPath); } } RECT r; GetClientRect(hwndList, &r); /// LVCOLUMN lvc = {0}; lvc.mask = LVCF_WIDTH | LVCF_TEXT; //lvc.fmt = LVCFMT_LEFT; lvc.pszText = TranslateT("Component Name"); lvc.cx = 220; // width of column in pixels ListView_InsertColumn(hwndList, 0, &lvc); lvc.pszText = L""; lvc.cx = 32 - GetSystemMetrics(SM_CXVSCROLL); // width of column in pixels ListView_InsertColumn(hwndList, 1, &lvc); lvc.pszText = TranslateT("State"); lvc.cx = 100 - GetSystemMetrics(SM_CXVSCROLL); // width of column in pixels ListView_InsertColumn(hwndList, 2, &lvc); /// LVGROUP lvg; lvg.cbSize = sizeof(LVGROUP); lvg.mask = LVGF_HEADER | LVGF_GROUPID; lvg.pszHeader = TranslateT("Plugins"); lvg.iGroupId = 1; ListView_InsertGroup(hwndList, 0, &lvg); lvg.pszHeader = TranslateT("Icons"); lvg.iGroupId = 2; ListView_InsertGroup(hwndList, 0, &lvg); lvg.pszHeader = TranslateT("Other"); lvg.iGroupId = 3; ListView_InsertGroup(hwndList, 0, &lvg); ListView_EnableGroupView(hwndList, TRUE); /// SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES | LVS_EX_CHECKBOXES | LVS_EX_LABELTIP); ListView_DeleteAllItems(hwndList); /// OBJLIST<FILEINFO> &todo = *(OBJLIST<FILEINFO> *)lParam; for (int i = 0; i < todo.getCount(); ++i) { int groupId = 3; LVITEM lvi = {0}; lvi.mask = LVIF_PARAM | LVIF_GROUPID | LVIF_TEXT | LVIF_IMAGE; if (_tcschr(todo[i].tszOldName, L'\\') != NULL) groupId = _tcsstr(todo[i].tszOldName, L"Plugins") != NULL ? 1 : 2; lvi.iItem = i; lvi.lParam = (LPARAM)&todo[i]; lvi.iGroupId = groupId; lvi.iImage = -1; lvi.pszText = todo[i].tszOldName; int iRow = ListView_InsertItem(hwndList, &lvi); if (iRow != -1) { lvi.iItem = iRow; if (groupId == 1) { lvi.mask = LVIF_IMAGE; lvi.iSubItem = 1; lvi.iImage = 0; ListView_SetItem(hwndList, &lvi); } } todo[i].bEnabled = false; } HWND hwOk = GetDlgItem(hDlg, IDOK); EnableWindow(hwOk, false); } // do this after filling list - enables 'ITEMCHANGED' below SetWindowLongPtr(hDlg, GWLP_USERDATA, lParam); Utils_RestoreWindowPosition(hDlg, 0, MODNAME, "ListWindow"); return TRUE; case WM_NOTIFY: if (((LPNMHDR) lParam)->hwndFrom == hwndList) { switch (((LPNMHDR) lParam)->code) { case LVN_ITEMCHANGED: if (GetWindowLongPtr(hDlg, GWLP_USERDATA)) { NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam; LVITEM lvI = {0}; lvI.iItem = nmlv->iItem; lvI.iSubItem = 0; lvI.mask = LVIF_PARAM; ListView_GetItem(hwndList, &lvI); OBJLIST<FILEINFO> &todo = *(OBJLIST<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA); if ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK) { todo[lvI.iItem].bEnabled = ListView_GetCheckState(hwndList, nmlv->iItem); bool enableOk = false; for (int i=0; i < todo.getCount(); ++i) { if (todo[i].bEnabled) { enableOk = true; break; } } HWND hwOk = GetDlgItem(hDlg, IDOK); EnableWindow(hwOk, enableOk ? TRUE : FALSE); } } break; } } break; case WM_COMMAND: if (HIWORD( wParam ) == BN_CLICKED) { switch(LOWORD(wParam)) { case IDOK: EnableWindow( GetDlgItem(hDlg, IDOK), FALSE); EnableWindow( GetDlgItem(hDlg, IDC_SELNONE), FALSE); mir_forkthread(ApplyDownloads, hDlg); return TRUE; case IDC_SELNONE: SelectAll(hDlg, false); break; case IDCANCEL: DestroyWindow(hDlg); return TRUE; } } break; case WM_SIZE: // make the dlg resizeable if (!IsIconic(hDlg)) { UTILRESIZEDIALOG urd = { sizeof(urd) }; urd.hInstance = hInst; urd.hwndDlg = hDlg; urd.lpTemplate = MAKEINTRESOURCEA(IDD_LIST); urd.pfnResizer = ListDlg_Resize; CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM)&urd); } break; case WM_GETMINMAXINFO: { LPMINMAXINFO mmi = (LPMINMAXINFO)lParam; // The minimum width in points mmi->ptMinTrackSize.x = 370; // The minimum height in points mmi->ptMinTrackSize.y = 300; } break; case WM_DESTROY: Utils_SaveWindowPosition(hDlg, NULL, MODNAME, "ListWindow"); Skin_ReleaseIcon((HICON)SendMessage(hDlg, WM_SETICON, ICON_BIG, 0)); Skin_ReleaseIcon((HICON)SendMessage(hDlg, WM_SETICON, ICON_SMALL, 0)); hwndDialog = NULL; delete (OBJLIST<FILEINFO> *)GetWindowLongPtr(hDlg, GWLP_USERDATA); SetWindowLongPtr(hDlg, GWLP_USERDATA, 0); break; } return FALSE; }