Ejemplo n.º 1
0
void CIORegView::ChangeCPU(int cpu)
{
	CPU = cpu;

	SendMessage(hRegCombo, CB_RESETCONTENT, 0, 0);
	for (int i = 0; ; i++)
	{
		IOReg reg = IORegs[CPU][i];
		char str[128];

		if (reg.type == ListEnd)
			break;
		else
		switch (reg.type)
		{
		case AllRegs:
			sprintf(str, "* %s", reg.name);
			break;
		case CatBegin:
			sprintf(str, "** %s", reg.name);
			break;
		case MMIOReg:
			sprintf(str, "*** 0x%08X - %s", reg.address, reg.name);
			break;
		}

		SendMessage(hRegCombo, CB_ADDSTRING, 0, (LPARAM)str);
	}
	ChangeReg(0);
}
LRESULT RegisteredUsersDialog::RegisteredUsersDialogProc(UINT uMsg, WPARAM wParam, LPARAM lParam) {
    switch(uMsg) {
        case WM_WINDOWPOSCHANGED: {
            RECT rcParent;
            ::GetClientRect(m_hWndWindowItems[WINDOW_HANDLE], &rcParent);

            ::SetWindowPos(m_hWndWindowItems[CB_FILTER], nullptr, (rcParent.right / 2)+3, (rcParent.bottom - GuiSettingManager::m_iOneLineGB - 3) + GuiSettingManager::m_iGroupBoxMargin,
                rcParent.right - (rcParent.right/2) - 14, GuiSettingManager::m_iEditHeight, SWP_NOZORDER);
            ::SetWindowPos(m_hWndWindowItems[EDT_FILTER], nullptr, 11, (rcParent.bottom - GuiSettingManager::m_iOneLineGB - 3) + GuiSettingManager::m_iGroupBoxMargin, (rcParent.right / 2) - 14, GuiSettingManager::m_iEditHeight, SWP_NOZORDER);
            ::SetWindowPos(m_hWndWindowItems[GB_FILTER], nullptr, 3, rcParent.bottom - GuiSettingManager::m_iOneLineGB - 3, rcParent.right - 6, GuiSettingManager::m_iOneLineGB, SWP_NOZORDER);
            ::SetWindowPos(m_hWndWindowItems[LV_REGS], nullptr, 0, 0, rcParent.right - 6, rcParent.bottom - GuiSettingManager::m_iOneLineGB - GuiSettingManager::m_iEditHeight - 11, SWP_NOMOVE | SWP_NOZORDER);
            ::SetWindowPos(m_hWndWindowItems[BTN_ADD_REG], nullptr, 0, 0, rcParent.right - 4, GuiSettingManager::m_iEditHeight, SWP_NOMOVE | SWP_NOZORDER);

            return 0;
        }
        case WM_COMMAND:
            switch(LOWORD(wParam)) {
                case (BTN_ADD_REG+100): {
                    RegisteredUserDialog::m_Ptr = new (std::nothrow) RegisteredUserDialog();

                    if(RegisteredUserDialog::m_Ptr != nullptr) {
                        RegisteredUserDialog::m_Ptr->DoModal(m_hWndWindowItems[WINDOW_HANDLE]);
                    }

                    return 0;
                }
                case IDC_CHANGE_REG: {
                    ChangeReg();
                    return 0;
                }
                case IDC_REMOVE_REGS:
                    RemoveRegs();
                    return 0;
                case CB_FILTER:
                    if(HIWORD(wParam) == CBN_SELCHANGE) {
                        if(::GetWindowTextLength(m_hWndWindowItems[EDT_FILTER]) != 0) {
                            FilterRegs();
                        }
                    }

                    break;
                case IDOK: { // NM_RETURN
                    HWND hWndFocus = ::GetFocus();

                    if(hWndFocus == m_hWndWindowItems[LV_REGS]) {
                        ChangeReg();
                        return 0;
                    } else if(hWndFocus == m_hWndWindowItems[EDT_FILTER]) {
                        FilterRegs();
                        return 0;
                    }

                    break;
                }
                case IDCANCEL:
                    ::PostMessage(m_hWndWindowItems[WINDOW_HANDLE], WM_CLOSE, 0, 0);
					return 0;
            }

            break;
        case WM_CONTEXTMENU:
            OnContextMenu((HWND)wParam, lParam);
            break;
        case WM_NOTIFY:
            if(((LPNMHDR)lParam)->hwndFrom == m_hWndWindowItems[LV_REGS]) {
                if(((LPNMHDR)lParam)->code == LVN_COLUMNCLICK) {
                    OnColumnClick((LPNMLISTVIEW)lParam);
                } else if(((LPNMHDR)lParam)->code == NM_DBLCLK) {
                    if(((LPNMITEMACTIVATE)lParam)->iItem == -1) {
                        break;
                    }

                    RegUser * pReg = reinterpret_cast<RegUser *>(ListViewGetItem(m_hWndWindowItems[LV_REGS],  ((LPNMITEMACTIVATE)lParam)->iItem));

                    RegisteredUserDialog::m_Ptr = new (std::nothrow) RegisteredUserDialog();

                    if(RegisteredUserDialog::m_Ptr != nullptr) {
                        RegisteredUserDialog::m_Ptr->DoModal(m_hWndWindowItems[WINDOW_HANDLE], pReg);
                    }

                    return 0;
                }
            }

            break;
        case WM_GETMINMAXINFO: {
            MINMAXINFO *mminfo = (MINMAXINFO*)lParam;
            mminfo->ptMinTrackSize.x = ScaleGui(GuiSettingManager::m_Ptr->GetDefaultInteger(GUISETINT_REGS_WINDOW_WIDTH));
            mminfo->ptMinTrackSize.y = ScaleGui(GuiSettingManager::m_Ptr->GetDefaultInteger(GUISETINT_REGS_WINDOW_HEIGHT));

            return 0;
        }
        case WM_CLOSE: {
            RECT rcRegs;
            ::GetWindowRect(m_hWndWindowItems[WINDOW_HANDLE], &rcRegs);

            GuiSettingManager::m_Ptr->SetInteger(GUISETINT_REGS_WINDOW_WIDTH, rcRegs.right - rcRegs.left);
            GuiSettingManager::m_Ptr->SetInteger(GUISETINT_REGS_WINDOW_HEIGHT, rcRegs.bottom - rcRegs.top);

            GuiSettingManager::m_Ptr->SetInteger(GUISETINT_REGS_NICK, (int)::SendMessage(m_hWndWindowItems[LV_REGS], LVM_GETCOLUMNWIDTH, 0, 0));
            GuiSettingManager::m_Ptr->SetInteger(GUISETINT_REGS_PASSWORD, (int)::SendMessage(m_hWndWindowItems[LV_REGS], LVM_GETCOLUMNWIDTH, 1, 0));
            GuiSettingManager::m_Ptr->SetInteger(GUISETINT_REGS_PROFILE, (int)::SendMessage(m_hWndWindowItems[LV_REGS], LVM_GETCOLUMNWIDTH, 2, 0));

            ::EnableWindow(::GetParent(m_hWndWindowItems[WINDOW_HANDLE]), TRUE);
            ServerManager::m_hWndActiveDialog = nullptr;

            break;
        }
        case WM_NCDESTROY: {
            HWND hWnd = m_hWndWindowItems[WINDOW_HANDLE];
            delete this;
            return ::DefWindowProc(hWnd, uMsg, wParam, lParam);
        }
        case WM_SETFOCUS:
            if((UINT)::SendMessage(m_hWndWindowItems[LV_REGS], LVM_GETSELECTEDCOUNT, 0, 0) != 0) {
                ::SetFocus(m_hWndWindowItems[LV_REGS]);
            } else {
                ::SetFocus(m_hWndWindowItems[EDT_FILTER]);
            }

            return 0;
        case WM_ACTIVATE:
            if(LOWORD(wParam) != WA_INACTIVE) {
                ServerManager::m_hWndActiveDialog = m_hWndWindowItems[WINDOW_HANDLE];
            }

            break;
    }

	return ::DefWindowProc(m_hWndWindowItems[WINDOW_HANDLE], uMsg, wParam, lParam);
}