|
Thanks! Right after you posted that I found this http://www.codeproject.com/threads/ipc_wmcopy.asp
Thanks again!
Rob
|
|
|
|
|
Hi,
I'm a bit clueless here really but I'm sure someone can help me out...
I'm using Chris Maunders MFCGridCtrl class. i want to trap a right click event on a cell. The documentation talks about overriding various "virtual" functions to achieve this.
How do I do this? because not of the grid classes appear in classwizard! I only know how to do this with classwizard.
Thanks
Jon
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
A virtual function means you can derive a class from the MFCGridCtrl class, and 'replace' those functions and things will work properly in terms of calls to the base class. So you need to create a new class, derived from the grid control, and then put in your own versions of those functions by hand.
Christian
As I learn the innermost secrets of the around me, they reward me in many ways to keep quiet.
Men with pierced ears are better prepared for marriage. They've experienced pain and bought Jewellery.
|
|
|
|
|
Thanks for your help.
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
I'm capturing a frame from a video stream. The data is being captured (I've verified that) as a 24-bit image. Part of the data being "captured" is the contents of the BITMAPINFOHEADER struct (again, this struct contains viable data).
I want to take this image and store it to the clipboard as a DIB.
Why doesn't this code work?
BITMAPINFO bmi;
memset(&bmi, 0, sizeof(BITMAPINFO));
bmi.bmiHeader = cb.bih;
HDC hMemDC = CreateCompatibleDC(NULL);
HBITMAP hBitmap = CreateDIBitmap(hMemDC, &bmi.bmiHeader, CBM_INIT, cb.pBuffer, &bmi, DIB_RGB_COLORS);
if (OpenClipboard(NULL))
{
EmptyClipboard();
if (!SetClipboardData(CF_DIB, hBitmap))
{
}
CloseClipboard();
}
It always says that the hBitmap handle is invalid when I try to call SetClipboardData(). The hBitmap isn't NULL.
|
|
|
|
|
try using a real DC (instead of NULL) in your CreateCompatibleDC call. i find that these CreateCompatible things often only work with a real DC.
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
I tried the CreateCompatibleDC method, and the results are the same.
The SDK documentation says that if you pass NULL to CreateCompatibleDC, you get a screen DC. Why isn't that good enough?
|
|
|
|
|
that might be true..
i only metion that becaseu i find that doing something like this:
CDC memDC;
memDC.CreateCompatibleDC(pRealDC);
CBitmap memBMP;
memBMP.CreateCompatibleBitmap(memDC, ...);
will often fail (i get a monochrome bitmap or something equally perverse). To make it work I have to use pRealDC in the CreateCompatibleBitmap call. using the 'compatible' DC screws things up.
so, as a rule, i always use a real DC (from GetDC(NULL), or a paint DC or a CClientDC) in these functions.
just a thought.
also, when i copy DIBs to the clipboard, i do it like this:
HGLOBAL CISImage::MakeClipboardDIB()
{
HGLOBAL hDIB = MakeDIB();
HGLOBAL hCBDIB = NULL;
if (hDIB)
{
DWORD dwSize = GlobalSize(hDIB);
hCBDIB = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, dwSize);
if (hCBDIB)
{
BYTE *pCBDIB = (BYTE *)GlobalLock(hCBDIB);
memcpy(pCBDIB, (BYTE *)hDIB, dwSize);
GlobalUnlock(hCBDIB);
}
GlobalFree(hDIB);
}
return hCBDIB;
}
...
if (OpenClipboard(AfxGetMainWnd()->m_hWnd))
{
CISImage img;
...put something in img...etc.
HGLOBAL hDib = img.MakeClipboardDIB();
HANDLE res = SetClipboardData(CF_DIB, hDib);
ASSERT(res);
CloseClipboard();
}
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
I can't find any reference to MakeDIB except for a MSDN sample app, and it requires parameters.
|
|
|
|
|
yeah. that's my own function. it just creates a typical BITMAPINFOHEADER and image data DIB. i'm assuming you already have a DIB floating around somewhere.
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
Wel, I have a populated BITMAPINFOHEADER and a shitload of captured bytes...
I've been trying to make a DIB that can be stored to the clipboard. Trouble is, I don't know what I've done right, and what I've done wrong.
Why does something like this have to be so hard in a *graphical* operating system?
|
|
|
|
|
sounds like you've got a DIB. have you tried displaying it (with something like StretchDIBits), just to be sure?
BITMAPINFO *pBMInfo = (LPBITMAPINFO)pDIB ;
LPVOID lpDIBBits = (LPVOID)(pDIB + pBMInfo->bmiHeader.biSize);
UINT32 lines = StretchDIBits(outHDC,
xPos, yPos,
outWidth, outHeight,
0,0,
inWidth,
inHeight,
lpDIBBits,
pBMInfo,
DIB_RGB_COLORS,
SRCCOPY);
that's the easiest way to tell if your DIB is correct/well-formed.
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
Yup, when I do a StrechDIBits, lines is equal to bmiHeader.biHeight.
|
|
|
|
|
hmmm.. have you tried the clipboard code i posted above?
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
not yet - in the process tho...
|
|
|
|
|
You can't just pass a dib handle to SetClipboardData - that would be too easy. You have to copy the contents into a global memory block and pass the handle of this memory block to SetClipboardData. DIBLOOK sample may be helpful; have a look at CopyHandle helper.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I've already tried the CopyHandle() method, and I get the same results.
|
|
|
|
|
|
Hi,
I have an MCI application that reads/catalogs audio CD's using the CDDB Interface.
There are two things I would like to get it to do that it currently does not;
1) Recognise that a CD has been loaded into the drive, so that I do not need to have a menu item to add a new CD.
2) Eject the drive after the information has been cataloged.
I know that for 2) there are a couple of KB Articles, Q165721 and Q168180, but I would like a simpler, more universal method, if possible.
Many Thanks in advance for any info.
Bryan Anslow.
|
|
|
|
|
Ejecting with MCI is easy. Assuming that you know the drive letter, send the following strings:
"open f: type cdaudio alias cdx0"
"set cdx0 door open"
cdx0 is just a sample alias. Any identifier should work.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Thanks Tomasz,
I use mciSendCommand() everywhere in this prog, so I found this worked;
mciSendCommand(_mciDevice, // Eject the CD
MCI_SET,
MCI_SET_DOOR_OPEN,
(DWORD)(LPVOID)&mciSet);
also, for finding out when a CD is inserted, I just added a line to my mainframe module (it's an MFC App)like;
ON_WM_DEVICECHANGE()
and the OnDeviceChange() function can find which device etc., by examining the passed parm,
Bryan.
|
|
|
|
|
I cannot find any useful functions from neither the MSDN nor the MFC source code. What can I do now? Please help me!
Law is meaningless without chaos.
Chaos without Law is equal to destruction.
Chaos and Law create our rich and colorful world.
|
|
|
|
|
Have a look on this site PJ Naughter has written a class that does the job!
Norm Almond
Chief Technical Architect
FS Walker Hughes Limited
|
|
|
|
|
I'm sorry to waste your time. But I don't know which article you refered to. Did you mean the FTPTransferDlg class?
Looking forward to your reply. Thank you.
Law is meaningless without chaos.
Chaos without Law is equal to destruction.
Chaos and Law create our rich and colorful world.
|
|
|
|
|
Can anyone tell me how to delete a file to the recycle bin programatically.
I can use CFile.Delete(), but this appears to delete the file completely, but what I would like to do is move the file into the recycle bin.
Thanks in advance for your help
|
|
|
|