If hgdiobj is a brush, UnrealizeObject does nothing, and the function returns TRUE
Announcement
Collapse
No announcement yet.
Need quick hand with C to PB convert
Collapse
X
-
Why Unrealizeobject hbrush? It's just been DeleteObject'd. The Win32API help says:
-
-
Kev,
thanks! I will make the changes and test it out.
Regards,
Jules
Leave a comment:
-
-
Jules,
This part is wrong (it needs <> otherwise you'll be trying to use a NULL handle!):
Code:IF ( hBrush [B]<>[/B] %NULL ) THEN lResult = UnrealizeObject(hBrush) END IF
Leave a comment:
-
-
Need quick hand with C to PB convert
I need help with this translation... Not sure what I missed. I'm hoping for a sharp C/C++ eye that can spot it.
Thanks, much appreciated in advance!
Regards,
Jules
C/C++ code...
Code:void CInPlaceEdit::PrepareBackground( CRect pos ) { CClientDC thisDC( this ); CClientDC parentDC( GetParent() ); CDC thisMem; INT OldParentMapMode = parentDC.SetMapMode( MM_LOENGLISH ); CBitmap* pOldThisBmp; thisMem.CreateCompatibleDC( &thisDC ); INT OldThisMapMode = thisMem.SetMapMode( MM_LOENGLISH ); CSize sz = pos.Size(); m_Background.DeleteObject(); m_Background.CreateCompatibleBitmap( &thisDC, sz.cx, -sz.cy ); pOldThisBmp = thisMem.SelectObject( &m_Background ); thisMem.BitBlt( 0, 0, sz.cx, sz.cy, &parentDC, pos.left, pos.top, SRCCOPY ); thisMem.SetMapMode( OldThisMapMode ); thisMem.SelectObject( pOldThisBmp ); parentDC.SetMapMode( OldParentMapMode ); m_Brush.DeleteObject(); m_Brush.CreatePatternBrush( &m_Background ); if ( m_Brush.m_hObject != NULL ) m_Brush.UnrealizeObject(); }
Code:'------------------------------------------------------------------------------ ' Get area of bitmap located under control and ' returns handle to a pattern brush ' don't forget to destroy brush when finished with it. ' ' %wm_ctlcoloredit ' hBrush = SelectObject(wParam,hObject) ' SetBrushOrg( wParam, 0, 0, BYVAL %NULL ) ' Call SetBkMode(wParam,%TRANSPARENT) ' FUNCTION = hBrush :EXIT FUNCTION '------------------------------------------------------------------------------ FUNCTION PrepareBackground( BYVAL hCtl AS DWORD,BYVAL rc AS RECT ) AS DWORD LOCAL ClientDC AS DWORD LOCAL parentDC AS DWORD LOCAL memDC AS DWORD LOCAL hBrush AS DWORD LOCAL lResult AS LONG LOCAL OldParentMapMode AS DWORD LOCAL OldThisMapMode AS DWORD LOCAL OldThisBmp AS DWORD LOCAL hBkgrndBitmap AS DWORD LOCAL pt AS POINTAPI clientDC = GetDC(hCtl) parentDC = GetDC(GetParent(hCtl)) OldParentMapMode = SetMapMode( parentDC,%MM_LOENGLISH ) memDC = CreateCompatibleDC( clientDC ) OldThisMapMode = SetMapMode( memDC, %MM_LOENGLISH ) pt.x = rc.nRight - rc.nLeft 'width pt.y = rc.nBottom - rc.nTop 'height Call DeleteObject(hBkgrndBitmap) hBkgrndBitmap = CreateCompatibleBitmap( memDC, pt.x, -pt.y ) OldThisBmp = SelectObject(memDC, hBkgrndBitmap ) lResult = BitBlt(memDC,0,0, pt.x, pt.y, parentDC, rc.nleft,rc.ntop, %SRCCOPY ) lResult = SetMapMode(memDC, OldThisMapMode ) lResult = SelectObject(memDC, OldThisBmp ) lResult = SetMapMode(parentDC, OldParentMapMode ) lResult = DeleteObject(hBrush) lResult = DeleteDC( memDC ) lResult = ReleaseDC( hCtl, clientDC) lResult = ReleaseDC( GetParent(hCtl), parentDC) hBrush = CreatePatternBrush( hBkgrndBitmap ) IF ( hBrush = %NULL ) THEN lResult = UnrealizeObject(hBrush) END IF Call DeleteObject(hBkgrndBitmap) FUNCTION = hBrush END FUNCTION 'call to function... 'GetWindowRect GetDlgItem(hWnd,%IDC_EDIT_1), rc 'hBrush = PrepareBackground(GetDlgItem(hWnd,%IDC_EDIT_1),rc)
Tags: None
-
Leave a comment: