|
You can always create a bitmap of the stuff that's stored on your device context and then Haru can print it to a PDF. Sounds viable?
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Rajesh,
Obviously, I'd much rather preserve my reports as vector graphics.
At the moment, I'm looking at wxPdfDocument - It's designed to be used from WxWidgets, but it may be possible to use from MFC,
Regards,
Sternocera
|
|
|
|
|
If you succeed in making it work with MFC, it must make a good article for CP.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
|
I want to implement drawing of standard listbox, treeview etc. to a layered window. I know there is a method with “fake” layered window under normal one but I need more flexible control on incorporation of standard controls to final image of a layered window.
I think there may be some hidden window with controls I need and whose drawing stuff can be redirected to some bitmap. If it's not possible with the hidden window then what about window that is out of screen (e.g. x = -2000, y = -2000)?
|
|
|
|
|
Try experimenting with WM_PRINTCLIENT[^].
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
 Thanks! It works! But there is something wrong with the alpha channel.
[img]http://smages.com/i/0c/74/0c74a1f057b9a7e17a0c27e2b4dd4766.png[/img]
I'm creating 32-bpp bitmap and asking the button do draw itself there with WM_PRINTCLIENT. What's wrong?
hdc = GetDC(hWnd);
hdcMemory = CreateCompatibleDC(hdc);
nBytesPerLine = ((szWin.cx * 32 + 31) & (~31)) >> 3;
stBmpInfoHeader.biSize = sizeof(BITMAPINFOHEADER);
stBmpInfoHeader.biWidth = szWin.cx;
stBmpInfoHeader.biHeight = szWin.cy;
stBmpInfoHeader.biPlanes = 1;
stBmpInfoHeader.biBitCount = 32;
stBmpInfoHeader.biCompression = BI_RGB;
stBmpInfoHeader.biClrUsed = 0;
stBmpInfoHeader.biSizeImage = nBytesPerLine * szWin.cy;
void* pvBits;
hbmpMem = CreateDIBSection(NULL, (PBITMAPINFO)&stBmpInfoHeader, DIB_RGB_COLORS, &pvBits, NULL, 0);
memset(pvBits, 0x88, szWin.cx * szWin.cy * 4);
if (hbmpMem)
{
HGDIOBJ hbmpOld = SelectObject(hdcMemory, hbmpMem);
SendMessage(ctrl, WM_PRINTCLIENT, (WPARAM)hdcMemory, PRF_CLIENT | PRF_CHILDREN | PRF_OWNED);
BLENDFUNCTION stBlend;
stBlend.AlphaFormat = AC_SRC_ALPHA;
stBlend.BlendFlags = 0;
stBlend.BlendOp = AC_SRC_OVER;
stBlend.SourceConstantAlpha = 255;
UpdateLayeredWindow(hWnd, hdc, &ptWinPos, &szWin, hdcMemory, &ptSrc, 0, &stBlend, ULW_ALPHA);
SelectObject(hdcMemory, hbmpOld);
DeleteObject(hbmpMem);
}
DeleteDC(hdcMemory);
DeleteDC(hdc);
|
|
|
|
|
Do you simply want to make a window that has a constant blend factor? Because if yes, then you don't need a bitmap and the fancy drawing and all the rest.
Aside of this, is your problem that the button seems to loose transparency? I supose that's simply because when the button gets drawn onto your bitmap it overwrites the alpha channel.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
I do need per-pixel alpha for some skinning engine So if control overrides alpha then I have to make one more bitmap (24 bpp) and then blit it to my 32b buffer? Or there is simpler solution?
|
|
|
|
|
How about filling the alpha channel after you rendered your controls?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Hi All,
On a TCHAR buffer I've some data. I want to check them either empty or not, the content.
I tried this.
<br />
TCHAR szMyBuffer[128];<br />
<br />
if(szMyBuffer != L"")<br />
But this is not work, what can I do on that?
Thanks a lot
I appreciate your help all the time...
CodingLover
|
|
|
|
|
You are checking the address of the buffer, you need to check the contents. Try:
if (!szMyBuffer[0])
if (szMyBuffer[0])
(Sorry for the brain freeze.)
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
It's quite the opposite (i.e. if (szMyBuffer[0]) ).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Well, you both are right, it is a matter of "where" you handle the error. Some people go by that style, Carlo.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Rajesh R Subramanian wrote: Some people go by that style, Carlo.
I use that style too. However, OP was asking for
if(szMyBuffer != L"")
replacement.
--Carlo the Nitpick.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I agree, but he might have meant to handle the error with if and write the processing code into else. Just that he wasn't clear with it.
But OK, you win today.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
You could also try
if (_tcslen(szMyBuffer) > 0)
About _tcslen[^]
Stupidity is an International Association - Enrique Jardiel Poncela
|
|
|
|
|
I hate that construct. Why do a CRT call when all that matters is the first character?
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Personally, because it's clearer to read. I gave another option, and so did others. Let the OP decide.
Stupidity is an International Association - Enrique Jardiel Poncela
|
|
|
|
|
CodingLover wrote: if(szMyBuffer != L"")
As Joe said, this isn't the buffer itself. You cannot check using the == operator.
If you are using std::string or CString, you could. That too I'd prefer checking their lengths. For buffers you could use CRT routines :
MSDN[^]
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
|
|
|
|
|
if (*szMyBuffer)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi all,
i have an ascii value in unsigned char* buffer, i want to convert it in Hex.
please tell me how can i convert it in hex.
and i also want to convert hex values in decimal .
so please tell me how can i do this.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
If you are using CString , then you haven't read my previous reply to you, a few days ago: printf tutorial for you[^]
If you are not using MFC, still still MUST read the printf tutorial and you can use _stprintf[^]
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
thanks
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
If you actually wanted to be thankful, I'll be glad if you can please read the tutorials that you're asked to.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|