|
Typically, one renders from a model and it is with regards to the model that the line is added/removed; the scene is just re-rendered. If you what you have to work with is just the image itself, then you'll have to just save the image data and restore it later. Or perhaps draw into an overlay layer that doesn't disturb the base image. Are you using plain ol' GDI or something fancier?
|
|
|
|
|
Drawing in normal mode with a pen of a specific color and then later setting the SetROP2() mode (I think that's what its called) to R2_XORPEN and using the same color, erases it.
This is not perfect but works for most cases. If you have drawn a bunch of lines or objects different colors on top of your line then XORing with the background will XOR it with the overlaid colors thus never restoring the original background.
|
|
|
|
|
Actually, that would simply replace the colored line with a black line (all the 1's go to 0's).
|
|
|
|
|
I disagree. Unless, you know the order of what was drawn on top of your line and then redraw it in reverse order using XOR it will not restore the original background.
Say your original background is black and you draw a yellow rect and then follow with a magenta rect where part of the magenta rect draws over a portion of the yellow rect. If you SetROP2(R2_XORPEN) and redraw/erase the yellow rect you will restore the black background for all locations except where the magenta rect was drawn since it will XOR with what's onscreen and that part is magenta. Then when you SetROP2(R2_XORPEN) and redraw/erase the magenta rect it will try to restore a yellow background for the parts that overlap and black on all non-overlapping pixels. Thus, you will be left with a different color than the black background on all locations where the pixels overlapped.
However, if you SetROP2(R2_XORPEN) and draw/erase the magenta rect first it will restore the overlapped pixels to yellow (and the rest to black) then when you follow with SetROP2(R2_XORPEN) on the yellow rect, your original black background will be restored with no garbage pixels.
|
|
|
|
|
Yup. That was the point. In ageement we are. If you have a picture of Natalie Portman and you draw lines all over it in normal mode, information is being lost. There is no way to recover it using SetROP2. You'll just have to save image data in order to remove the lines later. In effect, you are creating a model from which the scene is re-rendered, even if that model is as simple as the base image and line undo information.
|
|
|
|
|
I want to populate my listctrl using insertItem via: The arra i have is the list of all the values of the columns in the control for one row
void AddItem( AN ARRAY IS TO BE PASSED IN)
for (int i =0, i< 10; i++)
{ list2.InsertItem (how to?)
}
How do I pass in this array? How do I code the insertItem?
Appreciate your help,
ns
|
|
|
|
|
what is it an array of? is it a dynamic array, or a C-style array?
for a C-style array:
void AddItem(ArrayObjectType *pArray, int iArraySize)
{
for (int i=0;i<iArraySize;i++)
{
ArrayObjectType *p = pArray[i];
...
}
}
-c
All you have to do is tell the people they are being attacked, and denounce the opposition for lack of patriotism and exposing the country to danger.
-- Herman Goering, on how to control the public
|
|
|
|
|
Its probably all CStrings. THe array was supposedly of a fixed size. What if it were a vector? Would i still pass in the pointer?
I think I have a handle on how to insert the items row by row, so I'll hold off on posting about that. Hopefully I wont need to..
Appreciate your help,
ns
|
|
|
|
|
if it's a vector, you should pass a reference (not a pointer) to the vector. then you'll iterate through the vector, either with an iterator or with myVec[x] or myVec.at(x).
-c
All you have to do is tell the people they are being attacked, and denounce the opposition for lack of patriotism and exposing the country to danger.
-- Herman Goering, on how to control the public
|
|
|
|
|
[ Modified article: Corrected call to InsertItem() ]
void addItems
(CStringArray arrayOfStrings)
{
for (long nIndex=0; (nIndex < arrayOfStrings.GetLength()); nIndex++) {
list2.InsertItem (nIndex, arrayOfStrings.GetAt (nIndex);
}
}
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I have added a CEdit control and CSpin control to my dialog in the resource editor. So I attached the CSpin control to my CEdit control to inc and dec the value in the edit!
But now, I have the problem, that the spin is working the wrong way! When I click the up button of the spin, the value in the edit will dec, and when I click the down button the value will inc! That's not what I am want! How can I change this????
--
Nice greets, Daniel.
|
|
|
|
|
The "wrong way" is the default way for spin controls.
you will have to use a SetRange32( int nLower, int nUpper );
Set nLower to the MAXIMUN
set nUpper to the MINIMUM
|
|
|
|
|
Thanks!
--
Nice greets, Daniel.
|
|
|
|
|
Hi Daniel,
use CSpinButtonCtrl::SetRange(MIN_VALUE, MAX_VALUE) - this adjusts in which direction you have to press the arrows in order to de- or increase the value in the buddy CEdit box.
Gero
|
|
|
|
|
Hi Daniel,
You can either give the ranges other way round or you can override CWnd's OnNotify method
BOOL YourClass::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult) <br />
{<br />
LPNMHDR pnmh = (LPNMHDR) lParam; <br />
<br />
if(pnmh->code == UDN_DELTAPOS )<br />
{<br />
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pnmh;<br />
if(pNMUpDown->iDelta < 0)<br />
{<br />
}<br />
else<br />
{<br />
}<br />
}<br />
return true;<br />
}
-ve value of delta would suggest decrement and +ve would suggest increment
you can reverse the ways if you like.
Hope that would be of your help.
Nilesh
|
|
|
|
|
Thanks!
--
Nice greets, Daniel.
|
|
|
|
|
I'm writing a program which uses a derived classe of CSocket to handle incoming data. I have overloaded OnReceive to catch the new data. My question is this.
In my OnReceive function, I read the data and possibly do something with it. The doing something can take a little time. I'm wondering if OnReceive can be called while I'm still processing a previous OnReceive and thus interrupting my processing.
If it can, what kind of protections can I setup to protect the data I access in the function?
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|
|
u are just one thread right?? Or multithreading?
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Currently the application is single threaded. My question was, si there a possibility that MFC events or whatever they are called, can they overlap. Or will only one be called at any given time
Jared
jparsons@jparsons.org
www.prism.gatech.edu/~gte477n
|
|
|
|
|
nope the cant, cos ur single threaded.
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
How in the world can i get this to work
if i use IXMLDOMNode in the idl it compiles
if i use the using namespace in the c++ code i'm still good
however the headers created from the idl result in the following:
error C2872: 'IXMLDOMNode' : ambiguous symbol
Help!
|
|
|
|
|
In your idl file,
#include "msxml2.idl";
This will help MIDL solving type, while not including this idl in the type-library.
sometimes it helps to look at the IL generated code
a MS guy on develop.com "answering" .NET issues
|
|
|
|
|
Tried that and all i get from midl is
error MIDL2025 : syntax error : expecting an interface name or DispatchInterfaceName or CoclassName or ModuleName or LibraryName or a type specification near
idl = [id(1), helpstring("method TestXml")] HRESULT TestXml(IXMLDOMNode *pIXMLDOMNode);
atl class method = STDMETHOD(TestXml)(IXMLDOMNode *pIXMLDOMNode);
|
|
|
|
|
Ok, I have found the issue. The version of msxml.idl shipping with VC++6 and VS.NET is MSXML2. And the idl provided does not include the declaration of IXMLDOMNode.
You need MSXML3, and higher. Download the SDK here[^].
I just did a test, it went fine with import "msxml2.idl"; . I had also to make sure this file msxml2.idl supersedes msxml.idl from the included header directories.
PS : I would suggest you don't marshall IXMLDOMNode* at all, just a void* instead. And then you do a proper QI or cast in the implementation code.
sometimes it helps to look at the IL generated code
a MS guy on develop.com "answering" .NET issues
|
|
|
|
|
Hello:
I'm having problems trying to add a serie to a chart. This piece of code illustrates my problem:
_ChartPtr pChart= pCharts->Item["G1"]; // Get an existing chart (OK)
_WorksheetPtr pWorksheet= pWorksheets->Item["S1"]; // Get an existing worksheet (OK)
SeriesCollectionPtr pSeries= pChart->SeriesCollection(); // Get its series collection (OK)
RangePtr pRangeSector1= pWorksheet->Range["$C$5:$C$8"]; // Get a worksheet range (OK)
// I am only trying one of these lines
// Line 1
SeriesPtr pSerie1= pSeries->Add((IDispatch *)pRangeSector1, Excel::xlColumns); // Try to add a serie (exception launched)
// Line 2
SeriesPtr pSerie2= pSeries->Add("C5:C8", Excel::xlColumns); // Try to add a serie (exception launched)
Where is the mistake?
Thanks in advance.
|
|
|
|