|
What happens if you omit the LB_SETITEMDATA part? Do the list items appear (altough without being associated with their respective HACMDRIVERID )? If not, then the problem is somewhere else.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hello,
This is code from an OnEditCopy handler of the Visualization Toolkit. I am trying to add animations to my application by generating the frames (as bitmaps) and then redisplaying them. I have tried using the CPicture class here and the vtk offscreen rendering (using a bitmap writer object), but it is unreliable, crashing the program.
Another solution would be to adapt this code to store the contents. I have never used LPBITMAPINFOHEADER. Can anyone point me in the right direction on how to copy this bitmap data onto the view, thus displaying it? Thanks.
Ted
LPBITMAPINFOHEADER lpbi; // pointer to BITMAPINFOHEADER
DWORD dwLen; // size of memory block
HANDLE hDIB = NULL; // handle to DIB, temp handle
vtkWindow *vtkWin = pView->GetVTKWindow();
int *size = vtkWin->GetSize();
int dataWidth = ((size[0]*3+3)/4)*4;
dwLen = sizeof(BITMAPINFOHEADER) + dataWidth*size[1];
// allocate memory for the bitmap
hDIB = ::GlobalAlloc(GHND, dwLen);
// setup bitmap info header
lpbi = (LPBITMAPINFOHEADER) ::GlobalLock(hDIB);
lpbi->biSize = sizeof(BITMAPINFOHEADER);
lpbi->biWidth = size[0];
lpbi->biHeight = size[1];
lpbi->biPlanes = 1;
lpbi->biBitCount = 24;
lpbi->biCompression = BI_RGB;
lpbi->biClrUsed = 0;
lpbi->biClrImportant = 0;
lpbi->biSizeImage = dataWidth*size[1];
// start memory rendering
pView->SetupMemoryRendering(size[0],size[1], pView->GetDC()->GetSafeHdc());
vtkWin->Render();
// copy the bitmap data into the bitmap
memcpy((LPSTR)lpbi + lpbi->biSize, pView->GetMemoryData(), dataWidth*size[1]);
::GlobalUnlock(hDIB);
// turn screen rendering back on
pView->ResumeScreenRendering();
// now how can we draw this bitmap on the view (CDC)?
|
|
|
|
|
Ted Christiansen wrote:
now how can we draw this bitmap on the view (CDC)?
use CDC::StretchDIBits
-c
"I am angry that so many of the sons of the powerful and well-placed... managed to wangle slots in Reserve and National Guard units...Of the many tragedies of Vietnam, this raw class discrimination strikes me as the most damaging to the ideal that all Americans are created equal and owe equal allegiance to their country."
--Colin Powell, not talking about his boss
|
|
|
|
|
Chris,
I have tried this and I cant seem to figure out why the memory CDC's are 1x1 pixels.
I added these calls to set the size after I noticed this fact and they are
still 1x1:
CDC *frame = GetDocument()->AddFrame();
ASSERT(frame);
// pic->Load(tmpname);
frame->CreateCompatibleDC(GetDC());
CRect rect;
GetClientRect(&rect);
frame->SetViewportExt(rect.Width(), rect.Height());
frame->SetWindowExt(rect.Width(), rect.Height());
frame->BitBlt(0, 0, rect.Width(), rect.Height(), GetDC(), 0, 0, SRCCOPY);
CSize s = frame->GetWindowExt();
TRACE("CVtksampleView::OnSaveimage window: %d %d viewport: ", s.cx, s.cy);
s = frame->GetViewportExt();
TRACE("%d %d\n", s.cx, s.cy);
What am I missing?
Ted
|
|
|
|
|
Ted Christiansen wrote:
I cant seem to figure out why the memory CDC's are 1x1 pixels
you need to create a compatible bitmap, then select it into your memory DC, before you draw into it. by default, a DC comes with a 1x1 mono biitmap. (also, be sure to use the real dc, not the memory DC, when you make the compatible bitmap, otherwise, you'll get another 1x1).
-c
Argue for your limitations, and sure enough, they're yours.
|
|
|
|
|
I have a CFileDlgST browseforFolder that is spawned at the start of the app. If I do cancel, the app quits:
if(nRetValue == IDCANCEL)
{
AfxMessageBox ("No Image folder selected, terminating application");
PostQuitMessage(0);
}
BUT
if I already have the app up and running, and then this same CFileDialogST (from CP) pops up to select a browse folder, (it does go into the IDCANCEl condition), but the app doesnt terminate! The dlg vanishes but thats all!
???
I just read that it terminates a thread. I dont have a nmultithreaded app or anything, but would the dialog be considered a thread?
Thanks,
ns
|
|
|
|
|
I tried exit(0) instead and the app crashed! So one function crashes it and one is ignored by the app!!!
The crash only happens if the app is already running (and I didnt cancel out the first time), but then in the next time that same dialog comes upp, and I cancel it crashes! If I cancel out the fisrt time all is well.
|
|
|
|
|
where are you strying to exit from (what class)? I dont call any explicit commands to exit in my program.. however in my InitInstance() of my CMyApp i return false if anything fails to load, etc..
if you are forcing your users to browse when the program opens then do this in your app's InitInstance() function.. then if they hit cancel you can just return FALSE and the app will not continue to load..
hope that helps.
-dz
|
|
|
|
|
I'm in the view class. While the UI is up, at some point they can load a new database, and they browse to it. Thats where if they hit cancel, I want the app to end after asking "do you really want to exit?" etc.
|
|
|
|
|
I'm not sure what your scenario really is, but this sentence should terminate your app, be it dialog-based or SDI/MDI:
AfxGetMainWnd()->PostMessage(WM_CLOSE);
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
okay, long story short, newbie - beware.
form someones example of Little Install Builder, we loaded the app in a string and read it looking for a marker, how could i look through the string backwards, looking for a marker? i included the example
CString strTag;
int nLength;
char szModuleName[MAX_PATH];
char *ppMemoryBlock, *ppBlockEnd, *ptr;
char *pStartPos = 0;
// get our own name
GetModuleFileName(NULL, szModuleName, sizeof(szModuleName));
LoadFile(szModuleName, &ppMemoryBlock, &ppBlockEnd);
if (!ppMemoryBlock)
{
return FALSE;
}
ptr = ppMemoryBlock;
int nCounter = 0;
strTag = "{35C63374-512F-394a-8516-NE3513160CBG}";
//// reverse it to prevent detecting it in this executable
strTag.MakeReverse();
nLength = strTag.GetLength();
//// search in memory block for string
for ( ; ptr < ppBlockEnd; ptr++)
{
if (nCounter < nLength)
{
// compare part of string
if (*ptr == strTag.GetAt(nCounter))
{
// this part is OK
nCounter++;
}
else
{
// not good -> reset counter
nCounter = 0;
}
}
else
{
// found string !
// // rewind pointer (do not include marker tag)
for (int i=0; i < nLength; i++)
ptr--;
// do what got to do, they extracted file
// // skip marker
for (int j=0; j < nLength; j++)
ptr++;
pStartPos = ptr;
nCounter = 0;
}
}
// // release memory
GlobalFree((HGLOBAL)ppMemoryBlock);
i've tried, looking from ppBlockEnd ptr-- with no luck
any helps really appreciated.
shotgun
|
|
|
|
|
dear freinds,
i want to know that can i make the activex control of my developed mfc based application.
& it is possible to make activex control from exe file.
please help me.....
thanks!
ashutosh agrawal
mail me at:
ashutosh_agrawal78@rediffmail.com
|
|
|
|
|
Hi all,
Is there a way to get notified when the network connection is down or up in VC++?
Thanks
|
|
|
|
|
For Dial-up connections you can use RasConnectionNotification (available in all Windows OSs except 95).
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi Thanks,
do you know the LAN card link?
|
|
|
|
|
I'm looking for a source code control tool that will let us easily maintain multiple versions. (Go back to a version, fix a bug and get the fixes carried over to the later versions in an automated manner). The idea is we won't need to maintain multiple source bodies. Is such a tool available at all? If so which one is the best? We're using MS Visual SourceSafe 5.0 but it has quite a few bugs and it cannot do most of what we need.
Thanks
|
|
|
|
|
We are using CVS and it's not bad for the price .
Pavel
Sonork 100.15206
|
|
|
|
|
After using CVS you'll never want to use SourceSafe again.
And it couldn't be cheaper.
Concussus surgo.
When struck I rise.
|
|
|
|
|
Is there a way to integrate CVS with Visual Studio ?
|
|
|
|
|
ClearCase from Rational is the best Tool on the market.
But also the most expensive.
|
|
|
|
|
Bugra,
This appears to have promise...
http://www.sourcegear.com/vault/index.asp
I like their other products (Source Offsite) though I have never used them.
Ted
|
|
|
|
|
My problem is i can not draw a 24 bit bitmap using a CImageList. The colors get corrupted. This is my code. What am I doing wrong ? Can I use CImageList to draw 24 bit bitmaps because the code below works fine with 16 bit bitmaps.
First create the image list from a 24 bit bitmap
CImageList m_ImageList;
m_ImageList.Create (IDB_BITMAP2,39,2,RGB(255,0,255));
Then draw it in OnPaint method of my class
CPoint pt (0,0);
m_ImageList.Draw(pDC, m_iIndex, pt, ILD_TRANSPARENT);
Thank you very much
Orcun Colak
|
|
|
|
|
what is the bit depth of your display?
-c
"I am angry that so many of the sons of the powerful and well-placed... managed to wangle slots in Reserve and National Guard units...Of the many tragedies of Vietnam, this raw class discrimination strikes me as the most damaging to the ideal that all Americans are created equal and owe equal allegiance to their country."
--Colin Powell, not talking about his boss
|
|
|
|
|
I found the code below in the toolbar section of codeproject. Now it works fine.
CBitmap cBitmap;
cBitmap.Attach( LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP2), IMAGE_BITMAP, 0, 0,
LR_DEFAULTSIZE|LR_CREATEDIBSECTION)
);
CImageList cImageList;
cImageList.Create(39, 42,ILC_COLOR24|ILC_MASK,2, 1);
cImageList.Add(&cBitmap, RGB(255,0,255));
I guess CImageList can not load 24 bit bitmaps itself for some reason.
But when I load the bitmap and then add it to CImageList it worked.
Thank you very much for your time
Orcun Colak
|
|
|
|
|
Is there a way to show a default selection?
When I start the dialog everything is blank until I select something and I would like to show a default in the list.
Thanks for the help.
|
|
|
|
|