|
hINTModuleState wrote: Now what I need to do is to be able to "grab the name of" the passed parameter variable, and use it to customize the behaviour of the function Function1.
That is bad design. Take one mental step back and think what you want to *Do*.
You need to transport information about a WHAT (your variable value) and a HOW into your function. You can either introduce another parameter (as already posted).
Alternatively, and more "The C++ way" would be to use different parameter types and overloading.
class Strategy
{
public:
Strategy( int Value}
: m_value( Value)
{}
int GetValue(){ return value;}
private:
int m_value;
}
class StrategyA : public Strategy
{
StrategyA( int Value) : Strategy( Value)
{}
}
class StrategyB : public Strategy
{
StrategyB( int Value) : Strategy( Value)
{}
}class StrategyC : public Strategy
{
StrategyC( int Value) : Strategy( Value)
{}
}void Function1(StrategyA iArgument)
{
}
void Function1(StrategyB iArgument)
{
}
void Function1(StrategyC iArgument)
{
}
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
yes yes I am totally with you.
but for primitive types I needed that sort of trick which M Pillini game me so to automatically grad the variablke name and not oblige the developer to explicitly put a key name next to the var value.
it is also useful since he may forget to supply the wrong key name in the reverse process (reading process as opposed to storing, or receiving as opposed to sending the primitive var).
As for object, yes indeed I have the things that you explianed. More thnat that and since I may have differente types of objects serialized in same stream to be sent or saved to disk, which havce same key, then I need to add a type data member to the base class.
class CSerializeObjBase
{
public:
CSerializeObjBase(CString key,CString objType)
{
this->key=key;
this->objType=objType;
}
CSerializeObjBase(int key,CString objType)
{
this->key.Format(_T("%d"),key);
this->objType=objType;
}
~CSerializeObjBase(void){};
private:
CString key;
CString objType;
public:
void setObjKey(CString key){
this->key=key;
};
CString getObjKey(){
return key;
};
CString getObjType(){
return objType;
}
virtual bool serializeObject(CPacketBase* pStore){
return false;
};
};
Thk you for your intervention; and forgive the bad words, bcuase i am arab and consume time to formulate right sentences in english ans i am hurry now but i recognize the necessity of replying to you and thanking you.
So Thank you for your help.
Our Philosophy, Mohammed Baqir Al Sadr
|
|
|
|
|
i want to add for you all before i go to take the bus, that indeed i could have given up the necessity of exploiting of vraiable naming information, and rather exploited the simple order by which the variables or objects are put in the stream, in the serialisation process wether while writing to file or db or sending to network.
becuase in the reverse process the developer will have to take care of th e exact reverse order of fetching stream elkemnst onto vraiables and memebers of the object or objects obnside the object.
I am in a bad position. the java and C# people have an interprested lalgage so it is possible for them to query an unknow object type and ask it for its type and even query oits memùbers and even functions.
Thus it is easy for them to consstruct automatic tools for sending objects and i do'nt know.
for me i have many personal unmanaged C++ programs and i want besides to take the strategic decision of staying with unmanaged code. but of course i can not accept to be bypassed by the java and the C sharp people so i must do something even though C++ is not interpreted.
Thank you.
Our Philosophy, Mohammed Baqir Al Sadr
|
|
|
|
|
Hi,
I have an MFC app for which icon is displayed normally in all conditions except this -
- When I open 2 instances of the app and Windows XP groups them into 1 single entity in taskbar, the icon displayed is something other than my app original icon.
Any ideas regarding this ? (I'm already doing a SetIcon btw at my side)
Regards
Cage
|
|
|
|
|
Have you changed all resolutions of your icon? In one .ico file can be several sizes (16x16, 32x32, 48x48).
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Okay. So, you mean to say I should have 3 sizes images embedded into the ico file ?
The way I created the icon was to use create a 32 * 32 size icon.
Btw - how can we see for an ico file - how many sizes does it support ?
Thanks for the help,
Cage
|
|
|
|
|
cagespear wrote: Btw - how can we see for an ico file - how many sizes does it support ?
I use Visual Studio's built-in icon editor.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Ok. so I just added 16 * 16 as well as 48 * 48 image sizes to my icon. I can see all 3 sizes - 16, 32 and 48 in my visual studio icon editor.
But my problem still continues ...
As I told you earlier - I can see the icon fine in the titlebar, in the icon which shows up when you do an alt+tab but I see the default icon(hand with videocamera) rather than my app icon in taskbar properly when I have more than 1 instances open for my app and windows xp has "grouped" them into 1 with its taskbar setting.
1 part which I missed earlier was even in the xplorer view, the icon for my app is that default one instead of original app icon.
Thanks for your time,
Regards
Amit
|
|
|
|
|
The app icon is sometimes tricky. Best is to give it the lowest icon ID in the resource.h.
And as some rightly mentioned support all possible sizes and bit depths in the icon.
Greetings from Germany
|
|
|
|
|
KarstenK wrote: The app icon is sometimes tricky. Best is to give it the lowest icon ID in the resource.h
I second that. I had a similar problem which was solved by doing this
Graham
Librarians rule, Ook!
|
|
|
|
|
Hi all,
please tell me how can i convert CString to float or vice Versa.
i m using this,
float fvar;
CString foo;
foo = "123.45";
fvar= atof(foo);
but this not working.
Please tell me.
Thanks in advance.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
ThatsMe. wrote: but this not working.
any error message ?
|
|
|
|
|
No there is no error message.
but after calculation the final resul is Zero, that is wrong.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
try
fvar= atof((LPCSTR)foo);
Graham
Librarians rule, Ook!
|
|
|
|
|
i m also try this but same problem occur here.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
The only reason that I can think of that neither code works is that the string contains some other character before the numbers. atof will strip off any leading whitespace characters (MSDN says spaces and tabs only, but in my testing it also strips of newlines). Any other characters, probably including non printable characters, could cause it to return zero. Have you checked the characters in your string?
Graham
Librarians rule, Ook!
|
|
|
|
|
ThatsMe. wrote: but this not working.
Its working fine in my dialog based testapp. I could find only one warning -
"warning C4244: '=' : conversion from 'double' to 'float', possible loss of data".
Since atof() returns double instead of float .
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
is "." the right comma sign, or "," It depends on the system settings.
Set the warning level of the compiler higher to get a message. It also should work harder.
(Use double)
Greetings from Germany
|
|
|
|
|
I answered this for you on Codeguru, but in case you visit here more often...
The most likely reason I can think of (since you don't explain "not working" is this...
If you application is Unicode (default for VS2005 and later) then you can either change it to MBCS, or change your code to:
float fvar;
CString foo;
foo = _T("123.45");
fvar= _tstof(foo);
This change will allow it to work with either Unicode or MBCS.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
ThatsMe. wrote: please tell me how can i convert CString to float or vice Versa.
You can always use std::stringstream and the << operator instead of the old, insecure C-ish atof.
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
Hi,
I use GetDlgItem in thread. But it shows the error that GetDlgItem() does not take 1 parameter. For that i found i have to incude handle for my dialog box. I have displayed the dialog by using DoModal().
I dnt know how to create HANDLE for this dialog.Pls help me .
Anu
|
|
|
|
|
From your question, I think you're using MFC and your dialog class is derived from CDialog . Then call GetSafeHwnd() to get your dialog handle.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Try this.
CEdit* pBoxOne;
pBoxOne = (CEdit*) GetDlgItem(IDC_EDIT1);
GotoDlgCtrl(pBoxOne);
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Anu_Bala wrote: I use GetDlgItem in thread
You probably then call GetDlgItem outside your dialog class, which means that you are calling ::GetDlgItem and not CDialog::GetDlgItem (which are two different functions). The way to solve this is to pass the pointer to your class instance (the this pointer) in the thread parameter, cast it back to your class in the thread function and call GetDlgItem on it.
|
|
|
|
|
Whats the error? it needs to a handle to window?
|
|
|
|