Beispiel #1
0
void _draw_combobox(
		LPDRAWITEMSTRUCT itst
	)
{	
	TEXTMETRIC tm; 	

	wchar_t data[MAX_PATH];
	int x,y;

	DWORD txc = COLOR_WINDOWTEXT;
	DWORD bgc = _cl(COLOR_BTNFACE, LGHT_CLR);

	if (itst->itemState & ODS_SELECTED) {
		bgc = _cl(COLOR_BTNSHADOW, DARK_CLR-15);
		txc = COLOR_HIGHLIGHTTEXT;

	}
	if (itst->itemState & ODS_DISABLED) {
		bgc = _cl(COLOR_BTNFACE, FALSE);
		txc = COLOR_GRAYTEXT;

	}
		
	SetTextColor(itst->hDC, GetSysColor(txc));  
	SetBkColor(itst->hDC, bgc);

	GetTextMetrics(itst->hDC, &tm);

	y = (itst->rcItem.bottom + itst->rcItem.top - tm.tmHeight) / 2;
	x = LOWORD(GetDialogBaseUnits( )) / 4;
			
	SendMessage(itst->hwndItem, CB_GETLBTEXT, itst->itemID, (LPARAM)data);				
	ExtTextOut(itst->hDC, 3*x, y, ETO_CLIPPED | ETO_OPAQUE, &itst->rcItem, 
		data, (u32)(wcslen(data)), NULL);

}
INT_PTR CALLBACK
_benchmark_dlg_proc(
		HWND	hwnd,
		UINT	message,
		WPARAM	wparam,
		LPARAM	lparam
	)
{
	switch ( message )
	{
		case WM_CLOSE :
		{
			__lists[HBENCHMARK] = HWND_NULL;

			EndDialog( hwnd, 0 );
			return 0L;
		}
		break;

		case WM_COMMAND :
		{
			int code = HIWORD(wparam);			
			int id = LOWORD(wparam);

			if ( ( id == IDOK ) || ( id == IDCANCEL ) )
			{
				EndDialog( hwnd, 0 );
			}
			if ( id == IDB_REFRESH_TEST )
			{
				HWND h_button = GetDlgItem( hwnd, IDB_REFRESH_TEST );

				SetCursor( __cur_wait );
				EnableWindow( h_button, FALSE );
				{
					bench_item bench[CF_CIPHERS_NUM];

					wchar_t s_speed[50];
					int cnt;

					int lvcount = 0;
					int k = 0;

					cnt  = _benchmark(pv(&bench));
					ListView_DeleteAllItems( __lists[HBENCHMARK] );
						
					for ( k = 0; k < cnt; k++ )
					{
						_list_insert_item( __lists[HBENCHMARK], lvcount, 0, bench[k].alg, 0 );
						_list_set_item( __lists[HBENCHMARK], lvcount, 1, STR_EMPTY );

						_snwprintf( s_speed, sizeof_w(s_speed), L"%-.2f mb/s", bench[k].speed );
						_list_set_item( __lists[HBENCHMARK], lvcount++, 2, s_speed );
					}
				}
				EnableWindow( h_button, TRUE );
				SetCursor( __cur_arrow );
			}
		}
		break;

		case WM_INITDIALOG : 
		{
			__lists[HBENCHMARK] = GetDlgItem( hwnd, IDC_LIST_BENCHMARK );
			_init_list_headers( __lists[HBENCHMARK], _benchmark_headers );

			ListView_SetBkColor( __lists[HBENCHMARK], GetSysColor(COLOR_BTNFACE) );
			ListView_SetTextBkColor( __lists[HBENCHMARK], GetSysColor(COLOR_BTNFACE) );
			ListView_SetExtendedListViewStyle( __lists[HBENCHMARK], LVS_EX_FLATSB | LVS_EX_FULLROWSELECT );

			SetForegroundWindow(hwnd);

			_sub_class(GetDlgItem(hwnd, IDC_BUTTON), SUB_STATIC_PROC, HWND_NULL);
			return 1L;
		}
		break;

		case WM_CTLCOLOREDIT :
		{
			return (
				_ctl_color(wparam, _cl(COLOR_BTNFACE, LGHT_CLR))
			);
		}
		break;

		default:
		{
			int rlt = _draw_proc(message, lparam);
			if (rlt != -1)
			{
				return rlt;
			}
		}
	}
	return 0L;

}
Beispiel #3
0
void _draw_pass_rating(
		HWND     hwnd,
		dc_pass *pass,
		int      kb_layout,
		int     *entropy
	)
{
	int k = 0;
	int idx = -1;

	_pass_inf inf;			
	_check_password(pass, &inf);

	while ( pass_gr_ctls[k].id != -1 )
	{	
		pass_gr_ctls[k].hwnd = GetDlgItem( hwnd, pass_gr_ctls[k].id );
		pass_pe_ctls[k].hwnd = GetDlgItem( hwnd, pass_pe_ctls[k].id );

		pass_gr_ctls[k].color = 		
		pass_pe_ctls[k].color = _cl(COLOR_BTNFACE, 70);

		k++;		
	};

	if ( inf.flags & P_AZ_L  ) pass_gr_ctls[0].color = CL_BLUE;
	if ( inf.flags & P_AZ_H  ) pass_gr_ctls[1].color = CL_BLUE;
	if ( inf.flags & P_09    ) pass_gr_ctls[2].color = CL_BLUE;
	if ( inf.flags & P_SPACE ) pass_gr_ctls[3].color = CL_BLUE;
	if ( inf.flags & P_SPCH  ) pass_gr_ctls[4].color = CL_BLUE;
	if ( inf.flags & P_NCHAR ) pass_gr_ctls[5].color = CL_BLUE;

	if ( kb_layout != -1 )
	{
		pass_gr_ctls[5].color = GetSysColor(COLOR_GRAYTEXT);
		if ( kb_layout != KB_QWERTY )
		{
			pass_gr_ctls[4].color = pass_gr_ctls[5].color;
		}
	}	
	*entropy = (int)inf.entropy;

	if ( inf.entropy > 192 ) idx = 4;
	if ( inf.entropy < 193 ) idx = 3;
	if ( inf.entropy < 129 ) idx = 2;
	if ( inf.entropy < 81  ) idx = 1;
	if ( inf.entropy < 65  ) idx = 0;

	if ( !inf.entropy )
	{
		idx = 5;
	}
	pass_pe_ctls[idx].color = CL_BLUE;

	k = 0;
	while ( pass_gr_ctls[k].id != -1 )
	{						
		if ( pass_gr_ctls[k].hwnd )
		{
			InvalidateRect(pass_gr_ctls[k].hwnd, NULL, TRUE);
		}
		if ( pass_pe_ctls[k].hwnd )
		{
			InvalidateRect(pass_pe_ctls[k].hwnd, NULL, TRUE);
		}
		k++;
	}
}
Beispiel #4
0
void _draw_listview(
		LPDRAWITEMSTRUCT itst
	)
{
	DRAWTEXTPARAMS dtp         = { sizeof(dtp) };
	LVCOLUMN       lvc         = { sizeof(lvc) };
	wchar_t        s_text[200] = { 0 };
	int            cx, cy, k   = 0;
	int            offset      = 0;
	int            icon;
	BOOL           is_root;
	int            col_cnt     = Header_GetItemCount( ListView_GetHeader( itst->hwndItem ) );
	LVITEM         lvitem      = { LVIF_TEXT | LVIF_PARAM, itst->itemID, 0, 0, 0, s_text, countof(s_text) };
	COLORREF       bgcolor     = ListView_GetBkColor( itst->hwndItem );

	ListView_GetItem( itst->hwndItem, &lvitem );
	is_root = _is_root_item( lvitem.lParam );

	{
		void *user_data = wnd_get_long( __lists[HMAIN_DRIVES], GWL_USERDATA );
		if (user_data != NULL)
		{
			MessageBox( __dlg, s_text, NULL, 0 );
		}
	}

	if ( ( itst->itemState & ODS_SELECTED ) && IsWindowEnabled( itst->hwndItem ) /*&& ( lvitem.lParam != NULL )*/ ) 
	{
		if ( GetFocus( ) == itst->hwndItem )
		{
			bgcolor = CL_WHITE;
		} else {
			bgcolor = _cl( COLOR_BTNFACE, 80 );
		}
	}
	if ( is_root ) 
	{
		bgcolor = _cl( COLOR_BTNSHADOW, 60 );
	}
	if ( _is_marked_item(lvitem.lParam) ) 
	{
		bgcolor = _cl( COLOR_BTNSHADOW, 35 );
	}
	
	_fill( itst->hDC, &itst->rcItem, bgcolor );

	for ( ; k < col_cnt; k++ )
	{
		lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_IMAGE;
		ListView_GetColumn( itst->hwndItem, k, &lvc );

		itst->rcItem.left  = k ? itst->rcItem.right : 0;
		itst->rcItem.right = itst->rcItem.left + lvc.cx;

		lvitem.iItem       = itst->itemID; 
		lvitem.iSubItem    = k;

		ListView_GetItem( itst->hwndItem, &lvitem );
		dtp.iLeftMargin = dtp.iRightMargin = 5;		

		if ( (!itst->rcItem.left) && _is_icon_show( itst->hwndItem, k ) )
		{
			ImageList_GetIconSize( __dsk_img, &cx, &cy );
			offset = lvitem.lParam && !is_root ? 25 : 3;

			itst->rcItem.left += offset + cy + ( lvitem.lParam && !is_root ? 8 : 4 );
			icon = 0;

			if (! is_root ) 
			{
				if ( _is_splited_item(lvitem.lParam) ) icon = 1;
				if ( _is_cdrom_item(lvitem.lParam) )   icon = 2;
			}

			ImageList_Draw(
				__dsk_img, icon, itst->hDC, offset, itst->rcItem.top + 3, ILD_TRANSPARENT
				);
		} else 
		{
			offset = 0;
		}
		if ( offset && is_root )
		{
			DrawState(
				itst->hDC, 0, NULL, (LPARAM)s_text, 0, 
				itst->rcItem.left+5, itst->rcItem.top, 0, 0, DST_PREFIXTEXT | DSS_MONO
				);
		} else 
		{
			if ( wcslen(s_text) != 0 ) 
			{
				COLORREF text_color = GetSysColor( COLOR_WINDOWTEXT );

				if ( !_is_active_item(lvitem.lParam) )
				{
					text_color = GetSysColor( COLOR_GRAYTEXT );
				}
				SetTextColor( itst->hDC, text_color );

				if ( k >= 4 )
				{
					SelectObject( itst->hDC, __font_bold );
				}
				if ( !IsWindowEnabled( itst->hwndItem ) )
				{
					SetTextColor( itst->hDC, GetSysColor(COLOR_GRAYTEXT) );

					DrawTextEx(
						itst->hDC, s_text, -1, &itst->rcItem,
						DT_END_ELLIPSIS | ((lvc.fmt & LVCFMT_RIGHT) ? DT_RIGHT : FALSE), &dtp
						);
				} else 
				{
					DrawTextEx(
						itst->hDC, s_text, -1, &itst->rcItem,
						DT_END_ELLIPSIS | ((lvc.fmt & LVCFMT_RIGHT) ? DT_RIGHT : FALSE), &dtp
						);
					/*
					if ( GetFocus( ) == itst->hwndItem )
					{
						DrawFocusRect( itst->hDC, &itst->rcItem );
					}
					*/
				}
			}
		}
	}							
}
Beispiel #5
0
void _draw_static(
		LPDRAWITEMSTRUCT itst
	)
{
	UINT edge   = BDR_RAISEDINNER;
	UINT state  = DSS_NORMAL;
	UINT border = BF_RECT;

	DRAWTEXTPARAMS tp = { sizeof(tp) };
	WINDOWINFO wi;
	RECT rc;

	_wnd_data *gwl;
	_tab_data *tab;

	wchar_t data[MAX_PATH];
	int x = 6, y = 3;
	char curr;	

	if ( !itst ) return;
	switch ( itst->CtlType )
	{
		case ODT_LISTVIEW: _draw_listview(itst); break;
		case ODT_COMBOBOX: _draw_combobox(itst); break;
		case ODT_TAB:      _draw_tabs(itst);     break;

		case ODT_BUTTON:

        if ( itst->itemState & ODS_DISABLED ) state = DSS_DISABLED;
        if ( itst->itemState & ODS_SELECTED )
		{
			edge = BDR_SUNKENOUTER;
			x++; y++;
        }
		itst->rcItem.top++;

		GetWindowText( itst->hwndItem, data, MAX_PATH );
		GetClientRect( itst->hwndItem, &rc );

		gwl = wnd_get_long( itst->hwndItem, GWL_USERDATA );
		tab = wnd_get_long( GetParent(itst->hwndItem), GWL_USERDATA );

		curr = tab && ( tab->h_curr == itst->hwndItem );

		if ( gwl )
		{
			if ( !gwl->dlg[0] )
			{
				itst->rcItem.right  = itst->rcItem.left + 13;
				itst->rcItem.bottom = itst->rcItem.top  + 13;

				_fill( itst->hDC, &rc, _cl(COLOR_BTNFACE, FALSE) );
				_fill( itst->hDC, &itst->rcItem, /* (itst->itemState & ODS_FOCUS) ? _cl(COLOR_BTNFACE, FALSE) : */ _cl(COLOR_BTNFACE, LGHT_CLR) );

				GetWindowText(itst->hwndItem, data, MAX_PATH);
				if ( gwl->state )
				{
					ImageList_DrawEx(
						__img, 0, itst->hDC, itst->rcItem.right - 11, 2, 0, 0, CLR_NONE, GetSysColor(COLOR_BTNSHADOW), ILD_BLEND
					);
				}
				DrawEdge(
					itst->hDC, &itst->rcItem, BDR_SUNKENOUTER, border
					);
				DrawState(
					itst->hDC, NULL, NULL, (LPARAM)data, 0, itst->rcItem.right+4, 0, 0, 0, DST_PREFIXTEXT | state
					);

				if ( itst->itemState & ODS_FOCUS )
				{
					rc.bottom  = itst->rcItem.bottom - itst->rcItem.top + 2;					
					rc.left   += itst->rcItem.right + 2;

					DrawFocusRect( itst->hDC, &rc );
				}
				return;
			} else 
			{ 
				if ( curr )
				{							
					edge = BDR_SUNKENOUTER;
					x++; y++;
				} else {
					border = BF_FLAT;
				}
			}
		}

		_fill( itst->hDC, &itst->rcItem, (itst->itemState & ODS_FOCUS ) ?
			_cl( COLOR_BTNFACE, DARK_CLR ) :
			_cl( COLOR_BTNFACE, FALSE ) );

		DrawState( itst->hDC, NULL, NULL, (LPARAM)data, 0, x, y, 0, 0, DST_PREFIXTEXT | state );
		if ( itst->itemState & ODS_FOCUS )
		{
			modify_rect( rc, 1, 2, -2, -2 );
			if ( itst->itemState & ODS_SELECTED )
			{
				modify_rect( rc, 1, 1, 1, 1 );
			}
			DrawFocusRect( itst->hDC, &rc );
		}

		case ODT_STATIC:
		{
			GetWindowInfo(itst->hwndItem, &wi);
			GetWindowText(itst->hwndItem, data, MAX_PATH);

			if ( data[0] == L'#' )
			{
				GetWindowRect(GetParent(GetParent(itst->hwndItem)), &rc);

				itst->rcItem.right = rc.right - rc.left - 3;
				itst->rcItem.top = itst->rcItem.left = 1;

				_fill(itst->hDC, &itst->rcItem, _cl(COLOR_BTNSHADOW, DARK_CLR - 7));

				tp.iLeftMargin   += 10;
				itst->rcItem.top += 1;

				DrawTextEx(itst->hDC, data + 1, -1, &itst->rcItem, DT_END_ELLIPSIS, &tp);					
			}
			else 
			{
				if ( (wi.dwStyle & SS_SUNKEN) == 0 )
				{
					DrawEdge(itst->hDC, &itst->rcItem, edge, border);				
				}
			}
		}
		break;
	}
}
int _init_wizard_encrypt_pages(
		HWND        parent,
		_wz_sheets *sheets,
		_dnode     *node
	)
{
	wchar_t *static_head[ ] = 
	{
		L"# Choice iso-file",
		L"# Format Options",
		L"# Encryption Settings",
		L"# Boot Settings",
		L"# Volume Password",
		L"# Encryption Progress"
	};

	HWND    hwnd;
	dc_conf dcfg;
	int     k;
	int     count       = 0;

	BOOL    boot_device = (
		_is_boot_device( &node->mnt.info )
	);
	BOOL    force_small = (
		boot_device && ( dc_get_conf_flags(&dcfg) == ST_OK ) && ( dcfg.load_flags & DST_SMALL_MEM )
	);

	while ( sheets[count].id != -1 )
	{
		HWND hwnd;

		sheets[count].hwnd = 
			CreateDialog(
				__hinst, MAKEINTRESOURCE(sheets[count].id), GetDlgItem(parent, IDC_TAB), _tab_proc
				);

		hwnd = sheets[count].hwnd;

		EnumChildWindows( hwnd, __sub_enum, (LPARAM)NULL );

		SetWindowText( GetDlgItem( hwnd, IDC_HEAD ), static_head[count] );
		SendMessage( GetDlgItem( hwnd, IDC_HEAD ), (UINT)WM_SETFONT, (WPARAM)__font_bold, 0 );

		sheets[count].first_tab_hwnd = 
			(
				( sheets[count].first_tab_id != -1 ) ? GetDlgItem( hwnd, sheets[count].first_tab_id ) : HWND_NULL
			);

		count++;
	}
	///////////////////////////////////////////////////////////////
	hwnd = sheets[WPAGE_ENC_FRMT].hwnd;
	///////////////////////////////////////////////////////////////
	/////// FORMAT OPTIONS PAGE ///////////////////////////////////
	{
		HWND h_fs = GetDlgItem(hwnd, IDC_COMBO_FS_LIST);

		_sub_class( GetDlgItem(hwnd, IDC_CHECK_QUICK_FORMAT), SUB_STATIC_PROC, HWND_NULL );
		_set_check( hwnd, IDC_CHECK_QUICK_FORMAT, FALSE );

		for ( k = 0; k < array_num(fs_names); k++ )
		{
			SendMessage( h_fs, (UINT)CB_ADDSTRING, 0, (LPARAM)fs_names[k] );
		}
		SendMessage( h_fs, CB_SETCURSEL, 2, 0 );			
	}
	///////////////////////////////////////////////////////////////
	hwnd = sheets[WPAGE_ENC_CONF].hwnd;
	///////////////////////////////////////////////////////////////
	/////// ENCRYPTION SETTINGS PAGE //////////////////////////////
	{
		HWND h_combo_wipe = GetDlgItem(hwnd, IDC_COMBO_PASSES);

		_init_combo( h_combo_wipe, wipe_modes, WP_NONE, FALSE, -1 );

		EnableWindow( h_combo_wipe, node->dlg.act_type != ACT_ENCRYPT_CD);
		EnableWindow( GetDlgItem(hwnd, IDC_STATIC_PASSES_LIST), node->dlg.act_type != ACT_ENCRYPT_CD );

		_init_combo(
			GetDlgItem(hwnd, IDC_COMBO_ALGORT), cipher_names, CF_AES, FALSE, -1
			);

		if ( force_small )
		{
			EnableWindow( GetDlgItem(hwnd, IDC_COMBO_ALGORT), FALSE );
			SendMessage( GetDlgItem(hwnd, IDC_WIZ_CONF_WARNING), (UINT)WM_SETFONT, (WPARAM)__font_bold, 0 );

			SetWindowText( 
				GetDlgItem(hwnd, IDC_WIZ_CONF_WARNING),
				L"Your BIOS does not provide enough base memory,\n"
				L"you can only use AES to encrypt the boot partition!"
			);
		}
		for ( k = 0; k < array_num(combo_sel); k++ )
		{
			SendMessage( GetDlgItem(hwnd, combo_sel[k]), CB_SETCURSEL, 0, 0 );
		}	
	}
	///////////////////////////////////////////////////////////////
	hwnd = sheets[WPAGE_ENC_BOOT].hwnd;
	///////////////////////////////////////////////////////////////
	/////// BOOT SETTINGS PAGE ////////////////////////////////////
	{
		int dsk_num = -1;
		int rlt = _get_info_install_boot_page( &node->mnt.info, sheets, &dsk_num );

		__lists[HENC_WIZARD_BOOT_DEVS] = GetDlgItem(hwnd, IDC_BOOT_DEVS);

		_list_devices( __lists[HENC_WIZARD_BOOT_DEVS], TRUE, dsk_num );
		SendMessage( GetDlgItem(hwnd, IDC_COMBO_BOOT_INST), (UINT)CB_ADDSTRING, 0, (LPARAM)L"Use external bootloader" ); 

		if ( rlt != ST_OK )
		{
			SetWindowText( GetDlgItem(hwnd, IDC_WARNING), L"Bootable HDD not found!" );
			SendMessage( GetDlgItem(hwnd, IDC_COMBO_BOOT_INST), CB_SETCURSEL, 0, 0 );

			SendMessage( GetDlgItem(hwnd, IDC_WARNING), (UINT)WM_SETFONT, (WPARAM)__font_bold, 0 );
			EnableWindow( GetDlgItem(hwnd, IDB_BOOT_PREF), TRUE );
		} else {		
			SendMessage( GetDlgItem(hwnd, IDC_COMBO_BOOT_INST), (UINT)CB_ADDSTRING, 0, (LPARAM)L"Install to HDD" );
			SendMessage( GetDlgItem(hwnd, IDC_COMBO_BOOT_INST), CB_SETCURSEL, 1, 0 );
		}
	}
	///////////////////////////////////////////////////////////////
	hwnd = sheets[WPAGE_ENC_PASS].hwnd;
	///////////////////////////////////////////////////////////////
	/////// VOLUME PASSWORD PAGE //////////////////////////////////
	{
		int kbd_layout;
		_update_layout( node, -1, &kbd_layout );

		_init_combo( GetDlgItem(hwnd, IDC_COMBO_KBLAYOUT), kb_layouts, kbd_layout, FALSE, -1 );
		SetWindowText(GetDlgItem( hwnd, IDC_USE_KEYFILES), boot_device ? IDS_USE_KEYFILE : IDS_USE_KEYFILES );

		_sub_class( GetDlgItem(hwnd, IDC_CHECK_SHOW), SUB_STATIC_PROC, HWND_NULL );
		_set_check( hwnd, IDC_CHECK_SHOW, FALSE );

		_sub_class( GetDlgItem(hwnd, IDC_USE_KEYFILES), SUB_STATIC_PROC, HWND_NULL );
		_set_check( hwnd, IDC_USE_KEYFILES, FALSE );

		SendMessage(
			GetDlgItem( hwnd, IDP_BREAKABLE ),
			PBM_SETBARCOLOR, 0, _cl( COLOR_BTNSHADOW, DARK_CLR-20 )
		);	
		SendMessage(
			GetDlgItem(hwnd, IDP_BREAKABLE),
			PBM_SETRANGE, 0, MAKELPARAM(0, 193)
		);
		SetWindowText( GetDlgItem(hwnd, IDC_HEAD2), L"# Password Rating" );
		SendMessage( GetDlgItem(hwnd, IDC_HEAD2), (UINT)WM_SETFONT, (WPARAM)__font_bold, 0 );

		SendMessage( GetDlgItem(hwnd, IDE_PASS), EM_LIMITTEXT, MAX_PASSWORD, 0 );
		SendMessage( GetDlgItem(hwnd, IDE_CONFIRM), EM_LIMITTEXT, MAX_PASSWORD, 0 );
	}
	///////////////////////////////////////////////////////////////
	hwnd = sheets[WPAGE_ENC_PROGRESS].hwnd;
	///////////////////////////////////////////////////////////////
	/////// ENCRYPTION PROGRESS PAGE //////////////////////////////
	{
		_colinfo _progress_iso_crypt_headers[ ] = 
		{
			{ STR_HEAD_NO_ICONS, 100, LVCFMT_LEFT, FALSE },
			{ STR_HEAD_NO_ICONS, 120, LVCFMT_LEFT, FALSE },
			{ STR_NULL }
		};

		HWND h_list = GetDlgItem( hwnd, IDC_ISO_PROGRESS );
		int  rlt    = ST_OK;
		int  j      = 0;

		ListView_SetBkColor( h_list, GetSysColor(COLOR_BTNFACE) );
		_init_list_headers( h_list, _progress_iso_crypt_headers );

		while ( wcslen(_act_table_items[j]) > 0 )
		{
			_list_insert_item( h_list, j, 0, _act_table_items[j], 0 );
			if ( j != 2 ) ListView_SetItemText( h_list, j, 1, STR_EMPTY );

			j++;
		}
		SendMessage(
			GetDlgItem( hwnd, IDC_PROGRESS_ISO ),
			PBM_SETBARCOLOR, 0, _cl(COLOR_BTNSHADOW, DARK_CLR-20)
		);

		SendMessage(
			GetDlgItem( hwnd, IDC_PROGRESS_ISO ),
			PBM_SETRANGE, 0, MAKELPARAM(0, PRG_STEP)
		);
	}

	return count;

}
Beispiel #7
0
INT_PTR 
CALLBACK
_main_dialog_proc(
		HWND	hwnd,
		UINT	message,
		WPARAM	wparam,
		LPARAM	lparam
	)
{
	WORD id		= LOWORD(wparam);
	WORD code	= HIWORD(wparam);

	_wnd_data	*wnd;
	_dnode		*sel;
	_dmnt		*mnt;

	int k = 0;
	switch ( message )
	{
		case WM_INITDIALOG :
		{
			memset( __lists, HWND_NULL, sizeof(__lists) );

			__lists[HMAIN_DRIVES] = GetDlgItem( hwnd, IDC_DISKDRIVES );
			__dlg = hwnd;

			_init_main_dlg( hwnd );

			_load_diskdrives( hwnd, &__drives, _list_volumes(0) );
			{
				TCITEM     tab_item = { TCIF_TEXT };
				HWND       h_tab    = GetDlgItem(hwnd, IDT_INFO);
				_tab_data *d_tab    = malloc(sizeof(_tab_data));

				zeroauto( d_tab, sizeof(_tab_data) );
				d_tab->curr_tab = 1;

				wnd_set_long( hwnd, GWL_USERDATA, d_tab );

				wnd = _sub_class(
						h_tab, SUB_NONE,
						CreateDialog( __hinst, MAKEINTRESOURCE(DLG_MAIN_INFO),   GetDlgItem(hwnd, IDC_MAIN_TAB), _tab_proc ),
						CreateDialog( __hinst, MAKEINTRESOURCE(DLG_MAIN_ACTION), GetDlgItem(hwnd, IDC_MAIN_TAB), _tab_proc ),
						HWND_NULL
					);
				{
					__lists[HMAIN_INFO] = GetDlgItem( wnd->dlg[0], IDC_INF_TABLE );
					__lists[HMAIN_ACT]  = GetDlgItem( wnd->dlg[1], IDC_ACT_TABLE );
				}
				{
					__dlg_act_info = wnd->dlg[1];

					_list_insert_col( __lists[HMAIN_INFO], 380 );
					_list_insert_col( __lists[HMAIN_INFO], 90 );
					
					while (
						_list_insert_item( __lists[HMAIN_INFO], k, 0, _info_table_items[k], 0 )
						) k++;

					_set_header_text( 
						__lists[HMAIN_INFO], 0, STR_HEAD_NO_ICONS, sizeof_w(STR_HEAD_NO_ICONS) 
						);

					_list_insert_col( __lists[HMAIN_ACT], 90 );
					_list_insert_col( __lists[HMAIN_ACT], 70 );

					_list_insert_col( __lists[HMAIN_ACT], 85 );
					_list_insert_col( __lists[HMAIN_ACT], 50 );
						
					_list_insert_item( __lists[HMAIN_ACT],    0, 0, _act_table_items[0], 0 );
					ListView_SetItemText( __lists[HMAIN_ACT], 0, 2, _act_table_items[3] );

					_list_insert_item( __lists[HMAIN_ACT],    1, 0, _act_table_items[1], 0 );
					ListView_SetItemText( __lists[HMAIN_ACT], 1, 2, _act_table_items[4] );

					_init_combo(
						GetDlgItem( __dlg_act_info, IDC_COMBO_PASSES), wipe_modes, WP_NONE, FALSE, -1
						);

					SendMessage(
						GetDlgItem( __dlg_act_info, IDC_PROGRESS ),
						PBM_SETBARCOLOR, 0, _cl( COLOR_BTNSHADOW, DARK_CLR - 20 )
						);

					SendMessage(
						GetDlgItem( __dlg_act_info, IDC_PROGRESS ),
						PBM_SETRANGE, 0, MAKELPARAM(0, PRG_STEP)
						);
				}
				tab_item.pszText = L"Info";
				TabCtrl_InsertItem( h_tab, 0, &tab_item );
				{
					NMHDR mhdr = { 0, 0, TCN_SELCHANGE };
					TabCtrl_SetCurSel( h_tab, 0 );

					SendMessage(hwnd, WM_NOTIFY, IDT_INFO, (LPARAM)&mhdr);
				}
			}
			SendMessage( hwnd, WM_SYSCOLORCHANGE, 0, 0 );

			_set_timer( MAIN_TIMER, TRUE, TRUE );
			_set_timer( RAND_TIMER, TRUE, FALSE );
			_set_timer( POST_TIMER, TRUE, FALSE );

			return 0L;
		} 
		break;

		case WM_WINDOWPOSCHANGED :
		{
			WINDOWPOS *pos = (WINDOWPOS *)lparam;
			int flags = pos->flags;

			_dlg_right  = pos->cx + pos->x;
			_dlg_bottom = pos->cy + pos->y;
			_dlg_left   = pos->x;

			if ( ( flags & SWP_SHOWWINDOW ) || ( flags & SWP_HIDEWINDOW ) )
			{
				_set_timer( MAIN_TIMER, flags & SWP_SHOWWINDOW, TRUE );
			}
			return 0L;
		}
		break;

		case WM_ENTERSIZEMOVE :
		{
			//_middle_ctl(
			//	GetDlgItem(hwnd, IDC_DISKDRIVES),
			//	GetDlgItem(hwnd, IDC_RESIZING),
			//	TRUE
			//	);

			//ShowWindow(GetDlgItem(hwnd, IDC_DISKDRIVES), SW_HIDE);
			return 0L;
		}
		break;

		case WM_EXITSIZEMOVE :
		{
			//ShowWindow(GetDlgItem(hwnd, IDC_DISKDRIVES), SW_SHOW);
			return 0L;
		}
		break;

		case WM_SIZING :
		{
			RECT *rect = ((RECT *)lparam);

			rect->right = _dlg_right;
			rect->left  = _dlg_left;

			if ( rect->bottom - rect->top < MAIN_DLG_MIN_HEIGHT ) 
			{
				rect->bottom = rect->top + MAIN_DLG_MIN_HEIGHT;
			}
			return 1L;
		}
		break;

		case WM_SIZE :
		{
			int height = HIWORD(lparam);
			int width  = LOWORD(lparam);
			int k;

			_size_move_ctls _resize[ ] = 
			{
				{ -1, IDC_DISKDRIVES,   FALSE, 0, 0 },
				{ -1, IDC_STATIC_LIST,  TRUE,  0, 0 },
				{ -1, IDC_STATIC_RIGHT, TRUE,  0, 0 }
			};

			_size_move_ctls _move[ ] =
			{
				{ IDC_STATIC_LIST, IDC_MAIN_TAB,    TRUE,  0, 6 },
				{ IDC_STATIC_LIST, IDT_INFO,        FALSE, 0, 3 },
				{ IDT_INFO,        IDC_LINE_BOTTOM, TRUE,  0, 2 }
			};
			{
				int c_size_hide = _main_headers[1].width;
				int c_size_show = c_size_hide - GetSystemMetrics(SM_CXVSCROLL);
				int c_size_curr = ListView_GetColumnWidth( __lists[HMAIN_DRIVES], 1 );

				if ( GetWindowLong(__lists[HMAIN_DRIVES], GWL_STYLE) & WS_VSCROLL )
				{
					if ( c_size_curr != c_size_show ) ListView_SetColumnWidth( __lists[HMAIN_DRIVES], 1, c_size_show );
				} else {
					if ( c_size_curr != c_size_hide ) ListView_SetColumnWidth( __lists[HMAIN_DRIVES], 1, c_size_hide );
				}
			}

			if ( height == 0 || width == 0 )
			{
				return 0L;
			}
			for ( k = 0; k < array_num(_resize); k++ )
			{
				_resize_ctl(
					GetDlgItem(hwnd, _resize[k].id), height - _dlg_height, 0, _resize[k].val
					);
			}
			_dlg_height = height;

			for ( k = 0; k < array_num(_move); k++ )
			{
				_relative_move(
					GetDlgItem( hwnd, _move[k].anchor ), GetDlgItem( hwnd, _move[k].id ), _move[k].dy, _move[k].dy, _move[k].val
					);
				InvalidateRect( GetDlgItem( hwnd, _move[k].id ), NULL, TRUE );
			}
			_middle_ctl(
				GetDlgItem( hwnd, IDC_DISKDRIVES ),
				GetDlgItem( hwnd, IDC_RESIZING ),
				TRUE
				);

			return 0L;
		}
		break;

		case WM_SYSCOMMAND :
		{
			if ( wparam == SC_MINIMIZE || wparam == SC_RESTORE )
			{
				_set_timer( MAIN_TIMER, wparam == SC_RESTORE, TRUE );
			}
			return 0L;
		}
		break;

		case WM_APP + WM_APP_SHOW :
		{
			ShowWindow( hwnd, SW_HIDE );
		}
		break;

		case WM_NOTIFY :
		{
			if ( wparam == IDT_INFO )
			{
				if ( ((NMHDR *)lparam)->code == TCN_SELCHANGE )
				{
					HWND h_tab = GetDlgItem( hwnd, IDT_INFO );
					if ( !_is_curr_in_group(h_tab) )
					{
						_change_page( h_tab, TabCtrl_GetCurSel(h_tab) );
					}
				}
			}
			if ( wparam == IDC_DISKDRIVES )
			{
				sel = pv( _get_sel_item( __lists[HMAIN_DRIVES] ) );
				mnt = &sel->mnt;

				if ( ((NMHDR *)lparam)->code == LVN_ITEMCHANGED &&
					 (((NMLISTVIEW *)lparam)->uNewState & LVIS_FOCUSED ) )
				{
					_update_info_table( FALSE );
					_activate_page( );
					_refresh_menu( );					

					return 1L;
				}
				if ( ((NMHDR *)lparam)->code == LVN_ITEMACTIVATE )
				{
					BOOL mount = 
						( !(sel->mnt.info.status.flags & F_ENABLED) ) && 
						( sel->mnt.fs[0] == '\0' );
					
					if (! mount )
					{
						if (! sel->is_root ) __execute( mnt->info.status.mnt_point );
					} else {
						_menu_mount( sel );
					}
				}
				switch( ((NM_LISTVIEW *)lparam)->hdr.code )
				{
					case LVN_KEYDOWN : 
					{
						WORD key = ((NMLVKEYDOWN *)lparam)->wVKey;
						int item = ListView_GetSelectionMark( __lists[HMAIN_DRIVES] );

						switch ( key )
						{
							case VK_UP:   item -= 1; break;
							case VK_DOWN: item += 1; break;
						}
						if ( _is_root_item(_get_item_index( __lists[HMAIN_DRIVES], item )) )
						{
							ListView_SetItemState( __lists[HMAIN_DRIVES], item, LVIS_FOCUSED, TRUE );
						}
						if ( key != VK_APPS )
						{
							break;
						}
					}

					case NM_RCLICK :
					{
						int item;
						HMENU h_popup = CreatePopupMenu( );

						_dact *act = _create_act_thread( sel, -1, -1 );

						_update_info_table( FALSE );
						_activate_page( );

						_set_timer(MAIN_TIMER, FALSE, FALSE);

						_refresh_menu( );
						
						if ( ListView_GetSelectedCount( __lists[HMAIN_DRIVES] ) && 
							 !_is_root_item((LPARAM)sel) && _is_active_item((LPARAM)sel)
							 )
						{
							if ( mnt->info.status.flags & F_ENABLED )
							{
								if ( mnt->info.status.flags & F_CDROM )
								{
									AppendMenu( h_popup, MF_STRING, ID_VOLUMES_UNMOUNT, IDS_UNMOUNT );
								} else 
								{
									if ( mnt->info.status.flags & F_FORMATTING )
									{
										AppendMenu( h_popup, MF_STRING, ID_VOLUMES_FORMAT, IDS_FORMAT );
									} else
									{
										if ( IS_UNMOUNTABLE(&mnt->info.status) )
										{
											AppendMenu( h_popup, MF_STRING, ID_VOLUMES_UNMOUNT, IDS_UNMOUNT );
										}
										if ( !(mnt->info.status.flags & F_SYNC) )
										{
											AppendMenu( h_popup, MF_SEPARATOR, 0, NULL );
											AppendMenu( h_popup, MF_STRING, ID_VOLUMES_CHANGEPASS, IDS_CHPASS );
										}
										if ( !(act && act->status == ACT_RUNNING) )
										{
											if ( mnt->info.status.flags & F_SYNC )
											{
												if ( GetMenuItemCount(h_popup) > 0 )
												{
													AppendMenu( h_popup, MF_SEPARATOR, 0, NULL );
												}
												AppendMenu( h_popup, MF_STRING, ID_VOLUMES_ENCRYPT, IDS_ENCRYPT );
											} else
											{
												if ( GetMenuItemCount(h_popup) > 0 )
												{
													AppendMenu( h_popup, MF_SEPARATOR, 0, NULL );
												}
												AppendMenu( h_popup, MF_STRING, ID_VOLUMES_REENCRYPT, IDS_REENCRYPT );
											}
											AppendMenu( h_popup, MF_STRING, ID_VOLUMES_DECRYPT, IDS_DECRYPT );
										}
									}								
								}
							} else 
							{
								if ( mnt->info.status.flags & F_CDROM )
								{
									if ( *mnt->fs == '\0' )
									{
										AppendMenu( h_popup, MF_STRING, ID_VOLUMES_MOUNT, IDS_MOUNT );
									}
								} else {
									if ( *mnt->fs == '\0' )
									{
										AppendMenu( h_popup, MF_STRING, ID_VOLUMES_MOUNT, IDS_MOUNT );
									} else {
										AppendMenu( h_popup, MF_STRING, ID_VOLUMES_ENCRYPT, IDS_ENCRYPT );
									}
									if ( IS_UNMOUNTABLE(&mnt->info.status) )
									{
										AppendMenu( h_popup, MF_SEPARATOR, 0, NULL );
										AppendMenu( h_popup, MF_STRING, ID_VOLUMES_FORMAT, IDS_FORMAT );
									}
								}
							}
						}
						/*
						_state_menu(
							popup, sel && sel->status.flags & F_LOCKED ? MF_GRAYED : MF_ENABLED
							);
						*/
						item = TrackPopupMenu(
							h_popup,
							TPM_RETURNCMD | TPM_LEFTBUTTON,
							LOWORD(GetMessagePos( )),
							HIWORD(GetMessagePos( )),
							0,
							hwnd,
							NULL
						);

						DestroyMenu( h_popup );
						switch ( item )
						{
							case ID_VOLUMES_DECRYPT		: _menu_decrypt(sel);	break;
							case ID_VOLUMES_ENCRYPT		: _menu_encrypt(sel);	break;

							case ID_VOLUMES_FORMAT		: _menu_format(sel);	break;
							case ID_VOLUMES_REENCRYPT	: _menu_reencrypt(sel);	break;

							case ID_VOLUMES_UNMOUNT		: _menu_unmount(sel);	break;
							case ID_VOLUMES_MOUNT		: _menu_mount(sel);		break;

							case ID_VOLUMES_CHANGEPASS	: _menu_change_pass(sel); break;						
						}
						if ( item )
						{
							_refresh( TRUE );
						}
						_set_timer( MAIN_TIMER, TRUE, TRUE );

					}
					break;

					case NM_CLICK :
					{
						sel = pv(
							_get_item_index( __lists[HMAIN_DRIVES], ((NM_LISTVIEW *)lparam)->iItem )
							);

						_update_info_table( FALSE );
						_activate_page( );
						_refresh_menu( );						
					}
					break;

				}
			}
			if ( ((NMHDR *)lparam)->code == HDN_ITEMCHANGED )
			{
				InvalidateRect( __lists[HMAIN_DRIVES], NULL, TRUE );
			}
			if ( ((NMHDR *)lparam)->code == HDN_ITEMCHANGING )
			{
				return 0L;
			}
			if ( ((NMHDR *)lparam)->code == HDN_BEGINTRACK )
			{
				return 1L;
			}
		}
		break;

		case WM_COMMAND: 
		{
			_dnode *node = pv( _get_sel_item( __lists[HMAIN_DRIVES] ) );

			switch (id) 
			{
			case ID_SHIFT_TAB :
			case ID_TAB :
			{
				HWND h_current = GetFocus( );
				HWND h_next    = GetNextDlgTabItem( hwnd, h_current, id == ID_SHIFT_TAB );

				SetFocus( h_next );
			}
			break;

			case ID_TOOLS_DRIVER :
			{
				if ( __msg_q( __dlg, L"Remove DiskCryptor driver?") )
				{
					int rlt;
					if ( (rlt = _drv_action(DA_REMOVE, 0)) != ST_OK )
					{
						__error_s( __dlg, L"Error remove DiskCryptor driver", rlt );
					} else {
						return 0L;
					}
				}
			}
			break;

			case ID_TOOLS_BENCHMARK : _dlg_benchmark( __dlg ); break;
			case ID_HELP_ABOUT :      _dlg_about( __dlg ); break;
			
			case ID_HOMEPAGE : __execute( DC_HOMEPAGE ); break;			
			case ID_EXIT :
			{
				SendMessage( hwnd, WM_CLOSE, 0, 1 );
			}
			break;

			case IDC_BTN_WIZARD : _menu_wizard(node); break;
			case ID_VOLUMES_DELETE_MNTPOINT :
			{
				wchar_t *mnt_point = node->mnt.info.status.mnt_point;				
				if ( __msg_q( __dlg, L"Are you sure you want to delete mount point [%s]?", mnt_point ) )
				{
					_set_trailing_slash(mnt_point);
					DeleteVolumeMountPoint(mnt_point);
				}
			}
			break;

			case IDC_BTN_DECRYPT_ :
			case ID_VOLUMES_DECRYPT : _menu_decrypt( node ); break;

			case IDC_BTN_ENCRYPT_ :
			case ID_VOLUMES_ENCRYPT : _menu_encrypt( node ); break;

			case ID_VOLUMES_MOUNTALL : 
			case IDC_BTN_MOUNTALL_ : _menu_mountall( ); break;

			case ID_VOLUMES_DISMOUNTALL : 
			case IDC_BTN_UNMOUNTALL_ : _menu_unmountall( ); break;

			case ID_VOLUMES_DISMOUNT : _menu_unmount( node ); break;
			case ID_VOLUMES_MOUNT :    _menu_mount( node ); break;

			case ID_VOLUMES_FORMAT :    _menu_format(node); break;
			case ID_VOLUMES_REENCRYPT : _menu_reencrypt( node ); break;

			case ID_TOOLS_SETTINGS : _dlg_options( __dlg ); break;
			case ID_BOOT_OPTIONS :   _dlg_config_loader( __dlg, FALSE ); break;

			case ID_VOLUMES_CHANGEPASS : _menu_change_pass( node ); break;
			case ID_TOOLS_CLEARCACHE :   _menu_clear_cache( ); break;

			case ID_VOLUMES_BACKUPHEADER :  _menu_backup_header( node ); break;
			case ID_VOLUMES_RESTOREHEADER : _menu_restore_header( node ); break;

			case ID_TOOLS_ENCRYPT_CD: _menu_encrypt_cd( ); break;

			}
			switch ( id ) {
			case IDC_BTN_MOUNT_: 
			{		
				node->mnt.info.status.flags & F_ENABLED ?
					_menu_unmount(node) : 
					_menu_mount(node);
			}
			break;
			case ID_TOOLS_BSOD : 
			{
				if ( __msg_q( __dlg, L"Crash?" ) ) 
				{
					dc_get_bsod( );
				}
			}
			break;
			}
			if ( id == IDCANCEL )
			{
				ShowWindow(hwnd, SW_HIDE);
			}
			_refresh(TRUE);
		}
		break;

		case WM_CLOSE :
		{
			if ( lparam )
			{
				_tray_icon(FALSE);

				EndDialog(hwnd, 0);
				ExitProcess(0);
			} else {
				ShowWindow(hwnd, SW_HIDE);
			}
			return 0L;
		}
		break;

		case WM_DESTROY : 
		{
			PostQuitMessage(0);
			return 0L;
		}
		break;

		case WM_HOTKEY :
		{
			switch (wparam) 
			{
				case 0 : 
				{
					int mount_cnt;
					dc_mount_all(NULL, &mount_cnt, 0); 
				}
				break;

				case 1 : dc_unmount_all( ); break;
				case 2 : dc_clean_pass_cache( ); break;
				case 3 : dc_get_bsod( ); break;
			}
			return 1L;
		}
		break;

		case WM_ENDSESSION : 
		{
			if ( lparam & ENDSESSION_LOGOFF ) 
			{
				if ( __config.conf_flags & CONF_DISMOUNT_LOGOFF ) 
				{
					dc_unmount_all( );
				}
				if ( __config.conf_flags & CONF_WIPEPAS_LOGOFF ) 
				{
					dc_clean_pass_cache( );
				}
			}
		}
		break;

		case WM_SYSCOLORCHANGE :
		{
			COLORREF cl_light = _cl( COLOR_BTNFACE, LGHT_CLR );
			COLORREF cl_button = GetSysColor( COLOR_BTNFACE );

			int k;
			for ( k = 0; k < array_num(__lists); k++ )
			{
				if ( ( __lists[k] != HWND_NULL ) && ( __lists[k] != NULL ) )
				{
					ListView_SetBkColor( __lists[k], cl_button );
					ListView_SetTextBkColor( __lists[k], cl_button );
					ListView_SetExtendedListViewStyle( __lists[k], LVS_EX_FULLROWSELECT );

					if ( !IsWindowEnabled( __lists[k] ) )
					{
						// EnableWindow( __lists[k], TRUE );
						// EnableWindow( __lists[k], FALSE );
					}
				}
			}
			TreeView_SetBkColor( GetDlgItem(hwnd, IDC_TREE), cl_light );

			ListView_SetBkColor( __lists[HMAIN_DRIVES], cl_light );
			ListView_SetTextBkColor( __lists[HMAIN_DRIVES], cl_light );

			ListView_SetExtendedListViewStyle( __lists[HMAIN_DRIVES], LVS_EX_FULLROWSELECT );
			ListView_SetImageList( __lists[HMAIN_DRIVES], __dsk_img, LVSIL_SMALL );

		}
		break;

		case WM_APP + WM_APP_TRAY :
		{
			switch ( lparam ) 
			{
			case WM_LBUTTONDOWN : 
			{
				BOOL show = !IsWindowVisible(hwnd);				
				ShowWindow(hwnd, show ? SW_SHOW : SW_HIDE);

				if ( show )
				{
					SetForegroundWindow(hwnd);
				}
			}
			break;

			case WM_RBUTTONDOWN : 
			{
				POINT pt; int item;
				HMENU menu = CreatePopupMenu( );				

				AppendMenu( menu, MF_STRING, ID_VOLUMES_UNMOUNTALL, IDS_UNMOUNTALL );
				AppendMenu( menu, MF_STRING, ID_VOLUMES_MOUNTALL, IDS_MOUNTALL );
				AppendMenu( menu, MF_SEPARATOR, 0, NULL );

				AppendMenu( menu, MF_STRING, ID_TOOLS_SETTINGS, IDS_SETTINGS );
				AppendMenu( menu, MF_STRING, ID_HELP_ABOUT, IDS_ABOUT );
				AppendMenu( menu, MF_SEPARATOR, 0, NULL );
				AppendMenu( menu, MF_STRING, ID_EXIT, IDS_EXIT );

				GetCursorPos(&pt);
				SetForegroundWindow( hwnd );

				item = TrackPopupMenu ( menu,
					TPM_RETURNCMD | TPM_LEFTALIGN | TPM_BOTTOMALIGN | TPM_RIGHTBUTTON,
					pt.x, pt.y, 0, hwnd,
					NULL
				);

				DestroyMenu( menu );

				switch (item) {

				case ID_VOLUMES_UNMOUNTALL : _menu_unmountall( ); break;
				case ID_VOLUMES_MOUNTALL :   _menu_mountall( ); break;

				case ID_HELP_ABOUT :         _dlg_about( HWND_DESKTOP ); break;
				case ID_TOOLS_SETTINGS :     _dlg_options( __dlg ); break;

				case ID_EXIT : 
				{
					SendMessage(hwnd, WM_CLOSE, 0, 1);
				}
				break;
				}
			}
			break;
			}
		}
		break;

		default:
		{
			int rlt = _draw_proc( message, lparam );
			if (rlt != -1) 
			{
				return rlt;
			}
		}
	}	
	return 0L; 

}
Beispiel #8
0
INT_PTR CALLBACK
_password_dlg_proc(
		HWND	hwnd,
		UINT	message,
		WPARAM	wparam,
		LPARAM	lparam
	)
{
	WORD code	= HIWORD(wparam);
	WORD id		= LOWORD(wparam);

	wchar_t display[MAX_PATH] = { 0 };
	static dlgpass *info;

	static RECT rc_left  = { 0, 0, 0, 0 };
	static RECT rc_right = { 0, 0, 0, 0 };

	static cut;
	switch ( message )
	{
		case WM_DRAWITEM : 
		{
			DRAWITEMSTRUCT *draw = pv(lparam);

			static RECT left;
			static RECT right;

			switch ( draw->CtlID )
			{
				case IDC_FRAME_LEFT: 
				{
					if ( !rc_left.right )
					{
						_relative_rect( draw->hwndItem, &rc_left );
						rc_left.bottom -= cut;
					}
					MoveWindow(
						draw->hwndItem, rc_left.left, rc_left.top, rc_left.right, rc_left.bottom, TRUE
						);
				}
				break;
				case IDC_FRAME_RIGHT:
				{					
					if ( !rc_right.right )
					{
						_relative_rect( draw->hwndItem, &rc_right );
						rc_right.bottom -= cut;
					}
					MoveWindow(
						draw->hwndItem, rc_right.left, rc_right.top, rc_right.right, rc_right.bottom, TRUE
						);
				}
				break;
			}
			_draw_static( draw );
			return 1L;		
		}
		break;
		case WM_CTLCOLOREDIT : 
		{
			return (
				_ctl_color( wparam, _cl(COLOR_BTNFACE, LGHT_CLR) )
			);
		}
		break;
		case WM_INITDIALOG : 
		{
			int ctl_resize[ ] = {
				IDC_FRAME_LEFT,
				IDC_FRAME_RIGHT,
				-1
			};

			info = (dlgpass *)lparam;			
			_init_mount_points( GetDlgItem(hwnd, IDC_COMBO_MNPOINT) );

			SendMessage( GetDlgItem(hwnd, IDC_COMBO_MNPOINT), CB_SETCURSEL, 1, 0 );
			SendMessage( GetDlgItem(hwnd, IDE_PASS), EM_LIMITTEXT, MAX_PASSWORD, 0 );

			if ( info->node )
			{
				_snwprintf(
					display, sizeof_w(display), L"[%s] - %s", 
					info->node->mnt.info.status.mnt_point, info->node->mnt.info.device
					);
			} else
			{
				wcscpy(display, L"Enter password");
			}

			SetWindowText( hwnd, display );

			SetWindowText( GetDlgItem(hwnd, IDC_HEAD_PASS), L"# Current Password" );
			SendMessage( GetDlgItem(hwnd, IDC_HEAD_PASS), WM_SETFONT, (WPARAM)__font_bold, 0 );

			SetWindowText( GetDlgItem(hwnd, IDC_HEAD_MOUNT_OPTIONS), L"# Mount Options" );
			SendMessage( GetDlgItem(hwnd, IDC_HEAD_MOUNT_OPTIONS), WM_SETFONT, (WPARAM)__font_bold, 0 );

			_sub_class( GetDlgItem(hwnd, IDC_CHECK_SHOW), SUB_STATIC_PROC, HWND_NULL );
			_set_check( hwnd, IDC_CHECK_SHOW, FALSE );

			_sub_class( GetDlgItem(hwnd, IDC_USE_KEYFILES), SUB_STATIC_PROC, HWND_NULL );
			_set_check( hwnd, IDC_USE_KEYFILES, FALSE );

			{
				HWND mnt_combo = GetDlgItem( hwnd, IDC_COMBO_MNPOINT );
				HWND mnt_check = GetDlgItem( hwnd, IDC_CHECK_MNT_SET );
				HWND mnt_label = GetDlgItem( hwnd, IDC_MNT_POINT );

				BOOL enable;
				RECT rc_main;

				GetWindowRect(hwnd, &rc_main);
				enable = info->node && ( info->node->mnt.info.status.mnt_point[0] == L'\\' );

				EnableWindow( mnt_combo, enable );
				EnableWindow( mnt_check, enable );
				EnableWindow( mnt_label, enable );

				_sub_class( GetDlgItem(hwnd, IDC_CHECK_MNT_SET), SUB_STATIC_PROC, HWND_NULL );
				_set_check( hwnd, IDC_CHECK_MNT_SET, enable );

			}
			SendMessage(
				hwnd, WM_COMMAND, MAKELONG(IDE_PASS, EN_CHANGE), (LPARAM)GetDlgItem(hwnd, IDE_PASS)
				);

			SetForegroundWindow(hwnd);
			return 1L;

		}
		break;
		case WM_USER_CLICK : 
		{
			if ( (HWND)wparam == GetDlgItem(hwnd, IDC_CHECK_MNT_SET) )
			{
				EnableWindow(
					GetDlgItem(hwnd, IDC_COMBO_MNPOINT), _get_check(hwnd, IDC_CHECK_MNT_SET)
					);
				EnableWindow(
					GetDlgItem(hwnd, IDC_MNT_POINT), _get_check(hwnd, IDC_CHECK_MNT_SET)
					);
				return 1L;
			}

			if ( (HWND)wparam == GetDlgItem(hwnd, IDC_CHECK_SHOW) )
			{
				int mask = _get_check(hwnd, IDC_CHECK_SHOW) ? 0 : '*';

				SendMessage(GetDlgItem(hwnd, IDE_PASS), EM_SETPASSWORDCHAR, mask, 0 );
				InvalidateRect(GetDlgItem(hwnd, IDE_PASS), NULL, TRUE);

				return 1L;
			}

			if ( (HWND)wparam == GetDlgItem(hwnd, IDC_USE_KEYFILES) ) 
			{
				SendMessage(
					hwnd, WM_COMMAND, 
					MAKELONG(IDE_PASS, EN_CHANGE), (LPARAM)GetDlgItem(hwnd, IDE_PASS)
					);

				EnableWindow(GetDlgItem(hwnd, IDB_USE_KEYFILES), _get_check(hwnd, IDC_USE_KEYFILES));
				return 1L;
			}
		}
		break;
		case WM_COMMAND :

			if ( id == IDB_USE_KEYFILES )
			{
				_dlg_keyfiles(hwnd, KEYLIST_CURRENT);

				SendMessage(
					hwnd, WM_COMMAND, MAKELONG(IDE_PASS, EN_CHANGE), (LPARAM)GetDlgItem(hwnd, IDE_PASS)
					);
			}

			if ( code == CBN_SELCHANGE && id == IDC_COMBO_MNPOINT )
			{
				if ( SendMessage((HWND)lparam, CB_GETCURSEL, 0, 0) == 0 )
				{
					HWND h_combo = GetDlgItem(hwnd, IDC_COMBO_MNPOINT);

					int sel_item = 1;
					wchar_t path[MAX_PATH];

					if ( _folder_choice(hwnd, path, L"Choice folder for mount point") )
					{
						sel_item = (int)SendMessage(h_combo, CB_GETCOUNT, 0, 0);
						SendMessage(h_combo, CB_ADDSTRING, 0, (LPARAM)path);						
					}
					SendMessage(h_combo, CB_SETCURSEL, sel_item, 0);

				}
			}
			if (code == EN_CHANGE)
			{
				BOOL correct;
				int idx_status;

				dc_pass *pass = _get_pass(hwnd, IDE_PASS);
				int keylist = _get_check(hwnd, IDC_USE_KEYFILES) ? KEYLIST_CURRENT : KEYLIST_NONE;

				correct = 
					_input_verify(pass, NULL, keylist, -1, &idx_status
				);

				secure_free(pass);

				SetWindowText(GetDlgItem(hwnd, IDC_PASS_STATUS), _get_text_name(idx_status, pass_status));
				EnableWindow(GetDlgItem(hwnd, IDOK), correct);

				return 1L;
		
			}
			if ((id == IDCANCEL) || (id == IDOK)) 
			{
				if (id == IDOK)
				{
					info->pass = _get_pass_keyfiles(hwnd, IDE_PASS, IDC_USE_KEYFILES, KEYLIST_CURRENT);

					if (IsWindowEnabled(GetDlgItem(hwnd, IDC_COMBO_MNPOINT)) && 
							info->mnt_point) 
					{
						GetWindowText(
								GetDlgItem(hwnd, IDC_COMBO_MNPOINT), 
								(wchar_t *)info->mnt_point, 
								MAX_PATH
						);
					}
				}
				EndDialog (hwnd, id);
				return 1L;
	
			}
		break;
		case WM_DESTROY: 
		{
			_wipe_pass_control(hwnd, IDE_PASS);
			_keyfiles_wipe(KEYLIST_CURRENT);

			memset(&rc_right, 0, sizeof(rc_right));
			memset(&rc_left, 0, sizeof(rc_left));

			cut = 0;
			return 0L;

		}
		break;
		case WM_MEASUREITEM: 
		{
			MEASUREITEMSTRUCT *item = pv(lparam);

			if (item->CtlType != ODT_LISTVIEW)
				item->itemHeight -= 3;
 
		}
		break; 
	}
	return 0L;

}
Beispiel #9
0
INT_PTR CALLBACK
_password_change_dlg_proc(
		HWND	hwnd,
		UINT	message,
		WPARAM	wparam,
		LPARAM	lparam
	)
{
	WORD code = HIWORD(wparam);
	WORD id   = LOWORD(wparam);

	wchar_t display[MAX_PATH] = { 0 };
	static  dlgpass *info;
	int     k;

	int check_init[ ] = {
		IDC_CHECK_SHOW_CURRENT, IDC_USE_KEYFILES_CURRENT,
		IDC_CHECK_SHOW_NEW, IDC_USE_KEYFILES_NEW,
		-1
	};

	_ctl_init static_head[ ] = {
		{ L"# Current Password", IDC_HEAD_PASS_CURRENT, 0 },
		{ L"# New Password",     IDC_HEAD_PASS_NEW,     0 },
		{ L"# Password Rating",  IDC_HEAD_RATING,       0 },
		{ STR_NULL, -1, -1 }
	};

	switch (message) 
	{
		case WM_CTLCOLOREDIT : return _ctl_color(wparam, _cl(COLOR_BTNFACE, LGHT_CLR));
			break;

		case WM_CTLCOLORSTATIC : 
		{
			HDC dc = (HDC)wparam;
			COLORREF bgcolor, fn = 0;

			SetBkMode(dc, TRANSPARENT);

			k = 0;
			while (pass_gr_ctls[k].id != -1) 
			{
				if (pass_gr_ctls[k].hwnd == (HWND)lparam)
					fn = pass_gr_ctls[k].color;

				if (pass_pe_ctls[k].hwnd == (HWND)lparam)
					fn = pass_pe_ctls[k].color;

				k++;
			}
			SetTextColor(dc, fn);

			bgcolor = GetSysColor(COLOR_BTNFACE);
			SetDCBrushColor(dc, bgcolor);
			
			return (INT_PTR)GetStockObject(DC_BRUSH);
		
		}
		break;
		case WM_INITDIALOG : 
		{
			info = (dlgpass *)lparam;

			SendMessage(GetDlgItem(hwnd, IDE_PASS_NEW_CONFIRM), EM_LIMITTEXT, MAX_PASSWORD, 0);
			SendMessage(GetDlgItem(hwnd, IDE_PASS_CURRENT),     EM_LIMITTEXT, MAX_PASSWORD, 0);
			SendMessage(GetDlgItem(hwnd, IDE_PASS_NEW),         EM_LIMITTEXT, MAX_PASSWORD, 0);			

			SendMessage(hwnd, WM_COMMAND, 
				MAKELONG(IDE_PASS_NEW, EN_CHANGE), (LPARAM)GetDlgItem(hwnd, IDE_PASS_NEW));

			if (info->node) {
				_snwprintf(display, sizeof_w(display), L"[%s] - %s", 
					info->node->mnt.info.status.mnt_point, info->node->mnt.info.device);

			} else {
				wcscpy(display, L"Change password");

			}
			SetWindowText(hwnd, display);
		
			SendMessage(
				GetDlgItem(hwnd, IDP_BREAKABLE),
				PBM_SETBARCOLOR, 0, _cl(COLOR_BTNSHADOW, DARK_CLR-20)
			);

			SendMessage(
				GetDlgItem(hwnd, IDP_BREAKABLE),
				PBM_SETRANGE, 0, MAKELPARAM(0, 193)
			);

			k = 0;
			while (static_head[k].id != -1) {

				SetWindowText(GetDlgItem(hwnd, static_head[k].id), static_head[k].display);
				SendMessage(GetDlgItem(hwnd, static_head[k].id), (UINT)WM_SETFONT, (WPARAM)__font_bold, 0);
				k++;
			}

			k = 0;
			while (check_init[k] != -1) {

				_sub_class(GetDlgItem(hwnd, check_init[k]), SUB_STATIC_PROC, HWND_NULL);
				_set_check(hwnd, check_init[k], FALSE);
				k++;
			}	
			SetForegroundWindow(hwnd);
			return 1L;

		}
		break;
		case WM_USER_CLICK : 
		{
			if ( (HWND)wparam == GetDlgItem(hwnd, IDC_CHECK_SHOW_CURRENT) )
			{
				SendMessage(GetDlgItem(hwnd, IDE_PASS_CURRENT), 
					EM_SETPASSWORDCHAR, _get_check(hwnd, IDC_CHECK_SHOW_CURRENT) ? 0 : '*', 0
					);

				InvalidateRect(GetDlgItem(hwnd, IDE_PASS_CURRENT), NULL, TRUE);
				return 1L;

			}
			if ( (HWND)wparam == GetDlgItem(hwnd, IDC_CHECK_SHOW_NEW) )
			{
				int mask = _get_check(hwnd, IDC_CHECK_SHOW_NEW) ? 0 : '*';

				SendMessage(GetDlgItem(hwnd, IDE_PASS_NEW), EM_SETPASSWORDCHAR,	mask, 0);
				SendMessage(GetDlgItem(hwnd, IDE_PASS_NEW_CONFIRM), EM_SETPASSWORDCHAR,	mask, 0);

				InvalidateRect(GetDlgItem(hwnd, IDE_PASS_NEW), NULL, TRUE);
				InvalidateRect(GetDlgItem(hwnd, IDE_PASS_NEW_CONFIRM), NULL, TRUE);
				return 1L;

			}
			if ( (HWND)wparam == GetDlgItem(hwnd, IDC_USE_KEYFILES_CURRENT) ) 
			{
				SendMessage(
					hwnd, WM_COMMAND, MAKELONG(IDE_PASS_CURRENT, EN_CHANGE), (LPARAM)GetDlgItem(hwnd, IDE_PASS_CURRENT)
					);
				EnableWindow(
					GetDlgItem(hwnd, IDB_USE_KEYFILES_CURRENT), _get_check(hwnd, IDC_USE_KEYFILES_CURRENT)
					);
				return 1L;
			}
			if ( (HWND)wparam == GetDlgItem(hwnd, IDC_USE_KEYFILES_NEW) ) 
			{
				SendMessage(
					hwnd, WM_COMMAND, MAKELONG(IDE_PASS_NEW, EN_CHANGE), (LPARAM)GetDlgItem(hwnd, IDE_PASS_NEW)
					);
				EnableWindow(
					GetDlgItem(hwnd, IDB_USE_KEYFILES_NEW), _get_check(hwnd, IDC_USE_KEYFILES_NEW
					));
				return 1L;
			}
		}
		break;
		case WM_COMMAND :

			if ( id == IDB_USE_KEYFILES_CURRENT )
			{
				_dlg_keyfiles( hwnd, KEYLIST_CURRENT );

				SendMessage(
					hwnd, WM_COMMAND, MAKELONG(IDE_PASS_CURRENT, EN_CHANGE), (LPARAM)GetDlgItem(hwnd, IDE_PASS_CURRENT)
					);
			}
			if ( id == IDB_USE_KEYFILES_NEW )
			{
				_dlg_keyfiles( hwnd, KEYLIST_CHANGE_PASS );

				SendMessage(
					hwnd, WM_COMMAND, MAKELONG(IDE_PASS_NEW, EN_CHANGE), (LPARAM)GetDlgItem(hwnd, IDE_PASS_NEW)
					);
			}

			if ( code == EN_CHANGE ) 
			{
				BOOL correct_current, correct_new;
				int  id_stat_current, id_stat_new;

				dc_pass *pass;
				dc_pass *verify;

				ldr_config conf;

				int kb_layout = -1;
				int keylist;

				if ( info->node && _is_boot_device(&info->node->mnt.info) )
				{
					if (dc_get_mbr_config( -1, NULL, &conf ) == ST_OK)
					{
						kb_layout = conf.kbd_layout;
					}
				}
				if ( id == IDE_PASS_NEW )
				{
					int entropy;
					dc_pass *pass;

					pass = _get_pass(hwnd, IDE_PASS_NEW);

					_draw_pass_rating(hwnd, pass, kb_layout, &entropy);
					secure_free(pass);

					SendMessage(
						GetDlgItem(hwnd, IDP_BREAKABLE),
						PBM_SETPOS,
						(WPARAM)entropy, 0
						);
				}
				
				pass    = _get_pass(hwnd, IDE_PASS_CURRENT);
				keylist = _get_check(hwnd, IDC_USE_KEYFILES_CURRENT) ? KEYLIST_CURRENT : KEYLIST_NONE;

				correct_current = 
					_input_verify(pass, NULL, keylist, -1, &id_stat_current
				);

				secure_free(pass);

				pass    = _get_pass(hwnd, IDE_PASS_NEW);
				verify  = _get_pass(hwnd, IDE_PASS_NEW_CONFIRM);
				keylist = _get_check(hwnd, IDC_USE_KEYFILES_NEW) ? KEYLIST_CHANGE_PASS : KEYLIST_NONE;

				correct_new =
					_input_verify(pass, verify, keylist, kb_layout, &id_stat_new
					);

				secure_free(pass);
				secure_free(verify);				

				SetWindowText(GetDlgItem(hwnd, IDC_PASS_STATUS_CURRENT), _get_text_name(id_stat_current, pass_status));
				SetWindowText(GetDlgItem(hwnd, IDC_PASS_STATUS_NEW), _get_text_name(id_stat_new, pass_status));

				EnableWindow(GetDlgItem(hwnd, IDOK), correct_current && correct_new);

				return 1L;
		
			}
			if ( (id == IDCANCEL) || (id == IDOK) )
			{
				if ( id == IDOK )
				{
					info->pass     = _get_pass_keyfiles(hwnd, IDE_PASS_CURRENT, IDC_USE_KEYFILES_CURRENT, KEYLIST_CURRENT);
					info->new_pass = _get_pass_keyfiles(hwnd, IDE_PASS_NEW,     IDC_USE_KEYFILES_NEW,     KEYLIST_CHANGE_PASS);

					if ( IsWindowEnabled(GetDlgItem(hwnd, IDC_COMBO_MNPOINT)) && 
						 info->mnt_point
						 )
					{
						GetWindowText(
							GetDlgItem(hwnd, IDC_COMBO_MNPOINT), 
							(wchar_t *)info->mnt_point, 
							MAX_PATH
							);
					}
				}
				EndDialog (hwnd, id);
				return 1L;
	
			}
		break;
		case WM_DESTROY: 
		{
			_wipe_pass_control(hwnd, IDE_PASS_NEW_CONFIRM);
			_wipe_pass_control(hwnd, IDE_PASS_CURRENT);
			_wipe_pass_control(hwnd, IDE_PASS_NEW);		

			_keyfiles_wipe(KEYLIST_CURRENT);
			_keyfiles_wipe(KEYLIST_CHANGE_PASS);

			return 0L;
		}
		break;
		default:
		{
			int rlt = _draw_proc(message, lparam);
			if (rlt != -1) return rlt;
		}
	}
	return 0L;

}
Beispiel #10
0
static
INT_PTR CALLBACK
_keyfiles_dlg_proc(
		HWND	hwnd,
		UINT	message,
		WPARAM	wparam,
		LPARAM	lparam
	)
{
	static int			key_list;
	static list_entry  *head;

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

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

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

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

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

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

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

					byte keyfile[64];
					int rlt;					

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

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

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

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

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

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

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

				_keyfiles_wipe(key_list);

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

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

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

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

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

			_init_list_headers( h_list, _keyfiles_headers );

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

				} while ( key_file != NULL );
			} 

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

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

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

}