|
Hi all,
I hope this is the right forum to ask, I want to do it from C++ so I figured I could try here )
I'm trying to get an image from an html page that I have in memory. IWebBrowser2 doesn't let me do that AFAIK, it looks like I even have to actually create a window to use it. I just want to pass a string with html to some function, and have that function return a bitmap (with specifyable width & height ofcourse). I would prefer to use IE to do it, since I need to render MathML. Any thoughts? Thanks in advance.
cheers,
roel
|
|
|
|
|
I think you need to query for the interface to the DOM--
that's an IHTMLDocument2. It should allow access to the
images.
oh yeah... a link to example[^].
|
|
|
|
|
oh wait. did you want an image on the page or an image of the page.
|
|
|
|
|
Yeah I wanted an image _of_ the page... Thanks for replying anyway
|
|
|
|
|
Take a look at this msdn page[^] which lists all HTML interfaces used in Internet Explorer. Take a look at IHTMLPainter for instance. I have not tried/tested this and have no idea if this is what you are looking for but it sounds promising..
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
Hmm this is indeed an interesting list... Thanks, I'm going to look through it!
|
|
|
|
|
Hi,
I've been attempting some owner draw buttons and wish to set the check state of a CButton without using the BM_SETCHECK message or the SetCheck member function. The reason i want ot do this is that if you send the BM_SETCHECK message (the SetCheck function just sends the message) then windows redraws the checkbox, however i want to Set the check state without windows redrawing the checkbox.
I was hoping that someone may know where the check state of a button is stored and how to get at it from the HWND?
Thanks,
Jon
|
|
|
|
|
One solution is to derive a class from CButton and design your own set-check mechanism.
Kuphryn
|
|
|
|
|
I need to convert vector members of form std::vector<std::string> to LPSTR. Need to convert the string to char*. Has anyone done this? Any suggestions? Thanks for any help.
|
|
|
|
|
how about:
LPCSTR p = static_cast<LPCSTR> &myvector[0];
or using a std::string instead of vector next time and do:
LPCSTR p = mystr.c_str();
|
|
|
|
|
When I use the first solution it gives me:
error C2059: syntax error : '&'
I need to use a collection class for my list of strings. Thus the use of vector.
|
|
|
|
|
Tdcu wrote:
When I use the first solution it gives me:
error C2059: syntax error : '&'
Did you enter it exactly like it was shown in his response, he didn't use the correct formatting to display. He ment to type something like this:
<code>LPCSTR p = static_cast<LPCSTR> &myvector[0];</code>
<font color="green">
<code>LPCSTR p = static_cast<LPCSTR> &myvector;</code>
Nick Parker
Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein
|
|
|
|
|
Thanks Nick. I was leaving out the const (just using LPSTR).
|
|
|
|
|
Do you happen to have a code snippet of how you are declaring your vector? In other words, is it a vector of characters, or a vector of character arrays or strings?
If it is just characters, as a last resort you can always do a for loop to copy over the characters one by one.
Even a broken clock is right twice a day.
|
|
|
|
|
I want to create my own window class(similar to CWnd). I must do this without using MFC. Does anyone know of any examples or locations where I would be able to find information on this?
|
|
|
|
|
you get the MFC source with your VC, prolly "read and learn"?
|
|
|
|
|
Get out your classic Petzold 'Programming Windows' (you do have one don't you?) - it's in there. If you want an online sample, there is one here on CP: http://www.codeproject.com/useritems/Brainchild.asp. It's probably quite complex for a starter, though.
|
|
|
|
|
You could check out http://www.relisoft.com[^] which contains some useful articles about this stuff.
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
hi,
I've developed one ATL EXE server com. This server contains 2 threads.
The main thread (lets call it T1) will do following tasks:
1. Create second thread ( and this I think should be called T2) using "CoMarshalInterThreadInterfaceInStream".
2. Receive input from client application:
HRESULT CMainThread::ReceiveClientInput(BSTR AnyValue)<br />
{<br />
<br />
EnterCriticalSection(&cs); <br />
m_isFire = true;<br />
LeaveCriticalSection(&cs);<br />
<br />
return S_OK;<br />
}
T2 on the other hand continously (every 2 seconds) check for m_isFire value and fire the event:
void CSecondThread::CheckFlag(void)<br />
{<br />
<br />
EnterCriticalSection(&cs); <br />
<br />
if (isFire == true ){<br />
Fire_NotifyAllConnectedClients();<br />
isFire = false;<br />
}<br />
<br />
LeaveCriticalSection(&cs);<br />
<br />
}
Now, when event fired from above COM method, there is no client receive this event
I guess I've missed something in my code since I'm quite new in using VC++.
Thank u very very much in advance . Any advice, help and suggestions strongly aprreciated.
Regards,
newbie
|
|
|
|
|
Never ever use a shared variable for this. Create a named event and use WaitForObject() and SetEvent/ResetEvent or PulseEvent to set or clear that event.
But your bug, I believe lies inside the Fire_NotifyAllConnectedClients() function. Have a look there.
I don't think this is a serious possesion, and the evil most likely comes from your hand. Colin J Davies, The Lounge
|
|
|
|
|
It might be preferable to use unnamed synchronization objects if they
are only for use within the same process. That way you don't have to
think about naming issues or access by another application.
|
|
|
|
|
Thanks for the reply.
Actually I want to use that variable. Below is my real source code:
struct ScheduledDevice<br />
{<br />
CComBSTR RefID;<br />
CComBSTR Name;<br />
DATE StartTime;<br />
DATE EndTime;<br />
int Status;<br />
long Command;<br />
};<br />
<br />
typedef map<BSTR, ScheduledDevice> SCHEDULELIST;<br />
SCHEDULELIST m_Schedule;<br />
SCHEDULELIST m_SendToOPC;
At main thread I receive input from client:
HRESULT CMonitorDeviceThread::Add(BSTR DeviceName, DATE StartTime, DATE EndsTime, BSTR RefID)<br />
{<br />
ScheduledDevice obj;<br />
<br />
obj.Name = DeviceName;<br />
obj.StartTime = StartTime;<br />
obj.EndTime = EndsTime;<br />
obj.RefID = RefID;<br />
obj.Status = bookOpenStatus;<br />
<br />
EnterCriticalSection(&cs); <br />
m_Schedule[obj.RefID] = obj;<br />
LeaveCriticalSection(&cs);<br />
<br />
return S_OK;<br />
}
And at second thread the code will continously check and intiate the event:
while ( m_IsRun == TRUE )<br />
{<br />
<big>Command();</big><br />
Sleep(10000);
}<br />
<br />
void CMonitorDeviceThread::Command(void)<br />
{<br />
ScheduledDevice obj, OPCDev;<br />
SCHEDULELIST::iterator m_Iterator;<br />
bool IsErase = false;<br />
<br />
EnterCriticalSection(&cs);<br />
<br />
m_SendToOPC.clear();<br />
<br />
for ( m_Iterator = m_Schedule.begin(); m_Iterator != m_Schedule.end(); )<br />
{ <br />
<br />
SYSTEMTIME dtStartTime, dtEndTime, stCurDate;<br />
<br />
VariantTimeToSystemTime( (*m_Iterator).second.StartTime, &dtStartTime );<br />
VariantTimeToSystemTime( (*m_Iterator).second.EndTime, &dtEndTime );<br />
GetLocalTime(&stCurDate);<br />
<br />
CHighTime bookStartTime( dtStartTime ); <br />
CHighTime bookEndTime( dtEndTime ); <br />
CHighTime curTime( stCurDate ); <br />
<br />
CHighTimeSpan sDiffStartTime = bookStartTime - curTime;<br />
CHighTimeSpan sDiffEndTime = bookEndTime - curTime;<br />
<br />
long diffStart = sDiffStartTime.GetTotalMinutes(); <br />
long diffEnd = sDiffEndTime.GetTotalMinutes(); <br />
<br />
if ( ( diffStart == 0 || ( diffStart >= -5 && diffStart <= -1 ) ) && (*m_Iterator).second.Status == bookOpenStatus ) {<br />
<br />
OPCDev = (*m_Iterator).second;<br />
OPCDev.Command = 1;<br />
m_SendToOPC[OPCDev.RefID] = OPCDev;<br />
<br />
(*m_Iterator).second.Status = bookExecuteStatus;<br />
<br />
}<br />
<br />
<br />
if ( ( diffEnd == 0 || ( diffEnd >= -10 && diffEnd <= -1 ) ) && (*m_Iterator).second.Status == bookExecuteStatus ) {<br />
<br />
OPCDev = (*m_Iterator).second; <br />
OPCDev.Command = 0;<br />
m_SendToOPC[OPCDev.RefID] = OPCDev;<br />
<br />
(*m_Iterator).second.Status = bookCloseStatus;<br />
<br />
} else if ( diffEnd <= -11 ){<br />
<br />
m_Iterator=m_Schedule.erase(m_Iterator);<br />
IsErase = true;
}<br />
<br />
if ( !IsErase ){<br />
++m_Iterator;<br />
IsErase = false;<br />
}<br />
<br />
<br />
}
<br />
LeaveCriticalSection(&cs);<br />
<br />
<big>ProcessEvent();</big><br />
}<br />
<br />
void CMonitorDeviceThread::ProcessEvent()<br />
{<br />
<br />
if (m_SendToOPC.size() > 0 ) {<br />
<br />
long recCount = m_SendToOPC.size();<br />
long i=0;<br />
SAFEARRAYBOUND bounds = {recCount, 0};<br />
<br />
VARIANT pItems;<br />
VariantInit(&pItems);<br />
pItems.vt = VT_ARRAY | VT_BSTR | VT_BYREF;<br />
<br />
VARIANT pCommands;<br />
VariantInit(&pCommands);<br />
pCommands.vt = VT_ARRAY | VT_I4 | VT_BYREF;<br />
<br />
SAFEARRAY* psaItems = NULL;<br />
BSTR *strItems;<br />
psaItems = SafeArrayCreate(VT_BSTR, 1, &bounds);<br />
<br />
SAFEARRAY* psaCommands = NULL;<br />
long *lngCommands;<br />
psaCommands = SafeArrayCreate(VT_I4, 1, &bounds);<br />
<br />
SafeArrayAccessData(psaItems, (void**)&strItems);<br />
SafeArrayAccessData(psaCommands, (void**)&lngCommands);<br />
<br />
for ( m_OPCIterator = m_SendToOPC.begin(); m_OPCIterator != m_SendToOPC.end(); m_OPCIterator++)<br />
{<br />
strItems[i] = (*m_OPCIterator).second.Name;<br />
lngCommands[i] = (*m_OPCIterator).second.Command;<br />
i++;<br />
}<br />
<br />
SafeArrayUnaccessData(psaItems);<br />
SafeArrayUnaccessData(psaCommands);<br />
<br />
pItems.pparray = &psaItems;<br />
pCommands.pparray = &psaCommands;<br />
<br />
<big>Fire_NotifyAllConnectedClients(pItems, pCommands, i);</big><br />
<br />
SafeArrayDestroy(psaItems);<br />
SafeArrayDestroy(psaCommands);<br />
<br />
}<br />
<br />
}
Here is ATL wizard generated CP event file :
VOID Fire_NotifyAllConnectedClients(VARIANT Items, VARIANT Command, LONG saje)<br />
{<br />
T* pT = static_cast<T*>(this);<br />
int nConnectionIndex;<br />
CComVariant* pvars = new CComVariant[3];<br />
int nConnections = m_vec.GetSize();<br />
<br />
for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)<br />
{<br />
pT->Lock();<br />
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);<br />
pT->Unlock();<br />
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);<br />
if (pDispatch != NULL)<br />
{<br />
pvars[2] = Items;<br />
pvars[1] = Command;<br />
pvars[0] = saje;<br />
DISPPARAMS disp = { pvars, NULL, 3, 0 };<br />
pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, NULL, NULL, NULL);<br />
}<br />
}<br />
delete[] pvars;<br />
<br />
}
Again thank a lot
Regards,
Newbie
|
|
|
|
|
hi,
I've figured out what is the problem is.
When I assign value for variable at main thread, its not available at second thread: Below is the code example where I set the obj at main thread:
<br />
ScheduledDevice obj;
<br />
HRESULT CMonitorDeviceThread::Add(BSTR DeviceName, DATE StartTime, DATE EndsTime, BSTR RefID)<br />
{<br />
ScheduledDevice obj;<br />
<br />
EnterCriticalSection(&cs); <br />
obj.Name = DeviceName;<br />
obj.StartTime = StartTime<br />
obj.EndTime = EndsTime;<br />
obj.RefID = RefID;<br />
<big>obj.Status = 1;</big><br />
LeaveCriticalSection(&cs);<br />
<br />
return S_OK;<br />
}<br />
Below is the code where I refer back to the obj value at second thread for further processing:
<br />
HRESULT CMonitorDeviceThread::Execute()<br />
{<br />
EnterCriticalSection(&cs);<br />
if ( <big>obj.Status == 1</big> ){<br />
<br />
Fire_NotifyAllConnectedClients(Name, Status, ......);<br />
<big>obj.Status = 2;</big><br />
<br />
}<br />
LeaveCriticalSection(&cs);<br />
}<br />
For ur info I've try to declare obj as a static variable and manage to fire event to MFC clients:
<br />
static ScheduledDevice obj;<br />
But when I do simulation testing, after few times its cannot triggered event to clients anymore. It's back to original problem.
Does anybody knows what is the problem actually is ??
Thanx in advance.
Regards,
newbie.
|
|
|
|
|
Does somebody know, when the public DX9 SDK will be released?
Daniel Balas - Student
|
|
|
|
|
I believe that I read Feburary, but I do not know where I read this from.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|