|
it is a nice site.
http://www.functionx.com/visualc
|
|
|
|
|
Is it possible to use the tab order set for edit controls in the dialog editor in the program? Is it possible to access an edit box via its tab order?
I can access by the control ID like this:
CWnd* pt;
pt = AfxGetApp()->m_pMainWnd->GetDlgItem(IDC_EDIT1); <-----uses IDC_EDIT1
pt->SetWindowText("AAAAA");
Or I can access a different edit box by an offset to the first ID Like this:
pt = AfxGetApp()->m_pMainWnd->GetDlgItem(IDC_EDIT1 + 8); <----uses IDC_EDIT1 + 8
Or I can set up the IDs in an array, and access like this:
pt = AfxGetApp()->m_pMainWnd->GetDlgItem(IDArray[5]); <----uses ID stored in array
So, this leads me to ask if there is some way to use the tab order defined in the dialog editor to do something similar.
Thanks
|
|
|
|
|
You can iterate through the controls in their tab order with GetNextDlgTabItem()
|
|
|
|
|
The tab order determines what order the controls are placed on the dialog window
by changing the order of the control statements in the dialog resource.
I suppose you could enumerate all the child windows of the dialog with GetTopWindow() and
GetNextWindow() (which would iterate through the controls in reverse tab order) or use
EnumChildWindows(). For each child window, check its class with GetClassName() to see if it's an
edit control. If it's an edit control then process it accodingly.
This seems like a lot of work considering you have full control over which controls are in
the dialog and what all of their IDs are, even if you add or remove controls at runtime. Unless
controls are being added/removed by another process...
If I knew what you are trying to do I could maybe give you a more specific code example
Mark
|
|
|
|
|
Hi all, I was trying to change the application icon through the windows class by changing the icon macros loaded into windows class as shown below, but no matter what icon macro I choose the icon displayed is the application icon from IDI_APPLICATION macro.
<br />
windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
...<br />
...<br />
windowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);<br />
Could please tell how to change the icons by icon macros. Any help would be greatly appriciated.
Thanks
Scody
|
|
|
|
|
if you run this code wcex.hIconSm= LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL); what happens?
From the MSDN
HICON LoadIcon(HINSTANCE hInstance,LPCTSTR lpIconName);
hInstance
[in] Handle to an instance of the module whose executable file contains the icon to be loaded. This parameter must be NULL when a standard icon is being loaded
|
|
|
|
|
Hi WhiteSky,
I have just tried the code as you suggested
<br />
windowClass.cbSize = sizeof(WNDCLASSEX);<br />
windowClass.style = CS_HREDRAW | CS_VREDRAW;<br />
windowClass.lpfnWndProc = WndProc;<br />
windowClass.cbClsExtra = 0;<br />
windowClass.cbWndExtra = 0;<br />
windowClass.hInstance = hInstance;<br />
windowClass.hIcon = LoadIcon(windowClass.hInstance, (LPCTSTR)IDI_WINLOGO);
windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
windowClass.hbrBackground = NULL;
windowClass.lpszMenuName = NULL;
windowClass.lpszClassName = "AeroClass";<br />
windowClass.hIconSm = LoadIcon(windowClass.hInstance, (LPCTSTR)IDI_WINLOGO);<br />
but still the default application icon is displayed. I would like to use standard icon Windows logo to be displayed on my application window, so I was using NULL in my code in the previous posting.
All I want to do is change the icon on my application window to Windows logo using standard icon macro IDI_WINLOGO.
Any help would be greatly appriciated.
Thanks
Scody
|
|
|
|
|
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.
|
|
|
|