|
Yes, but why would you want to do this? Just send the control a EM_LIMITTEXT message and be done with it.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
That depends on what you mean by validate. I find the best approach to be disabling the OK button until all controls have valid data in them.
If your edit control is for a phone number, there are many ways for the user to input such a number, and you certainly do not want to start complaining to them until you know for sure they are through entering data and it is indeed incorrect.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thank you david for the suggestion. Yes its good idea to disable Ok button until valid data is entered. I will implement the same way in my project.
The requirement for me is like there are lot of dialogs which contains many edit controls, and i have stored all the minimum,maximum values for edit box in a file, so is it possible to write some generic version for validation check of edit controls, validation here is like if the input entered is greater or less than the maximum,minimum value it has to display a message.
|
|
|
|
|
Super Hornet wrote: ...is it possible to write some generic version for validation check of edit controls, validation here is like if the input entered is greater or less than the maximum,minimum value it has to display a message.
Are you using MFC?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Super Hornet wrote: The requirement for me is like there are lot of dialogs which contains many edit controls, and i have stored all the minimum,maximum values for edit box in a file, so is it possible to write some generic version for validation check of edit controls, validation here is like if the input entered is greater or less than the maximum,minimum value it has to display a message.
what abt subclassing the EditBox... read more here[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
Hi,
I have copied the winsocket program form the url::::http://www.codeproject.com/internet/winsockintro01.asp.
When I tried the build the copied code i am getting the following error
WinSock.cpp
D:\MAHA\DLG TEST\WinSock\WinSock.cpp(26) : error C2065: 'AfxBeginThread' : undeclared identifier
D:\MAHA\DLG TEST\WinSock\WinSock.cpp(108) : error C2065: 'sprintf' : undeclared identifier
Error executing cl.exe.
I have googled for this error, some one suggested to include the #include<afxwin.h> or #include<afx.h>..I tried for this and got the below error
D:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE\afxv_w32.h(14) : fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>
Error executing cl.exe.
Creating browse info file...
BSCMAKE: error BK1506 : cannot open file '.\Release\WinSock.sbr': No such file or directory
Can any one guide me how to aviod this error.
nandu
|
|
|
|
|
Including afxwin.h in your project's stdafx.h file should suffice.
Are you sure you really need to use sprintf() (with MFC)? There are (better) alternatives.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi DavidCrow,
Here the proble is "error C2065: 'AfxBeginThread'" and as of now i m not worried with sprint.f
As I said in the above mail theread, I took the code in the above specified url path. When i tried to comipl the code i got the error "error C2065: 'AfxBeginThread'".....and I dont know why i am getting this error.
Thanks
Nandu
|
|
|
|
|
Nandu_77b wrote: When i tried to comipl the code i got the error "error C2065: 'AfxBeginThread'".....and I dont know why i am getting this error.
Did you do the six bullet points near the top of the article?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
ya i ensured that i followed that six points..even then i am getting the same problem...have you tried copying the code to ur VC 6.0 and tried to complie?
I dont know where i m going wrong
-NA
|
|
|
|
|
Nandu_77b wrote: have you tried copying the code to ur VC 6.0 and tried to complie?
Yes, it works fine. The two files look like:
*** STDAFX.H ***
#include <afx.h>
#include <afxwin.h>
#include <afxext.h>
#include <afxdtctl.h>
#ifndef _AFX_NO_AFXCMN_SUPPORT
#include <afxcmn.h>
#endif // _AFX_NO_AFXCMN_SUPPORT
#include <winsock2.h>
#include <iostream>
#include <conio.h>
*** MAIN.CPP ***
#include "stdafx.h"
#include "main.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CWinApp theApp;
using namespace std;
UINT ServerThread(LPVOID pParam)
{
return 0;
}
void _tmain( void )
{
cout << "Press ESCAPE to terminate program\r\n";
AfxBeginThread(ServerThread, 0);
while (getch() != 27);
}
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi David,
Actualy what I did is I have included the afxwin.h in .cpp file rather than in stdafx.h. Now i included the afxwin.h in stdafx.h file it works fine.
But i dont know why it is throwing the error (fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h>) when i tried to INCLUDE THE afxwin.f in .cpp file.
Any how thanks for your support...have a nice day
|
|
|
|
|
use CreateThread instead of AfxBeginThread
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
are you sure that you working on MFC application!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
Hello,
I have a c++ application that I develop. I use Performance Counters in order to check its system usage. The HANDLES used are continuously increasing when I perform the following operations:
Open file – using fopen (I always close the files with fclose)
String operations – using standard c functions like strcmp, sprintf and so on
If anyone can point me a good article or solution (to check why the handles are increasing) I would highly appreciate it.
Thanks.
|
|
|
|
|
Hi all,
I want to create a bitmap by the function CreateDIBSection, and share the bitmap with other process.
HBITMAP CreateDIBSection(
HDC hdc, // handle to DC
CONST BITMAPINFO *pbmi, // bitmap data
UINT iUsage, // data type indicator
VOID **ppvBits, // bit values
HANDLE hSection, // handle to file mapping object
DWORD dwOffset // offset to bitmap bit values
);
Following MSDN, hSection is handle that created by CreateFileMapping.
Now I want ask that: in the shared-memory that hold by handle hSection: what is shared data? it is ppvBits?. If not, what is relating between ppvBits and data shared in the memory. I don't see any word in MSDN about this.
That is good if anyone give me a sample code.
Thank you.
The world is not enough!
|
|
|
|
|
|
phieu wrote: what is shared data? it is ppvBits?.
If you've provided a file mapping (hSection) then the data pointed to by ppvBits can be shared
through the file mapping. To do that, refer to the links suggested above
Mark
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
Thanks Mark.
OK, Now I see the data pointed to by ppvBits can be shared
through the file mapping.
But now I don’t know why: error code = 87 (ERROR_INVALID_PARAMETER) when
I call CreateDIBSection thought out but bitmap is valid.
Someone can tell me why?
Thank you.
Here is my code:
#define BITMAP_MMF_NAME "Global\\PRJ_IMS"
HANDLE m_hMMF;
HBITMAP m_hBitmap;
void CBitmapMMFDlg::OnButton3()
{
// TODO: この位置にコントロール通知ハンドラ用のコードを追加してください
int nWidth = 100, nHeight = 100;
long nSize = nWidth*nHeight*3;
// Create a file-mapping
m_hMMF = ::CreateFileMapping(
(HANDLE)0xFFFFFFFF,
NULL,
PAGE_READWRITE,
0,
nSize,
BITMAP_MMF_NAME);
DWORD dw = GetLastError();
if (m_hMMF)
{
// Create bitmap and map this bitmap to File-mapping
m_hBitmap = NULL;
HDC hdc = ::GetDC(NULL); // entire screen
//off-screen bitmap/image size - width must be DWORD aligned (multiples of 4)
LONG sizeImage = ((nWidth * 3 + 3) & 0xfffffffc) * nHeight;
BITMAPINFO bmpInfo;
memset(&bmpInfo,0,sizeof(bmpInfo));
bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmpInfo.bmiHeader.biWidth = nWidth;
bmpInfo.bmiHeader.biHeight = -nHeight;
bmpInfo.bmiHeader.biPlanes = 1;
bmpInfo.bmiHeader.biBitCount = 24;
bmpInfo.bmiHeader.biCompression = BI_RGB;
bmpInfo.bmiHeader.biSizeImage = sizeImage ;
bmpInfo.bmiHeader.biXPelsPerMeter = 0;
bmpInfo.bmiHeader.biYPelsPerMeter = 0;
bmpInfo.bmiHeader.biClrUsed = 0;
bmpInfo.bmiHeader.biClrImportant = 0;
//Create DIB Section - off screen bitmap
void* pBits = NULL;
DWORD dwOffset = 0;
m_hBitmap = CreateDIBSection(hdc, &bmpInfo, DIB_RGB_COLORS, &pBits, m_hMMF, dwOffset);
TRACE("Error code = %d \n", GetLastError());
// change bitmap bit data -> to test output
if(pBits != NULL)
{
for (int i = 0; i < 30000; i ++)
{
*((char*)(pBits) +i) = i%255;
}
}
/////////////////////////////////////////////////
// display bitmap
if (m_hBitmap != NULL)
{
CDC* pDC = GetDlgItem(IDC_STATIC)->GetDC();
if (pDC)
{
CDC dcMem;
dcMem.CreateCompatibleDC(pDC);
CBitmap* pBmp = CBitmap::FromHandle(m_hBitmap);
CBitmap* pOldBmp= dcMem.SelectObject(pBmp);
pDC->BitBlt(0,0, 100, 100, &dcMem, 0, 0, SRCCOPY);
}
}
}
}
|
|
|
|
|
I don't see anything right away...
Try changing to
bmpInfo.bmiHeader.biSizeImage = 0;
Also you calculate your file mapping size like this:
long nSize = nWidth*nHeight*3;
and your bmpInfo.bmiHeader.biSizeImage like this
LONG sizeImage = ((nWidth * 3 + 3) & 0xfffffffc) * nHeight;
Both should use the same calculation and the second method is better since DIB rows should be
aligned to a 4-byte boundary. In this case it's ok with a rowsize of 100
Mark
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
Is m_hBitmap NULL after the CreateDIBSection call?
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
m_hBitmap is not NULL, and I can display it ok, but GetLastError() = 87, INVALID_PARAMETER. I don't know why?
|
|
|
|
|
If it's not NULL then it was successful and calling GetLastError() isn't necessarily valid.
You only need to call that on failure.
From the docs:
"Most functions that set the thread's last-error code set it when they fail. However, some
functions also set the last-error code when they succeed. If the function is not documented to
set the last-error code, the value returned by this function is simply the most recent last-error
code to have been set; some functions set the last-error code to 0 on success and others do not."
Generally errors are checked for and handled something like:
m_hBitmap = CreateDIBSection(hdc, &bmpInfo, DIB_RGB_COLORS, &pBits, m_hMMF, dwOffset);
if (NULL == m_hBitmap)
{
TRACE("Error code = %d \n", GetLastError());
...do appropriate error handling/cleanup here
}
"If you can dodge a wrench, you can dodge a ball."
|
|
|
|
|
|
I am trying to write a GINA, but am faced with a problem... I need to retrieve some info over the internet/intranet. Does anyone know if this is possible, if so how would I go about it?
I have samples of writing a GINA, but all point to simply adding the password either from biometric readers or smartcards, I need to fetch a template over the net, scramble it and present it to the logon user (in a webpage).
Any ideas?
Thank you,
SeaSol
|
|
|
|