|
you'll have to overload the WM_CHAR event with OnChar() handler...
in it, you can filter the characters typed, and allow only the ones you want, such as the 10 digits plus the period ('.')... (also a sign if you like...).
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I use MFC dialog .net 2003
Could you please teach me how to implement this.
Where I overload WM_CHAR, How I call OnChar().
Thanks
MilkyWay
|
|
|
|
|
Loc Milkyway wrote: Where I overload WM_CHAR
exactly the same way you overload the EN_EDIT event...
Loc Milkyway wrote: How I call OnChar().
you don't call it, it is the framework that calls it for you each time a character is typed in the edit box, but before it is displayed...
void CMyEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) {
TCHAR c = (TCHAR) nChar;
if(::isdigit(c) || c == '.') {
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
}
here, you'll print only the 10 digits and the '.'
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Here is an article about one way to do this : [^]
|
|
|
|
|
When I use my application statically linked to MFC, this is no problem. Since I'm trying to use localized resources (multiple languages), I need to dynamically link MFC. When I make this one change, the program no longer links. I get the following:
xxxx.obj : error LNK2001: unresolved external symbol "class CProcessLocal<class _AFX_MAIL_STATE> _afxMailState" (?_afxMailState@@3V?$CProcessLocal@V_AFX_MAIL_STATE@@@@A)<br />
Release/xxxx.exe : fatal error LNK1120: 1 unresolved externals<br />
Error executing link.exe.
Is there some way around this? For those who aren't familiar with what this is for - it's the code you often see on the web for sending email from within an application. It uses MAPI to accomplish this (at least that's my understanding).
I've tried many searches but I only get code samples for sending email. Nothing on this linker issue.
Thanks for any help you may be able to provide.
-- modified at 9:44 Friday 18th November, 2005
|
|
|
|
|
I have a small API that consists of about 10-12 C++ classes. It's relatively straightforward C++, little use of templates other than in the public interefaces I use std::string for string types and in the impl I use stl for various collections. Now I'm having to look into migrating this to managed C++ for a client. How hard is this? Is it even worth doing given that there are now two versions of managed C++ (one for VS 2003, and a newer, incompatible one for 2005). Would it make more sense to just rewrite the API using C# (the API isn't enourmous, so this isn't that big of a deal)? The API uses sockets and is multi-threaded (it creates 3 threads to do it's work) if this makes a difference.
I'd very much like to hear from other's what their experience has been with something like this.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
Jim, between the older MC++ syntax and C++/CLI, the port would be far easier with C++/CLI. Except you'd need .NET 2 then.
|
|
|
|
|
Yeah, well I suspect I'll have to support both environments, which I really don't want to deal with.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
I'm more interested in why you are "having to look into migrating to MC++ for a client".
What is their reasoning ?
...cmk
Save the whales - collect the whole set
|
|
|
|
|
They (the client) say they have several other 3rd party libs they want to use which are all .Net based ( I gather they were written in C#), so they'd like to make use of our API plus these other libs in one .Net based app.
I don't know enough about managed C++ to say one way or the other whether this is worth the effort or not, so I was hoping to get some feedback from others who may have tried something like this.
My gut feeling is that it is NOT worth the effort/hassle/annoyance, and if they really need a .Net lib then we'd be better served by just re-writing our API in C#.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
Generalizing from my prior experience with this sort of thing (different languages, but similar situation), it's going to be a lot easier in the long run if you go ahead and port to C# now. Between the hassle of the two forms of managed C++, all of the required conditional compilation between the two, and so on, it sounds like a 'pure' C# solution would be preferable.
Software Zen: delete this;
|
|
|
|
|
Hello
I am using MFC to create a program that reads a file from the floppy. That floppy uses linux file system ext2. Can anyone give some hint to do it. I have understood ext2 system architecture. Can i use CreateFile(...) to get an handle to that file.
Thanks
Waiting for your kind responce...
Aqueel A. Mirza
We Believe in Excellence
|
|
|
|
|
Hello.
You can use CreateFile to get a handle to the volume. Then you can read and write disk sectors directly.
And seek.
All in even multiples of the sector size, of course.
Open it this way (m_drive is 'A' for drive A :
<code>
sprintf(fromFilePathName,"\\\\.\\%c:", m_drive);
hDrive = CreateFile(fromFilePathName, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, NULL);
dwErr = GetLastError();
if(hDrive != INVALID_HANDLE_VALUE && dwErr == NO_ERROR) {
// OK, go!
</code>
|
|
|
|
|
Does VC6 support C99 standard? if so how to enable it?
|
|
|
|
|
C99 ? what is that ?
it looks like a visual C++ Compiler error
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
|
yeah, that was a joke, saying that C99 kools like a compiler error number...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
C99 is adopted by ANSI at 2000
VC6 is released at 1998
My blogs:
http://blog.joycode.com/jiangsheng
http://blog.csdn.net/jiangsheng
http://bloglines.com/public/jiangsheng
Command what is yours
Conquer what is not
---Kane
|
|
|
|
|
i know that
but i also see that you definitely have no humour...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
machnotrix wrote: Does VC6 support C99 standard?
No. The C99 standard was finalized after VC6's release.
There's a chat transcript[^] on MSDN that briefly discusses C99 support in Microsoft's products.
Software Zen: delete this;
|
|
|
|
|
Can anyone see a problem with this code? It keeps resetting the original string line so it jumps out of the loop after the first token. What it should do is parse the whole line...
For some reason it doesn't seem to like the "\\" delimiter, if I use " " is works fine - but " " is not the delimiter I need.
Thanks for any help in advance
<br />
char * token;<br />
char dir_name_out[256];<br />
<br />
char *delims = "\\";<br />
<br />
strcpy(dir_name_out, "");
<br />
token = strtok(dir_name_in, delims);<br />
<br />
while(token != NULL)<br />
{<br />
if(strlen(token) > 8)<br />
{<br />
token[6] = '~';<br />
token[7] = '1';<br />
token[8] = '\0';<br />
}<br />
<br />
strcat(token, "\\");<br />
<br />
strcat(dir_name_out, token);<br />
<br />
token = strtok(NULL, delims);<br />
}<br />
u6ik
|
|
|
|
|
If you are just searching a path for its components, why not use _splitpath() or one of the various Pathxxx() functions from the Shell API? Much better than trying to do it yourself. Also, to create a short filename from a long one, just use GetShortPathName() .
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
Cheers Dave. Problem solved.
Although.. the original problem is a poser. Still, no time to mess around when you're on a deadline
Thanks again.
u6ik
|
|
|
|
|
u6ik wrote: Although.. the original problem is a poser.
What is the initial value of dir_name_in ?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
First, here's your code with the indentation restored (note: use the <pre>...</pre> tag when posting more than one line of code):
char * token;
char dir_name_out[256];
char *delims = "\\";
strcpy(dir_name_out, "");
token = strtok(dir_name_in, delims);
while(token != NULL)
{
if(strlen(token) > 8)
{
token[6] = '~';
token[7] = '1';
token[8] = '\0';
}
strcat(token, "\\");
strcat(dir_name_out, token);
token = strtok(NULL, delims);
} A couple of things about strtok . One, it modifies the original string, but nothing in your logic has an issue with that. Two, it returns a pointer within the original string. For this reason, operating on the token value is A Bad Idea. The line strcat(token,"\\"); could overwrite the '\0' delimiter placed by the preceding call to strtok . You would be better off copying the token out to a separate local string, and operating on that.
Software Zen: delete this;
|
|
|
|