LRESULT CDebugMemoryView::OnClicked(WORD /*wNotifyCode*/, WORD wID, HWND, BOOL& /*bHandled*/)
{
    switch (wID)
    {
    case IDC_REFRSH_MEM:
        RefreshMemory(true);
        break;
    case IDC_CHK_VADDR:
        RefreshMemory(false);
        break;
    case IDC_DUMP_MEM:
        m_Debugger->Debug_ShowMemoryDump();
        break;
    case IDC_SEARCH_MEM:
        m_Debugger->Debug_ShowMemorySearch();
        break;
    case IDCANCEL:
        EndDialog(0);
        break;
    }
    return FALSE;
}
void CDebugMemoryView::OnAddrChanged( UINT /*Code*/, int /*id*/, HWND /*ctl*/ )
{
	RefreshMemory(false);
}
LRESULT	CDebugMemoryView::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
	m_DataStartLoc = (DWORD)-1;
	m_CompareStartLoc = (DWORD)-1;
	memset(m_CompareData,0,sizeof(m_CompareData));
	memset(m_CompareValid,0,sizeof(m_CompareValid));

	HWND hScrlBar = GetDlgItem(IDC_SCRL_BAR);
	if (hScrlBar) {
		SCROLLINFO si;

		si.cbSize = sizeof(si);
		si.fMask  = SIF_RANGE | SIF_POS | SIF_PAGE;
		si.nMin   = 0;
		si.nMax   = 0xFFFF;
		si.nPos   = 0x8000;
		si.nPage  = 100;
		::SetScrollInfo(hScrlBar,SB_CTL,&si,TRUE);		
	} 

	m_MemAddr.Attach(GetDlgItem(IDC_ADDR_EDIT));
	m_MemAddr.SetDisplayType(CEditNumber::DisplayHex);
	m_MemAddr.SetValue(0x80000000,true,true);

	SendDlgItemMessage( IDC_CHK_VADDR, BM_SETCHECK, BST_CHECKED,0);

	if (m_MemoryList== NULL)
	{
		m_MemoryList = new CListCtrl;
		m_MemoryList->RegisterClass();
	}
	m_MemoryList->SubclassWindow( GetDlgItem( IDC_MEM_DETAILS ) );
	m_MemoryList->ShowHeader(false);
	m_MemoryList->SetSortEnabled(FALSE);
	m_MemoryList->AddColumn( _T( "Address" ), 90 );
	m_MemoryList->AddColumn( _T( "1" ), 20 );
	m_MemoryList->AddColumn( _T( "2" ), 20 );
	m_MemoryList->AddColumn( _T( "3" ), 20 );
	m_MemoryList->AddColumn( _T( "4" ), 20 );
	m_MemoryList->AddColumn( _T( "-" ), 10 );
	m_MemoryList->AddColumn( _T( "5" ), 20 );
	m_MemoryList->AddColumn( _T( "6" ), 20 );
	m_MemoryList->AddColumn( _T( "7" ), 20 );
	m_MemoryList->AddColumn( _T( "8" ), 20 );
	m_MemoryList->AddColumn( _T( "-" ), 10 );
	m_MemoryList->AddColumn( _T( "9" ), 20 );
	m_MemoryList->AddColumn( _T( "10" ), 20 );
	m_MemoryList->AddColumn( _T( "11" ), 20 );
	m_MemoryList->AddColumn( _T( "12" ), 20 );
	m_MemoryList->AddColumn( _T( "-" ), 10 );
	m_MemoryList->AddColumn( _T( "13" ), 20 );
	m_MemoryList->AddColumn( _T( "14" ), 20 );
	m_MemoryList->AddColumn( _T( "15" ), 20 );
	m_MemoryList->AddColumn( _T( "16" ), 35 );
	m_MemoryList->AddColumn( _T( "Memory Ascii" ), 140 );
	::SetWindowLongPtr(m_MemoryList->m_hWnd, GWL_EXSTYLE, WS_EX_CLIENTEDGE);
	RefreshMemory(false);
	int height = m_MemoryList->GetTotalHeight();
	
	RECT MemoryListRect = {0};
	::GetClientRect(GetDlgItem( IDC_MEM_DETAILS ), &MemoryListRect);

	if (height > MemoryListRect.bottom)
	{
		RECT MemoryListWindow = {0};
		GetWindowRect(&MemoryListWindow);
		SetWindowPos(NULL,0,0,MemoryListWindow.right - MemoryListWindow.left,(MemoryListWindow.bottom - MemoryListWindow.top) + (height - MemoryListRect.bottom), SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOZORDER);

		RECT DlgItemRect = {0};
		::GetWindowRect(GetDlgItem( IDC_BORDER ), &DlgItemRect);
		::SetWindowPos(GetDlgItem( IDC_BORDER ), NULL,0,0,DlgItemRect.right - DlgItemRect.left,(DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE);

		::GetWindowRect(GetDlgItem( IDC_MEM_DETAILS ), &DlgItemRect);
		::SetWindowPos(GetDlgItem( IDC_MEM_DETAILS ), NULL,0,0,DlgItemRect.right - DlgItemRect.left,(DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE);

		::GetWindowRect(GetDlgItem( IDC_SCRL_BAR ), &DlgItemRect);
		::SetWindowPos(GetDlgItem( IDC_SCRL_BAR ), NULL,0,0,DlgItemRect.right - DlgItemRect.left,(DlgItemRect.bottom - DlgItemRect.top) + (height - MemoryListRect.bottom), SWP_NOMOVE);
	}
	WindowCreated();
	return TRUE;
}