Data [6] acquired display

1. First create a thread during initialization cycle call to find the person information function

InitDialog BOOL (HWND the HWND) 
{ 

    // Register shortcut keys Fl 
    RegisterHotKey (HWND, 1 , 0 , VK_F1); // Note that to fill a hot key identifier, an identifier is to determine when the determination 
    
    // store the read data 
    = g_pPlayerBuffer (PTCHAR) the VirtualAlloc (NULL, 0x1000 , MEM_COMMIT, PAGE_READWRITE); // set the global variable buffer 
    
    return FALSE; 

}

2. Click on the calling thread in perspective when the button.

    Case IDC_BUTTON_VIEW: 

            // create a ThreadProcGetDate thread loop display character information, and parameters are temporarily not to set up a local variable 
            IF (! getThreadID (g_hReadThread)) 
            { 
                g_hReadThread = CreateThread (NULL, 0 , (LPTHREAD_START_ROUTINE) ThreadProcGetDate, (PDWORD) & dwParam , 0 , NULL); 

            } // to see if the thread before running an effective, if not create, if there is skipped, preventing users have been pressing 
        
            BREAK ;

3. Fill to create a function to read a thread

/ * **************************** ************************************************************ * / 
/ *              read the thread function                                                * / 
/ * **************** ************************************************** **** * / 
VOID WINAPI ThreadProcGetDate (DWORD of dwParam) 
{ 
    ZeroMemory (g_pPlayerBuffer, the sizeof stPlayerInfo * 33 is ); // clears a memory 

    the while ( to true ) // by calling the cycle to constantly refresh the character information     
    { 
        FindPlayer (g_ProcessInfo .m_hProcess, g_ProcessInfo.m_dwBaseAddress, g_pPlayerBuffer); // call the function to find the characters
     } 

}

4. The information is read out to the display control, first initializes the control environment

/ * **************************** ********************** * / 
/ *              the ListView initialization                                             * / 
/ * ****************** ************************************************** ** * / 
VOID InitListView (the HWND the hWnd) 
{ 
    // get dialog handle 
    the HWND hListViewCT the GetDlgItem = (the hWnd, IDC_LIST1); // Get a space on the main window of 
    the HWND hListViewT = ; the GetDlgItem (the hWnd, IDC_LIST2)
     // list name 
    PTCHAR the ListName [] = {the TEXT ( " number " ), the TEXT ( " state " ), the TEXT ( " blood" ), The TEXT ( " X " ), the TEXT ( " Y " ), the TEXT ( " Z " )}; 

    // list information 

    LVCOLUMN listInf = {NULL}; 
    listInf.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT; 
    listInf.fmt = LVCFMT_LEFT;   // column heading left alignment 
    listInf.cx = 60 ;   // the width of each column
     // add columns 
    for ( int I = 0 ; I < . 6 ; I ++ ) 
    {     
        listInf.pszText =The ListName [I]; 
        ListView_InsertColumn (hListViewCT, I, & listInf); // macro to the designated control, add a column header 
        ListView_InsertColumn (hListViewT, I, & listInf); 
    } 
    // set the dual buffer 
    DWORD dwSty = ListView_GetExtendedListViewStyle (hListViewCT ); // Gets the control of the current style 
    ListView_SetExtendedListViewStyle (hListViewCT, dwStym | LVS_EX_DOUBLEBUFFER); // set the new style 
    
    dwSty = ListView_GetExtendedListViewStyle (hListViewT); 
    ListView_SetExtendedListViewStyle (hListViewT, dwStym | LVS_EX_DOUBLEBUFFER); // set the new
     // set image 
}

The display on the control

