MCPcopy Create free account
hub / github.com/ProgerXP/Notepad2e / Encoding_AddToComboboxEx

Function Encoding_AddToComboboxEx

src/Edit.c:808–863  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

806
807
808void Encoding_AddToComboboxEx ( HWND hwnd, int idSel, BOOL bRecodeOnly )
809{
810 int i;
811 int iSelItem = -1;
812 COMBOBOXEXITEM cbei;
813 WCHAR wchBuf[256];
814 PENCODINGENTRY pEE = LocalAlloc ( LPTR, COUNTOF ( mEncoding ) * sizeof ( ENCODINGENTRY ) );
815 for ( i = 0; i < COUNTOF ( mEncoding ); i++ ) {
816 pEE[i].id = i;
817 GetString ( mEncoding[i].idsName, pEE[i].wch, COUNTOF ( pEE[i].wch ) );
818 }
819 qsort ( pEE, COUNTOF ( mEncoding ), sizeof ( ENCODINGENTRY ), CmpEncoding );
820 ZeroMemory ( &cbei, sizeof ( COMBOBOXEXITEM ) );
821 cbei.mask = CBEIF_TEXT | CBEIF_IMAGE | CBEIF_SELECTEDIMAGE | CBEIF_LPARAM;
822 cbei.pszText = wchBuf;
823 cbei.cchTextMax = COUNTOF ( wchBuf );
824 cbei.iImage = 0;
825 cbei.iSelectedImage = 0;
826 for ( i = 0; i < COUNTOF ( mEncoding ); i++ ) {
827 int id = pEE[i].id;
828 if ( !bRecodeOnly || ( mEncoding[id].uFlags & NCP_RECODE ) ) {
829 CPINFO cpi;
830 WCHAR *pwsz;
831 cbei.iItem = SendMessage ( hwnd, CB_GETCOUNT, 0, 0 );
832 if ( pwsz = StrChr ( pEE[i].wch, L';' ) ) {
833 StrCpyN ( wchBuf, CharNext ( pwsz ), COUNTOF ( wchBuf ) );
834 if ( pwsz = StrChr ( wchBuf, L';' ) ) {
835 *pwsz = 0;
836 }
837 } else {
838 StrCpyN ( wchBuf, pEE[i].wch, COUNTOF ( wchBuf ) );
839 }
840 if ( id == CPI_DEFAULT ) {
841 StrCatN ( wchBuf, wchANSI, COUNTOF ( wchBuf ) );
842 } else if ( id == CPI_OEM ) {
843 StrCatN ( wchBuf, wchOEM, COUNTOF ( wchBuf ) );
844 }
845 if ( ( mEncoding[id].uFlags & NCP_INTERNAL ) ||
846 ( IsValidCodePage ( mEncoding[id].uCodePage ) &&
847 GetCPInfo ( mEncoding[id].uCodePage, &cpi ) ) ) {
848 cbei.iImage = 0;
849 } else {
850 cbei.iImage = 1;
851 }
852 cbei.lParam = ( LPARAM ) id;
853 SendMessage ( hwnd, CBEM_INSERTITEM, 0, ( LPARAM ) &cbei );
854 if ( idSel == id ) {
855 iSelItem = ( int ) cbei.iItem;
856 }
857 }
858 }
859 LocalFree ( pEE );
860 if ( iSelItem != -1 ) {
861 SendMessage ( hwnd, CB_SETCURSEL, ( WPARAM ) iSelItem, 0 );
862 }
863}
864
865

Callers 1

SelectDefEncodingDlgProcFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected