Click here to Skip to main content
16,005,682 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralExecutable's Name Pin
ShankarPS7-Jun-04 23:30
ShankarPS7-Jun-04 23:30 
GeneralRe: Executable's Name Pin
Member 1624627-Jun-04 23:33
Member 1624627-Jun-04 23:33 
GeneralRe: Executable's Name Pin
ShankarPS8-Jun-04 1:25
ShankarPS8-Jun-04 1:25 
GeneralRe: Executable's Name Pin
Blake Miller9-Jun-04 4:11
Blake Miller9-Jun-04 4:11 
GeneralFail to initialise a CView derived view within a Splitter Window Pin
Seve Ho7-Jun-04 23:13
Seve Ho7-Jun-04 23:13 
GeneralRe: Fail to initialise a CView derived view within a Splitter Window Pin
Seve Ho7-Jun-04 23:50
Seve Ho7-Jun-04 23:50 
GeneralRe: Fail to initialise a CView derived view within a Splitter Window Pin
Andrew Quinn AUS8-Jun-04 0:26
Andrew Quinn AUS8-Jun-04 0:26 
GeneralRe: Fail to initialise a CView derived view within a Splitter Window Pin
Seve Ho8-Jun-04 18:08
Seve Ho8-Jun-04 18:08 
Hi,

I have looked into the #ifdef _DEBUG directives and the RUNTIME_CLASS macros too...But nothing is find to be suspecious, may be I am dull about it.