/ * ********************************************** 
** ListView display data 
********************************************** * / 
VOID ListViewPlayerInfo (the HWND the hWnd, PCHAR pPlayerBufferMemory) 
{ 
    // global task information 
    stPlayerInfo pstPlayerBuffer * = (stPlayerInfo * ) pPlayerBufferMemory; 

    // get dialog handle 
    the HWND hListViewCT = the GetDlgItem (the hWnd, IDC_LIST_VIEW_CT); 
    the HWND hListViewT = the GetDlgItem (the hWnd, IDC_LIST_VIEW_T ); 

    // definition of items 
    of LVITEM ListObj = {NULL}; 
    ListObj.mask = LVIF_TEXT;
     // refresh Clear
    ListView_DeleteAllItems(hListViewCT);
    ListView_DeleteAllItems(hListViewT);
    //文本缓存
    TCHAR Buffer[20] = { 0 };
    for (DWORD i = 0; i < 32; i++)
    {
        if (pstPlayerBuffer[i].x == 0 &&
            pstPlayerBuffer[i].y == 0 &&
            pstPlayerBuffer[i].z == 0)
        {
            continue;
        }
        if (pstPlayerBuffer[i].dwCT == 3)                //3=CT阵营 2=T阵营
        {
            swprintf_s(Buffer, 20, TEXT("%d"), i);
            ListObj.iSubItem = 0;
            ListObj.pszText = Buffer;
            ListView_InsertItem(hListViewCT, &ListObj);    //设置序号

            if (pstPlayerBuffer[i].dwHp == 1 || pstPlayerBuffer[i].dwState == 23)
                swprintf_s(Buffer, 20, TEXT("×"));
            else
                swprintf_s(Buffer, 20, TEXT(""));
            ListObj.iSubItem = 1;
            ListObj.pszText = Buffer;
            ListView_SetItem(hListViewCT, &ListObj);    //设置死活状态

            swprintf_s(Buffer, 20, TEXT("%d"), pstPlayerBuffer[i].dwHp);
            ListObj.iSubItem = 2;
            ListObj.pszText = Buffer;
            ListView_SetItem(hListViewCT, &ListObj);    //设置血量

            swprintf_s(Buffer, 20, TEXT("%.2f"), pstPlayerBuffer[i].x);
            ListObj.iSubItem = 3;
            ListObj.pszText = Buffer;
            ListView_SetItem(hListViewCT, &ListObj);    //设置x

            swprintf_s(Buffer, 20, TEXT("%.2f"), pstPlayerBuffer[i].y);
            ListObj.iSubItem = 4;
            ListObj.pszText = Buffer;
            ListView_SetItem(hListViewCT, &ListObj);    //设置y

            swprintf_s(Buffer, 20, TEXT("%.2f"), pstPlayerBuffer[i].z);
            ListObj.iSubItem = 5;
            ListObj.pszText = Buffer;
            ListView_SetItem(hListViewCT, &ListObj);    //设置z
        }
        else
        {
            swprintf_s(Buffer, 20, TEXT("%d"), i);
            ListObj.iSubItem = 0;
            ListObj.pszText = Buffer;
            ListView_InsertItem(hListViewT, &ListObj);    //设置序号

            if (pstPlayerBuffer[i].dwHp == 1 || pstPlayerBuffer[i].dwState == 23)
                swprintf_s(Buffer, 20, TEXT("×"));
            else
                swprintf_s(Buffer, 20, TEXT(""));
            ListObj.iSubItem = 1;
            ListObj.pszText = Buffer;
            ListView_SetItem(hListViewT, &ListObj);    //设置死活状态

            swprintf_s(Buffer, 20, TEXT("%d"), pstPlayerBuffer[i].dwHp);
            ListObj.iSubItem = 2;
            ListObj.pszText = Buffer;
            ListView_SetItem(hListViewT, &ListObj);    //设置血量

            swprintf_s(Buffer, 20, TEXT("%.2f"), pstPlayerBuffer[i].x);
            ListObj.iSubItem = 3;
            ListObj.pszText = Buffer;
            ListView_SetItem(hListViewT, &ListObj);    //设置x

            swprintf_s(Buffer, 20, TEXT("%.2f"), pstPlayerBuffer[i].y);
            ListObj.iSubItem = 4;
            ListObj.pszText = Buffer;
            ListView_SetItem(hListViewT, &ListObj);    //设置y

            swprintf_s(Buffer, 20, TEXT("%.2f"), pstPlayerBuffer[i].z);
            ListObj.iSubItem = 5;
            ListObj.pszText = Buffer;
            ListView_SetItem(hListViewT, ListObj &);    // Set Z 
        } 
    } 
}

 

Guess you like

Origin www.cnblogs.com/hanhandaren/p/11109600.html