|
Use this code:
BOOL CGrapDlg::OnInitDialog()
{
CDialog::OnInitDialog();
AfxBeginThread(PlotAttenuationThread, this);
return TRUE;
}
UINT PlotAttenuationThread(LPVOID pParam)
{
CGraphDlg* pDlg=(CGraphDlg*) pParam;
CWnd* gFrame = (CWnd*)pDlg->GetDlgItem(IDC_GRAPH_FRAME);
CDC* pDC = gFrame->GetDC();
ReleaseDC(pDC);
return 0;
}
A. Riazi
|
|
|
|
|
One problem you should be seeing is that the thread function is not a member function of CGrapDlg so you can't call GetDlgItem.
Also what Dave has posted regarding the use of MFC objects accross threads is a problem that cannot be ignored. There are Technical Notes on MSDN regarding this problem.
"No matter where you go, there your are..." - Buckaoo Banzi
<pete/>
|
|
|
|
|
How change a color of the cell and color of the text in Excel table via OBDC.
CDatabase database;
...
database.OpenEx(sSql,CDatabase::noOdbcDialog)
...
sSql = "CREATE TABLE Station (Train CHAR,Times CHAR,Way NUMBER,Comment CHAR)";
database.ExecuteSQL(sSql);
...
sSql.Format("INSERT INTO Station (Train,Times,Way,Comment) VALUES ('%s','%s',%d,'%s')",sTrain,sTime,iWay,sComment);
database.ExecuteSQL(sSql);
I want that color of this record was red.
// Sorry for my Englsih
|
|
|
|
|
Maybe with ADOX? otherwise, why not use the Excel COM objects?
|
|
|
|
|
It is good. But can you write a simple example how to use it? Or tell me how to do it? Or where can i read this in the internet?
|
|
|
|
|
|
|
Hi,
I remember seeing once an articale that showed how you can send email
from a c++ program.
Any help will be appreciated.
Tahnks
Shay
|
|
|
|
|
For starters try this article, http://www.codeproject.com/internet/zsmtp.asp[^]
From the Internet section on CP, you should be able to find several others.
Chris Meech
"what makes CP different is the people and sense of community, things people will only discover if they join up and join in." Christian Graus Nov 14, 2002.
"AAAAAAAAAHHHHHH!!!!! Those leaks are driving me crazy! How does one finds a memory leak in a garbage collected environment ??! Daniel Turini Nov. 2, 2002.
|
|
|
|
|
Thank you,
That was what I was looking for
Shay
|
|
|
|
|
Hi I'm new to SDI programming so I would need some guidance from you all..
How can I make sure that my window is maximised when I run my application? I keep having to click on the maximise button after I compile and run my project.
Thx
|
|
|
|
|
|
In CMainFrame::PreCreateWindow(), put a ShowWindow(SW_SHOWMAXIMIZED);
~RaGE();
|
|
|
|
|
Ok,
I'm creating a Tree that traverses system drives. Is there a way to automatically refresh removable drives and cdrom drives? Is there a windows message that gets sent out when a new cd or floppy is inserted??
Thanks
Dan Willis
|
|
|
|
|
in your mainframe window do :
/////////////////////////////////////////////////////////////////
// OnDeviceChange
/////////////////////////////////////////////////////////////////
#include <dbt.h>
BOOL CMainFrame::OnDeviceChange (UINT nEventType, DWORD dwData)
{
if (nEventType == DBT_DEVICEARRIVAL)
{
DEV_BROADCAST_HDR * pDevBroadcastHdr = (DEV_BROADCAST_HDR*)dwData;
if (pDevBroadcastHdr->dbch_devicetype == DBT_DEVTYP_VOLUME) // Logical Volume
{
DEV_BROADCAST_VOLUME* pDevBroadcastVolume = (DEV_BROADCAST_VOLUME*)pDevBroadcastHdr;
// on cherche la lettre du nouveau disque
if (pDevBroadcastVolume->dbcv_flags & DBTF_MEDIA)
{
char cVolume;
ULONG unitmask = pDevBroadcastVolume->dbcv_unitmask;
for (int i = 0; i < 26; ++i)
{
if (unitmask & 0x1)
break;
unitmask = unitmask >> 1;
}
cVolume = (i + 'A');
}
}
}
if (nEventType == DBT_DEVICEREMOVECOMPLETE)
{
}
return TRUE;
}
=============================
in your mainfrm.h
afx_msg BOOL OnDeviceChange (UINT nEventType, DWORD dwData);
|
|
|
|
|
in your message map of your MainFrame add also:
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
....
//}}AFX_MSG_MAP
ON_WM_DEVICECHANGE()
_MESSAGE_MAP()
|
|
|
|
|
That did it.
Thanks alot!
Dan Willis
|
|
|
|
|
How to detect that a drive is a DVD ?
The function GetDriveType is not helpful
Thanks
|
|
|
|
|
If you want to detect drive is DVD or CD, first use GetDriveType, then check capacity of disk. CD-ROM takes about 650-700 MB of data. If capacity is more than 700MB, it is a DVD!
A. Riazi
|
|
|
|
|
Search for STORAGE_MEDIA_TYPE. It's an enumeration defined in winioctl.h. I believe this is what you're looking for.
|
|
|
|
|
thanks, this was a good hint.
I have put the solution on the thread
|
|
|
|
|
<br />
#include <Winioctl.h><br />
BOOL CMainFrame::IsItADvd (char cVolume)<br />
{<br />
BOOL bResult = FALSE;<br />
CString sTemp;<br />
GET_MEDIA_TYPES GetMediaTypes;<br />
DWORD dwBytesReturned;<br />
<br />
sTemp.Format ("\\\\.\\%c:", cVolume);<br />
sTemp.MakeUpper ();<br />
HANDLE hDevice = CreateFile(sTemp,GENERIC_READ, FILE_SHARE_READ,NULL, OPEN_EXISTING, 0, NULL);<br />
<br />
if (hDevice == INVALID_HANDLE_VALUE)<br />
return FALSE;<br />
<br />
if (DeviceIoControl(hDevice, IOCTL_STORAGE_GET_MEDIA_TYPES_EX, NULL, 0, (void*)&GetMediaTypes, sizeof (GET_MEDIA_TYPES), &dwBytesReturned, NULL))<br />
bResult = (GetMediaTypes.DeviceType == FILE_DEVICE_DVD);
<br />
CloseHandle (hDevice);<br />
return bResult;<br />
}<br />
|
|
|
|
|
Hello,
Just wondering if there are any math tricks for doing this.. If not does anyone know the best way of doing this?
Given a CString "123".
I need to add each digit in the string.. The sum of this example would be 6 (1+2+3).
The string will always be at least 1 digit and no more than 3 digits.
Any ideas?
Rob
|
|
|
|
|
for (int i=0; i < str.GetLength(); i++
{
char digit = str.GetAt(i);
sum += (digit - '0');
}
-c
WWT2D?
|
|
|
|
|
Thanks. Wrote it a little different but you got me on the right track... THANK YOU,
Rob
|
|
|
|