|
What about...
unsigned char *srcString = "{abcdef}";
unsigned char *dstString = "";
memcpy (srcString+1, dstString, (srcString.length () - 2));
If it works you can still free the memory and delete the pointer avoiding the problem that Matthew said.
Up to that point you can work with *dstString as it was your original one.
Hope it helps
P.S. Im not sure if it works, I just asked about buffers and how to get parts of the memory two/three days ago, and this is something that I get from the answers I received.
-- modified at 6:29 Thursday 11th October, 2007
I forgot...
with the srcString + X you specify the first character you want without changing the "value" of where the pointer points.
at dsstString you can make the same leaving some intial chars unmodified adding X to his base adress
the last is the number of chars of the first string you wanna copy in the second
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
|
|
|
|
|
I want to use this function to get close event from WORD(like DoModal() in Dialog). My code like this:
---------------------------------------------------------------------------------------------
COleDispatchDriver DocProperties(pDispatch, FALSE);
_variant_t Property((long)Word::wdPropertyPages);
_variant_t Result;
DocProperties.InvokeHelper(DISPID_....,
DISPATCH_...,
VT_BSTRT,
(void*)&Result,
(BYTE*)VTS_VARIANT,
&Property);
---------------------------------------------------------------------------------------------
Is it correct idea? And what I have to input for 3 first parameters? Thank you.
|
|
|
|
|
hai,
iam using a 64 bit integer in my application.
now my problem is if i want to print its hexa value into a string, like
str.Format("%x",value);
it is printing only lsb 32 bits.
how can i achieve this using a single type specifier like %x.
how ever,
i got it solved with the following technique.
UINT64 value=0xabcdefef;
CString str;
unsigned long value1,value2;
value1=value>>32;
value2=value;
str.Format("%x%x",value1,value2);
can any body please suggest me what is the type specifier for unsigned int 64.
thanks in advance.
-- modified at 4:59 Thursday 11th October, 2007
|
|
|
|
|
I am not sure about but... can it help casting the value to (_UINT64)? I mean
str.Format (_T("%x"), (UINT64) value);
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
|
|
|
|
|
|
thanks nibu,
what i was looking for was exctly that.
|
|
|
|
|
Hello friends,
I require to show the dc into the Picture Control as a bitmap.
For that I am using the code like below, but only shows blank bitmap in the Picture control.
HDC DeskDC = GetDC(NULL);
HDC hdcStatic = GetDC(hWndStatic);
HBITMAP hb = CreateCompatibleBitmap(hdcStatic,200,200);
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);
SendMessage(hWndStatic, STM_SETIMAGE , IMAGE_BITMAP,(LPARAM)hb);
Please tell me if you know what is going wrong.
|
|
|
|
|
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
|
|
|
|
|