|
That's what I like about answering questions here -- you have to relearn the stuff in order to give accurate answers, even when you get to the basics.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
VC++ spews at ^^
if( aCurrCPA[ref_c] ^^ aCurrCPA[temp_c] )
produces this error
D:\Pete\Capture\vss\Tracker.cpp(208) : error C2059: syntax error : '^'
is it non-standard C?
|
|
|
|
|
GEEK OUT ALERT!!!!
XOR via AND and OR:
(a & !b) | (b & !a)
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Shouldn't it be
(a & ~b) | (b & ~a) not to mix logical and bitwise operators?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
so for a logical operator this should work
(bool1 && !bool2) || (bool2 && !bool1)
right?
Thanks for the super-fast answers, BTW
|
|
|
|
|
In fact, if we want get all clever about it we could use
#define XOR( a, b ) ((a) && !(b)) || ((b) && !(a))
|
|
|
|
|
template <class T>
T XOR(const T val1, const T val2)
{
return ( ((val1)&(~val2)) | ((~val1)&(val2)) );
}
Hope that I am correct!
"Dirty hands lead to important discovery..." - Thomas Edison
|
|
|
|
|
For this to work, the class used has to implement the operators &,| and ~.
Otherwise you get comile errors (right?)
Good Luck,
Bill
|
|
|
|
|
This is more efficient (maximum number of evaluations is 2, in the previous formula it is 4)
bool1?!bool2:bool2
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
nice
|
|
|
|
|
But that isn't done with AND and ORs.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
So much stuff from such a little subject
Another advantage of a?!b:b with respect to (a&&!b)||(!a&&b) is that the former does not have the "double evaluation" problem of the latter, which is important if one plans to make a macro out of it.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
My version works better for circuits
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
If you're doing TTL (which means only NANDs and negators), I think this is the way to go (my electronics are a little rusty, nevertheless, I could be wrong)
(a NAND !b) NAND (!a NAND b)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Yes that is logically the same thing. And since NAND is the primitive circuit that version is better.
Damn you Joaquin!!!!
(I just looked up half-adder in google and posted the first one I found.)
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
brilliant. you are a genius. damn i am still cursing myself for reaching this post and not thinking of it.
god... only a couple of hours here and i already love this site.
impuzible
|
|
|
|
|
Yup...
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Hello,
I want to access the Main dialog because of my program structure:
I have one dialog that has to be able to write data in two other dialogs.
All those three dialogs are used as controls of the main dialog.
Moreover, one of those dialogs has included two property sheets that need to send information to those other dialogs too.
I want to be able to access them and I've thought in those methods below:
----------------------------------------------
1)
Create a member function in the Application class that returns a pointer to the main dialog.
This allows me to use an extern call to the App object and to get directly the right type (returned from the function):
extern CMyApp MyApp;
MyApp.GetMainDialogPointer();
----------------------------------------------
2)
Get the main Window using AfxGetMainWnd():
((CMyMainDialog *)AfxGetMainWnd())->...
This is not the method I would like to use because of the fact that I need to use a type modifier each time I need to use the main dialog.
----------------------------------------------
3) Sending messages to the MainWindow and use the handler of those messages to interpret the parameters and to pass them to the right dialog?
----------------------------------------------
4)???
I don't know how to do it, do you know any other better method?
I'm sure that there is another method that could allow me to do that.
----------------------------------------------
As always thank you very much.
|
|
|
|
|
I think the better way is to use Doc/View architechture support,so if you use FormView then you can access it easily from every where.
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|
There's a myriad of ways to achieve that. For one, create a member variable m_pMainDlg in CMyApp of type CMyMainDialog * . Set this member appropriately in CMyApp::OnInitInstance . Now these two little helpers get you that pointer from anywhere:
CMyApp * GetMyApp()
{
return static_cast<CMyApp *>(AfxGetApp());
}
CMyMainDialog * CMyApp::GetMyMainDialog() const
{
return m_pMainDlg;
} To access the main dialog, use GetMyApp()->GetMyMainDialog() .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
dear all,
is any one know send a mail by using MFC programme?
thanks in advance..
|
|
|
|
|
did you try searching this site???
try searching for MAPI or SMTP
-c
Smaller Animals Software, Inc.
You're the icing - on the cake - on the table - at my wake. Modest Mouse
|
|
|
|
|
All MFC apps have this built in (for sedning the active document), although it doesnt tend to work the way you want. For a quick test add a menu item with the id of ID_FILE_SEND_MAIL. The problems I found with the standard implementation is that if your document is modified then it gets saved as a temporary file (with a .tmp extension) and then sent attached to the e-mail at that point. I re-wrote the function based on the default CDocument::OnFileSendMail as follows. Its a bit tricky as it handles multiple attachments etc, but if you need to use it, it will get you going a lot quicker.
[edit]
If you want the example code, mail me, I removed it to keep the forum speed up
Alctuall, I tried to remove it several times. If its still here, its a forum bug
[/edit]
Roger Allen
Sonork 100.10016RemoveTemp = TRUE;
m_sending_as_attachment = FALSE ;
// restore the original filename
if (DatasetType == TYPE_DATASET)
{
pntr->m_Filename = old_filename ;
pntr->m_Path = old_path ;
}
else
{
mpntr->m_Filename = old_filename ;
mpntr->m_Path = old_path ;
}
SetPathName(old_path + "\\" + old_filename, FALSE) ;
}
else
{
// use actual file since it isn't modified
lstrcpyn(szTempName, m_strPathName, _countof(szTempName));
}
#ifdef _UNICODE
char szTempNameA[_MAX_PATH];
_wcstombsz(szTempNameA, szTempName, _countof(szTempNameA));
#endif
// build an appropriate title for the attachment
TCHAR szTitle[_MAX_PATH];
if (!m_strPathName.IsEmpty())
AfxGetFileName(m_strPathName, szTitle, _countof(szTitle));
else
{
lstrcpyn(szTitle, m_strTitle, _countof(szTitle));
if (m_strTitle.Find('.') == -1) // no extension
{
// append the default suffix if there is one
CString strExt;
CDocTemplate* pTemplate = GetDocTemplate();
if (pTemplate != NULL &&
pTemplate->GetDocString(strExt, CDocTemplate::filterExt))
{
lstrcat(szTitle, strExt);
}
}
}
#ifdef _UNICODE
char szTitleA[_MAX_PATH];
_wcstombsz(szTitleA, szTitle, _countof(szTitleA));
#endif
// prepare the file description (for the attachment)
MapiFileDesc *fileDesc;
int num_attachments = 1 ;
if (DatasetType == TYPE_DATASET)
{
// single atatchment
fileDesc = new MapiFileDesc ;
}
else
{
// MultiSets need to also attach each of th sets in the m_ultiSet
fileDesc = new MapiFileDesc[1 + mpntr->no_in_use] ;
num_attachments = 1 + mpntr->no_in_use ;;
}
memset(fileDesc, 0, sizeof(MapiFileDesc) * num_attachments);
fileDesc[0].nPosition = (ULONG)-1;
char szPathAM[MAX_DATASETS_PER_MULTI][_MAX_PATH];
char szTitleAM[MAX_DATASETS_PER_MULTI][_MAX_PATH];
#ifdef _UNICODE
fileDesc[0].lpszPathName = szTempNameA;
fileDesc[0].lpszFileName = szTitleA;
#else
fileDesc[0].lpszPathName = szTempName;
fileDesc[0].lpszFileName = szTitle;
#endif
// setup the multiset bits in the fileDesc structure
if (DatasetType == TYPE_MULTISET)
{
for (int i = 0 ; i < mpntr->no_in_use ; i++)
{
fileDesc[i + 1].nPosition = (ULONG)-1 ;
#ifdef _UNICODE
CString temp_string ;
temp_string = mpntr->pntr[i]->m_Path + "\\" + mpntr->pntr[i]->m_Filename ;
_wcstombsz(szPathAM[i], temp_string, _countof(temp_string));
_wcstombsz(szTitleAM[i], mpntr->pntr[i]->m_Filename, _countof(mpntr->pntr[i]->m_Filename));
fileDesc[i + 1].lpszPathName = szPathAM[i] ;
fileDesc[i + 1].lpszFileName = szTitleAM[i] ;
#else
sprintf(szPathAM[i], "%s\\%s", mpntr->pntr[i]->m_Path, mpntr->pntr[i]->m_Filename) ;
sprintf(szTitleAM[i], "%s", mpntr->pntr[i]->m_Filename) ;
fileDesc[i + 1].lpszPathName = szPathAM[i] ;
fileDesc[i + 1].lpszFileName =szTitleAM[i] ;
#endif
}
}
// prepare the message (empty with 1 attachment)
MapiMessage message;
memset(&message, 0, sizeof(message));
message.nFileCount = num_attachments;
message.lpFiles = fileDesc;
// prepare for modal dialog box
AfxGetApp()->EnableModeless(FALSE);
HWND hWndTop;
CWnd* pParentWnd = CWnd::GetSafeOwner(NULL, &hWndTop);
// some extra precautions are required to use MAPISendMail as it
// tends to enable the parent window in between dialogs (after
// the login dialog, but before the send note dialog).
pParentWnd->SetCapture();
::SetFocus(NULL);
pParentWnd->m_nFlags |= WF_STAYDISABLED;
int nError = lpfnSendMail(0, (ULONG)pParentWnd->GetSafeHwnd(),
&message, MAPI_LOGON_UI|MAPI_DIALOG, 0);
// after returning from the MAPISendMail call, the window must
// be re-enabled and focus returned to the frame to undo the workaround
// done before the MAPI call.
::ReleaseCapture();
pParentWnd->m_nFlags &= ~WF_STAYDISABLED;
pParentWnd->EnableWindow(TRUE);
::SetActiveWindow(NULL);
pParentWnd->SetActiveWindow();
pParentWnd->SetFocus();
if (hWndTop != NULL)
::EnableWindow(hWndTop, TRUE);
AfxGetApp()->EnableModeless(TRUE);
if (nError != SUCCESS_SUCCESS &&
nError != MAPI_USER_ABORT && nError != MAPI_E_LOGIN_FAILURE)
{
AfxMessageBox(AFX_IDP_FAILED_MAPI_SEND);
}
delete []fileDesc ;
// remove temporary file, if temporary file was used
if (bRemoveTemp)
CFile::Remove(szTempName);
// TODO: Add your command handler code here
//CDocument::OnFileSendMail() ;
}
Roger Allen
Sonork 100.10016
If I'm not breathing, I'm either dead or holding my breath.
A fool jabbers, while a wise man listens. But is he so wise to listen to the fool?
|
|
|
|
|
Check out function CDocument::OnFileSendMail in MFC source code.
|
|
|
|
|
Check this
Mazy
"So,so you think you can tell,
Heaven from Hell,
Blue skies from pain,...
How I wish,how I wish you were here." Wish You Were Here-Pink Floyd-1975
|
|
|
|
|