|
thanks Cédric Moonen ,, now my project plays sounds fine.
|
|
|
|
|
Hi,
Does anyone have any code snippets showing what I need to do in order to draw what usually goes to a DC onto a bitmap instead?
I am not being lazy, I am just into recycling
|
|
|
|
|
Drawing is always done to a device context.
To create a bitmap out of it, the device context can be saved as a bitmap.
I found one article on CP -
http://www.codeproject.com/KB/graphics/drawing2bitmap.aspx
|
|
|
|
|
Thanks Superman, that looks to be EXACTLY what I need to do. I did try searching the Code Project site first but I probably chose bad keywords.
|
|
|
|
|
Below is a code snippet that demonstrates creating a memory DC, calling functions that use std GDI funtions to draw onto the DC, extracting the BMP from the DC and doing something with it, and finally clean up:
<br />
BOOL DoChart(CallContextObj *pCallContextObj)<br />
{<br />
CDC oMemDC;<br />
CBitmap *pOldBmp;<br />
CBitmap oBmp;<br />
<br />
long lWidth = 300;<br />
long lHeight = 200;<br />
pCallContextObj->GetParameterValue(_T("ChartWidth"),&lWidth);<br />
pCallContextObj->GetParameterValue(_T("ChartHeight"),&lHeight);<br />
<br />
CRect oBmpSize(0,0,lWidth,lHeight);<br />
<br />
oMemDC.CreateCompatibleDC(NULL);<br />
int iOldMapMode = oMemDC.SetMapMode(MM_TEXT);<br />
<br />
CWindowDC dcScreen(NULL);<br />
<br />
oBmp.CreateCompatibleBitmap(&dcScreen,oBmpSize.Width(), oBmpSize.Height());<br />
<br />
pOldBmp = oMemDC.SelectObject(&oBmp);<br />
<br />
WORD wChartType = 88;<br />
pCallContextObj->GetParameterValue(_T("ChartType"),&wChartType);<br />
<br />
BOOL bRetval = FALSE;<br />
TCHAR caError[1024];<br />
_tcscpy(caError,_T("Invalid Chart Type"));<br />
<br />
switch (wChartType)<br />
{<br />
case 0:<br />
bRetval = DoLineChart(pCallContextObj,&oMemDC,caError,oBmpSize);<br />
break;<br />
<br />
case 1:<br />
bRetval = DoBarChart(FALSE,pCallContextObj,&oMemDC,caError,oBmpSize);<br />
break;<br />
<br />
case 2:<br />
bRetval = DoBarChart(TRUE,pCallContextObj,&oMemDC,caError,oBmpSize);<br />
break;<br />
<br />
case 3:<br />
bRetval = DoOpenHiLowCloseChart(pCallContextObj,&oMemDC,caError,oBmpSize);<br />
break;<br />
<br />
case 4:<br />
bRetval = DoPieChart(pCallContextObj,&oMemDC,caError,oBmpSize);<br />
break;<br />
}<br />
<br />
if (bRetval)<br />
{<br />
char caHeaders[1024];<br />
<br />
#ifdef UNICODE<br />
BYTE *cpBuf = (BYTE *)pCallContextObj->GetUTF8OutputBufferPtr();<br />
#else<br />
BYTE *cpBuf = (BYTE *)pCallContextObj->GetOutputBufferPtr();<br />
#endif<br />
<br />
long lQuality = 75;<br />
pCallContextObj->GetParameterValue(_T("ImageQuality"),&lQuality);<br />
<br />
long lDataSize = WriteImage(oBmp,cpBuf,pCallContextObj->GetOutputBufferSize(),caError,(DWORD)lQuality);<br />
if (lDataSize > 0)<br />
{<br />
pCallContextObj->SuppressHeaders();<br />
<br />
sprintf(caHeaders,"Content-Type: image/jpeg\r\nContent-Length: %d\r\n\r\n",lDataSize);<br />
<br />
if (pCallContextObj->ServerSupportFunction(HSE_REQ_SEND_RESPONSE_HEADER,"200 OK",0,(LPDWORD)caHeaders) || ::GetLastError() == 10054)<br />
pCallContextObj->WriteClient((LPVOID)cpBuf,(LPDWORD)&lDataSize);<br />
<br />
*cpBuf = 0;<br />
pCallContextObj->EraseContent();<br />
}<br />
else<br />
bRetval = FALSE;<br />
}<br />
<br />
oMemDC.SetMapMode(iOldMapMode);<br />
oMemDC.SelectObject(pOldBmp);<br />
<br />
oMemDC.DeleteDC();<br />
<br />
if (!bRetval)<br />
{<br />
pCallContextObj->StartContent();<br />
pCallContextObj->WriteTitle();<br />
pCallContextObj->WriteContent(_T("Error Converting Bitmap!<BR>"));<br />
pCallContextObj->WriteContent(caError);<br />
pCallContextObj->EndContent();<br />
}<br />
<br />
return TRUE;<br />
}
onwards and upwards...
|
|
|
|
|
hi all,
I dont know wheither its the right forum for this question.But if any one have any idea please help me.
I have installed Visual studio 2005 and trying to build the project which is already running fine in another PC.
But i am getting this error when i build it in new machine.
Error 210 fatal error LNK1257: code generation failed
How can i solve it
Thanks
Raj
|
|
|
|
|
MSDN on LNK1257[^]:
When compiling with /GL, the linker failed to perform code generation. Investigate any compiler diagnostics that have been emitted and try to remedy them.
Do you have an otherwise clean build? You should set the warning level to maximum. Try /W4 or even /Wall.
|
|
|
|
|
Once try creating some new project of same type(SDI/MDI/Dialog) of your application and try compiling it.
If the above test ok then,
There can be many possibilities:
Try clean & rebuild of your project.
One reason could be compiler runs out of space - If your project size is very big, try splitting your project into smaller modules and compile.
Check if there is any call to macro(#define) is done inside any destructor etc..
Regards,
--
"Programming is an art that fights back!"
|
|
|
|
|
CapEditCopy “copies the contents of the video frame buffer and associated palette to the clipboard.”
per MSDN. The data on the clipboard can be validated using IsClipboardFormatAvailable(format)
where the format could be CF_DIB or CF_BITMAP.
Using either of these formats the validation is OK.
Now DIB and BITMAP structures and the data layout are definitely different.
I have been successful using CF_BITMAP.
I know, when ti works do not fix it , but...
I am just looking for someone smarter than me to come up with explanation.
Thanks for reading. Hope I did not waste your time.
Vaclav
|
|
|
|
|
It's possible to store the same data on the clipboard in more than one format. In other words it could be in both CF_DIB and CF_BITMAP. When you retrieve the data you get whichever format you ask for.
It's also possible for the application that supplies the data to use delayed rendering. It 'advertises' on the clipboard all the formats it can supply but does not actually supply the data until someone pastes it somewhere. It then supplies data in the requested format.
Phil
The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.
|
|
|
|
|
Thanks Phil,
since my app refuses to "grab a single AVI frame" I have been doing some more MSDN look-ups.
I do not recall where, but it MSDN states that the AVI frame is in DIB format.
Something else same up, CapEditCopy writes into clipboard without checking if it is in use.So I hack it by opening the clipboard and hoping it can be open, and than closing it. Real kluge.
Vaclav
|
|
|
|
|
Hi,
I have changed the normal dialog button to owner draw and used CBitmapButton.
But when the focus is on the button and when we hit enter it is not taking the keyboard input.
When we remove the owner draw, keyboard input works.
Can someone let me know how to enable keyboard input when the button is Owner draw and use CBitmapButton to place image on it.
Thanks in advance..
Ram..
|
|
|
|
|
Is the control recieving a WM_KEYDOWN when you bash enter when the focus is on it?
From what I remember of using BS_OWNERDRAW controls years ago you have to handle the keyboard messages yourself. Unlike BS_PUSHBUTTON the control doesn't generate BN_CLICKED notifications from someone pressing return/enter or space.
My first line of enquiry would be to override OnKeyDown in the button class and see what happens. If that's called then override OnKeyUp and send the button's parent a WM_COMMAND/BN_CLICKED when the enter or space key are released.
Cheers,
Ash
modified on Monday, September 20, 2010 11:39 AM
|
|
|
|
|
Visual C++ Solution
Accomplishing this task from a Visual C++ host is very straightforward. You can use an IWebBrowser2 interface to call the QueryInterface method for the IHTMLDocument2 interface. After you obtain a pointer to the document, then call QueryInterface for the IPersistFile interface. After you obtain this interface pointer, you can call the save method to save the file to disk.
HRESULT hr = E_FAIL;
IDispatch* pDisp = NULL;
IHTMLDocument2* pDoc = NULL;
pDisp = m_webOC.GetDocument();
if(SUCCEEDED(hr = pDisp->QueryInterface(IID_IHTMLDocument2,(void**)&pDoc)))
{
IPersistFile* pFile = NULL;
if(SUCCEEDED(pDoc->QueryInterface(IID_IPersistFile,(void**)&pFile)))
{
LPCOLESTR file = L"c:\\test1.htm";
pFile->Save(file,TRUE);
}
}
Hi all
I have seen this ariticle in MSDN.
In that i don't know m_webOC belongs to which object. If so how to create that object.
|
|
|
|
|
Form the article "How To Programmatically Save an HTML Page to Disk":
As a Web browser control host, or an application that is automating Internet Explorer, you may find it useful to be able to programmatically save the currently loaded document to disk without user intervention.
So, does your application host a Web Browser control?
Or, are you automating I.E.?
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 am not using Webrowser control
But it is an SDI appllication with CHtmlView..... I just want to save a web page and read them back.
Could u give any information on this...........
|
|
|
|
|
How about using CHtmlView::GetSource and writing it to a file.
|
|
|
|
|
You may follow Superman's suggestion or replace
pDisp = m_webOC.GetDocument();
with
pDispl = <YourCHtmlViewName>.GetHtmlDocument();
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]
modified on Monday, September 20, 2010 6:46 AM
|
|
|
|
|
Pallini , your solution goes fine :
pDispl = <<YourCHtmlViewName>>.GetHtmlDocument();
Thank you !!!
|
|
|
|
|
You are welcome.
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 want to combine all my files into a single file.
How can i do it.
Thanks in advance
|
|
|
|
|
You can do this from the command prompt using the command copy *.* newfile .
To do this programatically, open the destination file for writing using CreateFile .
Use FindFirstFile / FindNextFile to enumerate each file in the folder.
For each file found use CreateFile to open the file for reading.
Call ReadFile to read the entire contents of the file for reading and then use WriteFile on the destination file to write the contents that were read.
|
|
|
|
|
If you're using C++ you can combine files fairly easily. Open each one as an istream, open the destination file as an ofstream and then insert the streambufs of the input files to the destination file.
Something like:
std::ifstream a( "c:\\a.txt" );
std::ifstream b( "c:\\b.txt" );
std::ofstream c( "c:\\c.txt" );
c << a.rdbuf() << b.rdbuf();
will concatenate a.txt and b.txt and dump them in c.txt. It saves loads of tedious mucking about with C functions or Windows API functions.
Cheers,
Ash
|
|
|
|
|
Hello to all,
In my project I am sending email with attachment of jpeg image. I am using following user defined function in which logic of sending mail is written,
In foolowing function
lpszSubject = subject of mail
lpszTo = email address to whom u want to send mail
lpszName = name of person to whom u want to send mail
lpszText = email text
lpszFullFileName = path of the jpeg file to be attached
BOOL SendFile(LPCSTR lpszSubject, LPCSTR lpszTo,
LPCSTR lpszName, LPCSTR lpszText,
LPCSTR lpszFullFileName)
{
HINSTANCE hMAPI = ::LoadLibrary("mapi32.dll");
LPMAPISENDMAIL lpfnMAPISendMail =
(LPMAPISENDMAIL)::GetProcAddress(hMAPI, "MAPISendMail");
char szDrive[_MAX_DRIVE] = { 0 };
char szDir[_MAX_DIR] = { 0 };
char szName[_MAX_FNAME] = { 0 };
char szExt[_MAX_EXT] = { 0 };
char szFileName[MAX_PATH] = { 0 };
strcat(szFileName, szName);
strcat(szFileName, szExt);
char szFullFileName[MAX_PATH] = { 0 };
strcat(szFullFileName, lpszFullFileName);
MapiFileDesc MAPIfile = { 0 };
ZeroMemory(&MAPIfile, sizeof(MapiFileDesc));
MAPIfile.nPosition = -1;
MAPIfile.lpszPathName = szFullFileName;
MAPIfile.lpszFileName = szFileName;
char szTo[MAX_PATH] = { 0 };
strcat(szTo, lpszTo);
char szNameTo[MAX_PATH] = { 0 };
strcat(szNameTo, lpszName);
MapiRecipDesc recipient = { 0 };
recipient.ulRecipClass = MAPI_TO;
recipient.lpszAddress = szTo;
recipient.lpszName = szNameTo;
char szSubject[MAX_PATH] = { 0 };
strcat(szSubject, lpszSubject);
char szText[MAX_PATH] = { 0 };
strcat(szText, lpszText);
MapiMessage MAPImsg = { 0 };
MAPImsg.lpszSubject = szSubject;
MAPImsg.lpRecips = &recipient;
MAPImsg.nRecipCount = 1;
MAPImsg.lpszNoteText = szText;
MAPImsg.nFileCount = 1;
MAPImsg.lpFiles = &MAPIfile;
ULONG nSent = lpfnMAPISendMail(0, 0, &MAPImsg, NULL, 0);
FreeLibrary(hMAPI);
return (nSent == SUCCESS_SUCCESS || nSent == MAPI_E_USER_ABORT);
}
Now everything is working fine but I am getting some surprising results as below
(1)If at the sending side user is using Outlook Express then email goes with attachment perfectly at the receiving side on any mail client
(2)But if at the sending side user is using Microsoft Office Outlook then email goes but attachment is missing at receiving side. If at the receiving side also Microsoft Office Outlook is there then only we get the attachment.
Means in short from Microsoft Office Outlook to Microsoft Office Outlook email goes with attachment at receiving side.
but from Microsoft Office Outlook to other mail client (other than Microsoft Office Outlook) attachment is missing at receiving side.
Please anyone can tell me what I am missing in my code and how to solve this problem. It is really very very urgent so please help me out.
Thanks and Regards,
Anay
|
|
|
|
|
AnayKulkarni wrote: (2)But if at the sending side user is using Microsoft Office Outlook then email goes but attachment is missing at receiving side.
What type of attachment?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|