|
try this
CRect clRect;
m_ListEx.GetClientRect(clRect);
int nFitCount = clRect.Height() / m_ListEx.GetItemHeight(0);
if( nFitCount < GetItemCount())
{
// scrollbar needed
}
nave
|
|
|
|
|
Dear Naveen,
thanks for ur reply. but unfortunately, the items in my listbox are having different heghts.
so how can I calculate from from single one?
|
|
|
|
|
in that case try this
int nTop = m_List.GetTopIndex();
CRect ClientRect;
m_List.GetClientRect( &ClientRect );
BOOL bOutSide;
int nBottomitem = m_List.ItemFromPoint( CPoint( ClientRect.left,ClientRect.bottom), bOutSide );
if( FALSE == bOutSide )
{
int nCount = m_List.GetCount();
if( nCount > ( nBottomitem - nTop ))
{
// Scrollbar needed
}
}
nave
|
|
|
|
|
Hi
I am wondering how you can square a value in C++. I want to work out the square of a number that the user inputs but I dont know how you would type in the command so that the computer will square this number. What is the command for squared? Please help.
Thank You.
linda
|
|
|
|
|
Build it by yourself:
#define SQR(x) ((x)*(x))
and/or
double sqr(double const& x){<br />
return SQR(x);<br />
}
-- modified at 9:32 Monday 15th May, 2006
|
|
|
|
|
pow
Calculates x raised to the power of y.
#include <math.h>
#include <stdio.h>
void main( void )
{
double x = 9.0, y = 2.0, z;
z = pow( x, y );
printf( "%.1f to the power of %.1f is %.1f\n", x, y, z );
}
9 to the power of 2 is 81
----------
There go my people. I must find out where they are going so I can lead them.
- Alexander Ledru-Rollin
|
|
|
|
|
Hi everyone
thanks a bunch for all your help here.
I did want the value to be squared, not power to, it is the opposite of what pow does (if pow is to the power of - seeing it starts with Pow for Power). I was after the square - you know the square button on your calculator. So the square root.
Thanks
linda
|
|
|
|
|
In English, the Square of a number is the number raised to the power of two (or, multiplied by itself).
The Square Root of a number is "that number or quantity which, multiplied by itself, produces the given number."
sqrt
Calculates the square root.
double sqrt( double x );
Example
/* SQRT.C: This program calculates a square root. */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
void main( void )
{
double question = 45.35, answer;
answer = sqrt( question );
if( question < 0 )
printf( "Error: sqrt returns %.2f\n, answer" );
else
printf( "The square root of %.2f is %.2f\n", question, answer );
}
Output
The square root of 45.35 is 6.73
----------
There go my people. I must find out where they are going so I can lead them.
- Alexander Ledru-Rollin
|
|
|
|
|
The best way is just to multiply it by itself. Using pow is fine but not as efficient as simply multiplying the number by itself as it’s more general. Defining a macro is not a good idea (I can hear the screams of people objecting already): prefer inline functions to macros. There are many reasons for this, including:
- Macros are hard to debug. For example try stepping into a macro.
- Macros don't respect the C++ language rules. For example you can't put them into namespaces or use function overloading.
- Macros can have side effects which are very hard to identify and debug.
Macros have their place but most C++ programmers overuse them.
Steve
|
|
|
|
|
Than you for the great lesson :
I can add olso that they could be coded into a slower code:
(see my prev post and...)
SQR(3+5*7-6+sqr(5.9))
will be, unfortunatly , coded into
( 3+5*7-6+sqr(5.9)) ) * ( 3+5*7-6+sqr(5.9)) )
and we can say goodbye to the powerfull C++!
(Sorry, but nobody will read this post! )
|
|
|
|
|
simple Linda
you do this
double squared(double dNumberIn)
{
return dNumberIn *= dNumberIn;
}
all the best Alton
|
|
|
|
|
Hi all,
if i use this code in my derived CWndEx class:
BOOL CWndEx::PreTranslateMessage(MSG* pMsg)
{
if( IsDialogMessage( pMsg ) )
return TRUE;
else
return CWnd::PreTranslateMessage( pMsg );
}
then standing on a button in my CWndEx and pressing Tab key move me to the other controls in my CWndEx class. i have a child dialog in my CWndEx class and hiting the tab also step in the dialog's control. trouble is pressing the tab within the dialog will never get me back to the controls in CWndEx?
in more simple words : i can step into the dialog using the tab, but i can't step out of it using the tab , it keeps looping the controls inside the child dialog
any suggestions?
Yaron
Interface basics click here :
http://www.codeproject.com/com/COMBasics.asp
don't forget to vote
|
|
|
|
|
YaronNir wrote: in more simple words : i can step into the dialog using the tab, but i can't step out of it using the tab , it keeps looping the controls inside the child dialog
because once i enter the Dialog, Window start treating it as Dialog message!, there fore you seeing that behaviour!
"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
|
|
|
|
|
Hi guys,
I would like to know how can I connect my application to a mdb file.
I just wrote some others classes for this project. And the others are all in pure c++.
How can I do that?
tnx
|
|
|
|
|
Try ADO .
Make use the msado15.dll. It has a bunch of COM interfaces that serves all your DB needs.
#import "c:\Program Files\Common Files\System\ADO\msado15.dll"
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[V]--
[My Current Status]
|
|
|
|
|
ehm... where can i find the list of functions?
|
|
|
|
|
|
|
Salvodif wrote: I would like to know how can I connect my application to a mdb file.
See if this article is of any help.
"The largest fire starts with but the smallest spark." - David Crow
|
|
|
|
|
Hi,
I have MFC extension dll which contains some controls derived from standard Tree Controls class.
Now when i use these DLL an creating control on Dialog box at runtime it woks fine and the control is shown. But when i am initializing controls from DLL. these are not shown and its gives expection. When debugged. its fails at
-->HTREEITEM one = mytree.InsertItem("XYZ"); I guess, its giving expection at ::IsWindow(m_hWnd) and some how it is not getting the values of
m_hWnd in my case.
Can someone throw light on these and why works on Simple Dialog and not Property Page.
Thanks in advance
Abhi Lahare
|
|
|
|
|
I believe the OnInitDialog() function for the Property Page has to be called first before you can use controls in it. So make sure that OnInitDialog() for the page is being called first.
This is just a guess. It could be something else also.
this is this.
|
|
|
|
|
|
I think the problem is when you add points to the array.
Could you show the code where you are doing it?
It is actually a CPtrArray , and it is supposed to take different objects each time you add to it. You should new a CPoint etc variable and then add it to the array.
this is this.
|
|
|
|
|
Yes, OnDraw gets called in that case. Try to use your debugger to watch your data. Press F5 to start the debugger and F9 to put breakpoints. Try putting a brakpoint in the OnDraw function.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Hi,
I have the files "AA.doc" , "BB.doc" and "CC.doc", i want to create a zipp folder having these files in it. so i think they will compressed in end.
thanks for reply
Regards.
|
|
|
|