|
Art Cote wrote:
One question - is insertAdjacentHTML feasible for drag drop operation, i.e.,
These are separate things. Handling drag&drop events is a different matter, which should not interfere with adding html code to an existing page.
How low can you go ? (MS rant)
|
|
|
|
|
The solution:
BSTR bstrText = SysAllocString(L"<table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\" bordercolor=\"#CCCCCC\" bgcolor=\"#E6E6E6\"><tr><td width=\"11%\"> </td><td width=\"11%\"> </td><td width=\"11%\"> </td></tr><tr><td width=\"11%\"> </td><td width=\"11%\"> </td><td width=\"11%\"> </td></tr></table>");<br />
<br />
IHTMLDocument2 *pDoc; <br />
IDispatch * pDocDisp = NULL; <br />
pDocDisp = GetHtmlDocument();<br />
HRESULT h = pDocDisp->QueryInterface( IID_IHTMLDocument2, (void**)&pDoc );<br />
BSTR bstrWhere = SysAllocString(L"BeforeEnd"); <br />
IHTMLElement *pBody;<br />
IHTMLLocation *pLocation;<br />
pDoc->get_body( &pBody );<br />
<br />
pBody->insertAdjacentHTML( (BSTR)bstrWhere, (BSTR)bstrText);<br />
<br />
SysFreeString(bstrText);<br />
SysFreeString(bstrWhere);<br />
pDoc->Release();<br />
pDocDisp->Release();
works fine - putting a table into CHtmlEditView. However how does one access
the IHTMLTable interface - when I to get_activeElement I get the body,
not the selected table.
Thanks.
Art
|
|
|
|
|
Art Cote wrote:
I to get_activeElement I get the body,
not the selected table.
What selected table ? You haven't selected anything here.
I guess you mean you are willing to get a IHTMLTable pointer from the table you have just inserted. That's easy, change your html tags so that you add a <table ...> with a name="mytable" attribute.
Then from the document.all collection, you can ask the DOM to retrieve the IHTMLElement whose name is "mytable" :
IHTMLElementCollection::item Method
HRESULT item( VARIANT name /*VT_BSTR*/, <-- "mytable"
VARIANT index,
IDispatch** pdisp
);
Finally, cast it to IHTMLTable
How low can you go ? (MS rant)
|
|
|
|
|
Oops - I meant to get the only table element on the page-
eventually i will setup element selection.
The code works - does one need to update the document somehow ?? so the changes to the table are shown?
(fragment)
<br />
pDoc->get_all(&pCollect); <br />
pCollect->item(varID,varIdx, &pDocDisp );<br />
pDocDisp->QueryInterface(IID_IHTMLTable, (void**) &pElem);<br />
<br />
pElem->put_cols(cols);<br />
<br />
.
.
.
Thanks again...
art
|
|
|
|
|
|
I know this may sound like a dumb question, however I'm stumped. Can someone tell me what a Dword is used for?
Thanks,
John
|
|
|
|
|
a DWORD is the same as an unsigned int .
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
it's used wherever you need 32 bits of unsigned storage. there's no rule that says what you should do with it.
-c
"[it was..] one of those evenings when you feel that not only will there definitely be a revolution, but that the Association of Manufacturers will foot the bill."
-- Umberto Eco, Foucault's Pendulum
|
|
|
|
|
One more piece of information as to why the DWORD is defined. The windows header files as well as many other development frameworks #define all of their types with a name like DWORD, INT, UINT and so on. This is so that the underlying datatype, can be changed to a compatible when the program is ported to a new system. Such as moving your C++ code to the new 64-bit windows implemenation or even to linux or mac (depending on what you are programming).
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!
|
|
|
|
|
In the Intel environment, DWORD is a D ouble WORD , where a WORD is a 16 bit value. A DWORD is therefore a 32 bit value. It is used as a generic container for any 32 bit value (signed and unsigned integers, and some pointer values). DWORD originates from Intel x86 assembly language. It worked its way into Windows programming back in the MS-DOS and Windows 1.x/2.x/3.x days, when you had to deal with the segmented memory model.
Software Zen: delete this;
|
|
|
|
|
I most certainly can make sense of a DWORD now. Thanks you all for the help.
John
|
|
|
|
|
When working with console applications from within Visual C++.NET, How would I get the console window to stay open after the program has executed so that I may view the results of the code? Do you change these properties within Visual C++ or Windows?
|
|
|
|
|
You can start the program with either Run or Debug. One of them leaves the program open with a "press any key to continue" message. I don't remember which one though.
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
put a breakpoint on the last "}" on your main function.
lazy isn't my middle name.. its my first.. people just keep calling me Mel cause that's what they put on my drivers license. - Mel Feik
|
|
|
|
|
or do put a getch() at the end before it returns a value or before the last line.
void main(void)
{
// blah blah do everything here.
getch(); // will wait for a keypress until it does anything else
}
|
|
|
|
|
Hi,
I am debugging a MT application and by this time I am pretty sure that there can only be syncrinization problems.
I use the same CStringList objects in many of my worker threads in the following manner:
In my CWinApp derived class header
CCriticalSection m_CriticalSectionForList1;
CCriticalSection m_CriticalSectionForList2;
In my worker threads:
theApp.m_CriticalSectionForList1.Lock();
...
...
theApp.m_CriticalSectionForList1.Unlock();
.
.
.
theApp.m_CriticalSectionForList2.Lock();
...
...
theApp.m_CriticalSectionForList2.Unlock();
Do I really correctly use critical sections?
Thanks
R.
|
|
|
|
|
Looks ok to me. Are you also using the critical section in the main app thread?
What is the problem you are seeing?
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
The reason that I placed the CriticalSection variables in the App class is that -just like the CStringList's- I have to access them in different classes, therefore the App seemed to be the most obvious place. The CStringList are "produced" by the worker thread, and displayed by the UI. That's why I need CriticalSections in order to avoid mutual access.
The error I experience is something really weird: a function returns one value and some time later another value without having manipulated it's input, etc.
Another thougth: should the CStringList's be declared volatile if I use them both in my user interface class (for simplicity lat's say: CDialog, where they are declared) and my worker threads?
Thanks for your help.
R.
|
|
|
|
|
Anonymous wrote:
The reason that I placed the CriticalSection variables in the App class is that -just like the CStringList's- I have to access them in different classes, therefore the App seemed to be the most obvious place. The CStringList are "produced" by the worker thread, and displayed by the UI. That's why I need CriticalSections in order to avoid mutual access.
No you misunderstood me. I wasn't talking about where the critical section is defined. I meant that you need to lock it in the app thread, as well as the worker threads. If you aren't doing that, then this could well be the cause of your problem.
Anonymous wrote:
The error I experience is something really weird: a function returns one value and some time later another value without having manipulated it's input, etc.
A function that accesses the CStringList?
Anonymous wrote:
Another thougth: should the CStringList's be declared volatile if I use them both in my user interface class (for simplicity lat's say: CDialog, where they are declared) and my worker threads?
I don't think this is relevant to the problem at hand.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Neville Franks wrote:
No you misunderstood me. I wasn't talking about where the critical section is defined. I meant that you need to lock it in the app thread, as well as the worker threads. If you aren't doing that, then this could well be the cause of your problem.
Bingo. Thanks very much for your help.
R.
|
|
|
|
|
Anyone knows how to communicate with paraller port (lpt1) in visual C++ without MFC?
Help please..
|
|
|
|
|
Look up CreateFile() and WriteFile() in the Win32 API section of the MSDN.
Software Zen: delete this;
|
|
|
|
|
Under Win95, Win98 you can directly write the hex-value to the port (with assembler):
...
void outportb(unsigned int portid, unsigned char value)
{
__asm
{
mov edx, portid
mov al, value
out dx, al
}
}
...
outportb(0x378, 20);
...
Under NT-Systems, like Win2000, WinNT and XP you are not allowed to write directly to the ports.
It this case just use a port-driver like "UserPort" (just take a look on http://www.mattjustice.com/parport/par_nt.html).
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Hello!,
I am a little stuck with this piece of code, can anyone help me please?
Actually I don’t know how to implement the assignment operator and the overloaded operator. Can you give me some tips and ideas please. As it is apparent, I have just started with C++ programming.
//file myString.h
#include
class myString
{
private:
char* theString;
int length;
public:
myString();
myString(char*);
~myString();
myString(const myString&);
myString(const char*);
//the assignment operator
myString& operator=(const myString&);
myString& operator=(const char*);
int getLength();
const char* GetString();
// == operator overloaded for string comparison
friend int operator==(const myString&, const myString&);
friend int operator==(const myString&, const char*);
};
Thanks
|
|
|
|
|
I am not sure what you mean by the overload operator?
As far as the assignment operator, this is what you need to do:
1: check for a reference to the current object. There is no sense in reassigning of you are doing something like this:
Object A;
A = A;
Here is the code you use to do that check:
myString &operator=(const myString& rhs)
{
if (*this == rhs)
{
return *this;
}
...
}
2: delete all of your existing memory, to prevent memory leaks.
delete[] theString;
theString = NULL;
3: allocate and copy the data from the input parameters.
if (rhs.theString)
{
length = strlen(rhs.theString) + 1;
theString = new char[length];
strcpy(theString, rhs.theString);
}
4: Returns a reference to this object to make things like this possible:
Object A, B, C;
...
A = B= C;
Here is the code to do this:
return *this;
Good Luck
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!
|
|
|
|