|
jhoesche wrote: I am not sure that I understand - if I call the function from the base class...
You don't. It gets called from the owner of the derived dialogs (e.g., the application).
"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
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
DavidCrow wrote: You don't. It gets called from the owner of the derived dialogs (e.g., the
application).
I do not understand - can you give me an example of how this will work. Can I contact you directly by email if I need to?
|
|
|
|
|
jhoesche wrote: Can I contact you directly by email if I need to?
That would defeat the purpose of others being able to help you.
"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
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
My requirement is in MFC vc6.0 application
I need a function which receives a string and a float value
The string that i pass is a variable name used in the application.
When the function is called the passed value should get assigned to the variable which is passed as a string
Function SetVal(CString VarName, float value)
{
Suppose <varname> is Esim->Aut[35] and <value> is 5.5665
This function should set Esim->Aut[35] to 5.5665
}
Anybody pl help if this is possible.
|
|
|
|
|
C++ does not have a built-in way to associate a variable name with a string, at runtime. so, you will need to construct a way to create this association explicitly.
there are many ways to do it. the most basic is something like this:
void SetVal(CString VarName, float value)
{
if (VarName=="Var1")
Var1 = value;
else if (VarName=="Var2")
Var2 = value;
else if (VarName=="Variable3")
Variable3 = value;
etc..
}
|
|
|
|
|
Thanks for your help.
But... This doesnt help me
Becoz I have more than 1000 variables in my application for which I have to write this code to check for the variable.
Pl. suggest me if there is any direct way of doing the mapping.
|
|
|
|
|
manoharbalu wrote: Pl. suggest me if there is any direct way of doing the mapping.
there is no direct way of doing this. C++ does not know the 'name' of your variables at runtime.
if you have a lot of variables to deal with, you can use a std::map to map strings to floats. you will have to add the variable names to the map explicitly, but accessing the stored values will be simpler.
Google "C++ variable name map". this is a common question, and there are a lot of solutions out there.
|
|
|
|
|
manoharbalu wrote: Becoz I have more than 1000 variables in my application for which I have to write this code Write yourself a little app that will output the variable names like this:
"variable-name", variable-name,
Do that for all the variables, paste the output into your program, and you have a table that you can search at run-time.
By the way, use of sms-speak (Becoz, pl.) is not appreciated on this site.
|
|
|
|
|
I don't know of such a way but if you elaborate on your requirement someone here might help you on this. Another way would be to keep a check on the string passed and then compare it with what you want, thereafter set the value in the required value but then this may be an additional overhead depending on the parameters used in your code.
You talk about Being HUMAN. I have it in my name
AnsHUMAN
|
|
|
|
|
manoharbalu wrote: This function should set Esim->Aut[35] to 5.5665
So why not just use:
Esim->Aut[35] = 5.5665;
"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
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Have you considered using some kind of macro (using a #define ) instead of a function call?
|
|
|
|
|
Hi,
I tried to minimize the application using below code:
HWND lHwnd = FindWindow("Shell_TrayWnd",NULL);
SendMessage(lHwnd,WM_COMMAND,MIN_ALL,0);
I am confused with, Will it work with other language OS because I used hard code "Shell_TrayWnd"?
|
|
|
|
|
What do you mean by "other language OS"? Unix? Mac? Or do you mean other language, like C#?
|
|
|
|
|
I'm not sure but i think "language" he mentioned might be "other regional settings"...
|
|
|
|
|
It means Os ig other langauge like German, Italian, Fernch, Chinees etc
|
|
|
|
|
Are you trying to minimize the taskbar?
"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
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
I have Windows 7 x64 in Spanish and the line:
HWND lHwnd = FindWindow("Shell_TrayWnd",NULL);
In my computer returns:
lHwnd=0x0002008c {unused=0 }
Hope it helps.
|
|
|
|
|
i read the thread for using getsockno
culd u ket me knw how t o get the port no i ma using c#
|
|
|
|
|
We could if you learn how to use English, not sms-speak. (cud, u, knw, ma).
If you don't want to show respect here, why should we help you?
|
|
|
|
|
Hi all,
please help me to resolve this error.
Error:: sprintf' : cannot convert parameter 1 from 'TCHAR [128]' to 'char *' in Unicode Build
i m build my project as unicode.
thanks in advance.
|
|
|
|
|
For UNICODE you should use: swprintf[^]
You talk about Being HUMAN. I have it in my name
AnsHUMAN
|
|
|
|
|
use _stprintf( it has to work for both UNICODE and MBCS code)
|
|
|
|
|
|
Hello everybody,
I'm creating an application for a barcodescanner-device.
In the main-thread, a
gets(buffer); waites for user key-input.
In a separated thread I poll on the barcode-scanner.
If the user scans a barcode, I extract the barcode and want to place it into the stdin-buffer.
Then, the gets()-Function should see the (new) data into the stdin and returns like a real key-input.
I tried it already this way :
fscanf(stdin,"%s",barcode);
fflush(stdin);
but the gets(buffer); still waites for user input.
Is it possible to manipulate the imput buffer in this way?
Big thanks for any help
|
|
|
|
|
I guess u can not write in input stream and you can not read from output stream.
However it looks like you have two threads one is reading Barcode from device and you want to pass it into another thread.
Why you are using gets for that? You have two ways.
1. Start second thread after reading the Barcode. Pass barcode as an argument of thread
or
2. If you can not pass then you can use global variable.
|
|
|
|