BOOL CUBIGraphView::OnEraseBkgnd(CDC* pDC)
{
return false;
//return CView::OnEraseBkgnd(pDC);
}
CMainFrame* pMainFrame = (CMainFrame*)AfxGetMainWnd();
BOOL MoveWindow( HWND hWnd, // handle to window //pMainFrame->m_hWnd,
int X, // horizontal position
int Y, // vertical position
int nWidth, // width
int nHeight, // height
BOOL bRepaint // repaint flag );
GetParentFrame()->SetWindowText(_T("lybra"));
::ShowWindow(pMainFrame->m_hWnd, SW_SHOW); //SW_HIDE
ShellExecute(this->m_hWnd,"open",
"C://Program Files//...//AAA.exe",
"C://xxx.yyy","",SW_SHOW );
void CUBIGraphView::OnUpdateStop(CCmdUI* pCmdUI)
{
if (m_bSchedulerStarted)
pCmdUI->SetCheck(0);
else
{
pCmdUI->SetCheck(1);
pCmdUI->Enable(false);
}
}
atoi()
//Set the extended style for list control
SetProp(m_ListCtrl.GetSafeHwnd(),"SORT_COLUMN",(HANDLE)0);
SetProp(m_ListCtrl.GetSafeHwnd(),"SORT_DIRECTION",(HANDLE)1);
m_ListCtrl.SetExtendedStyle(LVS_EX_GRIDLINES|LVS_EX_FULLROWSELECT);
//Insert column with name
m_ListCtrl.InsertColumn(0, "Device Name", LVCFMT_LEFT, 110, -1);
m_ListCtrl.InsertColumn(1, "User Name", LVCFMT_LEFT, 100, -1);
m_ListCtrl.InsertColumn(2, "User Type", LVCFMT_LEFT, 100, -1);
m_ListCtrl.InsertItem(iDeviceCounter, g_LogItem[i].Device);
m_ListCtrl.SetItemText(iDeviceCounter, 1, g_LogItem[i].User);
m_ListCtrl.SetItemData(iDeviceCounter, iDeviceCounter);
//点亮某一行,如果要多行,多次调用,但在List属性中要把single selection 去掉
m_ListCtrl.SetItemState(iDeviceCounter,
LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
m_ListCtrl.EnsureVisible(iDeviceCounter, FALSE);
void CDeviceListDialog::OnColumnclickDeviceList(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
ListSortCtrl *pListSortCtrl = new ListSortCtrl;
pListSortCtrl->pListCtrl = &m_DeviceListCtrl;
int iSortNum = (int)GetProp(m_DeviceListCtrl.GetSafeHwnd(),"SORT_COLUMN");
int iSortAsc = (int)GetProp(m_DeviceListCtrl.GetSafeHwnd(),"SORT_DIRECTION");
if(iSortNum == pNMListView->iSubItem)
{
iSortAsc = (iSortAsc + 1)%2;
SetProp(m_DeviceListCtrl.GetSafeHwnd(),"SORT_DIRECTION",(HANDLE)iSortAsc);
}
SetProp(m_DeviceListCtrl.GetSafeHwnd(), "SORT_COLUMN", (HANDLE)pNMListView->iSubItem);
pListSortCtrl->bIfAsc = iSortAsc;
pListSortCtrl->iSortedCol = pNMListView->iSubItem;
m_DeviceListCtrl.SortItems(CompareFunc, (LPARAM)pListSortCtrl);
//After sort, the item data has been changed
for(int i = 0; i < m_DeviceListCtrl.GetItemCount(); i++)
m_DeviceListCtrl.SetItemData(i, i);
*pResult = 0;
}
//Callback function to sort ctrl list
int CALLBACK CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
//Callback function to sort the list
ListSortCtrl *pListSortCtrl = (ListSortCtrl*)lParamSort;
CString strItem1 = pListSortCtrl->pListCtrl->GetItemText(lParam1, pListSortCtrl->iSortedCol);
CString strItem2 = pListSortCtrl->pListCtrl->GetItemText(lParam2, pListSortCtrl->iSortedCol);
//Get the number of column
CHeaderCtrl* pHeader = (CHeaderCtrl*)( pListSortCtrl->pListCtrl->GetDlgItem(0) );
int nColumnCount = pHeader->GetItemCount();
if (pListSortCtrl->bIfAsc)
return strcmp(strItem1, strItem2);
else
return strcmp(strItem2, strItem1);
return 0;
}
#include "tlhelp32.h"
BOOL WINAPI SearchProcess(LPSTR ProcessName, PROCESSENTRY32 &pe32)
{
//Search for the process, if the process exists, pe32 store the information
HANDLE hProcessSnap;
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
memset(&pe32, 0, sizeof(pe32));
pe32.dwSize = sizeof(PROCESSENTRY32);
if (Process32First(hProcessSnap, &pe32))
{
do{
if (!strcmpi(pe32.szExeFile, ProcessName))
{
CloseHandle(hProcessSnap);
return true;
}
}
while(Process32Next(hProcessSnap, &pe32));
}
CloseHandle(hProcessSnap);
return false;
}
BOOL TerminateExe(LPSTR ProcessName)
{
//At first make sure the process is still running
PROCESSENTRY32 pe32;
if (SearchProcess(ProcessName, pe32))
{
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, false, pe32.th32ProcessID);
UINT uExitCode = 0;
if (hProcess)
{
TerminateProcess(hProcess, uExitCode);
return true;
}
}
return false;
}
::EnumWindows(EnumWindowsProc, 0) ;
BOOL CALLBACK EnumWindowsProc(HWND hWnd,LPARAM lParam)
{
//Callback proc to enum all the windows to
//HWND hwndViewer = (HWND)lParam;
char lpWinTitle[256];
::GetWindowText(hWnd, lpWinTitle, 256 - 1);
CString strTitle;
strTitle.Format("%s",lpWinTitle);
if(strTitle.Find("Word") != -1)
{
//Wordis running
g_hwndWord = hWnd;
g_pUBIGraphView->m_bWordRunning = true;
//Terminate the enumerating windows process
return false;
}
return true;
}
HANDLE hSubThread;
DWORD SubThreadID;
hSubThread = CreateThread(NULL, 0,
(LPTHREAD_START_ROUTINE)SchedulerThread,
this,
CREATE_SUSPENDED,
&SubThreadID);
SetThreadPriority(hSubThread, THREAD_PRIORITY_NORMAL);
ResumeThread(hSubThread);
CloseHandle(hSubThread);
CPoint pts[4];
pts[0].x = ...; pts[0].y = ...;
......
CRgn rgnRegion;
rgnRegion.CreatePolygonRgn(pts, 4, ALTERNATE);
CPoint point;
point.x = 100; point.y = 200;
if ( rgnRegion.PtInRegion(point) )
{
}