|
EDIT: This wasn't it either Turns out an application cannot select more than one bitmap into any one device at a time...i'll look into this more carefully now...
What causes SelectObject to fail???
I am trying to select a BITMAP into a memory DC I created using CreateCompatibleDC but it returns NULL...?
I can however select Pens, etc into the DC and everything is cool...why would a bitmap fail???
The bitmap is actually loaded my an imagelist and is retreieved using:
GetImageInfo(nImage, &ii);
CBitmap* pBmp = CBitmap::FromHandle(ii.hbmImage);
I'm inside a derived CImageList::Draw()
The memory DC is created from the pDC passed in as the first parameter to Draw .
All the handles and pointers to everything else are cool...for instance ii.hbmImage is not NULL...
I've tried using PJ Arends HBITMAP viewer, but can't get it working...
Any reason why SelectObject() would fail on BITMAPS??? I've tried MFC objects and SDK handles...still no go...
The only thing I can think of is...initially I first had one of my icons in the imagelist as an 24x24 32bit image...and the rest were normal 16x16...but i've since removed that 32bit image and still nothing...i've rebuilt and everything...?
Would SelectObject if a BITMAP is invalid or something??? What the heck is going wrong...any ideas???
Thanks
How do I print my voice mail?
|
|
|
|
|
The only thing I would say is the bitmap is incompatible with the dc.
What happens if you change the lines
<br />
CBitmap* pBmp = CBitmap::FromHandle(ii.hbmImage);<br />
memDC.SelectObject(pBmp);<br />
to
<br />
CBitmap bitmap;<br />
bitmap.CreateCompatibleBitmap(pDC, ii.rcImage.right - ii.rcImage.left, ii.rcImage.bottom - ii.rcImage.top);<br />
memDC.SelectObject(&bitmap);<br />
<br />
** Forgot a line **<br />
<br />
CImageList::Draw(&memDC, nImage, point, ILD_NORMAL);<br />
<br />
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
It worked!!!
Thanks
hoever i'm confused as to why...if the bitmap is larger than the DC is it not valid???
I added icons to the image list...but I thought/think they were stored as HBITMAP anyways...
Regardless...it appears to be working now which is great news
Thanks you muchly!!!
Cheers
How do I print my voice mail?
|
|
|
|
|
Pooh
I just remembered why I didn't use this approach...
I was trying to select bitmaps from an imagelist which had icons added by the user...
if I create a compatible bitmap, then how do I get those icons bitmaps into that compatible bitmap so when I draw I see icons which were loaded by user???
Creating a compatible bitmap would work if I was drawing directly to the bitmap...but I just wanted to select existing bitmaps images onto this memory DC then blit them to DC...???
Do I make sense???
I've been cranking away at this problem all day...sorry if I sound confused...
How do I print my voice mail?
|
|
|
|
|
I think I found the problem:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;131279
Hopefully this saves someone headaches
Cheers
How do I print my voice mail?
|
|
|
|
|
When I saw your problem I looked up SelectObject...
"An application can select a bitmap into memory device contexts only and into only one memory device context at a time. The format of the bitmap must either be monochrome or compatible with the device context; if it is not, SelectObject returns an error."
I figured, I can't see it being because of the single dc at a time rule, must be a compatibility problem. Wrong again!
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
Hi Guys,
Not sure if this is the best place to post this question, but I gotta start somewhere.
Here at work, we are using an ActiveX Spreadsheet control, but I cannot seem to find any information on its interfaces and the like. Can someone point me in the direction of where I can get some information about this control. We are using C++/MFC on the VC++ 7.1 system. So, what ever version of the control comes with that setup.
Much appericated.
Larry J. Siddens
|
|
|
|
|
Hi,
I am doing an image processing project. I have downloaded CxImage, I wanted to append the *.h files of CxImage to the external dependecies. When I tried adding them by going to Project | Add files and then selecting a particular *.h files, it adds the *.h files to the Header folder. Can any one tell me how to work with CxImage and add the *.h files to the external dependencies.
Thanks
|
|
|
|
|
"External dependencies" lists headers that you include that are not part of the project, that's what the "external" part means. Having the files in "External dependencies" doesn't make a difference when you build, since that is just a IDE feature.
--Mike--
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ | You Are Dumb
|
|
|
|
|
DnsQuery works great if dns server listing on port 53. How to specify a port number other that 53?
|
|
|
|
|
Hello,
I have ATL DLL Project with MFC support in VS2003. During one of build I got the next error: ‘error LNK2005: _DllMain@12 already defined in MSVCRT.lib’. I’ve figured out the same information was founded in mfcs71.lib. How to fix this problem? Please help!
Regards,
Leonid
|
|
|
|
|
I want to know (programatically, of course: I am not blind!) if my application is displaying a MessageBox() or otherwise engaged in a modal dialog.
The context of the question is this: I am in a CView* and I want to do something to the user interface. I need to know if my application is "busy" waiting for a modal dialog before I can proceed with my changes ???
I have tried GetActiveView() and it tells me if "this" view is the current "top" view. (I run modal loops in my views) so this is coverd.
I am about to try GetFocus() then GetOwnerWnd()...
Maybe someone already has the answer??
|
|
|
|
|
I got it, I think!
GetLastActivePopup()
I wonder where I was for the last XX years, I tought I knew WIN32.
It goes to show, you learn something every day!
|
|
|
|
|
OOps. this is not good: GetLastActivePopup() still returns my VIEW's HWND instead of that of the MessageBox()
I guess I can either (a) keep looking or (b) find someone smarter than me to give me the answer!
|
|
|
|
|
ummmmm
why dont u set a variable in the calling view or doc class when the dialog pops up and clear it when it goes away?
"there is no spoon" biz stuff about me
|
|
|
|
|
I tapught about that. The problem is that ma application has maybe 100 views or screens, and I want beautiful code, not a quick hack.
Whatever would force me to spend lots of time working like a robot is not a great idea. I may capture all invokation of message boxes and dialog boxes, but as I (or someone else) maintain my applicatio, I am scared to "forget" about it.
If I could use WIN32 to tell me is a messagebox is up and running, I write once and can rely on that no matter how my stuff is written, putting the logic in a base-class somewhere.
|
|
|
|
|
What did they do to VC++? All my VC++ 6 MFC program doesn't work properly. I tried to create a simple Hello World console program in VC++ .net and it gives cout not define.(Got stdio to work but I can't seem to get iostream or iostream.h to work)
|
|
|
|
|
With <iostream>
I get a lot of syntax error with cerrno and stdio. Missing { and ':'
|
|
|
|
|
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\cerrno(16): error C2143: syntax error : missing '{' before ':'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\cerrno(16): error C2059: syntax error : ':'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\cstdio(15): error C2143: syntax error : missing '{' before ':'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\cstdio(15): error C2143: syntax error : missing '{' before ':'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\cstdlib(15): error C2143: syntax error : missing '{' before ':'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\cstdlib(15): error C2059: syntax error : ':'
|
|
|
|
|
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World" << endl;
}
this will output as:
Hello World
ALL YOUR BASE ARE BELONG TO MICROSOFT!
Demonware Studios Leader
|
|
|
|
|
Nope. Don't you need to #include <iostream>
Currently this is what I have
#include <iostream>
using namespace std;
void main()
{
cout << "Hello World." << endl;
}
But getting a lot of
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\cerrno(16): error C2143: syntax error : missing '{' before ':'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\cerrno(16): error C2059: syntax error : ':'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\cstdlib(15): error C2143: syntax error : missing '{' before ':'
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\cstdlib(15): error C2059: syntax error : ':'
|
|
|
|
|
Got this to work
#include <iostream>
int main(){
std::cout << "Hello World" << std::endl;
}
|
|
|
|
|
I forgot to check th 'do not treat carrots as tags box' :P
so this is what i meant
#include <iostream>
ALL YOUR BASE ARE BELONG TO MICROSOFT!
Demonware Studios Leader
|
|
|
|
|
I want to invoke the context help question '?' mark on the title bar without the user clicking on it, how do I do that - can't find any info anyware, is there a windows message I can send to the dialog for it to activate ?
thanks,
lee.
|
|
|
|
|
k, got some windows related questions here,
1.I have this folder:
C:\Documents and Settings\my username(hidden for obvious reasons)\Local Settings\Temporary Internet Files
why can't I delete it?
1.if I go into cmd.exe and delete it it works but after that it is created right away. Why?
2.there are some files in this directory that I can delete from explorer.exe but not from cmd.exe or from my own program. Why? and how can I delete these files from my own program that I make and I want to delete them from it?
|
|
|
|