示例#1
0
// Set the enabled state of the window
void SetEnable(HWND hWnd, UINT id, bool b)
{
	// Validate arguments
	if (hWnd == NULL)
	{
		return;
	}

	if (b == false)
	{
		if (IsEnable(hWnd, id))
		{
			EnableWindow(DlgItem(hWnd, id), false);
			Refresh(DlgItem(hWnd, id));
		}
	}
	else
	{
		if (IsDisable(hWnd, id))
		{
			EnableWindow(DlgItem(hWnd, id), true);
			Refresh(DlgItem(hWnd, id));
		}
	}
}
示例#2
0
void CSunRaise::OnLClick(UINT nFlags, CPoint point)
{
	if (IsDisable())
		return;

	int x = rand() % 500;
	int y = rand() % 500;
	SetDrawPos(x, y);
}
示例#3
0
//---중요!!! 다이얼로그가 액티브상태가 아니라 그려지 않으면 원래 하위 게임유아이들도 그려지지 않으나,
//---이 브라우저는 윈도우가 뜨는 것이라 꼭 액티브상태를 꺼줘야한다.
//---따라서 cDialog::SetActiveRecursive() 를 사용하라. 
//---void CItemShopDlg::SetActive( BOOL val ) 참고.
void cBrowser::SetActive(BOOL val)
{
	if(IsDisable())
	{
		return;
	}
	
	m_bActive = val;

	if(val)
	{
		// 091221 LUJ, 맵 이동 시 종종 cBrowser의 소멸자 호출 시에
		//			ATL 오류가 발생한다. m_hwndIE가 사용되지 않은
		//			핸들로 나타난다. 오류 빈도를 줄이기 위해 창을
		//			열때에만 창을 생성하도록 수정
		if(0 == m_hwndIE)
		{
			m_hwndIE = CreateWindow(
				"AtlAxWin71",
				"about:blank",
				FULLSCREEN_WITH_BLT == GAMERESRCMNGR->GetResolution().dispType ? WS_POPUP : WS_CHILD,
				int(GetAbsX()),
				int(GetAbsY()),
				GetWidth(),
				GetHeight(),
				_g_hWnd,
				0,
				GetModuleHandle(0),
				0);
			CComPtr<IUnknown> punkIE = 0;

			if(S_OK == AtlAxGetControl(
				m_hwndIE,
				&punkIE))
			{
				m_pWebBrowser = punkIE;
			}
		}

		ShowWindow(
			m_hwndIE,
			SW_SHOW);
	}
	else
	{
		if(m_hwndIE)
		{
			ShowWindow(
				m_hwndIE,
				SW_HIDE);
		}
	}
}
示例#4
0
void CWndMessageBox::OnEnter( UINT nChar )
{
	if( IsDisable() )
		Destroy(); 
}
示例#5
0
文件: WndEdit.cpp 项目: viticm/pap2
//--------------------------------------------------------------------------
//	功能:窗口函数(处理消息)
//--------------------------------------------------------------------------
int KWndEdit::WndProc(unsigned int uMsg, unsigned int uParam, int nParam)
{
	int	nRet = 0;
	if (m_Flag & WNDEDIT_ES_WIN32_WND)
	{
		if (uMsg == WM_KEYDOWN)
			nRet = OnKeyDownWin32(uParam, nParam);
		if (uMsg == WND_M_SET_FOCUS)
			Win32Edit_SetFocus(m_hWin32Wnd, true);
		else if (uMsg == WND_M_KILL_FOCUS)
			Win32Edit_SetFocus(m_hWin32Wnd, false);
		return 0;
	}

	switch(uMsg)
	{
	case WM_LBUTTONDOWN:
	case WM_RBUTTONDOWN:
		if (IsVisible() && Wnd_GetFocusWnd() != (KWndWindow*)this)
		{
			Wnd_SetFocusWnd((KWndWindow*)this);
		}
		else
			nRet = KWndWindow::WndProc(uMsg, uParam, nParam);
		break;
	case WM_IME_CHAR:
	case WM_CHAR:
		if ((m_Flag & WNDEDIT_F_HAVE_FOCUS) && ((m_Style & WND_S_DISABLE) == 0))
		{
			if (InsertChar(uParam))
				UpdateData();
			nRet = 1;
		}
		break;
	case WM_KEYDOWN:
		if (!IsDisable())
			nRet = OnKeyDown(uParam, nParam);
		break;
	case WND_M_SET_FOCUS:
		if (m_pText)
		{
			if (m_Flag & WNDEDIT_ES_IME_AVAILABLE)
			{
				s_Ime.EnableLanguageChange();
				if (s_LastTimeIsIme)
				    s_Ime.OpenIME();
			}

//			m_nCaretPos = m_nTextLen;	//把光标位置设在文本末尾
			m_Flag |= WNDEDIT_F_HAVE_FOCUS;
			m_nCaretTime = 0;

//			CreateCaret(::g_GetMainHWnd(), (HBITMAP)NULL, 2, m_nFontSize);
            m_nCaretX = m_nAbsoluteLeft;
            m_nCaretY = m_nAbsoluteTop;
            SetCaretPos(m_nCaretX, m_nCaretY);
            s_Ime.SetCaretPos(m_nCaretX, m_nCaretY);

//          ShowCaret(::g_GetMainHWnd());
		}
		break;
	case WND_M_KILL_FOCUS:
//        DestroyCaret();

		if (m_Flag & WNDEDIT_ES_IME_AVAILABLE)
			s_LastTimeIsIme = s_Ime.IsIme();
		s_Ime.DisableLanguageChange();
		s_Ime.CloseIME();
		m_Flag &= ~WNDEDIT_F_HAVE_FOCUS;
		break;
	case WM_SYSKEYDOWN:
		if (m_pParentWnd)
			nRet = m_pParentWnd->WndProc(uMsg, uParam, nParam);
		break;
	case WM_MOUSEWHEEL:
		if (!IsDisable())
		{
			int zDelta = GET_Y_LPARAM(uParam);
			if (zDelta != 0)
				nRet = OnKeyDown(zDelta < 0 ? VK_DOWN : VK_UP, 0);
		}
		break;

    case WM_MOVING:
    case WM_MOVE:
    {
        if (m_Flag & WNDEDIT_ES_WIN32_WND)
        {
    	    Win32Edit_UpdateSizePos(m_hWin32Wnd, m_nAbsoluteLeft, m_nAbsoluteTop, m_Width, m_Height);
            break;
        }
    }
	default:
		nRet = KWndWindow::WndProc(uMsg, uParam, nParam);
		break;
	}
	return nRet;
}
示例#6
0
BOOL CCmdDlg::PreTranslateMessage(MSG* pMsg)
{
	CString strCmd;

	if (pMsg->message == WM_KEYDOWN)
	{
		// 屏蔽VK_ESCAPE、VK_DELETE
		if (pMsg->wParam == VK_ESCAPE || pMsg->wParam == VK_DELETE)
			return true;

		if (pMsg->wParam == VK_RETURN && pMsg->hwnd == m_editResult.m_hWnd)
		{
			int	len = m_editResult.GetWindowTextLength();
			CString strText;

			m_editResult.GetWindowText(strText);

			strCmd = strText.GetBuffer() + m_strResult.GetLength();

			strCmd.TrimLeft();
			strCmd.TrimRight();
			strText += _T("\r\n");

			if (0 == strCmd.CompareNoCase(_T("exit")))
			{
				OnBnClickedButtonClose();
				return true;
			}
			else if (0 == strCmd.CompareNoCase(_T("cls")))
			{
				m_strResult = _T("\r\n")+m_strResult.Right(m_strResult.GetLength()-m_strResult.ReverseFind('\n')-1); 
				SetDlgItemText(IDC_EDIT_RESULT,m_strResult);
				return true;
			}
			else
			{
				if (IsDisable(strCmd))
				{
					AfxMessageBox(_T("Don't use the string!"));
				}
				else
				{
					ExecuteShellCommand(m_clientid, strCmd);
					m_editResult.SetSel(-1);
				}
			}
			m_nCurSel = m_editResult.GetWindowTextLength();
		}
		// 限制VK_BACK
		if (pMsg->wParam == VK_BACK && pMsg->hwnd == m_editResult.m_hWnd)
		{
			if (m_editResult.GetWindowTextLength() <= m_strResult.GetLength())
				return true;
			else
			{
				CString strText;
				GetDlgItemText(IDC_EDIT_RESULT,strText);
				strText.Left(strText.GetLength()-1);
				SetDlgItemText(IDC_EDIT_RESULT,strText);
				UpdateData(TRUE);
			}
		}
	}
	// Ctrl没按下
	if (pMsg->message == WM_CHAR && GetKeyState(VK_CONTROL) >= 0)
	{
		int	nSize = m_editResult.GetWindowTextLength();
		m_editResult.SetSel(nSize, nSize);
		// 用户删除了部分内容,改变m_nCurSel
		if (nSize < m_nCurSel)
			m_nCurSel = nSize;
	}

	return __super::PreTranslateMessage(pMsg);
}