|
Having mysterious problems? 'Rebuild all' can help.
Tomasz Sowinski -- http://www.shooltz.com
- It's for protection - Protection from what? Zee Germans?
|
|
|
|
|
How should i use an array of BSTR s in some IScriptControl object?
I've tried with VT_ARRAY | VT_BSTR and it doesn't work.
rechi
|
|
|
|
|
|
|
isn't that vierd! (quote from Austin Powers: Goldmember)
and yet, i need the value and all the other OLESCRIPT_ HRESULT values... there seem to be a lot of them mentioned throughout the IActiveScript documentation yet none of them exist
anyway, thanks for your searching
- Roman -
|
|
|
|
|
Hello,
I've a data structure which is nested CArray structures 3 deep (years full of single years full of days full of hours).
Here is my .h code:
<br />
struct t_SchGoal {<br />
UINT Num : 21;
UINT Minutes : 11;
};<br />
<br />
struct t_SchDay {<br />
CArray <t_SchGoal, t_SchGoal&> SchGoal;<br />
UINT AvailableMinutes : 30;<br />
UINT bOverridden : 1;
};<br />
<br />
struct t_SchYear {<br />
CArray <t_SchDay, t_SchDay&> SchDay;<br />
};<br />
Then, there's the member of my document:
CArray <t_SchYear, t_SchYear&> m_SchYears;
In the CDoc init routine, I set all of the "AvailableMinutes" to 60 and I can verify this with the VC++ debugger (shows the nested m_SchYears structure tree and "AvailableMinutes" = 60).
However, when I try to access this value in code:
AvailMinutes = m_SchYears[YearIndex].SchDay[DayOfYear].AvailableMinutes;
I get nothing but 0 (instead of 60 that I KNOW is in there).
Upon trying the following code:
AvailMinutes = ((m_SchYears.GetAt(YearIndex)).SchDay.GetAt(DayOfYear)).AvailableMinutes;
The compiler complains that there is no copy constructor for my structures which is true since they're not classes. CArray has two return values for operator []--one of which is a &TYPE which is why I'm able to get away with the first line. However, it doesn't work.
I would rather not make indidual classes of each of these structures but I fear I may have to. Does anyone have any insight in to finding a way to get what I want? Or general academic comments on this situation?
Thanks!
JennyP
|
|
|
|
|
Sorry, in the last post, the CodeProject system cut out the CArray template definitions ... I'll try to copy it here again...hmm... I cannot seem to find the way to display the carrot symbols.... so I've replaced them with "[]"
<br />
struct t_SchGoal {<br />
UINT Num : 21;
UINT Minutes : 11;
};<br />
<br />
struct t_SchDay {<br />
CArray [t_SchGoal, t_SchGoal&] SchGoal;<br />
UINT AvailableMinutes : 30;<br />
UINT bOverridden : 1;
};<br />
<br />
struct t_SchYear {<br />
CArray [t_SchDay, t_SchDay&] SchDay;<br />
};<br />
JennyP
|
|
|
|
|
|
I think, the problem comes from your t_SchDay struct. You need to define a overloaded CopyElements collection-class-helper function or an assignment operator (operator =) for it. If it is not defined, CArray uses it's default implementation of CopyElements, which performs a bitwise copy. And this does not work for the CArray member of your t_SchDay - we are running in the mysterious lands of "undefined behavior"
--
Daniel Lohmann
http://www.losoft.de
|
|
|
|
|
try using the debugger and stepping into operator[] of CArray... it might be a bug in dreaded MFC's core.
- Roman -
|
|
|
|
|
also try taking out the bitfields, making them full-sized values... i always had problems with those bitfields and their quirks
- Roman -
|
|
|
|
|
I have already tried getting rid of the bitfields.... same result. Thanks, though.... I'll try stepping in to the []'s soon to see what's up.
JennyP
|
|
|
|
|
Hello Jenny
I have had your problems. Apparently you cannot have a CArray of structs and a struct contains a CArray as a member. if you change all your structs to classes then there will be no problem. Just declare those classes with everything public.
Anyway, I would suggest a std::vector instead of CArray. I think this will work with structs as well
Best regards,
Alexandru Savescu
|
|
|
|
|
Alexpro wrote:
I have had your problems. Apparently you cannot have a CArray of structs and a struct contains a CArray as a member. if you change all your structs to classes then there will be no problem. Just declare those classes with everything public.
Excuse me, but I can't believe that.
There is no syntactical difference in C++ between a struct and a class. The one and only difference is, that the default visibility of a struct is public and the default visiblity of a class is private.
You are really sure you changed nothing, but made "class" where was "struct" and only added a "public:"? No additional constructors, no assignment operators no super class?
--
Daniel Lohmann
http://www.losoft.de
|
|
|
|
|
Thanks everyone. I think I'll put a little extra time/care in to the code and create separate classes for each of my structs replete with data access methods with light error checking. This will also make all of my top level data access code more readable.
I don't know what vectors are or how to use them, so out of expedience, I'll make classes.
Thanks!
JennyP
|
|
|
|
|
you should use vectors, they're rather simple to use:
struct MyStruct
{
int v1;
int v2;
};
std::vector<MyStruct> a;
a.push_back(MyStruct(5,6));
a.insert(a.begin() + 0,MyStruct(5,6));
a.erase(a.begin() + 1);
a[0].v1 = a[0].v2;
as you can see, vectors aren't at all complicated and will save you much time debugging a collection class manually made (those sometimes have bugs )
- Roman -
|
|
|
|
|
A text report I print from my MFC program is different in Print Preview versus hard copy.
In fact zooming in and out in Print Preview changes what's displayed.
Example: one column in my report might be:
My dog has fleas.
But in Print Preview, this might show as:
My dog has fl
Given Microsoft Word also shows these sorts of anomalies in Print Preview, I've always assumed it's a difference between rendering on the screen versus rendering on the printer.
So, a sanity check please: should I worry about a bug in my program or not?
(PS I've spent an hour checking the web for something that says "print preview is only an approximation and may never be an accurate representation of the printed output" - but haven't found any such statement.)
Russell Robinson (russellr@rootsoftware.com)
Author of TTMaker (Advanced Timetabling Software)
http://www.rootsoftware.com
|
|
|
|
|
print preview is only an approximation and may never be an accurate representation of the printed output.
print preview does a whole lot of scaling to do what it does. sometimes it totally messes up font sizes (which may be why your text is being chopped - font didn't scale along with a clip box around it). the real test is the printer. if it works on the printer, i usually ignore whatever PP is doing.
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
if you have Acrobat Distiller or PDFWriter, print to that and see if the PDF that comes up has the same problem... if it does, go into Acrobat and explore through all the objects (text boxes, white filled rectangle boxes) that are there, see if something is getting printed over the text or if the textbox for the text is too small to fit the entire text (maybe miscalculated the width of the text)
- Roman -
|
|
|
|
|
In my app, I have the ability to create a text box in the view. The text box dialog has an Edit box in it that allows for multiple lines to be entered and allows for carriage returns. When I get the text back from the edit box, though, the carriage returns are supplemented with two characters -- newline and carriage return. I want to display the text from this edit box in exactly the same way as it is entered but when the text box shows up in the view, it has two strange box looking characters in it where the newline and carriage return should be and everything is on one with no line breaks. Any thoughts on how I can get this to change so that I can have the text box show up properly in the view.
|
|
|
|
|
how are you drawing the text in the view?
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
Here is the code that displays the text in the view:
pDC->SetTextColor(Color);
pOldFont = pDC->SelectObject(&m_TextFont);
pDC->TextOut(m_StartPoint.x, m_StartPoint.y, m_String);
pDC->SelectObject(pOldFont);
If this gives you any idea of what I'm doing wrong...
|
|
|
|
|
try using pDC->DrawText
-c
To explain Donald Knuth's relevance to computing is like explaining Paul's relevance to the Catholic Church. He isn't God, he isn't the Son of God, but he was sent by God to explain God to the masses. /. #3848917
|
|
|
|
|
make sure the destination text box (the one in your view, right?) also has the ES_MULTILINE window style (its also multi-line)
- Roman -
|
|
|
|
|
Stew wrote:
two strange box looking characters
These are actually a '\n' followed by a '\r'. If you switch it, i.e. make the '\r' followed by a '\n', it will be correctly displayed.
Check this link.
Anyway, could you post the code you use ? Because if you retrieve your text in a CString and redisplay it, it should not be any display problem.
~RaGE();
|
|
|
|