|
|
This code is supposed to draw the bitmap/image to an HDC specified:
image->Draw(hdc);
This was code was ok, and was drawing on CView::OnDraw()
Now I want the image to be drawn as an Icon/Thumbnail to a CListBoxCtrl.. This is my code (this code was taken from the CListImageCtrl article..)
I get the HBITMAP retunred from the function, then attach it on a CBitmap and then add the CBItmap, and then the icon is supposed to appear on the ListCtrl.. But it doesn't...
the original code is like this:
<br />
IPicture* pPic;<br />
OleLoadPicturePath(wpath, NULL, NULL, NULL, IID_IPicture,(LPVOID*)&pPic);<br />
<br />
...<br />
...<br />
...<br />
HBITMAP hPicRet = (HBITMAP)CopyImage(hPic, IMAGE_BITMAP, nWidth, nHeight , LR_COPYDELETEORG); <br />
<br />
CDC hdcSrc, hdcDst;<br />
hdcSrc.CreateCompatibleDC(NULL);<br />
hdcDst.CreateCompatibleDC(NULL);<br />
<br />
CBitmap* hbmSrcT = (CBitmap*) hdcSrc.SelectObject(hPicRet);<br />
<br />
CBitmap* hbmDstT = (CBitmap*) hdcDst.SelectObject(hBmReturn);<br />
<br />
hdcDst.BitBlt(XDest,YDest,nDestWidth, nDestHeight, &hdcSrc,0,0,SRCCOPY); <br />
<br />
pOldBitmapImage = (HBITMAP)SelectObject(hdcDst.m_hDC,bm);<br />
<br />
return pOldBitmapImage<br />
This code was ok but I modified this code because IPicture cant handle other image formats to i use an image library..
i replace this code:
CBitmap* hbmSrcT = (CBitmap*) hdcSrc.SelectObject(hPicRet);<br />
with:
hdcSrc.CreateCompatibleDC(NULL);<br />
image->Draw(hdcSrc.GetSafeHdc());<br />
T
The images doesn't appear.. I modified the code based on my understanding of CDC and Bitmaps..
Help please
"the possibilities are endles..."
|
|
|
|
|
Maverick wrote:
hdcSrc.CreateCompatibleDC(NULL);
image->Draw(hdcSrc.GetSafeHdc());
When you create a DC via CreateCompatibleDC it does not have a usable drawing surface (memory) associated with it. You have to use SelectObject to select a bitmap drawing surface into it. And be sure to restore the DC back to it's original state before deleting it.
hdcSrc.CreateCompatibleDC(NULL);
CBitmap TempBitmap;
TempBitmap.CreateCompatibleBitmap(hdcDst, image->Width(), image->Height());
CBitmap *pOldBitmap = (CBitmap *)hdcSrc.SelectObject(&TempBitmap);
image->Draw(hdcSrc.GetSafeHdc());
...
hdcSrc.SelectObject(pOldBitmap);
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
so, meaning before i draw to a CDC, it must have an attached HBITMAP first right?
tnx bro.!
"the possibilities are endless..."
|
|
|
|
|
Do I have to synchronize access to a CTypedPtrArray which is used from two different threads? Or can I just add items in one thread and delete items in the other? How can that by synchronized the easiest way. Thanks in advance for your help
Regards
Konrad
|
|
|
|
|
You may want to use a CCriticalSection to achieve synchronization.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I want to be able to, on a command, select the LAST line of text in my ViewEdit class and cut it or clear it. I have been working with
GetEditCtrl().SetSel(LineBeginning, LineEnd);
GetEditCtrl().Cut();
I am having a lot of difficulty in getting this to work correctly.
The problem I am having is selecting the last line, finding linebegining and line end.
Is there an easier way to clear or cut the last line of text?
Thanks
John
|
|
|
|
|
Hi all:
Recently I've finished the coding of a tiny function which is to specify the files(Mp3s) order (by which the one appear first can be played first in the Mp3 player, this order depending on the result of DOS command "dir").
I'm not familiar with file system, after a little research, I found that the order in which you copying file to the destination folder(Mp3 Player Destination drive) is the order that the mp3 will played. So I implemented the code according to this principle. I was excited to found I really can control which mp3 should be played first. But after a little testing I found that this principle is not running stable, It will out of order once in a while.
Finally I decided to turn to another alternative which is FDT(File Directory Table). I heard from some guys that FDT can decide the file order either but much at low level.I wish I could write to the FDT of each file such that to achieve the objective. Can anybody provide the principle of writing to FDT or totally different method to affected the file order?
really appreciated !!!
|
|
|
|
|
How do I convert a PDF file into an EMF format using Visual C++. Can anyone help.
Thanks in Advance,
fsdfsdfsdfsdfsdfsdf
|
|
|
|
|
You can set up a printer driver that will print to FILE and configure the print processor to use EMF format. Once this is configured, simply print the PDF to this "printer".
onwards and upwards...
|
|
|
|
|
How can one read a single bit from a file? Any ideas?
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
Can't you just read one byte, and then test the relevant bit of that byte?
|
|
|
|
|
yea, that's what I'll have to do.
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
Hi!
I have written a custom messagebox class which is based on CDialog . When I want to call it I have to create a variable of the class type and then call the CDialog::DoModal() function like this:
CMyMsgBox myMsgBox(strTitle, strMsg, MB_YESNO | MB_ICONQUESTION;
myMsgBox.DoModal();
How must I write a static function that I can then call and do the same thing in one line call?
For example:
CMyMsgBox(strTitle, strMsg, MB_YESNO | MB_ICONQUESTION;
Thanks
|
|
|
|
|
no need to call a static variable, just create a global free function ( or part of a namespace )
for example :
::MyMessageBox( ... );
int MyMessageBox(...)
{
CMyMsgBox myMsgBox(strTitle, strMsg, MB_YESNO | MB_ICONQUESTION;
return myMsgBox.DoModal();
}
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Thanks that works now but what is a reason for such functions to be declared static? Is that more efficient? Can I declare it static?
|
|
|
|
|
Hi,
i want to code something like this: on my hard drive is a file. and in my windows explorer i have a virtual drive which can be used like any other drive too, but it is using the file on my hard drive to read and save data on it. i want to do that because i can write some encryption code on the read and write functions to make my data protected.
I dont think that there is freeware out there doing exactly that. So i need a hint on how to get started with writing a driver for winXP which gives me a new virtual drive. I know that this must work because "Daemon-Tools" also make virtual CD-ROM-Drives.
Hope for any tutorials. thx
|
|
|
|
|
hello,
after i used DebugActiveProcess how can i have the handle of the thread who caused a debugging event? I am lost
Thank you!
|
|
|
|
|
It is in DEBUG_EVENT_HEADER.dwThreadId, which is passed into WaitForDebugEvent()
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
dwThreadId is a DWORD value. Is it possible to convert DWORD to HANDLE?
|
|
|
|
|
You can get a handle to the thread on the CREATE_THREAD_DEBUG_EVENT event - the DEBUG_CREATE_THREAD_DEBUG_INFO structure's .Handle member.
Then create a collection keyed by dwThreadId and look up the handle using that?
'--8<------------------------
Ex Datis:
Duncan Jones
Merrion Computing Ltd
|
|
|
|
|
ok
This works fine:
case CREATE_PROCESS_DEBUG_EVENT:
myHandle=DebugEv.u.CreateProcessInfo.hThread;
strangely not this
case CREATE_THREAD_DEBUG_EVENT:
myHandle=DebugEv.u.CreateThread.hThread;
Am i doing something wrong?
|
|
|
|
|
|
Hi All,
I want to capture all the registry data for any application. How can I find out the location in the registry where an application stores its information?
One way is finding out the node in registry under HEY_CURRENT_USER with node name equal to application name. But here its not guaranteed that all application would store the information in a node with the same name as application name.
For instance for an application with name "Adobe Reader 6.0" stores the information is under a node with name "Adobe Reader". Though both texts are very similar they do not match exactly. They may be very different also. So how do I go about it?
Any idea?
Also few applications store their information in some files. For Instance Quark Express. I want to capture all such files also.
Any suggestion?
Thanks,
Vaibhav Sanghavi.
|
|
|
|
|
that's a hard one.
Every application can pretty much do what they want when it comes to application settings.
Those can be stored in the registry ( HKEY_CURRENT_USER\Software is the common place, and other unsafe places ), in a file ( about anywhere the disk, )
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|