|
I use ATL Com AppWizard(in embedded Visual C++) to create a signature capturing DLL, i successfully let user to sign on a given rectangle square box.
However,
i have a big problem when coming to capture the signature inside the rectangle and save it to bmp (or jpg) file. i get the following attached code and trying to compile it inside embedded Visual C++ 4.0, and it comes out this error:
"GetDIBits: undeclared identifier" ...
it seems like eVC++(or Pocket PC 2003 SDK) doesn't have this library or doesn't support this function...
is there anyway i can do it ? this problem has been struggling me for few days ...
thanks
int WindowToBmpFile(LPCTSTR szFName, HWND hWnd)
{
HDC hDC, hMemDC;
HANDLE hBits, hFile;
HBITMAP hBitmap, hTmpBmp;
RGBQUAD RGBQuad;
DWORD ImgSize, plSize, dwWritten;
int i, CRes, Height, Width;
BITMAPFILEHEADER bmFH = {0x4d42, 0, 0,0};
LPBITMAPINFO pBmInfo, pBmInfoMem;
if((hFile = CreateFile(szFName, GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL)) == NULL) return 1;
SetCursor(LoadCursor(NULL, IDC_WAIT));
if(hWnd==HWND_DESKTOP)
{
Width = GetSystemMetrics(SM_CXSCREEN);
Height = GetSystemMetrics(SM_CYSCREEN);
}
else
{
RECT rc;
::GetClientRect(hWnd,&rc);
Width = rc.right-rc.left;
Height = rc.bottom-rc.top;
}
hDC = ::GetDC(hWnd);
hMemDC = CreateCompatibleDC(hDC);
hBitmap= CreateCompatibleBitmap(hDC, Width, Height);
pBmInfoMem = (LPBITMAPINFO)GlobalAlloc(GHND, sizeof(BITMAPINFO)+256*sizeof(RGBQUAD));
pBmInfo = (LPBITMAPINFO)GlobalLock(pBmInfoMem);
ZeroMemory(pBmInfo, sizeof(BITMAPINFO)+256*sizeof(RGBQUAD));
SelectObject(hMemDC, hBitmap);
BitBlt(hMemDC,0,0,Width,Height,hDC,0,0,SRCCOPY);
pBmInfo->bmiHeader.biSize = (DWORD)sizeof(BITMAPINFOHEADER);
pBmInfo->bmiHeader.biWidth = Width;
pBmInfo->bmiHeader.biHeight = Height;
pBmInfo->bmiHeader.biPlanes = 1;
pBmInfo->bmiHeader.biBitCount = (WORD)GetDeviceCaps(hDC, BITSPIXEL);
pBmInfo->bmiHeader.biCompression = BI_RGB;
pBmInfo->bmiHeader.biClrUsed = 256;
GetDIBits(hDC, hBitmap, 0,Height, NULL, pBmInfo, DIB_RGB_COLORS);
if(!pBmInfo->bmiHeader.biSizeImage)
pBmInfo->bmiHeader.biSizeImage = ((((pBmInfo->bmiHeader.biWidth * pBmInfo->bmiHeader.biBitCount) + 31) & ~31) /
* pBmInfo->bmiHeader.biHeight;
CRes = GetDeviceCaps(hDC, SIZEPALETTE);
plSize = CRes*sizeof(RGBQUAD);
ImgSize= pBmInfo->bmiHeader.biSizeImage;
bmFH.bfOffBits = plSize + sizeof(BITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER);
bmFH.bfSize = ImgSize + bmFH.bfOffBits;
WriteFile(hFile, &bmFH, sizeof(BITMAPFILEHEADER), &dwWritten, NULL);
WriteFile(hFile, &(pBmInfo->bmiHeader), sizeof(BITMAPINFOHEADER), &dwWritten, NULL);
hBits = GlobalAlloc(GHND, pBmInfo->bmiHeader.biSizeImage);
LPVOID lpBits = (LPVOID)GlobalLock(hBits);
ZeroMemory(lpBits, pBmInfo->bmiHeader.biSizeImage);
GetDIBits(hDC, hBitmap, 0,Height, lpBits, pBmInfo, DIB_RGB_COLORS);
WriteFile(hFile,lpBits,ImgSize,&dwWritten,NULL);
GlobalUnlock(lpBits);
GlobalUnlock(hBits);
GlobalFree(hBits);
GlobalUnlock(pBmInfo);
GlobalFree(pBmInfoMem);
DeleteObject(hBitmap);
DeleteDC(hMemDC);
::ReleaseDC(hWnd,hDC);
CloseHandle(hFile);
SetCursor(LoadCursor(NULL,IDC_ARROW));
return 0;
}
|
|
|
|
|
About your problem, I don`t know if this is the best solution, but it might help you to think of another way to get where you want:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcesdkr/html/_wcesdk_Win32_GetObject.asp[^]
In the remarks you see:
"In addition, the bmBits member of the BITMAP structure contained within the DIBSECTION will contain a pointer to the bitmap's bit values.
"
So you might try to create your file by writing these bits to the file.. It is possible you^ll need to write the file-header though...
Greetings,
Davy
|
|
|
|
|
Do you have any example or source code for DIBSection? especially in saving bitmap ? sorry to say that i am still a beginner to eVC++ ..
thanks a lot
|
|
|
|
|
Hi,
I am trying to develop a mpeg Video Player for Windows CE. I tried it with the Windows Media Player SDK, but I read, mpeg videos aren't supported. Is this right? Is there any other SDK to develope a video player that supports mpeg files?
Or is there a way to extend the SDK with this function?
Thanks for your tips and ideas.
Michael
|
|
|
|
|
Does anyone know how to send an object using NetworkStream or other classes
in .NET Compact Framework?
It is because I want to send an object from a pocket pc to another pocket pc
but I don't know how to do so. Could anyone help me? Thanks a lot!!!!
|
|
|
|
|
I am developing an eVC 4.0 dialog based application on Win CE.Net platform.
When I run application it shows application name on taskbar but without icon.
As SetIcon() is not supported by WinCE i used DrawIcon(), but still it does not show icon on Taskbar,it shows Icon only on dialog
Any Hint...
Thanks in Advance.
Ajay
|
|
|
|
|
Help me!!!
Active sync stopped working. So instead of downloading to device option, I chose 'emulator'.
But now even the emulator is not running. When I execute the program, a window pops up saying "connecting". It says connecting for a couple of seconds and then says timed out?
How do I get it right.
Help me soon, I have a demo on monday.
-hithesh
|
|
|
|
|
Did you changed the active platform configuration to the "Win32 (WCE emulator) Debug/Release" option?
|
|
|
|
|
No I didnt change it. But I did get this working. I just reinstalled the windows pocket pc 2003 sdk.
Thanks.
-hithesh
|
|
|
|
|
How do I download my application on to the win CE device (HP RX3115) and make it stay there?
I am using evc++
-hithesh
|
|
|
|
|
Hi !!!!
I run the server application (smart device application written in C# , VS Studio .NET 2003) in Pocket PC 2002 emulator , where server socket is listening on some port for incomming connections. When I run client application on my desktop pc , it tries to establish connection with my server which runs in Pocket PC 2002 emulator , the client cannot establish connection with my server ,and exception of type 'System.Net.Sockets.SocketException' occurs in system.dll . But when server with same code runs on desktop pc , client establishes connection with server succesfully.Is the problem from pocket pc 2002 emulator ?
Thanks.
|
|
|
|
|
Hello,
Can we use isolated storage in compact framework applications?
|
|
|
|
|
No this is missing in the compact framework version.
|
|
|
|
|
Hi, guys.
Need some help here.
I've been struggling against what I believe is a bug for a week now.
I have a C# compact framework application that displays a Login form. something like :
<br />
Login frmlogin = new Login();<br />
frmLogin.ShowDialog();<br />
if (frmLogin.DialogResult != DialogResult.OK)<br />
{<br />
Application.Exit();<br />
}<br />
frmLogin.Dispose();<br />
And the Login form has a "OK" button, with the following event handler :
<br />
private void btnOK_Click(object sender, System.EventArgs e)<br />
{<br />
try <br />
{ <br />
loginObj.DoLogin();<br />
this.DialogResult = DialogResult.OK;<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show(ex.Message,"Login Failed");<br />
}<br />
}<br />
The loginObj object is my business object that handles login data validation, and other operations. The DoLogin() method validates the login data, and it throws an exception if there's any required data missing.
When the exception is thrown, the message box is displayed, and when the user closes the message box, the contents of the Login form disappears! The contents of the main form is displayed instead. But the title of the form still shows "Login". The form hasn't been closed, because I can't click on the main form's buttons.
When I check at the running programs, the login window is still there. If I choose "Stop" on the Running Programs tab of the Memory Settings, the Login form is closed in a way like the DialogResult was set to DialogResult.OK and the program works normally.
I believe this behavior has nothing to do with the loginObj object or with the exception it throws, since when I displayed another message box on the same form to test it, the same thing happened.
Another interesting thing is that it only happens on the login form. I made tests to show message boxes on other forms displayed with ShowDialog(), but there were no problems.
Anyone has seen something like that? Any ideas?
Any help will be greatly appreciated!
|
|
|
|
|
I just found what was wrong!
I was setting the form's mainMenu outside InitializeComponent() method.
I was doing :
<br />
private void MainForm_OnLoad(object sender, System.EventArgs e)<br />
{<br />
loginObj.Load();<br />
this.mainForm = this.myMainForm;<br />
}<br />
and somehow this was causing the strange behavior. Go figure!
So, be aware that setting the form's mainMenu outside InitializeComponent() method will make the contents of your form disappear after showing any form with ShowDialog() or showing a MessageBox from that form.
|
|
|
|
|
i want to call a printer thats connected to a terminal that my PDA is connected to, so that i can print stuff on my PDA. how do i do that in coding? and is there any support for printer stuff in vb.net? i'm using it to develop a smart device application for my pda. thanks!
|
|
|
|
|
Hi,
I need to draw a dynamically generated 256x256 grayscale bitmap on screen.
Drawing it "pixel by pixel" is extremely slow. (several seconds)
Drawing it on an ofscreen bitmap and then blitting it on screen is slightly faster, but still unaceptable.
On the full framework I got around to accessing the bitmap data, and accessing the pixels directly, giving instant results.
Is there any way to achive this on the Compact Framework?
(or any other method that works...)
If the "AddressOf" worked for the bitmap, so I could get a IntPtr to it, I think I could then go in there and set the pixel data myself... But I was unable to find a way to do that.
(will C# do the trick?)
The current code:
Dim ImgRAW(256, 256) As Byte
' GetImage(Imgraw) '... Fill up dynamic image
Dim offbmp As New Bitmap(256, 256)
For scan = 1 To 255
For x = 1 To 255
t = ImgRAW(scan, x)
offbmp.SetPixel(x, scan, Color.FromArgb(t, t, t))
Next
Next
oG.DrawImage(offbmp, 400, 100)
Hope someone can help,
Thanks.
|
|
|
|
|
Hi...I'm working on the windows mobile 2003 platform (e200 spv) and would like to get the phones' location info and write it to a txt file.
Any suggestions?
dboy.spv
|
|
|
|
|
I thought I would post this here because I can't spot the error. This is my first attempt to code for a Pocket PC. The following code works fine on the desktop:
TCHAR szFilePath[MAX_PATH];
wsprintf(szFilePath, TEXT("%sTest.txt"), this->szAppRootDirectory);
HANDLE hFile = CreateFile(szFilePath, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if ( hFile == INVALID_HANDLE_VALUE )
{
MessageBox(hwnd, TEXT("Fatal error: Unable to open file."), NULL, MB_OK);
return R_ERROR;
}
DWORD dwBytesRead;
DWORD dwFileSize = SetFilePointer(hFile, 0, NULL, FILE_END);
TCHAR *szBuffer = new TCHAR[dwFileSize + 1];
SetFilePointer(hFile, 0, NULL, FILE_BEGIN);
ReadFile(hFile, szBuffer, dwFileSize, &dwBytesRead, NULL);
CloseHandle(hFile);
szBuffer[dwFileSize] = '\0';
Unfortunatelly, szBuffer fills w/ garbage (boxes) on the Pocket PC. Can anyone spot the error here? Thanks in advance.
|
|
|
|
|
Wouldn`t GetFileSize be an easier way to get the size of the file then moving the filepointer around?
The fact that boxes are displayed could be that the characters in the file are ANSI characters(1byte) and you compiled your application for Unicode (TCHAR is then a wide char (2byte) ), or the other way around...
Or the file contains unicode characters that are not supported by the font on your device...
Hope this can help you further...
Greetings,
Davy
|
|
|
|
|
That was the problem. Thanks.
|
|
|
|
|
Hello,
I wrote a software for WM2003 with eVC4 in C++. I post it in PocketPCFreeware here http://www.pocketpcfreewares.com/fr/index.php?soft=1299. Sorry it's in french but I plan to translate it in english.
Some users ask me the compatibility of the software with PPC2002: it doesn't work. I forgot something ? Have I to compile the soft with eVC3 ? Is there a problem with the compack framework (it doesn't work with it) ? Have I to add some DLL's ?
Please help me ...
Best regards
PS: sorry about my bad english
|
|
|
|
|
|
hi all,
i am trying to display a bmp image on xda o2.i have used bitblt function to display the source on the screen.....
but when i port it to the xda....it doesnot show up....
can u help with that.....
sasi
|
|
|
|
|
Hello,
Try following:
m_ctlTxtPicture.SetBitmap( ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_BMP_SUCCESS)) );
Here,
--> m_ctlTxtPicture is a control variable of Picture Control (Container for
the bitmap)
--> IDI_BMP_SUCCESS is resource ID for the bitmap.
Thank you
Mahesh J. Chavda
|
|
|
|
|