Author Topic: Sorry GDI HELP  (Read 947 times)

PushPop

  • Regular Member
  • *
  • Posts: 11
Sorry GDI HELP
« on: January 22, 2018, 08:32:26 AM »
Hi guys
I need help, I'm using gidiplus, everything works, but after a few minutes it does not refresh the display anymore.
I include the sources some one can help me.
Thank you and greetings
P.S. I have mistaken the file to send
I humbly apologize

PushPop

  • Regular Member
  • *
  • Posts: 11
Re: Sorry GDI HELP
« Reply #1 on: January 23, 2018, 01:32:48 AM »
Hi guys
After a few minutes I get the message:"Not enough storage is available to process this command." I can not understand why.
thank you
jj2007 / Mikl Datemi una dritta
Grazie

&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
_DrawString proc pWave:DWORD, Text_ :dword,X:dword,Y:dword
   local _UnicodeText[512]: byte
   LOCAL pRedAlfaBrush:dword,GdiPlusStringFormat:dword
   finit
   
   fild X
   fstp _layoutRect.x

   fild Y
   fstp _layoutRect.y
   mov esi,pWave
   invoke GdipCreateSolidFill,[esi].INFO.TextRGB,addr pRedAlfaBrush
   invoke GdipCreateStringFormat,0 , LANG_NEUTRAL, addr GdiPlusStringFormat
   invoke GdipSetStringFormatAlign,GdiPlusStringFormat,StringAlignmentNear
   invoke GdipSetStringFormatLineAlign,GdiPlusStringFormat,StringAlignmentNear

   invoke MultiByteToWideChar,0,0, Text_,0ffffffffh,addr _UnicodeText,512

   invoke GdipDrawString,[esi].INFO.Graphics, addr _UnicodeText, 0ffffffffh, [esi].INFO.pFont, addr _layoutRect ,GdiPlusStringFormat,pRedAlfaBrush
PrintError
   invoke GdipDeleteBrush,pRedAlfaBrush
   ret
_DrawString endp

mabdelouahab

  • Member
  • ***
  • Posts: 397
Re: Sorry GDI HELP
« Reply #2 on: January 23, 2018, 08:28:31 AM »
in _DrawString proc, Add:
   
Code: [Select]
invoke GdipDeleteStringFormat,GdiPlusStringFormat
And replace MainDraw proc with:

Code: [Select]
MainDraw proc hwnd:DWORD,hWParent:DWORD,pWave:DWORD
LOCAL hdc:HDC,memDC:HDC
LOCAL bitmap:PVOID
LOCAL hBmp0:HBITMAP
LOCAL hBmp:HBITMAP
LOCAL blend:BLENDFUNCTION
LOCAL rect:RECT,path:PVOID,brush:PVOID,color:DWORD,count:DWORD,pen:dword
LOCAL graphics:PVOID   
   
    mov hdc,rv(GetDC,hWParent)   
 
    invoke GetWindowRect,hwnd,ADDR rect
    mov edx,rect.right
    mov ecx,rect.bottom
    sub edx,rect.left
    sub ecx,rect.top
    mov rect.right,edx
    mov rect.bottom,ecx
    mov esi,pWave
    invoke GdipCreateBitmapFromScan0,rect.right,rect.bottom,0,PixelFormat32bppPARGB,0,addr [esi].INFO.BitMap
    invoke GdipGetImageGraphicsContext,[esi].INFO.BitMap,ADDR [esi].INFO.Graphics
   ;---------------------------------------------------------
    invoke DrawRoundRect,pWave,0,0,rect.right,rect.bottom,1,TRUE;
    invoke _TIMER
    invoke _DrawString,pWave,addr Time,100,100
   ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    mov blend.BlendOp,AC_SRC_OVER
    mov blend.BlendFlags , 0
    mov blend.AlphaFormat,AC_SRC_ALPHA
    mov blend.SourceConstantAlpha, 255
   
    mov memDC,rv(CreateCompatibleDC,hdc)
    invoke GdipCreateHBITMAPFromBitmap,[esi].INFO.BitMap,ADDR hBmp0,0
    mov hBmp,rv(SelectObject,memDC,hBmp0)

    invoke UpdateLayeredWindow,hwnd,0  ,ADDR rect,ADDR rect.right, memDC,addr ptZero, 0,addr blend , ULW_ALPHA

    invoke DeleteObject,rv(SelectObject,memDC,hBmp0)
    invoke DeleteObject,hBmp
    invoke DeleteDC,memDC
    invoke DeleteDC,hdc
    invoke GdipDisposeImage,[esi].INFO.BitMap
    invoke GdipDeleteGraphics,[esi].INFO.Graphics
    ret

MainDraw endp