|
You "only" got to understand the message. The cursor with the ID 1 is inserted in each file. You got to remove one.
Maybe you do this via including other header files in the *.rc files. Try to comment doubles out.
Greetings from Germany
|
|
|
|
|
I have two .rc files.
The contents of the files are:
resource1.rc:
1 CURSOR "file1.cur"
resource2.rc:
2 CURSOR "file2.cur"
No other contents in files.
And that two .rc file are in my project.
|
|
|
|
|
Look for #include "afxres.rc" string (usualy in TEXTINCLUDE 3 section)
It must be included in one file only
|
|
|
|
|
Hi,
is there an easy way (a function) to test if a CString contains only numbers?
Thanks
|
|
|
|
|
See
isdigit();
How to read your string?
|
|
|
|
|
WhiteSky wrote: atoi(m_Str);//return value is 0
If the string is as 12a3 then Index would be 12 and not 0 inspite of the fact that there exists a character in the third place.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
CString m_Str;
m_Str="123ABC";
Index=atoi(m_Str);//return value is 123
Gives 123 too, and m_Str doesn't contain only numbers...
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
speedy4711 wrote: CString contains only numbers?
CString str="1142654";
int i=atoi (str);
CString str1;str1.Format("%d",i);
if(str.GetLength ()==str1.GetLength ())
AfxMessageBox("string is pure number");
else
AfxMessageBox ("Characters exist");
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
_AnShUmAn_ wrote:
if(str.GetLength ()==str1.GetLength ())
Doesn't work with eg.
CString str="0x1142654";
|
|
|
|
|
SilentSilent wrote: Doesn't work with eg.
Since this value you are entering is a string x is treated as a character only, it doesn't represent a hexadecimal number nor did I check for this.So I would try and provide a solution for this...
Thanks for pointing this out...
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Here's a small function I use for validating user input:
bool IsNumeric(const CString& str)
{
if(str.IsEmpty())
return false;
for(int i = 0; i < str.GetLength(); i++)
if(str[i] < '0' || str[i] > '9')
return false;
return true;
} It only takes decimal non-negative integers into account. It's easy to extend for other types of numbers, should you want to.
--
Mit viel Oktan und frei von Blei, eine Kraftstoff wie Benziiiiiiin!
|
|
|
|
|
Jörgen Sigvardsson wrote: for(int i = 0; i < str.GetLength(); i++) if(str[i] < '0' || str[i] > '9') return false;
Doesn't work with eg.
CString str="0x1142654";
|
|
|
|
|
How often do you accept hexadecimal user input? And how hard would it be to extend it? I never claimed it would recognize all possible numeric syntaxes...
--
Mit viel Oktan und frei von Blei, eine Kraftstoff wie Benziiiiiiin!
|
|
|
|
|
speedy4711 wrote: test if a CString contains only numbers?
here's one more solution. You can give this a try...
CString s="253453";
CComVariant v;
v=s;
if(v.ChangeType(VT_INT)==S_OK)
{
CString str;str.Format ("%d",v.intVal );
AfxMessageBox (str);
}
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
I looked over the responses, and I want to point to two possible problems.
The first may be a leading Zero ( "0123" )
and the other is a value with a comma or a sign ( "-1,5" or "+ 2.7" )
I would resolve this with checking every char of being a digit or allowed other char.
Greetings from Germany
|
|
|
|
|
Why don't you just use strtol() ?
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Here is a base-10 checker that allows for ,'s and -'s (but doesn't check for placement). You can easily extend it to check for proper placement of special characters (,'s, and -'s) as well as other base numbers and floating point numbers.
bool is_digit_base10(const CString& str)
{
static CString allowedChars = _T("0123456789,-");
const unsigned int length = str.GetLength();
for (unsigned int i = 0; i < length; ++i)
{
char buffer[2] = {0};
buffer[0] = str[i];
if (-1 == allowedChars.FindOneOf(buffer))
{
return false;
}
}
return true;
}
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
hi, i am coding a multithreading application in vc++.net 2003.
and the thread i am starting from main thread,it actually gives it's control in the hands of external code, which is acually a driver. when the work is done i want that thread to unwind, but it doesn't stops,and when i call that function again it starts a new thread.
i tried to look for a function using which i can end a thread given it's thread id.
like _endthread,_endthreadex,exitthread.... etc..(i did not used .net runtime Tread class)
but the most they can do is to set thread exit code,
i want to know how to terminate child thread from parent thread, any API or tutorials will be helpful,,
thanks in advance
WIreD 0x90
|
|
|
|
|
Actually, you really don't want to forcibly terminate your thread. You should monitor something in your thread proc that will exit when the state is set by the parent thread.
One way of handling this is to create an event, say, m_hShutdown. At the top of your thread proc loop, do a WaitForSingleObject on m_hShutdown with a short timeout. When the event is set, exit the thread proc and your thread will terminate normally. In your parent code, simply call SetEvent(m_hShutdown) when you're ready to terminate the child thread.
Hope this helps.
|
|
|
|
|
IMO, you can take a global flag variable. In your thread function check for the flag value to be true(The flag value is set to true when you want the thread to end), so gracefully return from the thread function. Using AfxEndThread() , TerminateThread is not suggested. You must always try and return from the thread function whenever you want to end it...
If you are starting a thread in some function and want to instantiate the thread only once then you can use another flag variable. Set it true and check for the validity.
I hope that I understood you correctly...
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
WIr3D 0x90 wrote: i want to know how to terminate child thread from parent thread, any API or tutorials will be helpful,,
I second Mr Duncan's suggestion: Do NOT terminate threads unless you know they are safe to be killed. Should the thread be executing within the C-runtime library for instance, holding a mutex/critical section object, you will effectively cause a dead lock (sooner or later). To only safe way to terminate a thread is to use some form of communication. The absolutely simplest way is to pass a variable through CreateThread/_beginthread which your thread should monitor regularly. As soon as this variable's value becomes true (or whatever variable type you choose), you can then have the thread exit itself. During exit you can then make sure that various locks and resources are released as needed.
Seriously. Do not kill threads by forece. You will regret it later.
--
Mit viel Oktan und frei von Blei, eine Kraftstoff wie Benziiiiiiin!
|
|
|
|
|
Hey, guys.
The image list for a toolbar I'm writing is forced to a 16 color palette regardless of the color depth of the bitmap that I use. In some of the older MFC doc it mentions a 16 color limitation for toolbars. However, this is for an IE toolbar and I can see that others (such as Google) are able to use more color (either 256 or perhaps even true color).
My assumption is that they're doing complete owner draw code for the toolbar buttons, but I'm hoping I'm just missing something obvious. Anyone know how to coerce a toolbar to display the images in greater than 16 color without resorting to an owner draw scenario?
|
|
|
|
|
after creating the tool bar in main class . i.e CMainFrame . add a image list to the tool bar . that imagelist can containe 25 color icons . and we can give three imaage lists for tool bar . 1 for when button is Active . 2 for Wend button is disabled . and 3rd state is grayed. try this. bye
|
|
|
|
|
m_ilToolBar.Create(20,20,ILC_COLOR8,4,4);
Tanvon
the brain behind ...
I Blog here
|
|
|
|
|
after creating the tool bar in main class . i.e CMainFrame . add a image list to the tool bar . that imagelist can containe 256 color icons . and we can give three imaage lists for tool bar . 1 for when button is Active . 2 for Wend button is disabled . and 3rd state is grayed. try this. bye
|
|
|
|