|
What are you trying to do???
You want the bitmap to be a copy of a a 200x200 rect of the screen?
That's fine.
You should select the hb bitmap back out of the memory DC before you
hand it off to the static (picture) control.
<font color="Red">HGDIOBJ hOldBM = </font>SelectObject(hdcStatic,hb);
SetWindowLong(hWndStatic,GWL_STYLE,(GetWindowLong(hWndStatic,GWL_STYLE) & ~SS_TYPEMASK) | SS_BITMAP) ;
BitBlt(hdcStatic,0,0,200,200,DeskDC,0,0,SRCCOPY);
<font color="Red">SelectObject(hdcStatic, hOldBM);</font>
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thnk you vary much for you help. But still I am not able to perform the thing.
I am doing something like this as you have told me to do.
But getting NULL in hOLdBM. and So getting BLANK Image (black Image)
HDC DeskDC = GetDC(NULL);
HDC hdcStatic = GetDC(hWndStatic);
HBITMAP hb = CreateCompatibleBitmap(hdcStatic,200,200);
HGDIOBJ hOldBM = SelectObject(hdcStatic,hb);
SelectObject(hdcStatic, hOldBM);
SetWindowLong(hWndStatic,GWL_STYLE,(GetWindowLong(hWndStatic,GWL_STYLE) & ~SS_TYPEMASK) | SS_BITMAP) ;
BitBlt(hdcStatic,0,0,200,200,DeskDC,0,0,SRCCOPY);
SelectObject(hdcStatic, hOldBM);
SendMessage(hWndStatic, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hOldBM);
SendMessage(hWndStatic, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hb);
-- modified at 2:00 Friday 12th October, 2007
|
|
|
|
|
Try this
HDC DeskDC = GetDC(NULL);
HDC hdcMem = CreateCompatibleDC(0);
HBITMAP hb = CreateCompatibleBitmap(<font color="Red">DeskDC</font>,200,200); <font color="Red">
HGDIOBJ hOldBM = SelectObject(hdcMem,hb);
BitBlt(hdcMem,0,0,200,200,DeskDC,0,0,SRCCOPY);
SelectObject(hdcMem, hOldBM);
SetWindowLong(hWndStatic,GWL_STYLE,(GetWindowLong(hWndStatic,GWL_STYLE) & ~SS_TYPEMASK) | SS_BITMAP) ;
SendMessage(hWndStatic, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hb); *edit* Fixed my bug
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Thnx a lot.
It works. But it displays only monochrome bitmap. I.e. the image I m gettting in static control is Blak and white image.
|
|
|
|
|
I screwed up - see my modified post. Sorry about that
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thnx a lot for you help
I just made the little change and its working..................
HDC DeskDC = GetDC(NULL);
HDC hdcMem = CreateCompatibleDC(DeskDC);
HBITMAP hb = CreateCompatibleBitmap(DeskDC,200,200);
HGDIOBJ hOldBM = SelectObject(hdcMem,hb);
BitBlt(hdcMem,0,0,200,200,DeskDC,0,0,SRCCOPY);
SelectObject(hdcMem, hOldBM);
SetWindowLong(hWndStatic,GWL_STYLE,(GetWindowLong(hWndStatic,GWL_STYLE) & ~SS_TYPEMASK) | SS_BITMAP) ;
SendMessage(hWndStatic, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hb);
|
|
|
|
|
You found it....good
Cheers!
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thnx,
but I am not getting what you mean by attaching the bitmap.
Is that mean to create a new bitmap in resource and use that with SelectObject() . If I use this I am getting only that bitmap in the Static control and Not the Image of BitBlt .
|
|
|
|
|
Thnx again.
But I think your code will display the (device Contex) on the Dialog or window you want. That will be cleared when window will be refreshed.
What I want is to display the DC (Device Context ) permanently
i.e. taking it first in bitmap file and then displaying that in Static Picture control.
But I am not able do with the code i have posted. It show only Black Screen (i.e. There is noting in the bitmap).
I dont know how do show the DC permanent. If there is any other simple way please tell me
|
|
|
|
|
Again thnx for your help. but I am not able to unnderstand the code or to implement it. As I am using Win32 dialog based Application and not the MFC application.
And so I am using something like this.
HBITMAP hb = CreateCompatibleBitmap(hdcStatic,200,200);
hb = LoadBitmap(hInst,MAKEINTRESOURCE(IDB_BITMAP1));
HBITMAP hb1;
GetObject(hb,sizeof(hb),&hb1);
SelectObject(hdc,hb1);
//If I use getting nothing in the Static picture control
SendMessage(hWndStatic, STM_SETIMAGE , IMAGE_BITMAP,(LPARAM) hb);
//If I use this instead of above it shows the bitmap in the Static picture control
//bitmap means blank image (white image only)
SendMessage(hWndStatic, STM_SETIMAGE , IMAGE_BITMAP,(LPARAM) hb1);
|
|
|
|
|
First, sorry.
I thought Dialog based App using win32 was not Doc/View architechture, but yes MFC. As all what I posted is completelly useless I have deleted the messages. I'm going to explain where I did not understand you, if you clarificate a bit, maybe others can help you better.
quote:
"I require to show the dc into the Picture Control as a bitmap"
As I understand it the DC is the intermediate tool to display bitmap or work with the GUI/Printer. So you load a bitmap in it and you put it in somewhere. But the DC itself can not be shown anywhere as a bitmap, and a bitmap selected in it is already a bitmap, so is only a question of load the resource and place it.
quote:
"If I use this I am getting only that bitmap in the Static control and Not the Image of BitBlt."
Which image of the BitBlt? The BitBlt places the Bitmap selected by the DC where you want to place it, copying from the resources, masking or doing whatever you say in its flags. But if you don't have any image in your resources... what is supposed to be copied?...
So... What do you exactly want to be displayed at your picture control?
quote:
"What I want is to display the DC (Device Context ) permanently"
What do u mean with this? If you reload the same resource when the Dialog is being repainted... is not enough permanent?
If the image has to be so permanent... why don't include it in the picture control at design time?
quote:
"I dont know how do show the DC permanent"
???
quote:
"
//If I use getting nothing in the Static picture control
SendMessage(hWndStatic, STM_SETIMAGE , IMAGE_BITMAP,(LPARAM) hb);
//If I use this instead of above it shows the bitmap in the Static picture control
//bitmap means blank image (white image only)
SendMessage(hWndStatic, STM_SETIMAGE , IMAGE_BITMAP,(LPARAM) hb1);
"
is the blank IDB_BITMAP1 not the blank image you are loading?
And if that is not what you want... what do you want to get?
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Sorry for the Confusion.
I need to perform the simple thing. I want to show the Captured desktop in the Static Picture Control. And want that it doesn't get erased when Dialod get refereshed.
I know how to capture the Desktop using BitBlt. But don't know how to display it show it doesn't get erased.
|
|
|
|
|
Quote:
"I want to show the Captured desktop in the Static Picture Control"
NOW...
-- modified at 9:19 Thursday 11th October, 2007
quote:
"I know how to capture the Desktop using BitBlt. But don't know how to display it show it doesn't get erased."
You don't have a CDocument to save the datas independantly of what happens around. I would create another class derived from CObject to hold the datas. Once you capture the image... then save it there. Everytime you refresh the Dialog, put the info contained in that class another time in the static control.
Is the only thing I can say will stay as long you don't overwrite the data that is saved.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Hi, Thnx and sorry, sorry because I am fail to explaing my problem.
Threre is no problem in capturing the desktop Screen. The problem is showing it in such a way that even if the Dialog get refreshed it doesn't get erased. i.e. If someone minimize the dialog and the when resotre it. the image should be threre.
If I will use simple BitBlt() to set show the Image on Dialog the image will be erased.
|
|
|
|
|
Last message I told you.
If you only set the image in your static control once then, you will always lose it when something particular happens (like min / maximize).
So...
One way can it be, create an abstract class derived from CObject. Create a CBitmap member variable inside. Once you have the screen capture, save it in the help-class.
Then include the class to your dialog, and... Write the code to put the bitmap in the control, inside the CDialog::OnPaint ()
If you want to put a image in the control at running time, (I am not 100% sure but...) there is no way to do it permanently but including the desired image everytime the window is refreshed, if not... every time the window is moved, minimized and so on... the intern Invalidate () to clean your screen will erase the pixels that are in the image, and if you dont load them another time... there is nothing to do. Yes there is... look above
In your place... I would do it as I said. Capture the desktop, save the image in an abstract class (or in a intern variable of the dialog) and code the insertion of the image in the static control inside your OnPaint or OnDraw.
If there is another way to do it... I don't know how, so if another one answers you, I will learn something new as well. (Correct answer above)
Good luck
-- modified at 5:01 Tuesday 16th October, 2007
-- modified at 5:02 Tuesday 16th October, 2007
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Nelek wrote: If you only set the image in your static control once then, you will always lose it when something particular happens (like min / maximize).
Where did you get that from? The bitmap stays in the static control until you set another bitmap to it.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
As I said... I have learned something new.
I thought that for things that are not in the resources (dinamically charged) that was true. But I actually was wrong, so I apologize and retract what I said.
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Hello all,
I'm trying to find some info on grid computing and virtualization. I've seen an article about XGE (from Xoreax Incredibuild), I know and use Incredibuild already, but what I'm wondering is how their virtualization environment work. I'm trying to look for some information on the architecture behind this. Do you have any link that could help me, any information ?
Thanks,
Gérald
|
|
|
|
|
I am trying to inplace an edit box in a list control .Whenever I double click the item on the list control I am getting iItem of LPNMITEMACTIVATE as -1. Can any one suggest me regardig this
S.Yamini
|
|
|
|
|
From MSDN:
To obtain the items being activated, the receiving application should use the LVM_GETSELECTEDCOUNT message to receive the number of items that are selected and then send the LVM_GETNEXTITEM message with LVNI_SELECTED until all of the items have been retrieved
|
|
|
|
|
|
"To obtain the items being activated, the receiving application should use the LVM_GETSELECTEDCOUNT message to receive the number of items that are selected and then send the LVM_GETNEXTITEM message with LVNI_SELECTED until all of the items have been retrieved "
How did you use LVM_GETSELECTEDCOUNT, LVM_GETNEXTITEM, and LVNI_SELECTED? Can you give an sample code to solve the problem mentioned?
|
|
|
|
|
Hi all,
I want to get text on a Edit Control in MFC application. On MSDN I found that it is possible by using
GetDlgItemText(Edit_Control_ID)
But I'm confusing how to assign or used on the application. Give a feedback to me.
Thanks.
I appreciate your help all the time...
|
|
|
|
|
Will this helpful ?
CString strStaticText;<br />
GetDlgItem(IDC_EDIT1)->GetWindowText(strStaticText);
Regards,
Paresh.
|
|
|
|
|
Thanks. But I got this error
'CWnd::GetDlgItemTextA' : no overloaded function takes 1 arguments
left of '->GetWindowTextA' must point to class/struct/union
But on the explanation I don't found that more than one argument is passing.
I appreciate your help all the time...
|
|
|
|
|