|
Hi,
SYSTEMTIME st;
GetLocalTime(&st);
CString strHour, strMinute, strSecond;
strHour.Format(_T("%d"), st.wHour);
strMinute.Format(_T("%d"), st.wMinute);
strSecond.Format(_T("%d"), st.wSecond);
You can use this to get the current time. I f you need to update the time automatically.Use a timer with one second elapse time, and use this code in OnTimer().
Thanks
|
|
|
|
|
I try this[^] CControlBar, and goes very well .. into CMainFrame ... I try to implement it into CChildFrame, but has failed ... it can be dock an CControlBar ( or extended ) into CChildFrame ?
Thanks !
|
|
|
|
|
See here[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
This[^] is the first solution that I've tried, but seems not working in CControlBar case ...
|
|
|
|
|
Flaviu2 wrote: but seems not working
Which means?
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I try in this way :
protected:
CControlBarExt m_wndControlBar;
CTestDialog m_cDialog;
and
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if(CMDIChildWnd::OnCreate(lpCreateStruct) == -1)return -1;
if(! m_wndControlBar.Create(this, &m_cDialog, CString("ControlBar Demo"), IDD_DIALOG1))
{
TRACE0("Failed to create dialogbar\n");
return -1; }
m_wndControlBar.SetBarStyle(m_wndControlBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_wndControlBar.EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndControlBar);
return 0;
}
I get follow assetion failure :
ASSERT(pDockBar != NULL);
In the same way can be done CCOntrolBar in CMainFrame and goes well ...
|
|
|
|
|
Flaviu2 wrote: I get follow assetion failure :
Where? We cannot see your screen so have no way of knowing where these messages appear. Please make use of your debugger and trace what is happening in your code.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I succeded :
int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if(CMDIChildWnd::OnCreate(lpCreateStruct) == -1)return -1;
if(! m_wndControlBar.Create(this, &m_cDialog, CString("ControlBar Demo"), IDD_DIALOG1))
{
TRACE0("Failed to create dialogbar\n");
return -1; }
m_wndControlBar.SetBarStyle(m_wndControlBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
m_wndControlBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndControlBar);
return 0;
}
and goes well ... thank you very much for your patience. Bye.
|
|
|
|
|
dear friends, I want to take input from user as :-
f(x)= y = ax^2 + bx + c
i.e. custom function input from user then parse it and then integrate it. But I have no idea how to do ir. Please help me or suggest any book.
|
|
|
|
|
Try a Google search for "calculator c++", this is a fairly common sample exercise.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
If you want to write it, then that's a hard thing. If you just want to use it, look at:
Fast Mathematical Expressions Parser[^] here on codeproject!
Good luck,
Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
|
|
|
|
|
If you try to do everything at once, it's very hard. Breaking it into steps makes it simpler:
1. Turn the expression string into a list of tokens. A token can be a variable name, an operator, or a parenthesis.
2. Turn the token list into a tree of tokens, where each operator token has child tokens of its operands.
3. Integrate the lowest-level sub-expressions, than combine them according to the operators, e.g. the integral of A + B is the integral of A plus the integral of B.
====================================
For step 2, apply two rules to your token list until you have a single operator token left in the list, representing the whole expression. (If you end up with more than one token in the list, you probably started with an illegal expression):
1. If you have the pattern: "(", [token], ")", replace it with [token], i.e. delete parenthesis tokens around a single value.
2. In the most deeply-nested parentheses, replace [token] [operator] [token] in the list with [operator], and set [operator]'s left and right child-node pointers to the two token operands. Do this for the highest-precedence operators first.
|
|
|
|
|
Hi,
Well, the End result depends very much on the lanuage definitions you assume, and, what you want to do with the end result.
You need to define Language Rules, for instance, where do f,x,y,a,b,c come from.
In 'C' the compiler builds a Symbol Table, which is a cross referenced database of all variables encountered in a module.
What do you want to do with it. If you want to store it as a 'General Formula, your best bet is probably to convert it to RPN (Reverse Polish Notation) and write an RPN Evaluator for when the rubber hits the road,
In general, I would start with writing a Scanner,the Scanner breaks down the text into Tokens
the 'C' rules are like: A Variable starts with 'A..Z','a..z' or '_'
A Variable name can then be followed with the same, and the chars '0..9'
A Numerical starts with '0..9'
A White Space is a ' '(space), '\t' or a '\n'
So , in the above, the name of the first var is 'f', the next char is a '(' which is not a
legal char for a varname. So, the First token is a Lexical Token, with Identifier 'f'
The Next Token would be a Special Token, LPAREN,
Going on in general, (Your Language Definition does not allow for comments),
I would also write a Parser
The Parser calls the scanner , to pick off tokens One by One, ignoring intervening whitespace, or comments, and creates a parsing tree (But it all still depends what you want to do with the expression in the larger scheme of things.
A Book: Writing Compilers & Interpreters (An Applied Approach) by Ronald Mak, ISBN 0-471-50968-X
Bram
Bram van Kampen
|
|
|
|
|
I have tried to use a combination of get_offsetheight,get_offsetwidth,get_offsettop and getoffsetleft but the values returned are in reference to the immediate parent.
|
|
|
|
|
What do you mean by screen coordinates? Did you try "walking up" the inheritance tree, adding the offsets till you reach the top?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> If it doesn't matter, it's antimatter.<
|
|
|
|
|
Hello.
That's exactly what the method you're invoking returns, the height/width referenced to its parent coordinate system.
If you want to get the offset referenced to the screen (1st level of DOM) you can get it by adding all offset values invoking recursively to 'get_offsetParent' method (n-1) times.
Hope it helps.
Regards
|
|
|
|
|
can any one give me a hint on how to write a code in for loop that prints only even numbers with an input of n?
i.e. 0, 2, 4, 6, .....
|
|
|
|
|
What is n supposed to be?
This sounds a lot like a homework question... so I'll just give you a hint... divide by 2.
|
|
|
|
|
What would YOUR code look like without the "only even numbers" constraint?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
David: this code is for print n from 0 to n (n is an input number from the user).
int n;
cout << "Enter a number and press ENTER: ";
cin >> n;
for (int i = 0; i <= n; i = i++)
{
cout << i << " ";
}
cout << "\n";
I am suppose to do something to i++ + 2, or n-- - 2, or something.
|
|
|
|
|
Yolande MR wrote: for (int i = 0; i <= n; i = i++)
This is questionable at best. Try:
for (int i = 0; i <= n; i = i + 1)
Yolande MR wrote: I am suppose to do something to i++ + 2, or n-- - 2, or something. If each iteration of your loop is incrementing i by 1, then why not try incrementing by...
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Incrementing by....well, certain number... works, but only if you start from an already even number. Important to note that.
|
|
|
|
|
Albert Holguin wrote: ...but only if you start from an already even number. Important to note that.
It was already noted...zero. My suggestion reflected that.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
|
Chris:
I got i+=2, works the same!
|
|
|
|