|
Replace the 24 with the bpp of your screen. If you don't have a DC handy, you can do it like this:
CWindowDC dc(NULL);
GetDeviceCaps(dc, BITSPIXEL);
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.
|
|
|
|
|
Thanx, I did like you say. It's working.
Thanx a lot
Philip Patrick
|
|
|
|
|
I am trying to add a CStatic item in the form of an icon to a dialog box and I am having no luck...
I have added this code to the OnInitDialog section:
CStatic myStatic;
myStatic.Create(_T("my static"),
WS_CHILD|WS_VISIBLE|SS_ICON|SS_CENTERIMAGE, CRect(10,10,150,50),
this);
myStatic.SetIcon( ::LoadIcon(NULL, IDI_QUESTION) );
Is there anything wrong that I am doing?
|
|
|
|
|
You can do that this way:
1. Insert a picture control on your Dialog.
2. In properties of this control enter Type: Icon and Image: IDI_QUESTION.
Jerzy
|
|
|
|
|
but if I want to do it on the run?
|
|
|
|
|
Add CStatic myStatic in your class.
In OnInitDialog():
myStatic.Create(_T("my static"),
WS_CHILD|WS_VISIBLE|SS_ICON|SS_CENTERIMAGE, CRect(10,10,150,50),
this);
myStatic.SetIcon(::LoadIcon(::AfxGetInstanceHandle(),MAKEINTRESOURCE(IDI_QUESTION)));
|
|
|
|
|
And one more question...
I am trying to use icon 161 in shell32.dll...
The default Icon in the file actually has a green background, but
typically this background is not shown in Windows dialogs. How do
you make the background match the background of the dialog while
the rest of items retain their original color?
|
|
|
|
|
Hi - I need urgent help. I need some Visual C++ code that will allow me to export a screen image as a BMP/GIF and to save the file. I would greatly appreciate anyone's help. I am a newbie and need to do this somewhat urgently. Thanks everybody!
Imran
|
|
|
|
|
there are plenty of examples on this site. look around.
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
But I need actual code, not programmes. Or at least can you point me to some programmes??
Imran
|
|
|
|
|
there are at least three samples here
-c
------------------------------
Smaller Animals Software, Inc.
http://www.smalleranimals.com
|
|
|
|
|
chris,
first of all, thank you very much for even replying to my plea. It means a great deal to me. Now let me explain briefly. I am in London and its lat(ish) here. I am very new to programming and I was hoping to take an existing piece of code and tailor it for my needs. Those programmes are difficult for me to understand and although I will scour thru them it will take me ages and thats before I start tailoring it!
Imran
|
|
|
|
|
Then you need to learn some more C++ before you'll be up to the task. I know the code Chris would have been pointing too, and at least one is a complete solution that easily drops into existing programs. There are also my GDI+ articles, which are a viable solution if you're not using W95, and also drop right into existing code.
Don't try to run before you can walk - if you can't understand the code to save a bitmap then that's all there is to it. There are no solutions simpler than the ones provided and you'd do yourself a disservice not to take a step back and try something more basic if that is the level you are at.
Good luck.
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.
|
|
|
|
|
I am attempting to use SendMessage, and I need to pass a CString as one of the arguements. I can't seem to get this to work.
|
|
|
|
|
Pass string ( TCHAR * ) not CString. CString is an C++ object, and passing it may produce problems.
|
|
|
|
|
Wouldn't passing the (LPCTSTR) of the CString be the same thing?
Using LPCTSTR I get "cannot convert parameter 2 from 'const char *' to 'unsigned int'" on compile.
Using TCHAR I get "cannot convert parameter 2 from 'char [100]' to 'unsigned int'" on compile.
|
|
|
|
|
CString myString
SendMessage(MY_MESSAGE, *myString, 0);
void CMainFrm::OnMyMessage(WPARAM wParam, LPARAM)
{
CString test = wParam;
}
This gives me only the first character of the string myString.
|
|
|
|
|
Try This
put the address of the string
in a DWORD and passes as the LPARAM;
DWORD pdwAddress =(DWORD)&myString;
SendMessage(MY_MESSAGE, 0,
pdwAddress);
void CMainFrm::OnMyMessage(
WPARAM wParam, LPARAM lParam )
{
CString s;
s = *(CString *)lParam;
}
|
|
|
|
|
|
Perfect! It worked great, but I realized that it would better fit my needs to use PostMessage, and now it doesn't work. So what's the difference between the way they are called then, they look awfully similar to me.
Thanks
John
|
|
|
|
|
PostMessage() puts the message in the windows message queue and then returns, no processing of the message is performed before the window's message pump gets to run. With SendMessage() you "forces" the imidiate processing of the message so the message is processed *before* SendMessage() returns. SendMessage() isn't usually a good idea since you can get weird recursive effects if you arn't careful. The most common problem people seem to have with PostMessage() is that they are passing pointers to stack-allocated objects which goes out of scope (are destroyed) before the window procedure gets hold of the pointer... As always, mind your allocations.
|
|
|
|
|
Is there a speed penalty for using standard RTTI?
Just curious.
Steve
|
|
|
|
|
What do you mean by 'using standard RTTI'? Just turning on the compiler option or actually calling dynamic_cast?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
When using a IntelliMouse in a Visual c++ application how do you make the middle wheel
act like the other two mouse buttons ? When I am in a window
with a scrollbar if I click the middle wheel it goes into autoscroll mode. I want
to override this feature and make the middle mouse wheel act like the other two
mouse buttons so I can have it perform a different operation.
|
|
|
|
|
G'day Dawn.
You do this by overriding WM_MBUTTONDOWN/WM_MBUTTONUP
The class wizard does not give you these messages, but you can copy the code in your header and cpp file ( don't forget the code at the top of the .cpp ) and change the L or R to an M.
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.
|
|
|
|