|
You are spot on. I relied on discarding ctrl+V keystrokes but if I right click on the edit box, I have the option to paste in it.
Well spotted!
Adam.
www.beachwizard.com/travelogue[^]
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|
|
You COULD handle WM_PASTE also, this is where all clipboard pastes end up.
Just GetWindowText() the content into a local variable, call Default() , and validate the pasted text. If you want to revert to the old text you had before the insert, you can SetWindowText() it back from your local variable.
But EN_UPDATE is probably better.
|
|
|
|
|
Have you considered CEdit::SetLimitText ?
Never mind. I didn't read your post carefully enough.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Just replace the constant '3000' with a name of variable containing the dynamic limit:
DDV_MinMaxInt(pDX, m_vediVelocitat, 0, m_maxVelocitat);
Of course, you should set m_maxVelocitat to appropriate value before DoDataExchange is called.
As a side note, you can check 'number' flag in the edit properties invoked in dialog editor. This will block non-digit characters being typed. AFAIR, however, you can still paste anything into numeric edit, so DDV_ call is essential.
Tomasz Sowinski -- http://www.shooltz.com
*** Purgamentum init, exit purgamentum ***
|
|
|
|
|
Tomasz Sowinski wrote:
As a side note, you can check 'number' flag in the edit properties
And it fails miserably with a negative number. I think it is next to useless, and I would say that MS did not make their homework with regards to Edit controls.
Mostly useless stuff like IP edit YES, but nothing working for integers and floating points - that would give bad ratings.
|
|
|
|
|
jhwurmbach wrote:
And it fails miserably with a negative number.
I've got the impression that Joan is working with some kind of velocity, which probably is non-negative. In this case, ES_NUMBER may be usable, but DDV_ is still required.
Tomasz Sowinski -- http://www.shooltz.com
*** Purgamentum init, exit purgamentum ***
|
|
|
|
|
Take a look at my article at http://www.codeproject.com/tools/Colour.asp[^]. I use an subclassed edit control that limits the input between 0 and 255 using the EN_UPDATE notification message (NumEdit.cpp and NumEdit.h). This should give you an idea on one method of limiting user input without using DDV_*.
HTH
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
#include "stdafx.h"
#include <iostream.h>
#include <windows.h>
#include <tchar.h>
#define ErrorHandler(s) _ErrorHandler(s, __FILE__, __LINE__)
void _ErrorHandler(LPCSTR lpszLocation, LPCTSTR lpszSrcFile, UINT nSrcLine)
{
LPVOID lpMsgBuf;
DWORD dwError = GetLastError();
FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dwError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPSTR) &lpMsgBuf,
0,
NULL );
// Process any inserts in lpMsgBuf.
cout<<"ERROR @ "<<lpszLocation<<" : "<<'('<<dwError<<')'<<(LPCSTR)lpMsgBuf;
cout<<"SOURCE @ Line = "<<nSrcLine<<", File = "<<lpszSrcFile<<'\n';
// Free the buffer.
LocalFree( lpMsgBuf );
}
BOOL SetFileOwner(LPCTSTR lpszFileName, LPCSTR lpszAccount, LPCSTR lpszGroup)
{
PSECURITY_DESCRIPTOR pSD;
PSID pSID, pSIDGroup;
DWORD cbSID = 1024;
LPSTR lpszDomain;
DWORD cchDomainName = 80;
PSID_NAME_USE psnuType;
// Initialize a security descriptor.
pSD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR,
SECURITY_DESCRIPTOR_MIN_LENGTH); // defined in WINNT.H
if (pSD == NULL) {
ErrorHandler("LocalAlloc");
goto Cleanup;
}
if (!InitializeSecurityDescriptor(pSD,
SECURITY_DESCRIPTOR_REVISION)) { // defined in WINNT.H
ErrorHandler("InitializeSecurityDescriptor");
goto Cleanup;
}
// Retrieve the SID for User.
pSID = (PSID) LocalAlloc(LPTR, cbSID);
psnuType = (PSID_NAME_USE) LocalAlloc(LPTR, 1024);
lpszDomain = (LPSTR) LocalAlloc(LPTR, cchDomainName);
if (pSID == NULL || psnuType == NULL ||
lpszDomain == NULL) {
ErrorHandler("LocalAlloc");
goto Cleanup;
}
if (!LookupAccountName((LPSTR) NULL, // local name
lpszAccount,
pSID,
&cbSID,
lpszDomain,
&cchDomainName,
psnuType)) {
ErrorHandler("LookupAccountName");
goto Cleanup;
}
if (!IsValidSid(pSID))
{
ErrorHandler("IsValidSid");
goto Cleanup;
}
// Sets the owner to the SD
if (!SetSecurityDescriptorOwner(pSD, pSID, FALSE)) { // not a default SID
ErrorHandler("SetSecurityDescriptorOwner");
goto Cleanup;
}
// Retrieve the SID for Group.
cbSID = 1024;
pSIDGroup = (PSID) LocalAlloc(LPTR, cbSID);
if (pSIDGroup == NULL) {
ErrorHandler("LocalAlloc");
goto Cleanup;
}
if (!LookupAccountName((LPSTR) NULL, // local name
lpszGroup,
pSIDGroup,
&cbSID,
lpszDomain,
&cchDomainName,
psnuType)) {
pSIDGroup = (PSID)LocalReAlloc((HLOCAL) pSIDGroup, cbSID, LPTR);
lpszDomain = (LPSTR) LocalReAlloc((HLOCAL) lpszDomain, cchDomainName, LPTR);
if (pSIDGroup == NULL || lpszDomain == NULL) {
ErrorHandler("LocalReAlloc");
goto Cleanup;
}
if (!LookupAccountName((LPSTR) NULL, // local name
lpszGroup,
pSIDGroup,
&cbSID,
lpszDomain,
&cchDomainName,
psnuType)) {
ErrorHandler("LookupAccountName");
goto Cleanup;
}
}
if (!IsValidSid(pSIDGroup))
{
ErrorHandler("IsValidSid");
goto Cleanup;
}
// Sets the group to the SD
if (!SetSecurityDescriptorGroup(pSD, pSIDGroup, FALSE)) { // not a default SID
ErrorHandler("SetSecurityDescriptorGroup");
goto Cleanup;
}
// Use the new SD as the file's security info.
if (!SetFileSecurity(lpszFileName, OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION, pSD)) {
ErrorHandler("SetFileSecurity");
goto Cleanup;
}
return TRUE;
Cleanup:
FreeSid(pSID);
FreeSid(pSIDGroup);
if(pSD != NULL)
LocalFree((HLOCAL) pSD);
if(psnuType != NULL)
LocalFree((HLOCAL) psnuType);
if(lpszDomain != NULL)
LocalFree((HLOCAL) lpszDomain);
return FALSE;
}
int _tmain(int argc, TCHAR *argv[], TCHAR *envp[])
{
if (argc < 4) {
cout<<"ERROR @ main : Not enough parameters\n";
return 0;
}
TCHAR tszFileName[MAX_PATH];
char szUserName[256];
char szGroupName[256];
_tcscpy(tszFileName, argv[1]);
#if defined(_UNICODE) || defined(UNICODE)
if (!WideCharToMultiByte(CP_ACP, 0, argv[2], -1, szUserName, 256, NULL, NULL)) {
ErrorHandler("WideCharToMultiByte");
return 0;
}
if (!WideCharToMultiByte(CP_ACP, 0, argv[3], -1, szGroupName, 256, NULL, NULL)) {
ErrorHandler("WideCharToMultiByte");
return 0;
}
#else
strcpy(szUserName, argv[2]);
strcpy(szGroupName, argv[3]);
#endif
if (!SetFileOwner(tszFileName, szUserName, szGroupName)) {
cout<<"Operation Failed!\n";
return 0;
}
cout<<"Operation Succeeded!\n";
return 0;
}
=======================================================================
This program can set file and dir owner for "administrator"
or "administrators", but can't set for other user, else return
the "ERROR_INVALID_OWNER(1703L)"...
Why??? Please help me ~!!!
=======================================================================
|
|
|
|
|
This[^] is just for you
...if you're under 8 or younger. Chris Maunder, the Lounge
|
|
|
|
|
Thank you very much!!!!!!!!!!!!!!!!!!!!!!!!
|
|
|
|
|
how to calculate a runing time of program in "TICKS", in which computer calculates time of every thing. i m using simple Turbo c++.
|
|
|
|
|
ummmm
dwStartTickCount = GetTickCount(); // at the start
dwEndTickCount = GetTickCount(); //at the end
dwTicksToRun = dwEndTickCount - dwStartTickCount;
???
"... and so i said to him ... if it don't dance (or code) and you can't eat it either f**k it or throw it away" biz stuff about me
|
|
|
|
|
How to make a license file which makes the application expire after a specific date, and also how to stop copying the .exe file.
|
|
|
|
|
I'm sorry, but you're basically asking for someone to write you an article. You should post such questions to the article suggestions forum.
Do you know how to open and close a text file ? Use the registry ? Find out the current date/time from the system ? How do YOU think such a system would work ?
There is no way to stop people from copying a file.
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Christian Graus wrote:
There is no way to stop people from copying a file
which is probably a good thing, else it'd be stuck in d:\projects\myapp\debug all the time. Hard to distribute.
Signature space for rent. Apply by email to....
|
|
|
|
|
Jon Hulatt wrote:
which is probably a good thing, else it'd be stuck in d:\projects\myapp\debug all the time. Hard to distribute.
Hmmm... maybe they'll add that to force us to distribute all our apps by ASP.NET......
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
|
Forget about 'expiring' if you're trying to protect your shareware app. Cracker d00dz will be able to break it very easily.
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
Hello all.
I'm now creating a ActiveX control using mfc ActiveX control wizard.This control draws lines and arcs defined. Can I export my classes in this project? how? Thank u for any suggestion!
Best Regards
Denkor
|
|
|
|
|
I know that it provides IHTMLEventObj for access event process.
But I don't know how it acknowledge me when event occured.
|
|
|
|
|
can a variable be inserted into a structure(declared in some header file and containing some variables) during run-time? If yes, how?
|
|
|
|
|
I doubt it. You're asking an application to change the size of a class within itself. That's a big change.
Why would you want to ?
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Do you mean a self-growing array like std::vector()?
You can't change the declaration you gave to your compiler, this is compile-time.
But you can declare 'here is a pointer to any amount of memory'.
Strings do this all the time.
Or you can declare 'here are any number of XY objects': this would be a std::vector.
I hope this helped
|
|
|
|
|
When IE connect to a website using SSL,IE will display a dialog to ask user to select a certificate of him(or her).
In fact,IE connect to the system's CSP and search user's certificate.
my question is:
if my certificate is stored in other place,but not in the system's CSP or a SmartCard,how can I have IE use my certificate when it connect to a SSL website?
For example,I store my certificate(and private key) in my own USB card,which is not compatible with the SmartCard.What can I do?
I think that if I can hold up the event which occur when IE connect to the system CSP for requiring a user certificate(and private key),it will be simple!
thanks advance!
|
|
|
|
|
Hi I had a structure which looks like this:
1.
struct CMyStruct
{
5-6 CString ...;
int ...;
long ...;
1 CStringArray ...;
};
2.
My application is going to generate a lot of instances of CMyStruct; I therefore thought it to be a good idea to use the CArray MFC template class to *manage* my structs. (Adding, deleting etc.)
3.
Accordingly, I put the following definition in my dialog header file.
#include <afxtempl.h>
#include <Mystruct header file>
CArray<CMyStruct,CMyStruct&>MyStructArray;
4. After this I began using it in the following manner:
CMyStruct myStruct;
PopulateMyStruct(&myStruct);//Structure populated
MyStructArray.Add(myStruct);//ERROR PRODUCING LINE
5. On compilation i receive the following error:
\INCLUDE\afxtempl.h(443) : error C2582: 'CMyStruct' : 'operator =' function is unavailable
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\xlocale(467) : while compiling class-template member function 'void __thiscall CArray<struct CMyStruct,struct CMyStruct &>::SetAtGrow(int,struct CMyStruct &)'
6. What could I be doing wrong??
Any help would be greatly appreciated.
|
|
|
|
|