|
i have a dialog based application,
i used Showwindow to hide it before minimizing to system tray
still can't get it to work
by the way i am using ur CSystemTray class
why don't you add this in the class
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
Recently I find that my application always crashs with invalid double floating value, so I want to determine whether a double floating value is valid or not then I can do some extra work to avoid crashes.
Can anybody tell me is there any function or method to known whether a floating value is valid or invalid??
Thanks a lot
|
|
|
|
|
|
the result looks like 1.#NF, and no divided by zero exception occurs.
|
|
|
|
|
ashxly wrote:
the result looks like 1.#NF, and no divided by zero exception occurs
OK. This makes sense. The error occurs because infinity cannot be truely represented by any numerical value, including floats. You will certainly get a numerical overflow if you try to divide by zero[^].
So I think the cause is not that you have an 'invalid' float value (unlikely), but that you are performing an invalid mathematical action (like dividing by zero).
I Dream of Absolute Zero
|
|
|
|
|
Can you give us an example of an invalid floating point value?
Or more importantly where in your code this is causing the crash.
I Dream of Absolute Zero
|
|
|
|
|
have a look at <float.h>. it provides many functions to manage the infinites, undefined values, and so...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Have you looked at _isnan() ?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
yacc file:
%{
#include <stdio.h>
#include <ctype.h>
#define YYSTYPE double /* stack data type */
%}
%start list
%token NUMBER
%left '+' '-' /*left associative */
%left '*' '/' /*left associative */
%left UNARYMINUS
%%
list : /*empty*/
| list expr '\n'
{printf("%f\n",$2);}
| list error '\n'
{ yyerrok; }
;
expr : NUMBER
{ $$ = $1; }
| '-' expr %prec UNARYMINUS
{ $$ = -$2; }
| '+' expr %prec UNARYMINUS
{ $$ = $2; }
| expr '+' expr
{ $$ = $1 + $3; }
| expr '-' expr
{ $$ = $1 - $3; }
| expr '*' expr
{ $$ = $1 * $3; }
| expr '/' expr
{
if ($3)
$$ = $1 / $3;
else
{
$$ = 1;
printf (stderr, "%d.%d-%d.%d: division by zero",
@3.first_line, @3.first_column,
@3.last_line, @3.last_column);
}
}
| '(' expr ')'
{ $$ = $2; }
| '(' expr error
{ $$ = $2; yyerror("missing ')'"); yyerrok;}
;
%%
void main()
{
yyparse();
}
int yyerror(char* msg)
{
printf("Error: %s encountered \n", msg);
}
lex file:
%{
#include "cal.tab.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/*extern double yylval;
extern atof();*/
%}
digit [0-9]
integer {digit}+
exponant [eE][-+]?{integer}?
num {integer}("."{integer}?)?{exponant}?
%%
/*here! yylval can't get the right value */
{num} { yylval = atof(yytext);
printf("yylval is %f\n", yylval);
printf("yytext is %s\n",yytext);
return (NUMBER);
}
%%
int yywrap()
{
return 1;
}
|
|
|
|
|
What type of Language is That
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
It's Lex and YACC, as the subject says. The program looks like a simple four-function calculator.
|
|
|
|
|
but we are on the Visual C++ forum ... !
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
What's the actual problem you are having? How have you tested this and what are the error messages?
|
|
|
|
|
While communicating with a Smart Card and I need to hold the line low and wait a little bit of time and then set the line high again in order to get the Answer To Reset. However, I have never done this before and have no clue as to how to do it. Would it be possible for someone to show me (in C++) how to do this.
Thank you. If you need more info I will be glad to oblige.
P.S. I posted a couple of days ago about having to read 20 bytes from the serial port and that ties into this since the Answer to Reset I want to read is 20 bytes long.
|
|
|
|
|
When creating a dialog based MFC application in VC++.net how does one utilize control variables and other function like UpdateData() inside a user defined function?
|
|
|
|
|
please rephrase your question, i dont understand
|
|
|
|
|
So I wrote my own function which is called when I click a button. I defined and declared it in the main source file. I also associated some variables with some edit boxes through the setup wizard. When I try to use these edit box variables within the body of my function I get a linker error. The same happens when I try to use UpdateData() in my function. The only way I've found to use the variables in my function is to declare them at the top of the file - but then there are other errors because they are not defined where the rest of the code expects to find them - in the public section of the header file. I'm sure this is something really simple to fix but in my limited experience I just haven't yet come across a solution.
|
|
|
|
|
Well definately you should not declare those variables, they should be declared (and inserted into sourcecode) when you create them by wizard.
I dont use VC.NET, just a classical VC 6, but it works this way:
I have main dialog, it is a class, it has two sourcefiles, header classfile.h and code classfile.cpp. When I insert a button and add a function to it it creates a function (OnButton1 for example) which is member of the dialog class (it is defined in header and function code outline is inserted into cpp file). If i create a edit box and associate a variable to it its definition is added to header file. (are you sure you added it ? because if you add it and then click 'cancel' button, then changes are lost, you have to click 'Ok' button in the wizard).
So now we have a function which is member of dialog class and a variables which are members of the dialog class. So they should see each other and they should be able to access each other...
if this does not help then please post a build log or project files, where we can see what is the error.
|
|
|
|
|
i don't understand either, but why should it be different to call a these functions in a user defined function from a non one ???
of course, you cannot call everything (UpdateData() is MFC specific), but you call it the same way...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Does anyone know how to embed a bitmap on the work area of a CMDIFrameWnd?
Jay
|
|
|
|
|
Check this[^]article...Author has painted Logo in the Backgound Window....
Hope this will help you...
|
|
|
|
|
this is EXACTLY what I was looking for. Thanks!!!
|
|
|
|
|
When I write a text file to my hard disk, I add \n to each line and, when viewed in an editor, the file displays as one would expect. But when I upload this file to my host, the text is displayed in one long line. I've found that if I add \r\n instead of just \n at the end of each line, the effect is reversed - my hard disk file is one long line and the remote file is displayed on separate lines. I've tried using both binary and ascii upload modes. I'm currently creating two files with the only difference being the \r in one of them to get around this. Does anyone know of a better solution.
Jack
|
|
|
|
|
I have made my main Dialog resizable . But for some reason i couldnt use
MoveWindow to resize the tab(Member CTabCtrl variable). In other words the elements of the tab are not altered ? Does this have to be resized in a different manner ?
|
|
|
|
|
How can I simplify this:
grid[x][y] == 0 ? grid[x][y] = 1 : grid[x][y] = 0;
I was thinking that I could make a pointer (or address) to that part of the array, then like shift the bits or something (each part of the array is a BYTE), but I couln't figure out how to do it.
Any ideas? thanks
|
|
|
|