I attach my code as follows(It may be too longHmmm | :| , but I will attach both .h and .cpp file here... as it might help to find what is wrong), It is the CView derived class which cannot be created at the run-time. Anyone got idea what has happened that my .exe file fail to create the view, please let me know. I have been working on it for 3 days and no progress...Cry | :(( Cry | :(( Cry | :((

For the MPVIEWERView.h,
<br />
// MPVIEWERView.h : interface of the CMPVIEWERView class<br />
//<br />
<br />
<br />
#pragma once<br />
#include "RegularExpression.h"<br />
#include "afxcoll.h"<br />
#include "MPVIEWERDoc.h"<br />
#include ".\InboundRecordArray.h"<br />
#include ".\STATVIEW.h"<br />
<br />
class CMPVIEWERView : public CView<br />
{<br />
protected: // create from serialization only<br />
	CMPVIEWERView();<br />
	DECLARE_DYNCREATE(CMPVIEWERView)<br />
<br />
// Attributes<br />
public:<br />
	CMPVIEWERDoc * GetDocument() const;<br />
<br />
// Operations<br />
public:<br />
<br />
// Overrides<br />
	public:<br />
	virtual void OnDraw(CDC* pDC);  // overridden to draw this view<br />
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);<br />
protected:<br />
	virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);<br />
	virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);<br />
	virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);<br />
<br />
// Implementation<br />
public:<br />
	virtual ~CMPVIEWERView();<br />
#ifdef _DEBUG<br />
	virtual void AssertValid() const;<br />
	virtual void Dump(CDumpContext& dc) const;<br />
#endif<br />
<br />
protected:<br />
<br />
// Generated message map functions<br />
protected:<br />
		//afx_msg void OnTimer(UINT nIDEvent);	// Timer Event<br />
	DECLARE_MESSAGE_MAP()<br />
public:<br />
	afx_msg void OnFileStartlogging();<br />
<br />
	virtual void OnInitialUpdate(void);<br />
<br />
// Threads related functions and variable<br />
	static UINT run(LPVOID p);<br />
	void run();<br />
	volatile BOOL running;<br />
<br />
	void plot(void);<br />
<br />
	void CallbackGrepBlock(RegularExpression * cre, const REMatchInfo & Matches, unsigned LineIndex, unsigned StartOfLine, bool & bcontinue);<br />
	void CallbackGrepInbound(RegularExpression * cre, const REMatchInfo & Matches, unsigned LineIndex, unsigned StartOfLine, bool & bcontinue);<br />
	<br />
	<br />
	CStringArray ipColorArray;	// Array to Store "IP Color"<br />
	CPen CMPVIEWERView::GetColorPen(CString colorCode);<br />
	afx_msg void OnEditOptions();<br />
	int m_MaxLineShown;<br />
	int m_LineSpace;<br />
<br />
	afx_msg void OnUpdateFileStartlogging(CCmdUI *pCmdUI);<br />
<br />
	CString ReadConfig(CString option);<br />
	void WriteConfig(CString option, CString value);<br />
<br />
	void UpdateStatusBarText(CString newStatusText);<br />
<br />
	int blockNum; <br />
	int inboundNum;<br />
	<br />
	CInboundRecordArray inboundRecordArray;<br />
	CSTATVIEW * m_pStatView;<br />
	void SendStartLoggingMsg(void);<br />
	CString systemStr;<br />
	void dumpcall(void);<br />
	void RemoveALine(void);<br />
<br />
	void DrawBitmap( CDC *pDC, HBITMAP hBitmap, HPALETTE hPal, int xDest, int yDest );<br />
<br />
};<br />
<br />
#ifndef _DEBUG  // debug version in MPVIEWERView.cpp<br />
inline CMPVIEWERDoc* CMPVIEWERView::GetDocument() const<br />
   { return reinterpret_cast<CMPVIEWERDoc*>(m_pDocument); }<br />
#endif



For the MPVIEWERView.cpp,

// MPVIEWERView.cpp : implementation of the CMPVIEWERView class<br />
<br />
#include "stdafx.h"<br />
#include "MPVIEWER.h"<br />
#include "MPVIEWERDoc.h"<br />
#include "MPVIEWERView.h"<br />
#include ".\mpviewerview.h"<br />
#include ".\MainFrm.h"<br />
#include ".\STATVIEW.h"<br />
#include <WinSock.h><br />
#include <stdio.h><br />
#include <iostream><br />
#define SERVER_PORT htons(514)    /* Syslogd UDP Port */<br />
<br />
using namespace std;<br />
<br />
#include "RegularExpression.h"<br />
#include <vector><br />
#include <string><br />
#include <sstream><br />
<br />
#include ".\OptionsDlg.h"<br />
#include ".\TokenEx.h"<br />
#include <vector><br />
#include <string><br />
#include <sstream><br />
<br />
#ifdef _DEBUG<br />
#define new DEBUG_NEW<br />
#endif<br />
<br />
<br />
// CMPVIEWERView<br />
<br />
IMPLEMENT_DYNCREATE(CMPVIEWERView, CView)<br />
<br />
BEGIN_MESSAGE_MAP(CMPVIEWERView, CView)<br />
	// Standard printing commands<br />
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)<br />
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)<br />
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)<br />
	ON_COMMAND(ID_FILE_STARTLOGGING, OnFileStartlogging)<br />
	ON_COMMAND(ID_EDIT_OPTIONS, OnEditOptions)<br />
	ON_UPDATE_COMMAND_UI(ID_FILE_STARTLOGGING, OnUpdateFileStartlogging)<br />
