|
Simple MAPI is a very simple (as its name suggests) API for e-messaging. This API will use whenever messaging application that is registered as the "predetermined messaging application". If that happens to be the case in your target machines, then go search some Simple MAPI sample on the net (lots of them, for one without MFC dependencies, check Xiangyang Liu's article Sending and receiving e-mails from your program[^]).
To determine (non-programmatically) whether Outlook Express is the default messaging app, open it, go to Tools -> Options and look for a checkbox labeled "Outlook Express as predetemined Simple MAPI client".
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I am attempting to upgrade an application written for Windows 3.1 platform. It was originally developed using Borland C++ 4.5 and TurboPower Software's Data Entry Workshop 2.0. I am unfamilar with programming applications for Win 3.1 as I started learning on Win95. If all of the source code is available, is there a simple process of migrating it over to run on Win95/98/2000? Thanks in advance.
Rich
|
|
|
|
|
I'm afraid you have no other choice but to do it manually. The process ranges from moderately simple to almost impossible, depending on the complexity of the program and the libraries it depends on. In your case, I guess the TurboPower library will pose the most difficulties. MSDN provides very good porting tips in the article Porting 16-Bit Code to 32-Bit Windows[^].
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thank you for the response. I found the article Porting 16-Bit Code to 32-Bit Windows. Does anyone have any information on TurboPower library?
Rich
|
|
|
|
|
You could look at www.turbopower.com/products/orpheus
This may be the newer version of the old Win3.1 stuff - if so, and the calls etc are identical, it might ease the pain !!
Garth
|
|
|
|
|
I have an IDirectDrawSurface and I would like to save it as a bitmap. Im only interested in 24/32 formats. I have written some code, and it exports the file correctly. It locks the surface to get the bits, and then dumps it to a file. When I view the file with MS paint, it looks fine. However, when I open in Adobe Photoshop, the colors are off (I think the blue and red are switched). It seems odd to work in MSpaint but then not in photoshop. If anybody has experience doing this, please take a look at my code. Thanks
STDMETHODIMP CCaptureWindow::SaveScreenshot(LPTSTR pFile)
{
if (!g_pCapture || !g_pBaseFilter)
return E_UNEXPECTED;
CComPtr<IDDrawExclModeVideo> ddemv;
HRESULT hr;
if (FAILED(g_pCapture->FindInterface(&PIN_CATEGORY_PREVIEW,
&MEDIATYPE_Interleaved, g_pBaseFilter,
IID_IDDrawExclModeVideo, (void**)&ddemv)))
{
if (FAILED(hr = g_pCapture->FindInterface(&PIN_CATEGORY_PREVIEW,
&MEDIATYPE_Video, g_pBaseFilter,
IID_IDDrawExclModeVideo, (void**)&ddemv)))
{
return hr;
}
}
CComPtr<IDirectDrawSurface> pSurface;
CComPtr<IDirectDrawSurface7> pSurface7;
BOOL bExternal;
if (FAILED(hr=ddemv->GetDDrawSurface(&pSurface,&bExternal)))
return hr;
if (FAILED(hr=pSurface->QueryInterface(IID_IDirectDrawSurface7,(void**)&pSurface7)))
return hr;
DDSURFACEDESC2 desc;
desc.dwSize = sizeof(desc);
if (FAILED(hr=pSurface7->Lock(NULL,&desc,DDLOCK_WAIT | DDLOCK_READONLY,0)))
return hr;
if ((desc.ddpfPixelFormat.dwRGBBitCount < 24) || !(desc.ddpfPixelFormat.dwFlags & DDPF_RGB) || (desc.ddpfPixelFormat.dwFlags & DDPF_PALETTEINDEXEDTO8))
{
pSurface7->Unlock(NULL);
return E_UNEXPECTED;
}
HANDLE hFile = CreateFile(pFile,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0);
if (hFile == INVALID_HANDLE_VALUE)
{
pSurface7->Unlock(NULL);
return GetLastError();
}
CFile file(hFile);
BITMAPFILEHEADER bfh;
BITMAPINFO bmi;
DWORD sizeImage;
bfh.bfType = MAKEWORD('B','M');
bfh.bfReserved1 = 0;
bfh.bfReserved2 = 0;
bfh.bfOffBits = sizeof(bmi.bmiHeader);
bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biCompression = BI_RGB;
bmi.bmiHeader.biXPelsPerMeter = 0;
bmi.bmiHeader.biYPelsPerMeter = 0;
bmi.bmiHeader.biClrUsed = 0;
bmi.bmiHeader.biClrImportant = 0;
bmi.bmiHeader.biWidth = desc.dwWidth;
bmi.bmiHeader.biHeight = desc.dwHeight;
if (desc.ddpfPixelFormat.dwRGBBitCount == 32)
{
DWORD lPitch = desc.dwWidth * 3;
if (lPitch & 3)
lPitch = (lPitch & ~3) + 4;
sizeImage = desc.dwHeight * lPitch;
LPBYTE pBitmapMem = (LPBYTE)CoTaskMemAlloc(sizeImage+4);
if (!pBitmapMem)
{
pSurface7->Unlock(NULL);
return E_OUTOFMEMORY;
}
LPBYTE pCurrentWriteMem = (LPBYTE)pBitmapMem;
LPBYTE pCurrentReadMem = (LPBYTE)((LPBYTE)desc.lpSurface+((desc.dwHeight-1)*desc.lPitch));
for (DWORD i=0;i<desc.dwHeight;++i)
{
LPBYTE curWLine = pCurrentWriteMem;
LPBYTE curRLine = pCurrentReadMem;
for (DWORD j=0;j<desc.dwWidth;++j)
{
pCurrentWriteMem[0] = pCurrentReadMem[0];
pCurrentWriteMem[1] = pCurrentReadMem[1];
pCurrentWriteMem[2] = pCurrentReadMem[2];
pCurrentWriteMem += 3;
pCurrentReadMem += 4;
}
pCurrentWriteMem = curWLine + lPitch;
pCurrentReadMem = curRLine - desc.lPitch;
}
bfh.bfSize = sizeof(bfh) + sizeof(bmi.bmiHeader) + sizeImage;
bmi.bmiHeader.biBitCount = 24;
bmi.bmiHeader.biSizeImage = sizeImage;
file.Write(&bfh,sizeof(bfh));
file.Write(&bmi,sizeof(bmi.bmiHeader));
file.Write(pBitmapMem,sizeImage);
CoTaskMemFree(pBitmapMem);
}
else
{
sizeImage = desc.dwHeight * desc.lPitch;
bfh.bfSize = sizeof(bfh) + sizeof(bmi.bmiHeader) + sizeImage;
bmi.bmiHeader.biBitCount = (WORD)desc.ddpfPixelFormat.dwRGBBitCount;
bmi.bmiHeader.biSizeImage = sizeImage;
file.Write(&bfh,sizeof(bfh));
file.Write(&bmi,sizeof(bmi.bmiHeader));
file.Write(desc.lpSurface,sizeImage);
}
file.Close();
pSurface7->Unlock(NULL);
return S_OK;
}
|
|
|
|
|
First of all, looks like 75% of your code here is useless, you don't need to copy the source surface byte by byte. DirectDraw exposes a DC. Once you've got it, you simply do a StretchBlit to a destination DC.
<pre>
// m_pDDSOffscreen3 is a DirectDraw surface
HDC MemDC, SurfDC;
HBITMAP hBmp,hDib;
DDSURFACEDESC ddsd;
LPBYTE destbuffer=NULL;
BITMAP bmp;
PBITMAPINFO pbmi;
WORD cClrBits;
LPVOID lpBits=NULL;
if (m_pDDSOffscreen3==NULL) return;
// Get the size of the surface...
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_HEIGHT | DDSD_WIDTH;
m_pDDSOffscreen3->GetSurfaceDesc(&ddsd);
// Create the Memorybitmap now...
HRESULT hr = m_pDDSOffscreen3->GetDC(&SurfDC);
if (SUCCEEDED(hr))
{
// Create the Memorybitmap now...
MemDC = ::CreateCompatibleDC( NULL );
hBmp = ::CreateCompatibleBitmap( SurfDC, ddsd.dwWidth, ddsd.dwHeight );
::SelectObject( MemDC, hBmp );
::BitBlt( MemDC, 0, 0, ddsd.dwWidth, ddsd.dwHeight, SurfDC, 0, 0, SRCCOPY );
// Bitmapstruct init...
::GetObject( hBmp, sizeof(BITMAP), (LPSTR)&bmp ); cClrBits = (WORD) 24;
pbmi = (PBITMAPINFO) LocalAlloc(LPTR, sizeof(BITMAPINFOHEADER));
/* Initialize the fields in the BITMAPINFO structure. */
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pbmi->bmiHeader.biWidth = bmp.bmWidth;
pbmi->bmiHeader.biHeight = bmp.bmHeight;
pbmi->bmiHeader.biPlanes = bmp.bmPlanes;
pbmi->bmiHeader.biBitCount = 24;
if( cClrBits < 24 ) pbmi->bmiHeader.biClrUsed = 2^cClrBits;
pbmi->bmiHeader.biCompression = BI_RGB;
pbmi->bmiHeader.biSizeImage = (pbmi->bmiHeader.biWidth + 7) /8 *
pbmi->bmiHeader.biHeight * 24;
pbmi->bmiHeader.biClrImportant = 0;
hDib = ::CreateDIBSection(NULL,pbmi,DIB_RGB_COLORS,&lpBits,NULL,0);
if (hDib==NULL) TRACE("CreateDIBSection failed\n");
// Get the bits from the DC to save it to disk...
GetDIBits( SurfDC, hBmp, 0, (WORD) bmp.bmHeight, lpBits, pbmi, 0 );
if( lpBits == NULL ) TRACE( "No memory for screenshot!\n" );
if (bAddTail)
{
CString name=_T("");
if (GetDocument()->addShot(name,nStart,nEnd) &&
pThumb->AddItem(CBitmap::FromHandle(hDib), name))
{
GetDocument()->addShotInfo(nStart,nEnd,
pThumb->GetImageListIndex(),pThumb->GetItemIndex());
}
}
else
{
// remplace
replaceShot(CBitmap::FromHandle(hDib));
}
m_pDDSOffscreen3->ReleaseDC(SurfDC );
::SelectObject(MemDC,NULL);
::DeleteDC(MemDC);
::DeleteObject(hBmp);
::DeleteObject(hDib);
</pre>
<hr noshade>
<font size="-1" face="arial"><i>And I swallow a small raisin.</i></font>
<b style="background-image:'url(http://www.arstdesign.com/hands.jpg)';width:50px;height:45px"></b>
|
|
|
|
|
Thanks for the tip, but I think your solution seems slightly wasteful. You suggest creating a DIB from a DDB which requires allocating a new DDB + memory for the DIB bits. Isn't Lock'ing the surface the same thing as getting the DIB bits (and hence you can avoid the DDB HBITMAP stuff)?
|
|
|
|
|
Todd Jeffreys wrote:
You suggest creating a DIB from a DDB
Yes? That is AFAIK what the very definition of a .BMP-file says it contains.
|
|
|
|
|
I created 8 buttons on a page and created OnClick calls the easy way by double clicking the buttons. After doing this I put break points in each one. Then when I ran the program the broke in the wrong one...they were all off by 1 and the last one did nothing.
This maybe part of the problem or just another one, but the resource.h file has duplicated numbers all over the place. I would think that they should all be unique.
All explainations welcomed!!!
Thanks
|
|
|
|
|
what do you mean?
but the resource.h file has duplicated numbers all over the place. I would think that they should all be unique.<br />
|
|
|
|
|
I ended deleting all the buttons and then adding them back in and now they work.
I still have dublicate numbers...maybe they are on a window by window basis.
|
|
|
|
|
I still have dublicate numbers...maybe they are on a window by window basis.
what numbers.. of what???
|
|
|
|
|
resource.h example:
#define IDC_RADIO7 1017
#define IDC_CHECK8 1017
#define IDC_ACTV_7 1017
#define IDC_MALF08 1017
#define IDC_MALF08_SYS1 1017
#define IDC_SYS8_FAU 1017
#define IDC_SYS1_MODE_SEL_SWITCH4 1017
#define IDC_MF_FRONT1 1017
#define IDC_ALQ122_DUP 1017
#define IDC_MF1_FRONT 1017
|
|
|
|
|
Its a common problem.
Theres a tool at http://www.codeproject.com/macro/resorg.asp that can help you reorganise.
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
Has anyone found a workaround for disabling the arrow on an owner drawn menu when the popup menu item is disabled?
|
|
|
|
|
If you mean whether all the items to the left of the => arrow are disabled so you'd like to remove the menu item?
Can't you catch the OnInitMenu handler ( Or whatever it is in CMainFrame ) and call pMenu->ModifyMenu etc... to remove the arrow or just remove that menu item all together.
Asim Hussain
e: asim@jawache.net
w: www.jawache.net
|
|
|
|
|
Hi
Thank you for the reply. What I mean't is that I wanted to show the popup menu arrow as disabled in an owner drawn menu like it is in a standard menu if you disable the popup.
Cheers
Paul
|
|
|
|
|
Yaw all!
Happy new year! (To all Jewish folks)
<font color = blue>CWnd</font>::SetWindowPos(&wndTopMost,0,0,0,0,SWP_NOSIZE | SWP_NOMOVE) doesn't set my window to be topmost ( creates by <font color = blue>CWnd</font>::CreateEx() , Styles: WS_POPUP )!!!
I want it to appear above the taskbar, but it does-NOT!
Any? Help?
--BlackSmith--
/*The roof is on fire, we don't need no water, let the MF burn*/. BHG.
|
|
|
|
|
Ummm... Maybe you can try setting the desktop as the parent of your window with CWnd::SetParent .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
This is an MFC CFormView MDI application and this code is in the View class.
I have a CFileDialogST from which I want to terminate the app in case the user presses cancel. Its a class from CP by Davide Calabro. I trap the IDCANCEL and indeed i do get the messagebox, but I've tried
a. PostQuitMessage is ignored
b. PostMessage(WM_CLOSE) is ignored
c. SendMessage(WM_CLOSE) is ignored
d. exit(0) makes the app crash!
if(nRetValue == IDCANCEL)
{
AfxMessageBox ("No Image folder selected, terminating application");
PostMessage(WM_CLOSE);
}
This message No Image folder selected, terminating application shows up so I know it gets in the if .
Please help!
Thanks,
ns
|
|
|
|
|
|
I think PostMessage is a better alternative here --if using SendMessage(WM_CLOSE) inside a message handler, windows can get destroyed too soon.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I did like you said:
if(nRetValue == IDCANCEL)
{
AfxMessageBox ("No Image folder selected, terminating application");
AfxGetMainWnd()->PostMessage(WM_CLOSE);
}
and it crashes after the messagebox pops up. Same behavior as with exit(0);
???
thank you very much for helping,
ns
|
|
|
|
|
It goes to the end of mainframes destroy() where I write registry info, then suddenly gets into disassembly at the ending curly bracket of destroy(), and I can seem to get out of it, - have no clue how to interpret disassembly...crashes while stepping through disassembly somewhere...
|
|
|
|
|