|
I should have guessed....
|
|
|
|
|
Hence you don't need the Toolbox.
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
|
|
|
|
|
I am getting a string from map that can be either true or false. Is there any function or some alternative to convert this string into bool. So that I can store it in a bool variable.
string temp;
temp=MyMap.find("Check")->second;
I want to convert temp to bool.
THANKS.
|
|
|
|
|
bool bChecked = false;
if (temp == "true")
bChecked = true;
. You have to check for the case also but you got the idea.
|
|
|
|
|
Thanks for the reply.
This can be done. But instead I am looking for some function that does this like atoi() or itoa() for string to int and vice versa.
Is there any function for strings to bool.
|
|
|
|
|
please reply to this question[^] first before we can reply to you efficiently
|
|
|
|
|
pl_kode wrote: But instead I am looking for some function that does this like atoi() or itoa() for string to int and vice versa
Why ? That's quite simple, why do you want to use an existing function for that ?
pl_kode wrote: Is there any function for strings to bool.
Not as far as I know.
|
|
|
|
|
Good news: it exists, is atob . The bad news is that you have to code it (anyway you got so many hints about).
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
|
|
|
|
|
what kind of strings are supposed to be stored in MyMap.find("Check")->second ?
I mean, you'll have to test programmatically the string to assign another boolean variable to true or false...
|
|
|
|
|
toxcct wrote: what kind of strings are supposed to be stored in MyMap.find("Check")->second ?
From his snippet of code, I would say std::string.
|
|
|
|
|
you misunderstood me. I meant what is contained within that string ?
1/0 ?
true/false ?
checked/unchecked ?
white/black ?
|
|
|
|
|
true/false (well, that what he said in his post)
|
|
|
|
|
I prefer to be sure...
|
|
|
|
|
true/ false is stored in that
|
|
|
|
|
what about
bool f = temp == "true";
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
|
|
|
|
|
You still remember it.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
Well I forgot for a while, but then suddenly I spotted you vulture ready for hitting me!
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
|
|
|
|
|
hehehhehe!!!
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
bool bVal = (temp == "true"?true:false);
-@SuDhIrKuMaR@-
|
|
|
|
|
why do you need the ?: operator ? the std::string::operator==() already returns a bool.
in the same direction, why wouldn't you write this then :
bool bVal = ((temp == "true") == true ? true : false)
or
bool bVal = (((temp == "true") == true) == true ? true : false)
or just
bool bVal = (temp == "true")
|
|
|
|
|
Hi,
I have a class CMyPropertySheet derived from CPropertySheet . I have added a CButton control and a CToolbar on this propertysheet. I have also added command handlers for the button and toolbar buttons. I have created property sheet as modeless propertysheet with WS_CHILD style set.
Handler for button gets called, however, the toolbar is never gets enabled. I see that the toolbar is in disabled state.
If I remove the WS_CHILD style from CMyPropertySheet creation, everything works fine, as expected.
Any help would be highly appreciated.
Regards,
Paresh.
|
|
|
|
|
Hi,
I have a little problem with global hooks in my application. After setting the hook, the hook DLL gets attached only to two processes (the app which created the hook and a random process - last time I ran it it was Winamp;p) instead of all processes in the system.
Here's the code I use to create the hook:
void HookManager::Init(ListenerWindow *l) {
l->GetListeners().push_back(this);
TCHAR dllPath[MAX_PATH];
GetCurrentDirectory(MAX_PATH,dllPath);
#ifdef XWS_64
_tcscat_s(dllPath,MAX_PATH,_T("\\XWSHook64.dll"));
#else
_tcscat_s(dllPath,MAX_PATH,_T("\\XWSHook.dll"));
#endif
mHookInstance = LoadLibrary(dllPath);
if(!mHookInstance)
throw _T("Could not load the hook DLL.");
void (*pfnSetSharedHookHandles)(HWND,HHOOK) = (void(*)(HWND,HHOOK))
GetProcAddress(mHookInstance,"SetSharedHookHandles");
HOOKPROC pfnShellHookProc = (HOOKPROC)
GetProcAddress(mHookInstance,"ShellHookProc");
if(!pfnSetHookHandles || !pfnShellHookProc) {
FreeLibrary(mHookInstance);
mHookInstance = NULL;
throw _T("Could not locate the hook procedures.");
}
mShellHook = SetWindowsHookEx(WH_SHELL,pfnShellHookProc,mHookInstance,0);
if(!mShellHook) {
FreeLibrary(mHookInstance);
mHookInstance = NULL;
throw _T("Could not establish the system hook.");
}
pfnSetSharedHookHandles(l->GetHwnd(),mShellHook);
}
The only thing the hook DLL code really does is displaying a message box with the id of the current process in DllMain (with DLL_PROCESS_ATTACH). The ShellHookProc function doesn't do anything apart from calling CallNextHookEx().
Does anybody have an idea what can be wrong with it?
Thanks in advance,
Kosomot
|
|
|
|
|
I think you should also post your code for Shell Procedure also.
-@SuDhIrKuMaR@-
|
|
|
|
|
I didn't post the ShellHookProc, because currently it looks like this:
__declspec(dllexport) LRESULT ShellHookProc(int nCode,WPARAM wParam,LPARAM lParam)
{
return CallNextHookEx(g_hHook,nCode,wParam,lParam);
}
So I don't think this is the problem.
|
|
|
|
|
So your main purpose is dll injecting rather than hooking?
And there is also a chance that the message box function failed e because the window classes is not registerd yet. Try puttin a OutputDebugString() instead of messagebox.
|
|
|
|