|
You need to compensate for the printer DPI versus the screen DPI. You do this by reading the device caps and scaling the font to get the correct size.
|
|
|
|
|
vikas amin wrote:
a problem that he font size is very
small on the pritn-out , but actual
size in the display is fine visib
use CFont::CreatePointFont().. if you need 11 pt font then pass 11*10=110 value in this variable before printing
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
VC6
Win2K
I have a main menu with the following arrangement
<br />
File<br />
---Select Folder<br />
---Configure<br />
---Exit<br />
Start<br />
Stop<br />
Pause<br />
Resume<br />
I'm trying want the Stop, Pause and Resume items to grey out when they're disabled, but the methods I've tried in order to accomplish this have all failed in one way or another.
Calling pCmdUI->Enable(FALSE); in the update handler will disable the menu item, but it won't gray out.
If I use the following code, the menu item will gray out only after the user tries to click on it, and then, it doesn't un-gray unless it's allowed to AND the user clicks on it again.
BOOL bEnable = (m_bShowRunning && !m_bShowPaused);
DWORD dwFlags = (bEnable) ? MF_BYCOMMAND | MF_ENABLED
: MF_BYCOMMAND | MF_DISABLED | MF_GRAYED;
CMenu* pMenu = GetMenu();
pMenu->EnableMenuItem(ID_SHOW_PAUSE, dwFlags);
Does anyone have any helpful ideas?
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
-- modified at 8:11 Friday 7th October, 2005
|
|
|
|
|
John Simmons / outlaw programmer wrote:
Calling pCmdUI->Enable(FALSE); in the update handler will disable the menu item, but it won't gray out.
Then something else is wrong. I just had a look at several of my SDI applications, and if pCmdUI->Enable(FALSE) were used on any of the menu items, it was definitely grayed out. Perhaps your definition of "gray out" is different than mine.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
DavidCrow wrote:
Then something else is wrong.
Ummm, yeah, that one didn't get by me, hence my original message...
DavidCrow wrote:
I just had a look at several of my SDI applications, and if pCmdUI->Enable(FALSE) were used on any of the menu items, it was definitely grayed out.
Well that doesn't answer my question...
DavidCrow wrote:
Perhaps your definition of "gray out" is different than mine.
I seriously doubt that. Like I said, it *will* gray out when the user clicks it.
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote:
Well that doesn't answer my question...
It should have indicated to you that pCmdUI->Enable(FALSE) is the way to do this in MFC. For it not to work is a good indication that you are doing something wrong elsewhere. Trying to do this with that EnableMenuItem() and GetMenu() code is like sanding against the grain.
John Simmons / outlaw programmer wrote:
I seriously doubt that.
I don't. Unless you are messing around with colors, a menu item that is gray is synonomous with one that disabled. In other words, I've not seen an enabled menu item that was gray, nor have I seen a disabled menu item that was non-gray.
Have you considered creating a temporary SDI project that does nothing but alter menu items via the ON_UPDATE_COMMAND_UI() handler? That would help to eliminate other code that might be masking the real problem.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
-- modified at 9:52 Friday 7th October, 2005
|
|
|
|
|
It already is a SDI app, and no, I'm not messing with colors. Like I've already said twice, it grays out only AFTER the user clicks it.
I've even tried simply doing this on the updateUI handler:
pCmdUI->Enable(FALSE);
...and that still doesn't gray it out. This is all MFC with no derived classes regarding the menus, and all handlers were added through the class wizard, so I'm not doing anything strange at all.
I think it's got something to do with the fact that the menu is the main menu and not a sub menu (again, something I've already mentioned). I saw something somwhere that said the state of a menu items is updated before the menu is drawn. I'm thinking that since it's the main menu, and only drawn once (or when the window is resized?), it doesn't know about the disabled state because that's not checked until after the menu is drawn.
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Try this instead:
DWORD dwFlags = (bEnable) ? MF_BYPOSITION | MF_ENABLED
: MF_BYPOSITION | MF_DISABLED | MF_GRAYED;
pMenu->EnableMenuItem(1 or 2 or 3 or 4, dwFlags); Another idea would be to create a different menu hierarchy where Start, Stop, Pause, and Resume are all under a common menu item.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Deleted the menu items and created a toolbar. The updateUI stuff works on the buttons. I think it goes back to the fact that I'm playing with the mainmenu instead of a sub-menu...
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
|
Hello guys,
I have next strange situation :
I have a function
CString Add(CString var1,CString var2)
{
..
}
which i use for adding two huge integers.
then for example I declare two variables :
CString x = "457235872349857348957238945723894579234896234789563";
CString y = "573489573894573894579234852378456782345683475683746";
then add them , for example 1000 times
while()
{
..
Add(x,y);
..
}
It takes my computer aproximately 5 seconds to do these calculations.
But then i decided to modify the Add function like this :
CString Add(CString & var1,CString & var2)
{
..
}
I expected that the calculations would be faster as no copy objects would be created in this case inside Add function , as I was passing directly addresses.
But the result is opposite
Can anybody explain why ??
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
It sounds strange but to fine out the
reason
1)Study the function use to add the strings
2)Try passing integer value for experiment to chek the speed
3)Try to study passing the CSting memeber.
Send me the feed back
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
vikas amin wrote:
2)Try passing integer value for experiment to chek the speed
Can't do that this function is implemented only for adding string values.
vikas amin wrote:
1)Study the function use to add the strings
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
Giorgi Moniava wrote:
Can't do that this function is implemented only for adding string values.
and what about overloading (just a guess) ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote:
and what about overloading (just a guess) ?
I just do not need it. You see I wrote this function because I needed to add numbers , for example like this size: "32457345873428957394857394857389245792348578923457934827589345345346456456456456462"
and even bigger. As far as I know in none of the C++ standard types(__int64 ,double ,..) they would not place.
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
vikas just suggested it for a try of performance... now do what you want
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
whats wrong man whats that icon. What did not you like in my reply????
I explained you why I could not use int -s in my function.
And to tell you truth I don't understand why I should use int -s , I was just intersted why when using CString objects the result was faster rather then with CString & -s
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
Giorgi Moniava wrote:
What did not you like in my reply????
i am trying to help, so if what i and vikas suggested don't satisfy, ok, it our fault, but if you didn't ever try it, how can you say it is not the point, and why should i help you more on this thread ? (or you badly explained your problem otherwise).
Giorgi Moniava wrote:
I don't understand why I should use int-s ; I was just intersted why when using CString objects the result was faster rather then with CString & -s
i understood that point. vikas just suggested to try with int s (at least, here is how i understood it) to see if the performance loss was coming from your add() function. maybe you string addition is to be reviewed... of course, int s cannot store such long digited integers.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxx, I also tried on my side, the point that he's trying to figure out, is why passed 2 strings by reference takes more times than passing string by values to an EMPTY function.
see my other answer ...
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
toxcct wrote:
how can you say it is not the point
I did not say it. I said that using int -s was not my point as I has to add huge numbers.Even if with the ints -s case , happens so that int& - s are faster that will have no sense to me.
toxcct wrote:
to see if the performance loss was coming from your add() function.
You can try using empty Add() function , as Maximillien posted and you'll see that the result is same
toxcct wrote:
i am trying to help
thanks for that
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
indeed, I tried just with an empty Add function, and it take twice as much time calling 1000000 times the function when using references.
( edited : ok I tried again, with a bigger iteration count, this is the code I use ( CProfiler can be found here on CP ).
void CtestCloseView::OnTataToto()
{
CString x = "457235872349857348957238945723894579234896234789563";
CString y = "573489573894573894579234852378456782345683475683746";
CProfiler profiler;
__int64 ptime = 0;
profiler.ProfileStart(LOGNONE);
for ( int i = 0; i < 8000000; i++ )
{
AddMe( x, y );
}
ptime = profiler.ProfileEnd();
double dd = profiler.SecsFromTicks(ptime);
CString s1;
s1.Format( "CtestCloseView::OnTataToto(1) : %5.5f seconds\n", dd );
TRACE( s1 );
profiler.ProfileStart(LOGNONE);
for ( int i = 0; i < 8000000; i++ )
{
AddMe2( x, y );
}
ptime = profiler.ProfileEnd();
dd = profiler.SecsFromTicks(ptime);
s1;
s1.Format( "CtestCloseView::OnTataToto(2) : %5.5f seconds\n", dd );
TRACE( s1 );
}
void CtestCloseView::AddMe( CString s1, CString s2 )
{
}
void CtestCloseView::AddMe2( const CString& s1, const CString& s2 )
{
}
The result are ( with 8000000 iterations ) :
CtestCloseView::OnTataToto(1) : 6.39813 seconds
CtestCloseView::OnTataToto(2) : 1.27944 seconds
and with 20000000 iterations :
CtestCloseView::OnTataToto(1) : 15.96244 seconds
CtestCloseView::OnTataToto(2) : 3.19041 seconds
which shows that I was wrong in my first assesment, and passing by reference will take less time.
Maximilien Lincourt
Your Head A Splode - Strong Bad
-- modified at 9:21 Friday 7th October, 2005
|
|
|
|
|
Don't you find this strange ????
In every book I've read It is said that using references in some cases reduces some time.
As in functions no copy objects are created(moreover if the objects are big).
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
Yup , I did the same with my Add() function but incremented the iterations up to 900000
and CString& - s ended in 100 seconds while CString -s in 190
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
Maybe the extra level of indirection when you are using references overrides the performance cost of passing it by value?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
(Back in the old days...)
CString is reference counted object. This means that when you pass the CString to another routine by value, all it does is increment the ref count of the REAL data. This means that you don't allocate a new buffer for the CString.
As already shown, by using empty routines, const & is faster. But when you add back in all the other code, the extra dereference required to access the CString by reference might cost more than the cost of passing the string by value.
(Doh, what the previous post said.) :->
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
-- modified at 9:56 Friday 7th October, 2005
|
|
|
|