|
open the resource header file, find the definition for the icons. Give the icon you want the smaller number. The default Icon for an exe is the first icon found (the one with the smallest number).
|
|
|
|
|
You can override PreCreateWindow() to use your custom window class instead of the default...
This example assumes szMyRegisteredWindowClass points to the class name associated with your
"windowClass"
BOOL MyWindowClass::PreCreateWindow(CREATESTRUCT& cs)
{
if( !CBaseWndClass::PreCreateWindow(cs) )
return FALSE;
cs.lpszClass = szMyRegisteredWindowClass;
cs.style = <possible override default window style here>;
cs.dwExStyle = <possible override default extended window style here>;
return TRUE;
}
|
|
|
|
|
Hello,
I want to send mails(with attachments) from my MDI based application.
I got lot of articles from CodeProject regarding MAPI. I choose "David Brooks" article which uses simple MAPI.
Here is my code ...
class CSendFileTo
{
protected:
HWND m_hWndParnt; // Window handle
enum Error {SUCCESS, NO_ATTACHMENT=0x1001, NOT_A_WINDOW, LIB_LOAD_FAILED, GETPROC_FAILED};
// MAPI related data members
HINSTANCE hMAPI;
public:
CSendFileTo();
virtual ~CSendFileTo();
CSendFileTo(HWND hWnd)
{
m_hWndParnt = hWnd;
}
unsigned int SendMail(CString const &strAttachmentFileName,CString const &strSubject=_T(""),CString const &strToAddr=_T(""),CString const &strToName=_T(""),CString const &strBody=_T(""))
{
if (strAttachmentFileName.IsEmpty())
return NO_ATTACHMENT;
if (!m_hWndParnt || !::IsWindow(m_hWndParnt))
return NOT_A_WINDOW;
hMAPI = ::LoadLibraryA(_T("MAPI32.DLL"));
if (!hMAPI)
return LIB_LOAD_FAILED;
ULONG (PASCAL *SendMail)(ULONG, HWND, MapiMessage*, FLAGS, ULONG);
(FARPROC&)SendMail = GetProcAddress(hMAPI, _T("MAPISendMail"));
if (!SendMail)
{
::FreeLibrary(hMAPI);
return GETPROC_FAILED;
}
TCHAR szFileName[_MAX_PATH];
TCHAR szPath[_MAX_PATH];
TCHAR szSubject[_MAX_PATH];
TCHAR szBody[_MAX_PATH];
TCHAR szToName[_MAX_PATH];
TCHAR szToAddr[_MAX_PATH];
strcpy(szFileName, (LPCTSTR)strAttachmentFileName);
strcpy(szPath, (LPCTSTR)strAttachmentFileName);
strcpy(szSubject, (LPCTSTR)strSubject);
strcpy(szBody, (LPCTSTR)strBody);
strcpy(szToAddr, (LPCTSTR)strToAddr);
strcpy(szToName, (LPCTSTR)strToName);
// Setting Attachment Info
MapiFileDesc fileDesc;
ZeroMemory(&fileDesc, sizeof(fileDesc));
fileDesc.nPosition = (ULONG)-1;
fileDesc.lpszPathName = szPath;
fileDesc.lpszFileName = PathFindFileName(szFileName); // Remove the path
// Setting Recepient Info
MapiRecipDesc recpnts;
ZeroMemory(&recpnts, sizeof(recpnts));
recpnts.ulReserved =0;
recpnts.ulRecipClass = 1;
recpnts.lpszName = szToName;
recpnts.lpszAddress = szToAddr;
//Setting the Message Info
MapiMessage message;
ZeroMemory(&message, sizeof(message));
message.lpszSubject = szSubject;
message.nFileCount = 1;
message.nRecipCount = 1;
message.lpszNoteText = szBody;
message.lpRecips = &recpnts;
message.lpFiles = &fileDesc;
int nError = SendMail(0,m_hWndParnt, &message, MAPI_LOGON_UI|MAPI_DIALOG, 0);
if (nError != SUCCESS_SUCCESS && nError != MAPI_USER_ABORT && nError != MAPI_E_LOGIN_FAILURE)
return nError;
::FreeLibrary(hMAPI); // Freeing the DLL handle
return SUCCESS;
}
void ShowError(UINT errCod)
{
if (errCod)
{
CString str;
str.Format("Error: %X", errCod);
AfxMessageBox(str);
}
}
};
// Invoking Send Mail function
void CDefectLinkerDlg::OnButtonSend()
{
CSendFileTo sendTo(this->m_hWnd);
int nError = sendTo.SendMail(m_attachments,strSubject,strURL,strName,strBody);
if(nError != 0)
{
sendTo.ShowError(nError);
}
}
I can run this application. I got the MS Outlook 2000 window and it shows my mail with attachment.
But when I press the "Send" button in Outlook , both my application and the MS
Outlook program is closed.
But that mail is located in my Outbox. But Outlook cannot deliver that meesage ..,I got "Mail delivery failure" error...!
What will be the problem ?
Pls help me...
Thanks in advance
vinsankar
|
|
|
|
|
What return value of sendTo.SendMail
|
|
|
|
|
Hello,
SendMail returns '0' (i.e Sucess)
But the application that calls MAPI closed when I press the "Send" button.
Thanks,
vinsankar
|
|
|
|
|
But when I run your code its working and if click on Send button in Outlook its working and also when I close Outlook it returns to my program I think maybe your problem isnt of this code
|
|
|
|
|
Did your problem solve?
|
|
|
|
|
Hello,
No ...But I overcome that problem by using MS Outlook automation...
I Don't know ...why that Simple MAPI program crashes when using with an MDI app...?
Thanks...& regards...
vinsankar
|
|
|
|
|
I didnt know where's problem I checked your code and it worked fine
|
|
|
|
|
Hello everyone,
I just created a program that use a WIN32 internet APIs, so i found the useful library called WININET.lib and i decided to add some functionalities like changing internet setting and so on, the problem is when i tried to change the username/password using InternetSetOption then calling InternetAttemptConnect function nothing happens (the settings rest in default stat)another questions is how do i change username and password even when the first parameter of InternetSetOption is NULL for example :
InternetSetOption(NULL,INTERNET_OPTION_USERNAME,
lpszUser, strlen(lpszUser)+1);
(change the defaut setting of dial up connection)
I'll be wondered if someone could help or just to post a tutorial for how to use InternetSetOption function (its not enough documented in MSDN for me)
Thank you
Anyone who considers arithmetical methods of producing random numbers is, of course, in a state of sin.
John von Neumann
|
|
|
|
|
Can any body tell me how to include a class from dll in vc++
I just have the my.dll file
and i know about the classes present in it
just give me an idea about how to do this
Sarguna
|
|
|
|
|
One more thing i forgot to mention
i don't have any source file of i know what is the class and the functions present in it
|
|
|
|
|
|
Hello!
i want display an item of context menu, gray and disable. Therefore i call EnableMenuItem function in my code, but it don't work correctly.
what do i do???
<br />
void CMyView::OnContextMenu(CWnd* pWnd, CPoint point) <br />
{<br />
if (WindowFromPoint(point) == GetDlgItem(IDC_LISTCTRL))<br />
{<br />
CMenu MyMenu;<br />
MyMenu.LoadMenu(IDR_LISTMENU);<br />
CMenu *pContextMenu;<br />
pContextMenu = MyMenu.GetSubMenu(0);<br />
if(m_iListIndex == -1)<br />
{<br />
pContextMenu->EnableMenuItem(IDR_MENUITEM1, MF_GRAYED);<br />
}<br />
else<br />
{<br />
<br />
}<br />
<br />
pContextMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_LEFTBUTTON | <br />
TPM_RIGHTBUTTON, point.x, point.y, AfxGetMainWnd());<br />
}<br />
UpdateData(FALSE);<br />
}
Zo.Naderi-Iran
|
|
|
|
|
I test your code its working check if of menu
|
|
|
|
|
|
thank you, that link is useful for me;)
Zo.Naderi-Iran
|
|
|
|
|
Hi ALL
I wrote some code and i dont know why the compiler throw me this error message :
RegistryCall.obj : error LNK2001: unresolved external symbol "private: static class CRegistryCall * CRegistryCall::m_cRegistryCallObject" (?m_cRegistryCallObject@CRegistryCall@@0PAV1@A)
RegistryCall.obj : error LNK2001: unresolved external symbol "private: static bool CRegistryCall::m_bExistObject" (?m_bExistObject@CRegistryCall@@0_NA)
The code :
H file :
class CRegistryCall <br />
{<br />
private:<br />
CRegistryCall();<br />
<br />
public:<br />
static CRegistryCall* CreateInstance();<br />
virtual ~CRegistryCall();<br />
<br />
<br />
private:<br />
static bool m_bExistObject;<br />
static CRegistryCall* m_cRegistryCallObject;<br />
};
Cpp File :
CRegistryCall::CRegistryCall()<br />
{<br />
m_bExistObject = true;<br />
m_cRegistryCallObject = NULL;<br />
}<br />
<br />
CRegistryCall::~CRegistryCall()<br />
{<br />
if(m_bExistObject)<br />
{<br />
m_bExistObject = false;<br />
delete m_cRegistryCallObject;<br />
<br />
}<br />
}<br />
<br />
CRegistryCall* CRegistryCall::CreateInstance()<br />
{<br />
if(!m_bExistObject)<br />
{<br />
m_bExistObject = true;<br />
m_cRegistryCallObject = new CRegistryCall();<br />
}<br />
<br />
return m_cRegistryCallObject;<br />
}
This class need to act as singleTon.
Thanks for any help.
|
|
|
|
|
Yanshof wrote: RegistryCall.obj : error LNK2001: unresolved external symbol "private: static bool CRegistryCall::m_bExistObject" (?m_bExistObject@CRegistryCall@@0_NA)
When you use a static variable in a class you need to initialize it with some value in the .cpp file.(or outside the class) SO for the variables that you are using as static (eg for m_bExistObject) put this line on top of the .cpp file.
bool CRegistryCall::m_bExistObject =true;
and you can do like wise for the other variables too...
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
if u writing in a console application then in the project-- settings options,
set use mfc in a shared dll option. it will work out
|
|
|
|
|
raghuji.rao wrote: if u writing in a console application then in the project-- settings options,
set use mfc in a shared dll option. it will work out
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Yes you need to two lines to your code in cpp file
bool CRegistryCall::m_bExistObject =true;
And also for cRegistryCallObject
|
|
|
|
|
hi all,
I have a CRichEditCtrl created on CView derived class.
After Creating the Rich edit control it's default font is something different than what i want. and it's bold also.
so to chnge the font i am selecting all the data present in control and then
applying new font to it.
but when i paste the data that is not compatible with mine font again i need to select all the data and then apply font on it!!
so my question is that is there any way to change the clipboard data's font
so that my control will receive data in compatible font only..
or is there any way that whatever font i want my rich edit control to have
i should tell it before creation as some parameter..(i think this shouls be the way )
means if i want that my rich edit control should have only this font say "courier new" and it is going to be fix for all it's lifetime then
i should create rich edit that starts with this font only??
if anybody know's please reply..
Thanks and Regards
Harshal shete
|
|
|
|
|
harsha_1234 wrote: is there any way that whatever font i want my rich edit control to have
I have solution for this.....
Declare CFont *c; reference in the class .
If you want if for lifetime
you have to add the following code in OnInitDialog where m_pRichEdit is variable of RichEditCtrl ....
c=new CFont();<br />
c->CreatePointFont(180,"Monotype Corsiva");<br />
m_pRichEdit.SetEventMask(m_pRichEdit.GetEventMask() |ENM_CHANGE);
Then Just make method for RichEditControl Text Change.
Write Following statement in it.
GetDlgItem(IDC_RICHEDIT21)->SetFont(c);
You can take font name as parameter and provide it to the CreatePointFont method of CFont. You will get the desired output.
Hope This will help you.
The secret of life is not enjoyment
but education through experience.
- Swami Vivekananda.
|
|
|
|
|
Hi i Tried this it is applying the font but the boldness of the font is still there i want to disable the boldness also..
|
|
|
|