|
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
|
|
|
|
|
I need some tips on what is the best way to fix this.
I need a way to view a log file in my program.
The log file is in standard ASCII text format.
But problem is that the log file can be 2-300 MB big.
And I don't want to load the whole file into memory.
So I can’t use the standard CEdit.
Anyone know if there exists any controller for this?
Maybe an enhanced read-only CEdit controller that supports what I need?
Someone must have needed to do this before.
Or I need to start coding something my self. If so What’s best way to do it ?
Is it to create a new controller inherited from CEdit and only show the first 100 lines and manipulate the scroll bar to fool the user that there are more to show and when user scrolls down read in the next 100 lines (depends on how much was scrolled ofcourse) from the log file and show that? Any ides and tips are appreciated.
/Mathias
|
|
|
|
|
Are you using 9X? If so, you may want to skip the CEdit entirely - it is limited to 64K of data.
I'd use a custom control, although this is no trivial amount of work. Are there any articles here on CodeProject about this kind of thing?
You can pick your friends, and you can pick your nose, but you can't pick your friend's nose.
|
|
|
|
|
A viewer is easy, editing the file is more awkward.
Simply create a SDI prog with a CScrollView style and the create what was called a virtual view onto the file. The easy way if to create a DWORD array in which you store the position of the start of each line, e.g. read the file and for each line store the start position of each line, makes finding each line easier, when scrolling backwards. Or the old fashioned way write this data to a temporary binary file, which is then used as an index. Remember to display the 1st screen full very quickly
Then when reading the file store "100" lines, i.e. a bit more than a screen full into a CStringArray. You now have the data to display.
This is a bit of a kludge but it solves the problem of stepping backwards through an ASCII file.
There is a cavaet beware of the bug that the max value in a scroll control is 32767, so if you file is > 32767 you need to find the M$ workaround.
I have ued this method for a specialised file viewer and it works very well.
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
A good way to access files that are very large is to use memory mapped files. PJ Naughter has a good class wrapper to handle implementing them. Essentially, the file is mapped into memory and you access it (forwards or backwards) with pointers as if everything were in an array. The operating system handles all of the buffering of data for you.
You can take any section of the file and do with it what you want in any sort of control, and it works for both read-only and writeable files. I have used memory mapped files that are on the order of 600+ MB without difficulty.
Dave
"You can say that again." -- Dept. of Redundancy Dept.
|
|
|
|