|
Hey,
Anyone knows how to convert a CImage to an HBITMAP ?
Thanks.
|
|
|
|
|
What is a CImage ? If it's a bitmap of some sort, unless it's a DIB, it surely has operator HBITMAP defined ?
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
CImage is available when using Microsoft Forms Image 2.0 control.
and it doesn't have HBITMAP operator.
I think it has something to do with IPictureDisp and IPicture.
Hope it helps.
|
|
|
|
|
It's not mentioned in the latest MSDN. If it's a COM object, it may support an IStream, in which case you can get it via a GDI+ Image object. Beyond that I do not know.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
I don't know about CImage too... but if you have access to IPicture , it is easy. This interface has get_Handle(OLE_HANDLE* pHandle) function. After return, the pointer inside pHandle is actually HBITMAP
Hope this will help you
Philip Patrick
"Two beer or not two beer?" <shakesbeer>
Web-site: www.saintopatrick.com
|
|
|
|
|
Question 1:
I have a bitmap on a dialog (using MFC) and I have a CStatic control variable for it. I need how to get IDB_BITMAP specified into a HBITMAP so I can use SetBitmap to change the bitmap. IDB_BITMAP is a resouce in the project.
-----------------------------------------------------
Question 2:
I need to launch a file in it's default App when the user clicks a button. It doesn't really need to be that elaborate. Does WinExec work or will that only do apps?
Thanks if you can help me.
- Matt Newman
- Matt Newman
-Sonork ID: 100.11179:BestSnowman
|
|
|
|
|
1. CBitmap::LoadBitmap() to load it from the resources, then just pass the CBitmap object to SetBitmap() - that'll automagically call CBitmap::operator HBITMAP().
2. ShellExecute() [more info in the VC forum FAQ].
--Mike--
My really out-of-date homepage
Buffy's on. Gotta go, bye!
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
I was working on what was a small project and all of a sudden I was hearing you know what would be cool... and if would be really nice if....
Thanks alot for the help
- Matt Newman
- Matt Newman
-Sonork ID: 100.11179:BestSnowman
|
|
|
|
|
Michael Dunn wrote:
CBitmap::LoadBitmap() to load it from the resources, then just pass the CBitmap object to SetBitmap() - that'll automagically call CBitmap::operator HBITMAP().
This is what I tried:
CBitmap bmpBitmap;
bmpBitmap.LoadBitmap(IDB_2000INDY340);
m_ctlBmp.SetBitmap(bmpBitmap);
m_ctlBmp is a CStatic control variable pointing to a Picture control the Picture control is set as a bitmap. IDB_2000INDY340 is a valid bitmap resouce ID but nothing shows up. Am I skipping something?
- Matt Newman
- Matt Newman
-Sonork ID: 100.11179:BestSnowman
|
|
|
|
|
... The CBitmap object is destroyed after this function ends, and the HBITMAP inside it released too. Maybe this is the problem.
I found this somewhere in the samples of Platform SDK:
m_cPic is the CStatic here
HBITMAP hbm = (HBITMAP)::LoadImage(AfxGetApp()->m_hInstance,
MAKEINTRESOURCE(IDB_MAP),
IMAGE_BITMAP, 0, 0, LR_LOADTRANSPARENT);
m_cPic.SetBitmap(hbm);
This works fine in my test project and loads the bitmap as transparent (pixel 1,1 is the trans color)
Also. I noticed that you have to make size of your CStatic on the dialog same or greater than the size of that bitmap.
Philip Patrick
"Two beer or not two beer?" <shakesbeer>
Web-site: www.saintopatrick.com
|
|
|
|
|
That's wheat I was looking for. Thanks.
- Matt Newman
- Matt Newman
-Sonork ID: 100.11179:BestSnowman
|
|
|
|
|
bmpBitmap is created on the stack, so whenever that function returns, bmpBitmap is destructed and it destroys the bitmap GDI object along with it. Make the CBitmap object a member of the dialog class, and the load/set calls in OnInitDialog() .
--Mike--
My really out-of-date homepage
Buffy's on. Gotta go, bye!
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
I have made a small utility app that loading a DLL with LoadLibrary((LPCSTR) "TheDLL.dll");
But, when I tested this on two computers that doesn't have VC++ or VisualStudio installed it cant find the DLL!?... The return value from LoadLibrary(...) is NULL but on my two computers with VC++ installed it works fine!
The DLL is a keyboard hook DLL.
Is there something that has to be installed on the system?
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
Does the target DLL exist anywhere on these PCs? If so, try putting a copy in the same folder as the app. If not, get a copy from one of your VC++ PCs. If this doesn't work, does this DLL have any dependencies that are missing? And lastly, there might be a permissions problem... though it doesn't really sound like one...
|
|
|
|
|
Sounds like it is a dependency problem. Make sure the non-VC systems have all the required support dll's. Did you build the app and dll in release or debug? Could be you are missing the debug dll's on the target system.
|
|
|
|
|
Could you be nice to tell me how to compile the DLL then in debug mode or release mode?
I think I have compile it in debug, because when I look on the Project -> Settings then "Settings For" and Win32 Debug is selected in the combo box. But when I try to change it then nothing happens when I recompile it!
HEEELP!!
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
Try. . .
from the MSDev menu
Build->Batch Build...
Yours Truly
|
|
|
|
|
GOD DAMN I'M SO HAPPY NOW!
THANK YOU! It works now!
------------------------------
©0d3 ©®4©k3® - That's me!
------------------------------
|
|
|
|
|
Any sample on using CreateWindow API from c# ? I’m aware of “MessageBox” sample on MSDN but I’ve no idea on how to retrieve HWND of Form and Instance handle. I’m trying to put together code to use virtual listview. virtual listview is available in SDK not with .Net. Any idea would be truly appreciated.
Thanks
|
|
|
|
|
I am using CRichEditView and have managed to make it so that the urls in the view automatically become links using EM_AUTOURLDETECT but i do not know how to capture the event of clicking on the link. Can anyone help....i think it has something to do with EN_LINK
==================================================
The Eclypse
|
|
|
|
|
I am making a DLL, which contains classes and stuff for my exe (..the exe has not been made yet) when i compile the dll in debug mode, it compiles no problem, but when i attempt to compile in release mode, it gives me the following error during linking:
Linking...
LINK : error : Internal error during ReadSymbolTable
ExceptionCode = C0000005
ExceptionFlags = 00000000
ExceptionAddress = 004623F2
NumberParameters = 00000002
ExceptionInformation[ 0] = 00000000
ExceptionInformation[ 1] = 00000008
CONTEXT:
Eax = 022A06A0 Esp = 0012E6D8
Ebx = 00000002 Ebp = 013A0424
Ecx = 022A06A0 Esi = 02290C64
Edx = 00000000 Edi = 02290C64
Eip = 004623F2 EFlags = 00010246
SegCs = 0000001B SegDs = 00000023
SegSs = 00000023 SegEs = 00000023
SegFs = 00000038 SegGs = 00000000
Dr0 = 0012E6D8 Dr3 = 00000002
Dr1 = 013A0424 Dr6 = 022A06A0
Dr2 = 00000000 Dr7 = 00000000
Error executing link.exe.
Tool execution canceled by user.
Does anyone know why?
==================================================
The Eclypse
|
|
|
|
|
Hi.
Is there an advantage to using dynamic binding instead of static binding?
I have both Deitel & Deitel C++ How to Program and Stroustrup's Special Edition. I read all of the first book and finished chapter fifteen of Stroustrup. So I understand virtual functions and virtual base. However, I am not to the point where I can implement virtual functions and virtual base without asking: How do you implement them effectively?
For example, "virtual" only works for pointer and reference. That is completely conceivable. However, it seems you have to declare an object of a derived class and then *cast* a new class from the base class to the derive class just to get it working right.
-----------------
classDerived cDerived = new classDerived;
classBase *cBase = &cDerived;
-----------------
The example above comes straight from Deitel & Deitel. So everything looks okay. What is the point of declaring two separate classes? I understand that the use of "virtual," but I do not understand the performance of "virtual" if you have to declare an object of the derived class and an object of the base class. Under what specific situation do you implement dynamic binding? Please be very specific because I found that neither Deitel & Deitel nor Stroustrup give a convincing example of dynamic binding.
Lastly, I too want to implement dynimic binding if it is possible to declare *one* object of either the base class or the derived class. The following is *not correct*:
------------------------
classBase *cDynamic = new classDerived
------------------------
In other words, *virtual* would be great if there is a way to use it without having to declare two seperate classes like the example from Deitel & Deitel.
Thanks,
Kuphryn
|
|
|
|
|
<small><b>kuphryn wrote:
</b></small><i>Lastly, I too want to implement dynimic binding if it is possible to declare *one* object of either the base class or the derived class. The following is *not correct*:
------------------------
classBase *cDynamic = new classDerived
------------------------
In other words, *virtual* would be great if there is a way to use it without having to declare two seperate classes like the example from Deitel & Deitel.</i>
There is no reason you cannot do this, I did it extensively in a paint package I wrote. I created a virtual base class called CTool, or something, and then created derived classes like CToolFill, CToolRectangle, etc. My Mainframe had a member CTool*, and when I changed tools I would delete it, and make it a new CToolFill, or whatever tool was selected.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
<Center><A href = "http://www.sonork.com" target = "_Blank">Sonork</A> ID 100.10002:MeanManOz</Center><Center>I live in <U><B>Bob's HungOut</B></U> now</center>
|
|
|
|
|
My original concern was not with the use of virtual function. I basically feared resource loss and performance reduction because using virtual function requires declaration of multiple classes, including one base and at least one derived. null_pointer made a good point at GameDev forums that a pointer takes up very little resource. I believe he implied that even thought virtual requires declaration of multiple class objects, doing so through pointer takes up few resources.
I see the big picture is sometimes "virtual" is a necessity. It is not an option in some cases where the program has no way of knowing which function you are implying.
So the question came down to the performance of static binding and dynamic binding. If there is no performance difference, then I think it is better to just use dynamic binding with inheritance.
Kuphryn
|
|
|
|
|
With this:
classDerived cDerived = new classDerived;
classBase *cBase = &cDerived;
You are creating only one object (with new). The other is a pointer variable that points to the already created object.
Besides that, the following:
classBase *cDynamic = new classDerived
works fine. Is the same idea than before, but having one object and one pointer instead of two pointers, and is the way that is usually used.
|
|
|
|