|
Possibly he need a fuzzy logic [^] variable...
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]
|
|
|
|
|
kaku_lala wrote: Why can't I use float data type to define my own boolean type?
You could. Doesn't this compile?
float f;
if (f) { }
Now, why would you want to? What benefit is there from using a float as a boolean?
There are plenty of flaws as well - as soon as you start doing arithmetic with floats involving numbers that cannot be precisely represented in a float, you're in for trouble.
Consider this short program:
#include <iostream>
int main()
{
float g = 0.0;
while (g < 10.0)
{
g += 0.1;
std::cout << g << std::endl;
}
}
Simple, right? Not entirely - here's part of the output:
7.7
7.79999
7.89999
7.99999
8.09999
8.2
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
kaku_lala wrote: Why can't I use float data type to define my own boolean type?
Can you guess the output ? Try this code;
typedef float FLOATBOOL;
bool func_check_BF(FLOATBOOL x)
{
if (x)
{
cout << x << " is TRUE - FLOATBOOL" << endl;
return true;
}
else
{
cout << x << " is FALSE - FLOATBOOL" << endl;
return false;
}
}
bool func_check(bool x)
{
if (x)
{
cout << x << " is TRUE - bool" << endl;
return true;
}
else
{
cout << x << " is FALSE - bool" << endl;
return false;
}
}
int main(int argc, char* argv[])
{
func_check_BF((FLOATBOOL)0);
func_check_BF((FLOATBOOL)0.1);
func_check_BF((FLOATBOOL)1);
func_check((bool)0);
func_check((bool)0.1);
func_check((bool)1);
return 0;
}
Any way it is pointless! It should be only TRUE or FALSE for a boolean variable.Otherwise your customer may blessed with cocktails from a tea wending machine.
|
|
|
|
|
Hallo,
i have the following problem:
i have an SDI application, in the Test_Doc.cpp i call the function(): OnDlg() which is afx_msg function(), and this function calls another function: OnFontDlg() which is void and defined in another file: Font_Dlg.h and Font_Dlg.cpp, when trying to call the function
OnDlg() i get an error C2352: CFont_Dlg::OnFontDlg illegal call of non-staic function
i searched in google but i could not find any help.
Has anybody an idea to fix this problem?
Thanks in advance.
|
|
|
|
|
You cannot call a class member function like you call a normal function. Either use a class object to invoke that function or make the function as a static member function.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
thanks alot it works have a nice day.
|
|
|
|
|
how are you calling the function?
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
I have to define a directive depending upon the value of an expression.
For Eg:
In the following statement when I change the value of DLEVEL then the STACK value changes correctly as the value of DLEVEL is a constant.
#define DLEVEL 0
#if DLEVEL == 0
#define STACK 100
#else
#define STACK 50
#endif
printf("STACK = %d\n",STACK);
However in the following STACK value changes incorrectly when I change the value of x since the x is not a const expression.
const int x = 0;
#define DLEVEL x
#if DLEVEL == 0
#define STACK 100
#else
#define STACK 50
#endif
printf("STACK = %d\n",STACK);
Anyway to define a directive depending upon the value of an expression ?
RKP
|
|
|
|
|
RKP728 wrote: Anyway to define a directive depending upon the value of an expression ?
No - macros are evaluated before the compiler even sees the code, never mind being evaluated at run-time!
To see the code after macros have been evaluated, use the /P compiler option.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
yes stuart you are correct
macros gets preprocessed before expression compilation
RKP
|
|
|
|
|
Here are two ways that may help you:
1. delayed compile-time decision
#define STACK (STACKX==0?100:50)
...
#define STACKX 12
...
printf("STACK = %d\n",STACK);
2. run-time decision
#define STACK(x) (x==0?100:50)
printf("STACK = %d\n",STACK(12));
|
|
|
|
|
i am new to this programming. actually an MFC is developed using mediaplayer control. in that we are displaying the input image. in that image we are giving region of interest coordinates manually. but our people wanted it to be done just by mouse click using mspaint control. can you help me in this.
|
|
|
|
|
Reposting may not help you. Rephrasing the query to something better may help you though...
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
|
Not unless you read the guidelines[^] and rephrase your query to be in accordance with it.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
REPOST! Your question asked earlier was much clear.
Actual query:
vvlnkishore wrote:i am trying to embed mspaint into an mfc application. in that i wanted to load a bitmap image and when i click at a position in the image with a mouse i want to read the position coordinates. is it possible ? if so please help me
load your bitmap into a picture control or a static control and then handle the WM_LBUTTONDOWN message on that control.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
vvlnkishore wrote: but our people wanted it to be done just by mouse click using mspaint control. can you help me in this.
Running Mspaint.exe is easy enough, but how are you planning on getting your image to it?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
i will call it using shellexecute & give the location of the image to be opened. then it will open. but i want some more from it. i want to extract pixel coordinates when i click at a point using mouse.
|
|
|
|
|
Why you want to call mspaint I think its better you write it yourself.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
vvlnkishore wrote: but our people wanted it to be done just by mouse click
My reply[^] for your previous post.
vvlnkishore wrote: can you help me in this.
I fear I can't any more! Sorry boss!!
|
|
|
|
|
hi, I want find out all files of the dictonary to compare existing the specific file,I used WIN32_FIND_DATA about window API,as it:
<prex>
char path[MAXPATH];
GetCurrentDirectory(MAXPATH,path)
WIN32_FIND_DATA findFileData;
findFileData.dwFileAttributes=FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_READONLY;
HANDLE fHandle=FindFirstFile(path,&findFileData);
if(fHandle!=INVALID_HANDLE_VALUE){
do{
if(!strcmp(findFileData.cFileName,strFilename)){
if(DeleteFile(strFilename)){
MessageBox(NULL,"delete file success","UDatabase",MB_OK);
break;
}
}
}while(FindNextFile(fHandle,&findFileData));
FindClose(fHandle);
}
but it ocur exception :0xC0000005: Access violation writing location 0x00405f0c at if(fHandle!=INVALID_HANDLE_VALUE),can you help me please ,thank you !
david zhang
|
|
|
|
|
You can have a look here[^] and here[^]
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
yeah ,I will look it ,thank you very much
best wishes!
david zhang
|
|
|
|
|
I have checked your code, its fine and no access violation caused so far. By the way, At present your code does not check all the files available in the current directory, I changed the code like -
GetCurrentDirectory(MAX_PATH,path);
<font color='red'>strcat(path,_T("\\*.*"));</font>
WIN32_FIND_DATA findFileData;
findFileData.dwFileAttributes=FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_READONLY;
HANDLE fHandle=FindFirstFile(path,&findFileData);
Now it compares all available files with strFilename .
Just a suggestion...
|
|
|
|
|
The following may or may not address your issue, but here are some things I've noticed.
Firstly the following is pointless:
fresh888888 wrote: findFileData.dwFileAttributes=FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_READONLY;
The documentation for FindFirstFile[^] states that:
LPWIN32_FIND_DATA lpFindFileData is an out only parameter.- The search is performed strictly on the name of the file, not on any attributes such as a date or a file type (for other options, see FindFirstFileEx).
Secondly your pattern (the first parameter passed to FindFirstFile[^]) contains no wildcard. You probably mean something like this:
char path[MAXPATH];
GetCurrentDirectory(MAXPATH, path);
PathAppend(path, "*");
Steve
|
|
|
|