|
I have created a program using the doc/view architecture, and using CEditView as the view window. When you are typing something, and then save the document, the caret is moved back to the start of the text, and I want to know how to stop this from happening.
I have tried responding to the ON_FILE_SAVE message, and finding the position of the caret with pCaretPoint = CEditView->GetCaretPos() , then calling CDocument::OnFileSave() , and then using CEditView->SetCaretPos(pCaretPos) to set the caret position to its initial position, however I think the caret gets re-set after CDocument::OnFileSave() as this has no effect.
Any help is much appreciated
|
|
|
|
|
I created a resource only dll and have been trying to load it into my project without much luck. The code to load the dll essentially
HINSTANCE m_hinst;
m_hinst = LoadLibrary(name.dll);
Instead of a pointer to the dll, the return value is continually, 0x10000000.
Do I have some dll project settings incorrect, or am I doing something wrong?
|
|
|
|
|
if LoadLibrary() is returning 0x10000000, then 0x10000000 is the "pointer to your dll" aka the dll's load address.
Bikram Singh
I believe we should all pay our tax with a smile. I tried - but they wanted cash.
|
|
|
|
|
|
Any ideas? Is their any way to programmatically have a printer
already selected if you know the name of the printer you want to
print to?
Please, any response any one can give me will be greatly
appreciated.
Sincerely,
Danielle (an overworked graduate student)
|
|
|
|
|
BOOL CMyApp::SetPrinterDevice(LPTSTR pszDeviceName)
{
HANDLE hPrinter;
if (OpenPrinter(pszDeviceName, &hPrinter, NULL) == FALSE)
return FALSE;
DWORD dwBytesReturned, dwBytesNeeded;
GetPrinter(hPrinter, 2, NULL, 0, &dwBytesNeeded);
PRINTER_INFO_2* p2 = (PRINTER_INFO_2*)GlobalAlloc(GPTR,
dwBytesNeeded);
if (GetPrinter(hPrinter, 2, (LPBYTE)p2, dwBytesNeeded,
&dwBytesReturned) == 0)
{
GlobalFree(p2);
ClosePrinter(hPrinter);
return FALSE;
}
ClosePrinter(hPrinter);
HGLOBAL hDevMode = GlobalAlloc(GHND, sizeof(*p2->pDevMode) +
p2->pDevMode->dmDriverExtra);
DEVMODE* pDevMode = (DEVMODE*)GlobalLock(hDevMode);
memcpy(pDevMode, p2->pDevMode, sizeof(*p2->pDevMode) +
p2->pDevMode->dmDriverExtra);
GlobalUnlock(hDevMode);
DWORD drvNameLen = _tcslen(p2->pDriverName);
DWORD ptrNameLen = _tcslen(p2->pPrinterName);
DWORD porNameLen = _tcslen(p2->pPortName);
DWORD devNameSize = sizeof(DEVNAMES) +
(ptrNameLen + porNameLen + drvNameLen + 3)*sizeof(TCHAR);
HGLOBAL hDevNames = GlobalAlloc(GHND, devNameSize);
DEVNAMES* pDevNames = (DEVNAMES*)GlobalLock(hDevNames);
pDevNames->wDriverOffset = sizeof(DEVNAMES)/sizeof(TCHAR);
memcpy((LPTSTR)pDevNames + pDevNames->wDriverOffset,
p2->pDriverName, drvNameLen*sizeof(TCHAR));
pDevNames->wDeviceOffset = (WORD)(pDevNames->wDriverOffset + drvNameLen + 1);
memcpy((LPTSTR)pDevNames + pDevNames->wDeviceOffset,
p2->pPrinterName, ptrNameLen*sizeof(TCHAR));
pDevNames->wOutputOffset = (WORD)(pDevNames->wDeviceOffset + ptrNameLen + 1);
memcpy((LPTSTR)pDevNames + pDevNames->wOutputOffset,
p2->pPortName, porNameLen*sizeof(TCHAR));
pDevNames->wDefault = 0;
GlobalUnlock(hDevNames);
GlobalFree(p2);
m_hDevMode = hDevMode;
m_hDevNames = hDevNames;
return TRUE;
}
Igor Green
http://www.grigsoft.com[^]
Compare It! + Synchronize It! : Files and folders comparison never was easier!
|
|
|
|
|
Hello
I have a question
I am trying to send mail with mapi
I have configured my outlook express and I have an account called TestProfile there.
So I load up mapi like this:
<br />
<br />
LHANDLE session;<br />
MapiMessage *mes;<br />
MapiRecipDesc from;<br />
char messId[512],mname[50],maddr[30],fsubj[50];<br />
HINSTANCE hMAPI;<br />
<br />
<br />
ULONG (PASCAL FAR *mSendMail)(ULONG, ULONG, MapiMessage*, FLAGS, ULONG);<br />
ULONG (PASCAL FAR *mLogoff)(LHANDLE, ULONG, FLAGS, ULONG);<br />
ULONG (PASCAL FAR *mLogon)(ULONG, LPTSTR, LPTSTR, FLAGS, ULONG, LPLHANDLE);<br />
ULONG (PASCAL FAR *mFindNext)(LHANDLE, ULONG, LPTSTR, LPTSTR, FLAGS, ULONG, LPTSTR);<br />
ULONG (PASCAL FAR *mReadMail)(LHANDLE, ULONG, LPTSTR, FLAGS, ULONG, lpMapiMessage FAR *);<br />
ULONG (PASCAL FAR *mFreeBuffer)(LPVOID);<br />
<br />
<br />
hMAPI=LoadLibrary("MAPI32.DLL");<br />
if (hMAPI==NULL)<br />
{<br />
MessageBox(0,"nu exista MAPI.DLL ","ciudat",MB_OK);<br />
}<br />
(FARPROC &)mSendMail=GetProcAddress(hMAPI, "MAPISendMail");<br />
<br />
MessageBox(0,"am ajuns aici","a",MB_OK);<br />
<br />
(FARPROC &)mLogon=GetProcAddress(hMAPI, "MAPILogon");<br />
(FARPROC &)mLogoff=GetProcAddress(hMAPI, "MAPILogoff");<br />
(FARPROC &)mFindNext=GetProcAddress(hMAPI, "MAPIFindNext");<br />
(FARPROC &)mReadMail=GetProcAddress(hMAPI, "MAPIReadMail");<br />
(FARPROC &)mFreeBuffer=GetProcAddress(hMAPI, "MAPIFreeBuffer");<br />
<br />
<br />
if (mLogon==NULL)<br />
{<br />
MessageBox(0,"nu exista functia mlogon ","ciudat",MB_OK);<br />
}<br />
<br />
then I logon to mapi because I understand that you can't send mail if you don't correct me if I am wrong
<br />
<br />
ULONG a;<br />
<br />
a=mLogon(NULL,NULL,NULL,MAPI_NEW_SESSION ,NULL,&session);<br />
switch(a)<br />
{<br />
case MAPI_E_FAILURE:<br />
<br />
MessageBox(0,"One or more unspecified errors occurred during logon. No session handle was returned.","a",MB_OK); <br />
break;<br />
case MAPI_E_INSUFFICIENT_MEMORY: <br />
MessageBox(0,"There was insufficient memory to proceed. No session handle was returned. ","a",MB_OK);<br />
break;<br />
case MAPI_E_LOGIN_FAILURE:<br />
MessageBox(0,"There was no default logon, and the user failed to log on successfully when the logon dialog box was displayed. No session handle was returned. ","a",MB_OK);<br />
break;<br />
<br />
case MAPI_E_TOO_MANY_SESSIONS:<br />
MessageBox(0,"The user had too many sessions open simultaneously. No session handle was returned. ","a",MB_OK);<br />
break;<br />
case MAPI_E_USER_ABORT:<br />
<br />
MessageBox(0,"The user canceled the logon dialog box. No session handle was returned. ","a",MB_OK);<br />
break;<br />
case SUCCESS_SUCCESS:<br />
MessageBox(0,"a mers?!?","ciudat",MB_OK);<br />
break;<br />
<br />
default:<br />
{<br />
MessageBox(0,"m-am dat reaku ","ciudat",MB_OK);<br />
}<br />
<br />
}<br />
<br />
now here is the problem I always end up in the default wich means it is none of the above
This started after I made that outlook account TestProfile
I made it because I read a article on codeproject.com about mapi and it said that I should have one like that and I made one but I still can't send mail not even with the program from that article(compiled source code)
Before I did this MAPI used to log on but I never got to send any mail
It always prompted me if I wanted my mail to be send and I always said yes but I never got to send any mail.
Maby I did something wrong I don't know here is how tryed to send it:
<br />
<br />
mes->ulReserved=0;<br />
mes->lpszSubject=fsubj;<br />
mes->lpszNoteText="bla bla bal";<br />
mes->lpszMessageType=NULL;<br />
mes->lpszDateReceived=NULL;<br />
mes->lpszConversationID=NULL;<br />
mes->flFlags=MAPI_SENT;<br />
mes->lpOriginator->ulReserved=0;<br />
mes->lpOriginator->ulRecipClass=MAPI_ORIG;<br />
mes->lpOriginator->lpszName=mes->lpRecips->lpszName;<br />
mes->lpOriginator->lpszAddress=mes->lpRecips->lpszAddress;<br />
mes->nRecipCount=1;<br />
mes->lpRecips->ulReserved=0;<br />
mes->lpRecips->ulRecipClass=MAPI_TO;<br />
mes->lpRecips->lpszName=mname;<br />
mes->lpRecips->lpszAddress=maddr;<br />
mes->nFileCount=1;<br />
mes->lpFiles=(MapiFileDesc *)malloc(sizeof(MapiFileDesc));<br />
memset(mes->lpFiles, 0, sizeof(MapiFileDesc));<br />
mes->lpFiles->ulReserved=0;<br />
mes->lpFiles->flFlags=NULL;<br />
mes->lpFiles->nPosition=-1;<br />
mes->lpFiles->lpszPathName="D:\a.txt";<br />
mes->lpFiles->lpszFileName="a.txt";<br />
mes->lpFiles->lpFileType=NULL;<br />
mSendMail(session, NULL, mes, NULL, NULL);<br />
<br />
I am running win xp
please help out
thank you for your time
oh, and here is the name of that app I took from codeproject and it did not work for me to send mail with it :
Sending Email using MAPI - A COM DLL
By Aisha Ikram
|
|
|
|
|
Have you tried scaling the code down to something a wee bit smaller? What does the following produce:
HINSTANCE hMAPIInstance = LoadLibrary("MAPI32.DLL");
LPMAPILOGON lpMAPILogon = (LPMAPILOGON) GetProcAddress(hMAPIInstance, "MAPILogon");
LPMAPIRESOLVENAME lpMAPIResolveName = (LPMAPIRESOLVENAME) GetProcAddress(hMAPIInstance, "MAPIResolveName");
LPMAPISENDMAIL lpMAPISendMail = (LPMAPISENDMAIL) GetProcAddress(hMAPIInstance, "MAPISendMail");
LHANDLE lSession;
UINT uResult = (*lpMAPILogon)((UINT) m_hWnd, NULL, NULL, 0, 0, &lSession);
MapiRecipDesc *prMapiRecipient;
uResult = (*lpMAPIResolveName)(lSession, (UINT) m_hWnd, (LPSTR) lpszRecipient, 0, 0, prMapiRecipient);
lpMapiRecipDesc->ulReserved = 0;
lpMapiRecipDesc->ulRecipClass = MAPI_TO;
MapiMessage MapiMsg = {0};
MapiMsg.lpszSubject = (LPSTR) lpszSubject;
MapiMsg.lpszNoteText = (LPSTR) lpszBody;
MapiMsg.nRecipCount = 1;
MapiMsg.lpRecips = prMapiRecipient;
uResult = (*lpMAPISendMail)(lSession, (UINT) m_hWnd, &MapiMsg, 0, 0);
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
hey I scaled it down as much as I could
and it doesn't matter what that returns as long as mapi logon didn't work no?
|
|
|
|
|
me also but I didn`t log in wrote:
hey I scaled it down as much as I could
I've seen worse!
me also but I didn`t log in wrote:
and it doesn't matter what that returns as long as mapi logon didn't work no?
What is the "that" which you are referring to?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I've been searching this topic for quite a while on
the codeproject, however, I can only find the similar
project using .Net in C# or VB.
I'm planning on writing an MP3 ripper, which can read
from CD ,then translate to MP3 format. But the key is,
I'm planning on Win 32 API, not .Net!! And it will be
written in C++.
If you do know a similar project elsewhere, or maybe
even on codeproject, please let me know. However, I
don't think there is one has been written, so you any
one of you who are looking for a topic to write, will you
please consider it?
Thanks.
-----------------------------
C++ without virtual functions is not OO. Programming with classes but without dynamic binding is called "object based", but not "object oriented".
|
|
|
|
|
See these links:
Both of these rock but BASS is newer.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Thanks for your reply. However, the link for
the BASS does not work, would you fix it?
Thanks again.
-----------------------------
C++ without virtual functions is not OO. Programming with classes but without dynamic binding is called "object based", but not "object oriented".
|
|
|
|
|
|
Thanks.
-----------------------------
C++ without virtual functions is not OO. Programming with classes but without dynamic binding is called "object based", but not "object oriented".
|
|
|
|
|
I've filled my list box with alot of file path names, a they ALL are wider than the list box, but the horz scroll bar is still disabled. Why is it disabled, and how to I enable it?
wWw.KruncherInc.cOm - My cool programs
|
|
|
|
|
|
As Joe does not update his CP articles, and the pgh.net URL has not been active in quite some time, I thought I'd provide you with this:
http://flounder.com/hscroll.htm
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I am trying to use GDI+ for the first time and am trying to access each row and column of a jpeg image of 298 X 448 dimension. Is there any function for it or any way to do that?
|
|
|
|
|
Is there a way to show tooltips even on disabled buttons?
|
|
|
|
|
i had a a question like this one i the past but I didn't get the answer I wanted;
I want to know how can I hook a windows function for example
int connect(
SOCKET s,
const struct sockaddr FAR *name,
int namelen
);
and replace it with a function of mine or something like this until I let the program call it like in a firewall.
please help me.
gabby
|
|
|
|
|
There are a few articles here on CodeProject dealing with API hooking.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
i have a project which being planed to pretent API HOOK by other programs.
for instance. I want to use the WINAPI OpenProcess function. But it is easily to Hook by other program by GetModulHandle("Kernel32.dll")...........
so i changed the file name of the "Kernel32.dll" to "myprocess.dll" and put it in my project and i want to use the OpenProcess function in "myprocess.dll" but not in the "Kernel32.dll" anymore
anyone who knows how to do it?
many thanks
|
|
|
|
|
Extreme programming?? What's that? I increasingly hear
people talking about it, but I have no idea what's that
about. If you know, would you share it?
Thanks
-----------------------------
C++ without virtual functions is not OO. Programming with classes but without dynamic binding is called "object based", but not "object oriented".
|
|
|
|
|
|