EMF?

Vous débutez et vous avez besoin d'aide ? N'hésitez pas à poser vos questions
Ollivier
Messages : 4190
Inscription : ven. 29/juin/2007 17:50
Localisation : Encore ?
Contact :

EMF?

Message par Ollivier »

En fouinant sur le forum anglais, je suis tombé sur ce code.
Qu'est-ce que c'est l'EMF en fait?

Code : Tout sélectionner

Global hemf

Procedure WndProc(hWnd, uMsg, wParam, lParam)
  result = #PB_ProcessPureBasicEvents
  Select uMsg
    Case #WM_SIZE
      RedrawWindow_(hWnd, #NULL, #NULL, #RDW_ERASE|#RDW_INTERNALPAINT|#RDW_INVALIDATE)
    Case #WM_PAINT
      GetClientRect_(hWnd, @r.RECT)
      r\left = r\right/4
      r\right = 3*r\right/4
      r\top = r\bottom/4
      r\bottom = 3*r\bottom/4
      hdc = BeginPaint_(hWnd, @ps.PAINTSTRUCT)
      PlayEnhMetaFile_(hdc, hemf, @r)
      EndPaint_(hWnd, @ps)
  EndSelect
  ProcedureReturn result
EndProcedure

hwnd = OpenWindow(0, 0, 0, 640, 480, #PB_Window_ScreenCentered|#PB_Window_SizeGadget|#PB_Window_SystemMenu, "emf test")
If hwnd
  hdcEmf = CreateEnhMetaFile_(#NULL, #NULL, #NULL, #NULL)
  If hdcEmf
    Rectangle_(hdcEmf, 100, 100, 200, 200)
    MoveToEx_(hdcEmf, 100, 100, #NULL)
    LineTo_(hdcEmf, 200, 200)
    MoveToEx_(hdcEmf, 200, 100, #NULL)
    LineTo_(hdcEmf, 100, 200)
    hemf = CloseEnhMetaFile_(hdcEmf)
    SetWindowCallback(@WndProc())
    Repeat
      Event=WaitWindowEvent()
      If Event=#PB_Event_CloseWindow
        DeleteEnhMetaFile_(hemf)
        Quit=1
      EndIf
    Until Quit
  EndIf
EndIf
End