Is there any code that i can call to refresh the image display(used paint) on the win32 but maintaining the messages?
I only wish to update only the fingerprint image and show the live image. The text windows + the other picture remains.
http://imgur.com/S6UcpAt
EDIT:
case WM_PAINT:
wmId = LOWORD(wParam);
hdc = BeginPaint(hWnd, &ps);
refresh=!refresh;
if((start==true)&&(refresh==true)&&(stop!=true))
{
if(cycle==0)
{
myKad(hWnd);
cycle=1;
}
windowName = MultiByteStringToWideString(name1, CP_ACP);
LoadAndBlitBitmap(windowName.c_str(), hdc,500,0);
fingerprint();
LoadAndBlitBitmap(TEXT("outresized.bmp"), hdc,500,300);
refresh=!refresh;
char buffer[100]; // Just to show the # of loops it is at
sprintf(buffer,"%d",round);
windowName = MultiByteStringToWideString(buffer, CP_ACP);
::MessageBox(NULL,windowName.c_str(), __T("Error"), MB_OK);//just to show #loop.
round++;
::MessageBox(NULL,__T("REFRESHED"), __T("Error"), MB_OK);
//RedrawWindow(hWnd,&fingerprintSection,NULL,RDW_INTERNALPAINT|RDW_VALIDATE|RDW_UPDATENOW|RDW_NOCHILDREN);
InvalidateRect( hWnd, &fingerprintSection, TRUE );
}
EndPaint(hWnd, &ps);
OLD
this is the what i tried but still unsuccessful
RECT fingerprintSection;//area that i want to refresh
fingerprintSection.left=500;
fingerprintSection.top=300;
fingerprintSection.bottom=540;
fingerprintSection.right=660;
if (wmId!=IDM_STOP)
{
fingerprint(); //this function will save the fingerprint to "outresized.bmp"
LoadAndBlitBitmap(TEXT("outresized.bmp"), hdc,500,300);
InvalidateRect( hWnd, &fingerprintSection, TRUE );
}
this is my bitmap code if u want to see
bool LoadAndBlitBitmap(LPCWSTR szFileName, HDC hWinDC,int x,int y)
{
// Load the bitmap image file
HBITMAP hBitmap;
hBitmap = (HBITMAP)::LoadImage(NULL, szFileName, IMAGE_BITMAP, 0, 0,
LR_LOADFROMFILE);
// Verify that the image was loaded
if (hBitmap == NULL) {
::MessageBox(NULL, __T("LoadImage Failed"), __T("Error"), MB_OK);
return false;
}
// Create a device context that is compatible with the window
HDC hLocalDC;
hLocalDC = ::CreateCompatibleDC(hWinDC);
// Verify that the device context was created
if (hLocalDC == NULL) {
::MessageBox(NULL, __T("CreateCompatibleDC Failed"), __T("Error"), MB_OK);
return false;
}
// Get the bitmap's parameters and verify the get
BITMAP qBitmap;
int iReturn = GetObject(reinterpret_cast<HGDIOBJ>(hBitmap), sizeof(BITMAP),
reinterpret_cast<LPVOID>(&qBitmap));
if (!iReturn) {
::MessageBox(NULL, __T("GetObject Failed"), __T("Error"), MB_OK);
return false;
}
// Select the loaded bitmap into the device context
HBITMAP hOldBmp = (HBITMAP)::SelectObject(hLocalDC, hBitmap);
if (hOldBmp == NULL) {
::MessageBox(NULL, __T("SelectObject Failed"), __T("Error"), MB_OK);
return false;
}
// Blit the dc which holds the bitmap onto the window's dc
BOOL qRetBlit = ::BitBlt(hWinDC, x, y, qBitmap.bmWidth, qBitmap.bmHeight,
hLocalDC, 0, 0, SRCCOPY);
if (!qRetBlit) {
::MessageBox(NULL, __T("Blit Failed"), __T("Error"), MB_OK);
return false;
}
// Unitialize and deallocate resources
::SelectObject(hLocalDC, hOldBmp);
::DeleteDC(hLocalDC);
::DeleteObject(hBitmap);
return true;
}