END_MESSAGE_MAP()<br />
<br />
// CMPVIEWERView construction/destruction<br />
<br />
CMPVIEWERView::CMPVIEWERView()<br />
: m_MaxLineShown(0)<br />
, m_LineSpace(0)<br />
, blockNum(0)<br />
, inboundNum(0)<br />
, m_pStatView(NULL)<br />
, systemStr(_T(""))<br />
{<br />
	// TODO: add construction code here<br />
	// Variable Initialization<br />
	m_LineSpace = _ttoi(ReadConfig("linespace"));<br />
	m_MaxLineShown = _ttoi(ReadConfig("maxlines"));<br />
	running = FALSE;<br />
	m_pStatView = NULL;<br />
	systemStr.Format("MP Viewer is not running."); <br />
}<br />
<br />
CMPVIEWERView::~CMPVIEWERView()<br />
{<br />
}<br />
<br />
BOOL CMPVIEWERView::PreCreateWindow(CREATESTRUCT& cs)<br />
{<br />
	// TODO: Modify the Window class or styles here by modifying<br />
	//  the CREATESTRUCT cs<br />
	return CView::PreCreateWindow(cs);<br />
}<br />
<br />
// CMPVIEWERView drawing<br />
<br />
void CMPVIEWERView::OnDraw(CDC* pDC)<br />
{<br />
	CMPVIEWERDoc* pDoc = GetDocument();<br />
	ASSERT_VALID(pDoc);<br />
	if (!pDoc)<br />
		return;<br />
	// TODO: add draw code for native data here<br />
	plot();<br />
}<br />
<br />
<br />
// CMPVIEWERView printing<br />
<br />
BOOL CMPVIEWERView::OnPreparePrinting(CPrintInfo* pInfo)<br />
{<br />
	// default preparation<br />
	return DoPreparePrinting(pInfo);<br />
}<br />
<br />
void CMPVIEWERView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)<br />
{<br />
	// TODO: add extra initialization before printing<br />
}<br />
<br />
void CMPVIEWERView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)<br />
{<br />
	// TODO: add cleanup after printing<br />
}<br />
<br />
// CMPVIEWERView diagnostics<br />
<br />
#ifdef _DEBUG<br />
void CMPVIEWERView::AssertValid() const<br />
{<br />
	CView::AssertValid();<br />
}<br />
<br />
void CMPVIEWERView::Dump(CDumpContext& dc) const<br />
{<br />
	CView::Dump(dc);<br />
}<br />
<br />
CMPVIEWERDoc* CMPVIEWERView::GetDocument() const // non-debug version is inline<br />
{<br />
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMPVIEWERDoc)));<br />
	return (CMPVIEWERDoc*)m_pDocument;<br />
}<br />
#endif //_DEBUG<br />
<br />
// CMPVIEWERView message handlers<br />
<br />
void CMPVIEWERView::OnInitialUpdate(void)<br />
{<br />
	CView::OnInitialUpdate();<br />
	<br />
	//SetTimer(TIMER_EXPIREONELINE, 1000, NULL); // Run OnTimer() every 10 second<br />
<br />
}<br />
<br />
UINT CMPVIEWERView::run(LPVOID p) <br />
{<br />
	CMPVIEWERView * me = (CMPVIEWERView *) p;<br />
	me->run();<br />
	return 0;<br />
}<br />
<br />
void CMPVIEWERView::run()<br />
{<br />
	SOCKET				sockfd;<br />
	int					n;<br />
	SOCKADDR_IN			servaddr, cliaddr;<br />
    char				mesg[1024];<br />
    int sin_size = sizeof(struct sockaddr_in);<br />
<br />
	sockfd = socket(AF_INET, SOCK_DGRAM, 0);<br />
	<br />
	servaddr.sin_family      = AF_INET;<br />
	servaddr.sin_addr.s_addr = htonl(INADDR_ANY);<br />
	servaddr.sin_port        = htons(SERVER_PORT);<br />
	memset(&(servaddr.sin_zero), 0, 8);<br />
	if(bind(sockfd, (LPSOCKADDR) &servaddr, sizeof(servaddr))==0) {<br />
		SendStartLoggingMsg();<br />
		systemStr.Format(_T("%s"), COleDateTime::GetCurrentTime().Format(_T("MP Viewer started running since %I: %M: %S %p, %m/%d/%Y")));<br />
		//m_pStatView->lblStart.Format(_T("%s"), COleDateTime::GetCurrentTime().Format(_T("MP Viewer started running since %I: %M: %S %p, %m/%d/%Y")));<br />
		<br />
		m_pStatView->lblStart = CTime::GetCurrentTime();<br />
		m_pStatView->running = TRUE;<br />
<br />
<br />
		plot();		// Force Repaint<br />
<br />
	}<br />
	else {<br />
		MessageBox("Bind operation failed");<br />
	}<br />
<br />
    CString block_str   = "<[0-9]+>([a-zA-Z]+\\s+\\d+ \\d+:\\d+:\\d+) .* ruleset=check_relay, arg1=(.*), arg2=(.*), relay=.*, reject=550 5\\.7\\.1 Rejected: This system is protected by Mail Prove Service, \\d+\\.\\d+\\.\\d+\\.\\d+ is blacklisted\\. Please go to www\\.mailprove\\.com to unblock\\.";<br />
<br />
	CString inbound_str = "<[0-9]+>([a-zA-Z]+\\s+\\d+ \\d+:\\d+:\\d+) .*: .*: from=<(.*)>, size=(\\d+), class=.*, nrcpts=.*, msgid=<.*>, proto=.*, daemon=.*, relay=(.*) \\[(.*)\\]";<br />
	//while(1)<br />
	while (running)<br />
	{<br />
		n = recvfrom(sockfd, mesg, 1024, 0,(LPSOCKADDR) &cliaddr,  &sin_size);<br />
		mesg[n] = '\0';	/* null terminate */	 <br />
		//cout<<"Message Received           :"<<mesg<<endl<<endl<<endl;<br />
		//MessageBox(mesg);<br />
		CFile file("messagelog.txt", CFile::modeWrite);		// Write Message to Log file	    <br />
		file.SeekToEnd();<br />
		file.Write(mesg, n+1);<br />
		file.Write("\r\n", 2);<br />
		file.Close();<br />
<br />
		RegularExpression reo_block;<br />
		__hook(&RegularExpression::OnGrepping, &reo_block, &CMPVIEWERView::CallbackGrepBlock);<br />
		reo_block.Expression = block_str;<br />
		reo_block.StringToMatch = mesg;<br />
		reo_block.Grep();<br />
<br />
		RegularExpression reo_inbound;<br />
		__hook(&RegularExpression::OnGrepping, &reo_inbound, &CMPVIEWERView::CallbackGrepInbound);<br />
		reo_inbound.Expression = inbound_str;<br />
		reo_inbound.StringToMatch = mesg;<br />
		reo_inbound.Grep();<br />
	}<br />
	shutdown(sockfd, SD_BOTH);<br />
	//shutdown(sockfd, 0x02);<br />
	if (closesocket(sockfd) == 0) {<br />
		AfxMessageBox("Closed socket successfully",MB_OK);<br />
		systemStr.Format(_T("%s"), COleDateTime::GetCurrentTime().Format(_T("MP Viewer stopped at %I: %M: %S %p, %m/%d/%Y")));<br />
<br />
		m_pStatView->lblStart = CTime::GetCurrentTime();<br />
		m_pStatView->running = FALSE;<br />
<br />
		plot();		// Force Repaint<br />
	} else {<br />
		AfxMessageBox("Failed to close socket", MB_OK);<br />
	}<br />
<br />
}<br />
void CMPVIEWERView::plot(void)<br />
{<br />
<br />
	CDC * pDC;<br />
	pDC = GetDC();<br />
<br />
	CRect rect;<br />
	GetClientRect(&rect);<br />
<br />
	CBrush NewBrush(RGB(255,255,255));				CBrush * pBrush = pDC->SelectObject(&NewBrush);<br />
<br />
	CRect urect=rect; // Rectangle to update<br />
	pDC->Rectangle(urect);<br />
	pDC->SelectObject(pBrush);<br />
<br />
	CPen pen( PS_SOLID, 0, RGB(255,0,255));<br />
	CPen* pPenOld = pDC->SelectObject(&pen);<br />
	int nMap = pDC->SetMapMode(MM_HIENGLISH);		// Set Paint Unit: 1 = 0.001 inch<br />
<br />
	int x1 = 500;<br />
	int x2 = 3000;<br />
	int y1 = -4000;<br />
	int y2 = -1000;<br />
	<br />
	int red,green,blue = 0;<br />
		<br />
<br />
	CString colorCode;<br />
	CString ip;<br />
	for (int i=0; i<ipColorArray.GetSize(); i++) <br />
	{<br />
		CString ipColor = ipColorArray[i];<br />
		ip = ipColorArray[i];<br />
		ip.Delete(ipColor.GetLength()-1, 1);<br />
<br />
		colorCode = ipColor.Right(1);		// Get Last Character<br />
		y2-=m_LineSpace;<br />
<br />
		if (colorCode.Compare("g") == 0) {<br />
			red = 0; green = 255; blue = 0;<br />
		} else if (colorCode.Compare("r") == 0) {<br />
			red = 255; green = 0; blue = 0;<br />
		} else {<br />
			red = 255; green = 255; blue = 255;<br />
		}<br />
<br />
		CPen pen( PS_SOLID, 0, RGB(red, green, blue));<br />
		pPenOld = pDC->SelectObject(&pen);<br />
		pDC->SetTextColor(RGB(red, green, blue));<br />
		pDC->MoveTo(x1, y1);<br />
		pDC->LineTo(x2, y2);<br />
		pDC->TextOut(x2, y2, ip);<br />
		pDC->TextOut(x2, y2, ip);			<br />
	}<br />
<br />
<br />
		<br />
}<br />
<br />
void CMPVIEWERView::CallbackGrepBlock(RegularExpression* cre, const REMatchInfo & Matches, unsigned LineIndex, unsigned StartOfLine, bool & bcontinue)<br />
{<br />
	std::string whatmatched1(Matches[1].string);<br />
	std::ostringstream sout1;<br />
	sout1 << whatmatched1;<br />
	std::string ws1(sout1.str());<br />
	CString dateTime(ws1.c_str());<br />
<br />
	std::string whatmatched2(Matches[2].string);<br />
	std::ostringstream sout2;<br />
	sout2 << whatmatched2;<br />
	std::string ws2(sout2.str());<br />
	CString relay(ws2.c_str());<br />
	<br />
	std::string whatmatched3(Matches[3].string);<br />
	std::ostringstream sout3;<br />
	sout3 << whatmatched3;<br />
	std::string ws3(sout3.str());<br />
	CString ip(ws3.c_str());<br />
	<br />
	m_pStatView->AddBlockRecord(dateTime, relay, ip);<br />
	m_pStatView->AddBlockListRecord(dateTime, relay, ip);	<br />
<br />
	while (ipColorArray.GetSize() >= m_MaxLineShown) {		// Remove the first elements is size exceeded<br />
		ipColorArray.RemoveAt(0, 1);<br />
	}<br />
	ipColorArray.Add(ip+"r");	// Color for Inbound: (r)ed<br />
<br />
	blockNum++;	// Block Number +1;<br />
	<br />
	plot();<br />
<br />
	CString log_msg = "Blocked " + ip + "\r\n";<br />
	int length = log_msg.GetLength();<br />
	LPCTSTR str = log_msg;<br />
<br />
	CFile file("simplelog.txt", CFile::modeWrite);		<br />
	file.SeekToEnd();<br />
	file.Write(str, length);<br />
	file.Close();<br />
<br />
}<br />
<br />
void CMPVIEWERView::CallbackGrepInbound(RegularExpression* cre, const REMatchInfo & Matches, unsigned LineIndex, unsigned StartOfLine, bool & bcontinue)<br />
{<br />
	std::string whatmatched1(Matches[1].string);<br />
	std::ostringstream sout1;<br />
	sout1 << whatmatched1;<br />
	std::string ws1(sout1.str());<br />
	CString dateTime(ws1.c_str());<br />
<br />
	std::string whatmatched2(Matches[2].string);<br />
	std::ostringstream sout2;<br />
	sout2 << whatmatched2;<br />
	std::string ws2(sout2.str());<br />
	CString email(ws2.c_str());<br />
<br />
	std::string whatmatched3(Matches[3].string);<br />
	std::ostringstream sout3;<br />
	sout3 << whatmatched3;<br />
	std::string ws3(sout3.str());<br />
	CString size(ws3.c_str());<br />
<br />
	std::string whatmatched4(Matches[4].string);<br />
	std::ostringstream sout4;<br />
	sout4 << whatmatched4;<br />
	std::string ws4(sout4.str());<br />
	CString relay(ws4.c_str());<br />
<br />
	std::string whatmatched5(Matches[5].string);<br />
	std::ostringstream sout5;<br />
	sout5 << whatmatched5;<br />
	std::string ws5(sout5.str());<br />
	CString ip(ws5.c_str());<br />
	m_pStatView->AddInboundRecord(dateTime, email, size, relay, ip);<br />
	m_pStatView->AddInboundListRecord(dateTime, email, size, relay, ip);	<br />
<br />
	while (ipColorArray.GetSize() >= m_MaxLineShown) {		// Remove the first elements is size exceeded<br />
		ipColorArray.RemoveAt(0, 1);<br />
	}<br />
	ipColorArray.Add(ip+"g");	// Color for Inbound: (g)reen<br />
	inboundNum++;	// Inbound Number + 1;<br />
<br />
	plot();<br />
<br />
	// Log inbound IP to simplelog.txt<br />
	CString log_msg = "Inbound " + ip + "\r\n";<br />
	int length = log_msg.GetLength();<br />
<br />
	LPCTSTR str = log_msg;<br />
<br />
	CFile file("simplelog.txt", CFile::modeWrite);		// Write Message to Log file	    <br />
	file.SeekToEnd();<br />
	file.Write(str, length);<br />
	<br />
	file.Close();<br />
}<br />
<br />
<br />
void CMPVIEWERView::OnEditOptions()<br />
{<br />
	// TODO: Add your command handler code here<br />
	COptionsDlg dlg;<br />
	if (dlg.DoModal() == IDOK) {<br />
		m_MaxLineShown = dlg.maxLineShown;<br />
		m_LineSpace = dlg.lineSpace;<br />
	}<br />
	CString value;<br />
	value.Format("%i", m_MaxLineShown); <br />
	WriteConfig(_T("maxlines"), _T(value));<br />
	value.Format("%i", m_LineSpace); <br />
	WriteConfig(_T("linespace"), _T(value));<br />
}<br />
<br />
<br />
void CMPVIEWERView::OnFileStartlogging()<br />
{<br />
	// TODO: Add your command handler code here<br />
	//AfxMessageBox("Choose Menu Item: Logging", MB_OK, 0);<br />
<br />
    running = !running;<br />
	if (running) {<br />
		AfxBeginThread(run, this);<br />
	} else {	// Send Empty messages to server to force end connection<br />
		MessageBox("Running is FALSE, Send End Connection Message to Server");<br />
		<br />
		SOCKET sockfd;											<br />
		SOCKADDR_IN servaddr;<br />
		int sin_size = sizeof(struct sockaddr_in);<br />
		<br />
		CString endStr;<br />
		endStr.Format(_T("%s"), COleDateTime::GetCurrentTime().Format(_T("Stop logging at %I: %M: %S %p, %m/%d/%Y")));<br />
<br />
		LPTSTR sendstr = new TCHAR[endStr.GetLength()+1];<br />
		_tcscpy(sendstr, endStr);<br />
<br />
<br />
		//char sendstr[1024] = _T(endStr);<br />
		//int n;<br />
				<br />
		servaddr.sin_family = AF_INET;<br />
		servaddr.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");<br />
		servaddr.sin_port = htons(514);<br />
<br />
		sockfd = socket(AF_INET, SOCK_DGRAM, 0);<br />
<br />
		sendto(sockfd, sendstr, strlen(sendstr), 0, (LPSOCKADDR) &servaddr, sin_size);<br />
<br />
	}<br />
}<br />
<br />
<br />
void CMPVIEWERView::OnUpdateFileStartlogging(CCmdUI *pCmdUI)<br />
{<br />
	// TODO: Add your command update UI handler code here<br />
	if (running == TRUE) {<br />
		pCmdUI->SetText("Stop Logging");<br />
	} else {<br />
		pCmdUI->SetText("Start Logging");<br />
	}<br />
}<br />
<br />
CString CMPVIEWERView::ReadConfig(CString option)<br />
{<br />
	CFile file("config.txt", CFile::modeRead);<br />
	<br />
	ULONGLONG nLen = file.GetLength();<br />
	char* pBuffer = new char[ nLen + 1 ];<br />
	file.Read( pBuffer, nLen );<br />
	pBuffer[ nLen ] = 0;<br />
	CString strTemp = pBuffer;<br />
	delete [] pBuffer;<br />
	file.Close();<br />
<br />
	CTokenEx tok;<br />
	CStringArray lines;<br />
	tok.Split(strTemp, "\n", lines);<br />
<br />
	// Retrieve Config Values<br />
<br />
	for (int i=0; i<lines.GetSize(); i++) {<br />
        lines[i].Trim();<br />
		if (lines[i].Find(option, 0) == 0) {		// Domain<br />
			lines[i].Delete(0, option.GetLength());<br />
			return lines[i].Trim();<br />
		}<br />
	}<br />
	<br />
	return "";<br />
}<br />
<br />
void CMPVIEWERView::WriteConfig(CString option, CString value)<br />
{<br />
<br />
	CFile file_r("config.txt", CFile::modeRead);<br />
	<br />
	ULONGLONG nLen = file_r.GetLength();<br />
	char* pBuffer = new char[ nLen + 1 ];<br />
	file_r.Read( pBuffer, nLen );<br />
	pBuffer[ nLen ] = 0;<br />
	CString strTemp = pBuffer;<br />
	delete [] pBuffer;<br />
	file_r.Close();<br />
<br />
	CTokenEx tok;<br />
	CStringArray lines;<br />
	tok.Split(strTemp, "\n", lines);<br />
<br />
	// Retrieve Config Values<br />
    CFile file_w("config.txt", CFile::modeWrite);<br />
<br />
	for (int i=0; i<lines.GetSize(); i++) {<br />
<br />
		lines[i].Trim();<br />
		lines[i] += "\r\n";<br />
		if (lines[i].Find(option, 0) != 0) {		// Not the option we want to change<br />
			int nLen = lines[i].GetLength(); <br />
			file_w.Write( lines[i], nLen );<br />
		<br />
		} else {<br />
			CString strToWrite;<br />
			strToWrite = option + "    " + value + "\r\n";<br />
			int strToWrite_length = strToWrite.GetLength(); <br />
			file_w.Write( strToWrite, strToWrite_length );<br />
			<br />
		}<br />
	}<br />
<br />
	file_w.Close();<br />
<br />
}<br />
void CMPVIEWERView::SendStartLoggingMsg(void)<br />
{<br />
		SOCKET sockfd;											<br />
		SOCKADDR_IN servaddr;<br />
		int sin_size = sizeof(struct sockaddr_in);<br />
		<br />
		CString startStr;<br />
		startStr.Format(_T("%s"), COleDateTime::GetCurrentTime().Format(_T("Start logging at %I: %M: %S %p, %m/%d/%Y")));<br />
<br />
		LPTSTR sendstr = new TCHAR[startStr.GetLength()+1];<br />
		_tcscpy(sendstr, startStr);<br />
<br />
<br />
		//char sendstr[1024] = _T(endStr);<br />
		//int n;<br />
				<br />
		servaddr.sin_family = AF_INET;<br />
		servaddr.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");<br />
		servaddr.sin_port = htons(514);<br />
<br />
		sockfd = socket(AF_INET, SOCK_DGRAM, 0);<br />
<br />
		sendto(sockfd, sendstr, strlen(sendstr), 0, (LPSOCKADDR) &servaddr, sin_size);<br />
}<br />
<br />
void CMPVIEWERView::dumpcall(void)<br />
{<br />
	MessageBox("CMPVIEWERView's dumpcall"); <br />
}<br />
<br />
void CMPVIEWERView::RemoveALine(void)<br />
{<br />
	if (ipColorArray.GetSize() > 0) {<br />
		ipColorArray.RemoveAt(0, 1);		// Remove oldest line<br />
		plot();<br />
	}<br />
}<br />
<br />
// DrawBitmap	- Draws a bitmap (DDB & DIB section) onto a device<br />
// pDC		- Pointer to a device context<br />
// hBitmap	- Handle of the bitmap<br />
// hPal		- Handle of a logical palette associated with the bitmap<br />
// xDest	- x-coordinate of the upper-left corner of the destination rect<br />
// yDest	- y-coordinate of the upper-left corner of the destination rect<br />
void CMPVIEWERView::DrawBitmap( CDC *pDC, HBITMAP hBitmap, HPALETTE hPal, int xDest, int yDest )<br />
{<br />
	// Get logical coordinates<br />
	BITMAP bm;<br />
	::GetObject( hBitmap, sizeof( bm ), &bm );<br />
	CPoint size( bm.bmWidth, bm.bmHeight );<br />
	pDC->DPtoLP(&size);<br />
<br />
	CPoint org(0,0);<br />
	pDC->DPtoLP(&org);<br />
<br />
	// Create a memory DC compatible with the destination DC<br />
	CDC memDC;<br />
	memDC.CreateCompatibleDC( pDC );<br />
	memDC.SetMapMode( pDC->GetMapMode() );<br />
	<br />
	//memDC.SelectObject( &bitmap );<br />
	HBITMAP hBmOld = (HBITMAP)::SelectObject( memDC.m_hDC, hBitmap );<br />
	<br />
	<br />
	// Select and realize the palette<br />
	if( hPal && pDC->GetDeviceCaps(RASTERCAPS) & RC_PALETTE)<br />
	{<br />
		SelectPalette( pDC->GetSafeHdc(), hPal, FALSE );<br />
		pDC->RealizePalette();<br />
	}<br />
	pDC->BitBlt(xDest, yDest, size.x, size.y, &memDC, org.x, org.y, SRCCOPY);<br />
<br />
	::SelectObject( memDC.m_hDC, hBmOld );<br />
}



