|
Try IShellDispatch2::IsServiceRunning with service name as WSearch .
|
|
|
|
|
Thanks, that did the trick.
|
|
|
|
|
Hi I have created a list box using CListBox class. I want to give the hover effect on the list box item. like combo box.
Please anyone can help me how to do that.
Thanks
|
|
|
|
|
You will need to handle the WM_MOUSEMOVE message and do the handling yourself.
|
|
|
|
|
Can u post some sample code please ???
|
|
|
|
|
No, but here is the rough idea.
1. Create a new class derived from CListBox -> CHoverListBox.
2. Make it owner drawn (a window style).
3. Override DrawItem() and possibly OnMeasureItem(). You will need DrawItem since you will be changing the visual appearance of the control while hovering.
4. Add a message handler for WM_MOUSEMOVE, and in this handler figure out which item the cursor is over. Cooridnates of the mouse is supplied in screen coords, so you should convert them to client coords using CListBox::ScreenToClient(). Then use CListBox::GetItemRect() to find the hovered item. Set a flag for this item, and then call Invalidate(FALSE) to force a repaint.
5. Implement DrawItem() to look at the flag set, and paint the items accordingly.
6. Now you have a reusable class.
7. Write an article about what you did and post it on this site.
Tip: Do not use CListBox::SetItemData() to set the flag, because the space is likely to be needed by the users of your control. Use a separate integer in your class instead.
|
|
|
|
|
Hi!
I'm passing a string variable to a function. Only the first letter of the string value is assigned to the formal parameter. Here is my function:
void setTextToButtons(stringw country, int tabSelected);
irr::core::stringw country = irr::core::stringw(list->getItem(countryCode));
setTextToButtons(country, tabSelected);
void CGameMenuPlayerProfileState::setTextToButtons(stringw country, int tabSelected)
{
stringw query;
query = L"Select Name from ";
if(tabSelected = 17) {query += L"Test";}
else if(tabSelected == 18){query += L"ODI";}
else if(tabSelected == 19){query += L"T20I";}
else {query += L"Test";}
query += L" WHERE Team = '";
query += country;
query += "' ORDER BY RANDOM() LIMIT 11";
printf("%s\n",query.c_str());
playerLst = SQLdb.Query(query);
printf("Selected Country%s\n", country);
for(int i = 0; i < 11; i++)
{
m_pPlayerBtn[i]->setText(irr::core::stringw(playerLst[i]).c_str());
cout<<query.c_str()<<endl;
}
}
How to pass the full string value in to the function?
|
|
|
|
|
You are not using this correctly
printf("Selected Country%s\n", country);
First off, unless stringw is a typedefed _wchar_t* you need a cast function. Then, you need capital %S to print a unicode string using printf.
The parameter passing looks ok otherwise. (even though I alway use const& for those types)
|
|
|
|
|
Hi!
It's typedefed. It's defined as follows:
typedef string<wchar_t> stringw;
My probelm is how to get the full string in to my formal parameter. Now only the first letter is present when I print the string inside the function. How to pass the full string value?
|
|
|
|
|
T.RATHA KRISHNAN wrote: My probelm is how to get the full string in to my formal parameter. Now only the first letter is present when I print the string inside the function.
You're wrong here. You send the full string to the function BUT you are printing it incorrectly. As the previous poster said, you have to use %S instead of %s in your printf (your string is side characters, check the documentation of printf).
|
|
|
|
|
Ok. I got it right. But the text is not assigned to the buttons correctly.
Can you please refer this line in my code:
for(int i = 0; i < 11; i++)
{
m_pPlayerBtn[i]->setText(irr::core::stringw(playerLst[i]).c_str());
printf("%S\n",irr::core::stringw(playerLst[i]).c_str());
}
I am getting playerLst using Sqlite query. and setting the first(0th) player name
to the first button in my array of buttons. This is not working. Contents of playerLst
is also not printing. Program Crashes.
|
|
|
|
|
What is the type of playerLst ?
What are you trying to do here:
irr::core::stringw(playerLst[i]).c_str()
Why not pass the string directly instead of constructing a temporary string ?
T.RATHA KRISHNAN wrote: Program Crashes.
What is the exact error message ? Did you try debugging to inspect the problem more in details ? You should really start to learn how to use your debugger, this is much much more efficient than asking questions on a forum.
|
|
|
|
|
playerLst is of type irr::core::stringc . Sqlite Query returns only a stringc . So I've used a stringc variable. But setText method expects a const wchar_t* . As I already said,
I've to iterate this playerLst array and set the each element as text to corresponding button in an array of buttons. How to do?
|
|
|
|
|
You ae mixing single-byte character strings and multi-byte character strings. You can't just mix them the way you are doing. I really suggest you take the time to understand the string encoding. See for instance this article[^].
|
|
|
|
|
T.RATHA KRISHNAN wrote: Only the first letter of the string value is assigned to the formal parameter.
How are you verifying this?
T.RATHA KRISHNAN wrote: cout<<query.c_str()<<endl;< blockquote="">
Should you be using wcout here?
T.RATHA KRISHNAN wrote: printf("%s\n",query.c_str());
Have you tried using a capital 'S' in the format string?
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
you are mixing wchar with char size strings. You need conversion NOT cast.
c_str() should do the job
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Don't use printf. The interface to printf isn't type checked so the compiler has no idea that you're passing complete rubbish to it. What's happening is...
- your code sticks a pointer to a lump of wide characters on the stack
- printf looks at it's format string and sees that you want the first argument on the stack interpreted as a lump of ordinary characters terminated by a zero
- it starts reading your wide character array, sees the first character is non-zero but, as it's reading the memory byte by byte it sees the high byte of the first character as the string terminator. It prints one character
- printf stops processing having done everything you told it to do
So what can you do about it?
The first thing is stop using printf. Printf is a C function - while it's bundled in the C++ library it's pretty useless. Use streams, they're the equivalent C++ mechanism. AND you don't have to convert your function arguments either. Instead of trying to use:
printf( "%s\n", str.c_str() );
you can use:
std::wcout << str << std::endl;
Look ma, no conversions! Same number of function calls and the compiler can probably optimise it a lot easier. You also get type safety - if you try and use a stream with an object type it doesn't understand the compiler will tell you.
Cheers,
Ash
|
|
|
|
|
Aescleal wrote: - your code sticks a pointer to a lump of wide characters on the stack
And even this is just a lucky coincident. It could just as well be other things, like an integer describing the length of the string, or whatever's first in the passed object. Interpreting that as a pointer to anything will not make anyone happy.
|
|
|
|
|
Well he did .c_str() on the string so he will repeatably get a pointer to a lump of wide characters. Had he used the correct format string he'd probably have been safe. Okay, maybe not safe as he would have had no idea why it was working looking at the rest of his posts on here.
Cheers,
Ash
|
|
|
|
|
Well, here
stringw country;
...
printf("Selected Country%s\n", country);
he got 'lucky'.
|
|
|
|
|
Cool, I missed that one. I was too busy nashing me teeth at the others I could see.
Cheers,
Ash
|
|
|
|
|
Hi Friends,
I am going to learn MFC Smart Device technology, i don't have a material please help me..
Thanks and Regards,
D.Manivelan
|
|
|
|
|
Member 4482742 wrote: I am going to learn MFC Smart Device technology, i don't have a material please help me.
Well you need to learn to use the smart tools like this[^].
It's time for a new signature.
|
|
|
|
|
I have drawn an image over a picture control. I want to draw transparent mask (grey color) over the image.
How can I do that?
|
|
|
|
|