|
You can use *scanf -type functions, but functions specifically designed to do convert strings to numeric values already exist and will likely perform better than the *scanf -type functions. You do not need to use a shotgun to kill a fly...
Look up the strtol /wcstol , strtoul /wcstoul , and StrToIntEx functions.
The StrToIntEx function handles leading whitespace, and sign indicator (ignored), and a leading 0x hex. specifier. Much more robust parsing than you get doing something simple like using "%x" with a *scanf -type function.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
hi,
I am trying to draw a owner draw check box. I want to draw a focus rect around my control. But i don't know when to draw the focus rect. In a normal check box the foucs rect is not drawn when the focus is set through the mouse. But if we set the focus through the keyboard, the focus rect is draw.So my question is is there any way to know how the foucs came to a control( via keyboard or mouse )?
Thanks in advance
nav
|
|
|
|
|
Hi Nav,
Naveen raj mohan wrote: So my question is is there any way to know how the foucs came to a control( via keyboard or mouse )?
You can find out what had the focus before you get it, but you can't find out if it came from the mouse or the keyboard; in general, you don't need to know how it got there, you just care about the fact it did.
To find out what had it before, handle WM_SETFOCUS, and take a look at the wParam - that's the HWND of what had the focus before (note that it can be NULL). If you're using MFC, handle OnSetFocus(CWnd *pwnd) - the pwnd is what had the focus before.
Naveen raj mohan wrote: I want to draw a focus rect around my control.
Try the DrawFocusRect API (or CDC::DrawFocusRect if you're using MFC).
- Dy
|
|
|
|
|
A control draws the foucs rect if it have.
consider the case i have added a check box with tab stop style. By default windows behaviour, when i click on the the check box it dosen't draw a focus rect. But if i press the tab once and the click on the check box, it will draw the foucs.
In my case i am useing an owner draw chak box. So i don't want to draw a frame rect when ever i have focus but only when the focus comes to check box after the the user have pressed the tab key.
Isn't this correct method
Thanks
nave
|
|
|
|
|
Take a look at ODS_FOCUS and ODA_FOCUS . Carefully go through the documentation on them.
Nibu thomas
Software Developer
|
|
|
|
|
Can u please send me the link
nave
|
|
|
|
|
Naveen R wrote: Can u please send me the link
Click here[^]
Nibu thomas
Software Developer
|
|
|
|
|
But that dosen't meet my requirment
consider the case i have added a check box with tab stop style. By default windows behaviour, when i click on the the check box it dosen't draw a focus rect. But if i press the tab once and the click on the check box, it will draw the foucs.
In my case i am useing an owner draw chak box. So i don't want to draw a frame rect when ever i have focus but only when the focus comes to check box after the the user have pressed the tab key.
Isn't this correct method ?
is there any way to do this?
nave
|
|
|
|
|
Naveen R wrote: But that dosen't meet my requirment
Why?
When the ODS_FOCUS bit is set this means the item has focus hence you have to draw the focus rect else don't draw the focus rect.
I do it this way.
An eg:
<font color=blue>void</font> CMyButton::DrawItem(LPDRAWITEMSTRUCT lpdi)
{
<font color=green>
<font color=blue>if</font>((lpdi->itemState & ODS_FOCUS) == ODS_FOCUS)
{
<font color=green>
yourDC.DrawFocusRect(...);
}
}
Nibu thomas
Software Developer
|
|
|
|
|
According to the above code the focus rect will be drawn when u just click on the control. isn't it?
nave
|
|
|
|
|
Naveen R wrote: According to the above code the focus rect will be drawn when u just click on the control. isn't it?
Is it working? Did you check?
It works for me with keyboard and mouse. This is the proper way of doing it.
Nibu thomas
Software Developer
|
|
|
|
|
It will draw a focus rect. but i will draw the focus rect when ever the control has foucs. The normal behaviour should be like the one below . Try it out in a dialog based application with one check box having the tab stop property.
1. User click on the check box.
The check box have the foucs but it dosen't draw a focus rect.
2. Now press tab.
A focus rect will be draw in any of the controls in the dialog
3.Now click on the check box
Focus rect is draw in the check box.
nave
|
|
|
|
|
I am a newbie with ActiveX, COM and all. I have a few questions.
1. What is the difference between ActiveX and COM?
2. I have planned to start COM with MS Office automation. Can anyone kindly point out a few STEP BY STEP articles which helps to create COM Addin Controls? (using MFC/VC++/VB)
I got some from MSDN, but I know you guys can give me some real nice data.
Many Thanks.
Aljechin Alexander
|
|
|
|
|
Aljechin 1. What is the difference between ActiveX and COM?
ActiveX control is a COM Object which implements certain set of interfaces.They were intended to provide developers with a generic,COM-based architecture for building re-usabale Microsoft Controls.
"Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"
|
|
|
|
|
can any one give clear details
JAYARAJ
|
|
|
|
|
Could any suggest a good book, articles websites etc.. on MFC and socket program.
I've read a lot of great articles here on The Code Project and I am able to create a simple echo server and client program.
But now I want to learn more
Thank you for your time.
|
|
|
|
|
The basic concept of programming for sockets can be read from Windows socket Programming.
It can be easily integrated with MFC with WinSock etc
Vision is Always important and so is your ATTITUDE.
Wishes.
Anshuman Dandekar
|
|
|
|
|
|
hi
There is no Link tab in Project->Settings of my VC++ IDE.I am using VC 6.0 enterprise Edition.What could be the reason behind this?
Thanx in advance
"Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"
|
|
|
|
|
What sort of project is it ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote: What sort of project is it
does the tab settings depend on project too??
anyway the project uses MFC,ATL& COM if that makes difference...
"Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"
|
|
|
|
|
I would not have thought so, but it's such a bizarre problem that I hoped you were creating some sort of weirdo project that happened to hide it
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian Graus wrote: I hoped you were creating some sort of weirdo project
i think it's really weirdo since i opened other projects and the link tab is visible
"Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"
-- modified at 0:09 Wednesday 22nd February, 2006
|
|
|
|
|
Is your project a static library, a DLL or an application?
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Ryan Binns wrote: Is your project a static library, a DLL or an application?
it's an MFC application...(.exe)
"Every morning I go through Forbes list of 40 richest people in the world. If my name is not in there, I go to work..!!!"
|
|
|
|