Help! I need somebody help!
Would you please help me?
Questionhow to add acess record in thread? Pin
Lido Paul7-Jun-04 21:33
Lido Paul7-Jun-04 21:33 
AnswerRe: how to add acess record in thread? Pin
Hesham Amin7-Jun-04 22:01
Hesham Amin7-Jun-04 22:01 
GeneralRe: how to add acess record in thread? Pin
Lido Paul7-Jun-04 22:47
Lido Paul7-Jun-04 22:47 
GeneralRe: how to add acess record in thread? Pin
Lido Paul7-Jun-04 22:48
Lido Paul7-Jun-04 22:48 
QuestionHow to get the correct data type of table struct&amp;#65311; Pin
utiao7-Jun-04 20:47
utiao7-Jun-04 20:47 
QuestionHow can I get local computer names on Windows 98? Pin
windsock7-Jun-04 20:09
windsock7-Jun-04 20:09 
Questionhow to use RegisterHotKey? Pin
Abhi Lahare7-Jun-04 19:44
Abhi Lahare7-Jun-04 19:44 
AnswerRe: how to use RegisterHotKey? Pin
Mike Dimmick8-Jun-04 1:33
Mike Dimmick8-Jun-04 1:33 
QuestionHow to append software register mechanism? Pin
toowit7-Jun-04 19:38
toowit7-Jun-04 19:38 
AnswerRe: How to append software register mechanism? Pin
Vadim Tabakman7-Jun-04 19:42
Vadim Tabakman7-Jun-04 19:42 
GeneralRe: How to append software register mechanism? Pin
toowit7-Jun-04 20:04
toowit7-Jun-04 20:04 
GeneralRe: How to append software register mechanism? Pin
Vadim Tabakman7-Jun-04 20:19
Vadim Tabakman7-Jun-04 20:19 
GeneralRe: How to append software register mechanism? Pin
toowit7-Jun-04 20:39
toowit7-Jun-04 20:39 
AnswerRe: How to append software register mechanism? Pin
Henry miller8-Jun-04 3:38
Henry miller8-Jun-04 3:38 
Questionhow could I disable Escape the dialog Pin
lonely_life7-Jun-04 19:19
lonely_life7-Jun-04 19:19 
AnswerRe: how could I disable Escape the dialog Pin
Johan Rosengren7-Jun-04 19:27
Johan Rosengren7-Jun-04 19:27 
GeneralRe: how could I disable Escape the dialog Pin
lonely_life7-Jun-04 20:33
lonely_life7-Jun-04 20:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.