PA_GetUpdateHDC

4D - Documentation   Français   English   German   4D Plugin API, Command Theme List   4D Plugin API, Command Alphabetical List   Back   Previous   Next

version 2003


PA_GetUpdateHDC long

ParameterTypeDescription
This command does not require any parameters
Function resultlongHDC where the area can draw

Description

The routine PA_GetUpdateHDC works only under Windows. It returns the current Device Context that the plug-in can use to draw whatever it wants.

This routine must be called when PA_GetAreaEvent returns eAE_Update. Otherwise, it does nothing and PA_GetLastError returns eER_BadEventCall.

Example

Sample Drawing in the Design environment. Assuming the usual dispatch in PluginMain has been done. PluginMain calls the area main routine.

   void DoArea (PA_PluginParameters params)
   {
      PA_AreaEvent   event = PA_GetAreaEvent(params);
      switch(event)
      {
         /* . . . */
         case eAE_DesignUpdate :
         {
            HDC      hdc;
            PA_Rect   rect;
      // tell 4D we will draw ourselves
            PA_CustomizeDesignMode( params );
      // get the HDC and the area rect
            hdc = (HDC) PA_GetUpdateHDC();
            rect = PA_GetAreaRect( params );
      // Paint something
            AreaPaint( hdc, rect );
         }
            break;
   }

   void AreaPaint( HDC hdc, PA_Rect parect )
   {
      HBRUSH   hbrush;
      RECT      rect;
      HGDIOBJ   old;
   // We need to use a Windows RECT
      rect.left   = parect.fLeft;
      rect.top    = parect.fTop;
      rect.right  = parect.fRight;
      rect.bottom = parect.fBottom;

      hbrush = CreateSolidBrush( 0 );
   
      old = SelectObject( hdc, hbrush );
      FrameRect( hdc, &rect, hbrush ); // Sample Drawing
      SelectObject( hdc, old );
   }

See Also

Create and use an external area.

Error Handling

Use PA_GetLastError to see if an error occurred (eER_BadEventCall)


4D - Documentation   Français   English   German   4D Plugin API, Command Theme List   4D Plugin API, Command Alphabetical List   Back   Previous   Next