|
CarolLamoreaux wrote: I took out the ON_COMMAND line and everything seems fine now.
Yes, it would be - I've just looked at one of my MFC apps - ID_FILE_NEW is handled by your app class (which would be derived from CWinApp ), which then delegates to the OnNewDocument in your document class, so you shouldn't have been handling ID_FILE_NEW in your document anyway.
|
|
|
|
|
i have a custom treectrl derived from mfc's ctreectrl
i'm using custom draw to modify it's layout (colors, fonts, etc..). i'm only drawing the text part because i dont wanna go into drawing and coding the other tree stuff like the open/close buttons and stuff
the last thing i need to do is to add text wrapping. when the text is too long to display, i need it to wrap to the next line instead of being truncated (adding elipsis)
i've been searching for a while and i still couldn't find a way to solve this
i can do the text wrapping part easily using cdc and drawtext, my only problem is the item's "row height". it looks like it is set to accommodate only one line of text per item row. a 2nd line would paint, but it would get overwritten by the next item row.
any suggestions? thanks
|
|
|
|
|
See this[^].
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
that won't work in my case because the texts have different lengths
some only have 1 line, some needs to wrap in 2, and some needs to wrap in 4 or more lines
if i used that, all item (all rows) would have the same height. if i set the height to the highest that i need, the ones with only 1 line would have some trailing line breaks
if i use a smaller height that the highest that i need, the highest one would still be truncated
i need a way to change the height on a per item basis
|
|
|
|
|
Then maybe look at this[^] and read up the description for the iIntegral member.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
that worked great, thanks
|
|
|
|
|
Hi,
I also have the same requirement, actually I want to implement the word wrap functionality in the tree view control but in my case it is CTreeViewCtrl that belongs to WTL and not MFC.
Could you please share your code fragment if possible or guide me how to handle the custom draw for the control and wrap the text.
Thanks in advance.
|
|
|
|
|
Please consider the following C program.
main()
{
int i, j, *p;
i = 25;
j = 100;
p = &i;
printf("%f", i/(*p) );
}
I took an online quiz on C and the correct answer was syntax error. I cannot find anything
wrong with the above program. I tried both GCC and the Microsoft Development Stdio
and both conmpilers accept the program.
Please comment.
Thanks
Bob
|
|
|
|
|
it's ok for me as well. p is of type int* , so *p is an int ...
and nothing forbids you to divide an int with another int .
so the result should be 1. (notice the . which means it is a float - actually, the division returns an int, but I suspect (not sure though) that the %f asks for an implicit cast)
|
|
|
|
|
Well, i see no syntax error either, what i do see and imho could cause a problem are the following:
-if main is actually the main entry routine then it should look like this: int main(int argc, char **argv); , but that wouldn't give you a syntax error, besides, that alone is just a function definition, nothing says it is "THE MAIN" entry point method. Besides, i think nowadays most compilers will accep that as the main entry point anyways.
-the "%f" in printf will expect a floating point value rather than an integer, but then again, not a syntax error
-you didn't specify any return type for the method, am not sure how compilers handle that but VC++ selfrigthously will take it as int, and might call you names for not returning anything from that method. But again, that is not a syntax error.
Hmm...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
I don't agree. the synopsis of the main() function (as an application entry point), there are several syntaxes allowed, and int main(int argc, char **argv) is definitely not *THE* ultimate one.
in C, the returned type is not mandatory. if not provided, int is assumed.
and under windows, main can accept a third parameter which is an array containing the environment variables...
|
|
|
|
|
See the Besides, i think nowadays most compilers will accep that as the main entry point anyways. part in my post, but you are right, sorry for the confusement.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
normally, a C++ compiler would not accept a not typed function ; so the minimal main should be int main() at least...
|
|
|
|
|
toxcct wrote: and under windows, main can accept a third parameter which is an array containing the environment variables...
Windows it's not alone, UNIX main has the above feature too.
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]
|
|
|
|
|
CPallini wrote: Windows it's not alone
and you say this to me ?!
when you're not sure, don't talk about something you don't know... that's what I did
|
|
|
|
|
toxcct wrote: and you say this to me ?!
Shouldn't I?
Why?
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]
|
|
|
|
|
BobInNJ wrote: Please comment.
printf("%f", (double) i / *p);
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
As David Crow already pointed out, there is an error, but it is not a syntactic one.
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]
|
|
|
|
|
BobInNJ wrote:
p = &i;
That was a syntax error in the previous version of the C standard, comments begining with "//" were introduced in C99.
|
|
|
|
|
why in mfc programming # prgma once is used??
|
|
|
|
|
To avoid multiple inclusion of the same header file. This used to be like this:
#ifndef MY_HEADER_FILE_H__
#define MY_HEADER_FILE_H__
...
#endif
But using pragma once makes it easier.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Code-o-mat wrote:
But using pragma once makes it easier.
but not portable, it's a Microsoft specific pragma (as far as I know).
|
|
|
|
|
As far as i know you are right.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Recent versions of GNU compiler also support it.
|
|
|
|
|
Maximilien wrote: it's a Microsoft specific pragma (as far as I know).
My bad, I mistook you for the original poster! I am officially embarrassed
led mike
|
|
|
|