📄 messagesearch.cpp
字号:
/*****************************************************************************
* Copyright Statement:
* --------------------
* This software is protected by Copyright and the information contained
* herein is confidential. The software may not be copied and the information
* contained herein may not be used or disclosed except with the written
* permission of MediaTek Inc. (C) 2005
*
* BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
* AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
* NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
* SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
* SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
* THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
* NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
* SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
*
* BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
* LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
* AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
* OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
* MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
* WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
* LAWS PRINCIPLES. ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
* RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
* THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
*
*****************************************************************************/
// MessageSearch.cpp : implementation file
//
#include "stdafx.h"
#include "QMMINWSimulator.h"
#include "MessageSearch.h"
#include "limits.h"
#include "OutgoingMessage.h"
IMPLEMENT_DYNAMIC(MessageSearch, CDialog)
MessageSearch::MessageSearch(CWnd* pParent /*=NULL*/)
: CDialog(MessageSearch::IDD, pParent)
{
buffer_for_str = (char*) malloc(20);
}
MessageSearch::~MessageSearch()
{
free(buffer_for_str);
}
void MessageSearch::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_RADIO_MSGID, RdMsgId);
DDX_Control(pDX, IDC_LIST_SERACH_RESULTS, SearchResult);
DDX_Control(pDX, IDC_STATIC_SEARCHBY, static_search_by);
DDX_Control(pDX, IDOK, GoButton);
DDX_Control(pDX, IDC_STATIC_SEARCH_RESULT, static_search_result);
DDX_Control(pDX, IDC_RADIO_MSGNAME, RdMsgName);
DDX_Control(pDX, IDC_BUTTON_CLOSE, close_button);
DDX_Control(pDX, IDC_STATIC_MSGSRCH_ENTER, generic_enter_text);
}
BEGIN_MESSAGE_MAP(MessageSearch, CDialog)
ON_WM_WINDOWPOSCHANGING()
ON_BN_CLICKED(IDOK, OnBnClickedOk)
ON_BN_CLICKED(IDC_RADIO_MSGID, OnBnClickedRadioMsgid)
ON_BN_CLICKED(IDC_RADIO_MSGNAME, OnBnClickedRadioMsgname)
ON_WM_CLOSE()
ON_NOTIFY(NM_DBLCLK, IDC_LIST_SERACH_RESULTS, OnNMDblclkListSerachResults)
ON_BN_CLICKED(IDC_BUTTON_CLOSE, OnBnClickedClose)
END_MESSAGE_MAP()
// MessageSearch message handlers
void MessageSearch::OnBnClickedOk()
{
CString WindowText;
SearchText.GetWindowText(WindowText);
if(WindowText.CompareNoCase(CString(_T(""))))
{
if(RdMsgId.GetCheck())
{
unsigned long msgid = _ttoi(WindowText);
if(msgid < (2*INT_MAX +1))
{
SearchTheMsgId(msgid);
}
else
AfxMessageBox(109);
}
else
{
SearchMsgForText(WindowText);
}
}
else
{
AfxMessageBox(IDS_STRING_ENTER_VALID_STRING);
SearchText.SetFocus();
}
// TODO: Add your control notification handler code here
//OnOK();
}
void MessageSearch::SetTheLibraryIdentifier(HINSTANCE lib_id)
{
library_identifier = lib_id;
}
BOOL MessageSearch::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
RdMsgId.SetCheck (1);
//StaticEnter.SetString( CString("Enter Message ID"));
UpdateData(FALSE);
LoadString(library_identifier,IDS_STRING_MESSAGE_ID,stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
SearchResult.InsertColumn(0,stringID_to_string,LVCFMT_LEFT);
LoadString(library_identifier,IDS_STRING_MESSAGE_NAME,stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
SearchResult.InsertColumn(1,stringID_to_string,LVCFMT_LEFT);
SearchResult.SetColumnWidth(0,125);
SearchResult.SetColumnWidth(1,125);
if(SearchText.GetSafeHwnd() == NULL)
SearchText.SubclassWindow(GetDlgItem(IDC_EDIT_MSGID_OR_MSGNAME)->m_hWnd);
SearchText.SetWindowText(_T(""));
DWORD style = SearchText.GetStyle();
DWORD style1 = style;
style1 |= (ES_NUMBER);
SearchText.ModifyStyle(style,style1);
DWORD ex_style = ListView_GetExtendedListViewStyle(SearchResult.m_hWnd);
::SendMessage(SearchResult.m_hWnd, LVM_SETEXTENDEDLISTVIEWSTYLE,
LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);
LoadString(library_identifier,IDS_STRING_SEARCH_BY,stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
static_search_by.SetWindowText(stringID_to_string);
LoadString(library_identifier,IDS_STRING_BY_ID,stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
RdMsgId.SetWindowText(stringID_to_string);
LoadString(library_identifier,IDS_STRING_BY_NAME,stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
RdMsgName.SetWindowText(stringID_to_string);
LoadString(library_identifier,IDS_STRING_GO,stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
GoButton.SetWindowText(stringID_to_string);
LoadString(library_identifier,IDS_STRING_SRCH_RESULTS,stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
static_search_result.SetWindowText(stringID_to_string);
LoadString(library_identifier,IDS_STRING_ENTER_ID,stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
generic_enter_text.SetWindowText(stringID_to_string);
LoadString(library_identifier,IDS_STRING_CLOSE,stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
close_button.SetWindowText(stringID_to_string);
LoadString(library_identifier,IDS_STRING_DLG_MSG_SRCH,stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
SetWindowText(stringID_to_string);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void MessageSearch::OnBnClickedRadioMsgid()
{
LoadString(library_identifier,IDS_STRING_ENTER_ID,stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
generic_enter_text.SetWindowText(stringID_to_string);
SearchText.SetWindowText(_T(""));
DWORD style = SearchText.GetStyle();
DWORD style1 = style;
style1 |= (ES_NUMBER);
SearchText.ModifyStyle(style,style1);
UpdateData(FALSE);
}
void MessageSearch::OnBnClickedRadioMsgname()
{
LoadString(library_identifier,IDS_STRING_ENTER_NAME,stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
generic_enter_text.SetWindowText(stringID_to_string);
UpdateData(FALSE);
SearchText.SetWindowText(_T(""));
DWORD style = SearchText.GetStyle();
DWORD style1 = style;
style1 &= ~(ES_NUMBER);
SearchText.ModifyStyle(style,style1);
}
void MessageSearch::OnClose()
{
// TODO: Add your message handler code here and/or call default
CDialog::OnClose();
}
void MessageSearch::OnOK()
{
// TODO: Add your specialized code here and/or call the base class
CDialog::OnOK();
}
void MessageSearch::OnNMDblclkListSerachResults(NMHDR *pNMHDR, LRESULT *pResult)
{
int selected_item;
if((selected_item = SearchResult.GetSelectionMark())!=-1)
{
CString SelectedMsgId = SearchResult.GetItemText(selected_item,0);
UINT32 MsgId = _ttoi(SelectedMsgId);
GetParent()->PostMessage(WM_SET_VALUES_IN_DIALOG,MsgId,0);
*pResult = 0;
OnOK();
}
}
void MessageSearch::SearchTheMsgId(UINT32 msgid)
{
SearchResult.DeleteAllItems();
COutgoingMessage * outgoing_msg;
int item_count = 0;
if(cmessagemanager.m_plstOutGoingMsg->GetCount())
{
for(POSITION pos=cmessagemanager.m_plstOutGoingMsg->GetHeadPosition();pos!=NULL;)
{
outgoing_msg = (COutgoingMessage *)cmessagemanager.m_plstOutGoingMsg->GetNext(pos);
if(outgoing_msg->GetMessageId() == msgid)
{
CString WindowText;
SearchText.GetWindowText(WindowText);
SearchResult.InsertItem(item_count,CString(itoa(msgid,buffer_for_str,10)));
SearchResult.SetItemText(item_count,1,outgoing_msg->GetMessageName());
item_count++;
}
}
}
if(!item_count)
{
AfxMessageBox(IDS_STRING_MESSAGE_NOT_FOUND);
}
}
void MessageSearch::SearchMsgForText(CString WindowText)
{
CString strMessageName;
SearchResult.DeleteAllItems();
COutgoingMessage * outgoing_msg;
int item_count = 0;
if(cmessagemanager.m_plstOutGoingMsg->GetCount())
{
for(POSITION pos=cmessagemanager.m_plstOutGoingMsg->GetHeadPosition();pos!=NULL;)
{
outgoing_msg = (COutgoingMessage *)cmessagemanager.m_plstOutGoingMsg->GetNext(pos);
strMessageName = outgoing_msg->GetMessageName();
strMessageName.MakeUpper();
WindowText.MakeUpper();
if(strMessageName.Find(WindowText,0)!= -1)
{
char * buffer = (char*) malloc(10);
SearchResult.InsertItem(item_count,CString(itoa(outgoing_msg->GetMessageId(),buffer,10)));
SearchResult.SetItemText(item_count,1,outgoing_msg->GetMessageName());
item_count++;
}
}
}
if(!item_count)
{
AfxMessageBox(IDS_STRING_MESSAGE_NOT_FOUND);
}
}
BOOL MessageSearch::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message == WM_KEYDOWN)
{
if(pMsg->wParam == VK_RETURN)
{
int selected_item_in_search_results = SearchResult.GetSelectionMark();
if((selected_item_in_search_results !=-1)&&(GetFocus() == (CWnd*)&SearchResult))
{
CString SelectedMsgId = SearchResult.GetItemText(selected_item_in_search_results,0);
UINT32 MsgId = _ttoi(SelectedMsgId);
GetParent()->PostMessage(WM_SET_VALUES_IN_DIALOG,MsgId,0);
OnOK();
return 1;
}
else
{
if(GetFocus() == (CWnd*)&SearchText)
{
OnBnClickedOk();
return 1;
}
else if((GetFocus() == &close_button) || (GetFocus() == &GoButton))
{
return(CDialog::PreTranslateMessage(pMsg));
}
}
}
else if(pMsg->wParam == VK_DOWN)
{
if(GetFocus() == (CWnd*) &RdMsgName)
{
return 1;
}
else
return(CDialog::PreTranslateMessage(pMsg));
}
else if(pMsg->wParam == VK_UP)
{
if(GetFocus() == (CWnd*) &RdMsgId)
{
return 1;
}
else
return(CDialog::PreTranslateMessage(pMsg));
}
else if(pMsg->wParam == VK_ESCAPE)
{
CDialog::OnOK();
return 1;
}
else
return(CDialog::PreTranslateMessage(pMsg));
}
return CDialog::PreTranslateMessage(pMsg);
}
void MessageSearch::OnBnClickedClose()
{
CDialog::OnOK();
// TODO: Add your control notification handler code here
}
void MessageSearch::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos)
{
if (lpwndpos->cx == -1)
if (lpwndpos->cy == -1) // is init time
{
lpwndpos->x = 257; // change here if you want to move left or right the window.
lpwndpos->y = 41; // change here if you want to move top or bottom the window.
CDialog::OnWindowPosChanging(lpwndpos);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -