Archive for August, 2007

Handling OnCtlColor()

HBRUSH CPlayBackQueryDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);

// TODO: Change any attributes of the DC here

if(nCtlColor == CTLCOLOR_DLG)
{
return gbrushDlgBkGround;
}
else if(nCtlColor == CTLCOLOR_EDIT)
{
pDC->SetTextColor(guiEditTextColor());
pDC->SetBkColor(gclrEditBk);
return gbrEditBk;
}
else if(nCtlColor == CTLCOLOR_STATIC)
{
pDC->SetBkMode(TRANSPARENT);
return gbrBlueRectBk;
}
else
return gbrushDlgBkGround;
// TODO: Return a different brush if the default is not desired
return hbr;
}

Advertisements

Leave a Comment

Handling database

    try
{
CString sConnection;

sConnection.Format(“DRIVER={PostgreSQL ANSI};SERVER=%s;port=%s;DATABASE=%s;UID=%s;PWD=%s;”, gstGlobalValues.pgsqlIP, gstGlobalValues.pgsqlPort, gstGlobalValues.pgsqlUserName, gstGlobalValues.pgsqlUserName, gstGlobalValues.pgsqlPassword );
m_db.OpenEx(sConnection);
}
catch(CDBException *e)
{
MessageBox(“Unable to connect with PostgreSQL.\n\nThe error message from PostgreSQL is \n\n”+e->m_strError,”Error message from PostgreSQL”, MB_ICONINFORMATION);
e->Delete();
EndDialog(IDCANCEL);
return TRUE;
}

{
CRecordset rs(&m_db);
CString sQuery;

sQuery.Format(“select min(tran_date), max(tran_date) from %s;”, frTRANSACTION_TBL);

try
{
rs.Open(AFX_DB_USE_DEFAULT_TYPE, sQuery);

if(rs.GetRecordCount() <= 0)
{
MessageBox(“\nNo test transaction found in database.\t\n”, “Testing not yet done”, MB_ICONEXCLAMATION);
EndDialog(IDCANCEL);
return TRUE;
}

i = 0;
rs.GetFieldValue(i, sQuery);
m_stSysTime1.wYear = atoi(sQuery.Mid(0,4));
m_stSysTime1.wMonth = atoi(sQuery.Mid(5,2));
m_stSysTime1.wDay = atoi(sQuery.Mid(8,2));

i++;
rs.GetFieldValue(i, sQuery);
m_stSysTime2.wYear = atoi(sQuery.Mid(0,4));
m_stSysTime2.wMonth = atoi(sQuery.Mid(5,2));
m_stSysTime2.wDay = atoi(sQuery.Mid(8,2));

rs.Close();
}
catch(CDBException *e)
{
MessageBox(“Unable to fetch test transaction records from PostgreSQL.\n\nThe error message from PostgreSQL is \n\n”+e->m_strError,”Error message from PostgreSQL”, MB_ICONINFORMATION);
e->Delete();
EndDialog(IDCANCEL);
return TRUE;
}

}

Leave a Comment