Ejemplo n.º 1
0
BOOL 
CALLBACK 
_enum_proc(
		HWND   hwnd,
		LPARAM lparam
	)
{
	wchar_t caption[200];
	void *data;

	if ( *(HWND *)lparam == hwnd )
	{
		return 1L;
	}
	data = wnd_get_long( hwnd, GWL_USERDATA );
	if ( data )
	{
		GetWindowText( hwnd, caption, sizeof_w(caption) );
		if ( wcscmp(caption, DC_NAME) == 0 )
		{
			*(HWND *)lparam = hwnd;
		}
	}
	return 1L;
}
Ejemplo n.º 2
0
BOOL _is_curr_in_group( 
		HWND h_tab 
	)
{
	_tab_data *tab;

	tab = wnd_get_long(GetParent(h_tab), GWL_USERDATA);
	return (
		tab && (tab->curr_tab == TabCtrl_GetCurSel(h_tab))
	);

}
Ejemplo n.º 3
0
LRESULT 
CALLBACK 
_static_proc(
		HWND   hwnd,
		UINT   msg,
		WPARAM wparam,
		LPARAM lparam
	)
{
	int code = HIWORD(wparam);
	int rlt  = 1;

	_wnd_data *data = wnd_get_long(hwnd, GWL_USERDATA);
	if ( !data ) return 1L;

	switch ( msg ) 
	{
		case BM_GETCHECK :
		{
			rlt = (data->state) ? BST_CHECKED : BST_UNCHECKED;
		}
		break;

		case BM_SETCHECK :
		{
			data->state = wparam ? BST_CHECKED : BST_UNCHECKED;
			rlt = 0; 
		}
		break;

		case WM_KEYUP: 
		{
			if (wparam != VK_SPACE) break;
		}

		case WM_LBUTTONDBLCLK :
		case WM_LBUTTONDOWN :

			_change_page(hwnd, 0);
			rlt = 0;
			break;

	}
	CallWindowProc( data->old_proc, hwnd, msg, wparam, lparam );
	return rlt;	

}
Ejemplo n.º 4
0
LRESULT 
CALLBACK 
_key_proc(
		HWND   hwnd,
		UINT   msg,
		WPARAM wparam,
		LPARAM lparam
	)
{
	char resolve;
	wchar_t text[500] = { 0 };

	int shift = 0;
	_wnd_data *data = wnd_get_long( hwnd, GWL_USERDATA );

	if ( !data ) return 1L;

	if ( _keyup(msg) || _keydown(msg) ) 
	{
		wchar_t key[100] = { 0 };

		if ( GetKeyState(VK_CONTROL) < 0 )	shift |= MOD_CONTROL;
		if ( GetKeyState(VK_SHIFT) < 0 )	shift |= MOD_SHIFT;
		if ( GetKeyState(VK_MENU) < 0 )		shift |= MOD_ALT;

		resolve = _key_name( wparam, shift, key );
		if ( _keyup(msg) && !resolve ) 
		{
			GetWindowText( hwnd, text, sizeof_w(text) );				
			if ( text[wcslen(text) - 2] == L'+' )
			{
				SetWindowText(hwnd, STR_NULL);
			}
			return 0L;
		}
		if ( !_keyup(msg) && resolve )
		{
			data->vk = MAKELONG(shift, wparam);
		}
		SetWindowText( hwnd, key );
		return 0L;

	}
	CallWindowProc( data->old_proc, hwnd, msg, wparam, lparam );
	return 1L;	

}
Ejemplo n.º 5
0
void __unsub_class(
		HWND hwnd
	)
{
	_wnd_data *data = wnd_get_long( hwnd, GWL_USERDATA );
	int k = 0;

	if ( data )
	{		
		while ( data->dlg[k] && ( data->dlg[k] != HWND_NULL ) )
		{
			DestroyWindow( data->dlg[k] );
			k++;
		}
		free( data );
		SetWindowLongPtr( hwnd, GWL_USERDATA, 0 );
	}
}
Ejemplo n.º 6
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 );
					}
					*/
				}
			}
		}
	}							
}
Ejemplo n.º 7
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;
	}
}
Ejemplo n.º 8
0
INT_PTR 
CALLBACK
_options_dlg_proc(
		HWND	hwnd,
		UINT	message,
		WPARAM	wparam,
		LPARAM	lparam
	)
{
	_ctl_init ctl_chk_general[ ] =
	{
		{ STR_NULL, IDC_AUTO_MOUNT_ON_BOOT,		CONF_AUTOMOUNT_BOOT		},
		{ STR_NULL, IDC_EXPLORER_ON_MOUNT,		CONF_EXPLORER_MOUNT		},
		{ STR_NULL, IDC_CACHE_PASSWORDS,		CONF_CACHE_PASSWORD		},
		{ STR_NULL, IDC_UNMOUNT_LOGOFF,			CONF_DISMOUNT_LOGOFF	},
		{ STR_NULL, IDC_FORCE_UNMOUNT,			CONF_FORCE_DISMOUNT		},
		{ STR_NULL, IDC_WIPE_LOGOFF,			CONF_WIPEPAS_LOGOFF		},
		{ STR_NULL, IDC_AUTO_START,				CONF_AUTO_START			}
	};

	_ctl_init ctl_chk_extended[ ] =
	{
		{ STR_NULL, IDC_HARD_CRYPTO_SUPPORT,	CONF_HW_CRYPTO		},
		{ STR_NULL, IDC_HIDE_FILES,				CONF_HIDE_DCSYS		},
		{ STR_NULL, IDC_DISABLE_TRIM,			CONF_DISABLE_TRIM	},
		{ STR_NULL, IDC_SSD_OPTIMIZATION,		CONF_ENABLE_SSD_OPT	}
	};

	_ctl_init static_head_general[ ] = 
	{
		{ L"# Mount Settings",		IDC_HEAD1, 0 },
		{ L"# Password Caching",	IDC_HEAD2, 0 },
		{ L"# Boot Options",		IDC_HEAD3, 0 }
	};

	_ctl_init static_head_extended[ ] = 
	{
		{ L"# Extended Settings",	IDC_HEAD1, 0 }
	};

	WORD   code             = LOWORD(wparam);
	WORD   id               = LOWORD(wparam);
	DWORD _flags            = 0;
	DWORD _hotkeys[HOTKEYS] = { 0 };

	_wnd_data *wnd;

	int check = 0; 
	int k     = 0;

	switch ( message )
	{
		case WM_INITDIALOG :
		{
			TCITEM     tab_item = { TCIF_TEXT };
			HWND       h_tab    = GetDlgItem( hwnd, IDT_TAB );
			_tab_data *d_tab    = malloc(sizeof(_tab_data));

			wnd = _sub_class(
				h_tab, SUB_NONE,
				CreateDialog( __hinst, MAKEINTRESOURCE(DLG_CONF_GENERAL), GetDlgItem(hwnd, IDC_TAB), _tab_proc ),
				CreateDialog( __hinst, MAKEINTRESOURCE(DLG_CONF_EXTNDED), GetDlgItem(hwnd, IDC_TAB), _tab_proc ),
				CreateDialog( __hinst, MAKEINTRESOURCE(DLG_CONF_HOTKEYS), GetDlgItem(hwnd, IDC_TAB), _tab_proc ),
				HWND_NULL
				);

			memset(d_tab, 0, sizeof(_tab_data));

			d_tab->active = wnd->dlg[0];
			wnd_set_long(hwnd, GWL_USERDATA, d_tab);
			{
				for ( k = 0; k < array_num(ctl_chk_general); k++ )
				{
					_sub_class( GetDlgItem( wnd->dlg[0], ctl_chk_general[k].id ), SUB_STATIC_PROC, HWND_NULL );
					_set_check( wnd->dlg[0], ctl_chk_general[k].id, __config.conf_flags & ctl_chk_general[k].val );
				}
				for ( k = 0; k < array_num(ctl_chk_extended); k++ )
				{
					_sub_class( GetDlgItem( wnd->dlg[1], ctl_chk_extended[k].id ), SUB_STATIC_PROC, HWND_NULL );
					_set_check( wnd->dlg[1], ctl_chk_extended[k].id, __config.conf_flags & ctl_chk_extended[k].val );
				}
				if ( ! (__config.load_flags & DST_HW_CRYPTO) )
				{
					wchar_t s_ch_label[MAX_PATH] = { 0 };

					HWND h_check = GetDlgItem( wnd->dlg[1], IDC_HARD_CRYPTO_SUPPORT );
					EnableWindow( h_check, FALSE );

					GetWindowText( h_check, s_ch_label, sizeof_w(s_ch_label) );
					wcscat( s_ch_label, L" (not supported)" );

					SetWindowText( h_check, s_ch_label );
				}
				for ( k = 0; k < array_num(static_head_general); k++ )
				{
					SetWindowText(GetDlgItem(wnd->dlg[0], static_head_general[k].id), static_head_general[k].display);
					SendMessage(GetDlgItem(wnd->dlg[0], static_head_general[k].id), (UINT)WM_SETFONT, (WPARAM)__font_bold, 0);
				}
				for ( k = 0; k < array_num(static_head_extended); k++ )
				{
					SetWindowText(GetDlgItem(wnd->dlg[1], static_head_extended[k].id), static_head_extended[k].display);
					SendMessage(GetDlgItem(wnd->dlg[1], static_head_extended[k].id), (UINT)WM_SETFONT, (WPARAM)__font_bold, 0);
				}
				SendMessage(
					wnd->dlg[0], WM_USER_CLICK, (WPARAM)GetDlgItem(wnd->dlg[0], IDC_AUTO_START), 0
					);

				_sub_class(
					GetDlgItem(wnd->dlg[2], IDC_KEY_USEEXT), SUB_STATIC_PROC, HWND_NULL
					);

				k = 0;
				while ( hotks_edit[k].id != -1 )
				{
					wchar_t key[200] = { 0 };

					_sub_class(
						GetDlgItem(wnd->dlg[2], hotks_edit[k].id), SUB_KEY_PROC, HWND_NULL
						);

					_sub_class(
						GetDlgItem(wnd->dlg[2], hotks_chk[k].id), SUB_STATIC_PROC, HWND_NULL
						);

					_set_check( wnd->dlg[2], hotks_chk[k].id, __config.hotkeys[k] );
					SendMessage(
						wnd->dlg[2], WM_USER_CLICK, (WPARAM)GetDlgItem(wnd->dlg[2], hotks_chk[k].id), 0
						);

					_key_name(HIWORD( __config.hotkeys[k]), LOWORD(__config.hotkeys[k]), key );
					SetWindowText(GetDlgItem(wnd->dlg[2], hotks_edit[k].id), key);

					((_wnd_data *)wnd_get_long(
						GetDlgItem(wnd->dlg[2], hotks_edit[k].id), GWL_USERDATA)
						)->vk = __config.hotkeys[k];

					k++;
				}
			}
			tab_item.pszText = L"General";
			TabCtrl_InsertItem(h_tab, 0, &tab_item);

			tab_item.pszText = L"Extended";
			TabCtrl_InsertItem(h_tab, 1, &tab_item);

			tab_item.pszText = L"Hot Keys";
			TabCtrl_InsertItem(h_tab, 2, &tab_item);
			{
				k = 1;
				while ( wnd->dlg[k] != 0 )
				{
					ShowWindow( wnd->dlg[k], SW_HIDE );
					k++;
				}
			}
			SetForegroundWindow( hwnd );
			return 1L;
		}
		break;

		case WM_NOTIFY :
		{		
			if ( wparam == IDT_TAB )
			{
				if ( ((NMHDR *)lparam)->code == TCN_SELCHANGE )
				{
					HWND h_tab = GetDlgItem(hwnd, IDT_TAB);

					if ( !_is_curr_in_group(h_tab) )
					{
						_change_page( h_tab, TabCtrl_GetCurSel(h_tab) );
					}
				}
			}
		}
		break;

		case WM_COMMAND :
		{
			/*
			switch (id) 
			{
			case ID_SHIFT_TAB :
			case ID_TAB :
			{
				HWND h_current = GetFocus( );
				HWND h_next    = GetNextDlgTabItem( sheets[index].hwnd, h_current, id == ID_SHIFT_TAB );

				SetFocus( h_next );
			}
			break;
			*/

			if ( (id == IDOK) || (id == IDCANCEL) )
			{
				wnd = wnd_get_long( GetDlgItem(hwnd, IDT_TAB), GWL_USERDATA );
				if ( wnd ) 
				{
					for ( k = 0; k < array_num(ctl_chk_general); k++ )
					{	
						_flags |= _get_check(wnd->dlg[0], ctl_chk_general[k].id) ? ctl_chk_general[k].val : FALSE;
					}
					for ( k = 0; k < array_num(ctl_chk_extended); k++ )
					{	
						_flags |= _get_check(wnd->dlg[1], ctl_chk_extended[k].id) ? ctl_chk_extended[k].val : FALSE;
					}
					k = 0;
					while ( hotks_edit[k].id != -1 )
					{					
						if ( _get_check(wnd->dlg[2], hotks_chk[k].id) )
						{
							_hotkeys[k] = (
								(_wnd_data *)wnd_get_long(GetDlgItem(wnd->dlg[2], hotks_edit[k].id), GWL_USERDATA)
								)->vk;
						}
						k++;
					}
				}
				
				if ( id == IDCANCEL ) check = TRUE;
				if ( id == IDOK ) 
				{
					_unset_hotkeys(__config.hotkeys);	
					check = _check_hotkeys(wnd->dlg[0], _hotkeys);					

					if ( check )
					{
						if ( _hotkeys[3] && !__config.hotkeys[3] ) {
							if (! __msg_w( hwnd, L"Set Hotkey for call BSOD?" ) )
							{
								_hotkeys[3] = 0;
							}
						}
						if ( (_flags & CONF_AUTO_START) != (__config.conf_flags & CONF_AUTO_START) )
						{
							autorun_set(_flags & CONF_AUTO_START);
						}
						__config.conf_flags = _flags;
						memcpy(&__config.hotkeys, &_hotkeys, sizeof(DWORD)*HOTKEYS);

						dc_save_conf(&__config);						

					}
					_set_hotkeys(hwnd, __config.hotkeys, FALSE);

				}
				if ( check )
				{
					EndDialog (hwnd, id);
				}
				return 1L;
			}
		}
		break;

		case WM_DESTROY : 
		{
			wnd = wnd_get_long( GetDlgItem(hwnd, IDT_TAB), GWL_USERDATA );
			if ( wnd )
			{
				for ( k = 0; k < array_num(ctl_chk_general); k++ )
				{
					__unsub_class(GetDlgItem(wnd->dlg[0], ctl_chk_general[k].id));
				}
				for ( k = 0; k < array_num(ctl_chk_extended); k++ )
				{
					__unsub_class(GetDlgItem(wnd->dlg[1], ctl_chk_extended[k].id));
				}
				__unsub_class(GetDlgItem(wnd->dlg[1], IDC_KEY_USEEXT));

				k = 0;
				while ( hotks_edit[k].id != -1 )
				{
					__unsub_class(GetDlgItem(wnd->dlg[2], hotks_edit[k].id));
					__unsub_class(GetDlgItem(wnd->dlg[2], hotks_chk[k].id));
					k++;
				}
			}
			__unsub_class(GetDlgItem(hwnd, IDT_TAB));

		}
		break;

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

}