Rectangle as bitmap

Re: Rectangle as bitmap

Postby nageswaragunupudi » Thu Oct 07, 2021 10:58 am

Natter wrote:Hi.

There is a dialog box with brush. I need to select a certain rectangle on this window and save it to a file as a bitmap. How to do it ?

If it is a large dialog with a brush I can provide solution.
But I doubt if it is an Activex control
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10465
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Rectangle as bitmap

Postby Natter » Thu Oct 07, 2021 11:05 am

Sorry, I didn't understand :(
Natter
 
Posts: 1182
Joined: Mon May 14, 2007 9:49 am

Re: Rectangle as bitmap

Postby Antonio Linares » Thu Oct 07, 2021 11:08 am

Is the activex showing the same image all the time or does it change like a map ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41855
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Rectangle as bitmap

Postby Natter » Thu Oct 07, 2021 11:15 am

This is a map. I want to print large formats A1, A0
Natter
 
Posts: 1182
Joined: Mon May 14, 2007 9:49 am

Re: Rectangle as bitmap

Postby Antonio Linares » Thu Oct 07, 2021 11:23 am

I think that you can only get an image of what it is shown on the screen, unless the activex provides a method to do it.

What activex is it ?

Please build and run c:\FWH\samples\olebrow.prg and look for the activex and inspect the methods that it provides or
check the documentation about it
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41855
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Rectangle as bitmap

Postby Natter » Thu Oct 07, 2021 11:28 am

This is IE. I work through it with the Maps API. There is no means for printing or output to a file in this API
Natter
 
Posts: 1182
Joined: Mon May 14, 2007 9:49 am

Re: Rectangle as bitmap

Postby Antonio Linares » Thu Oct 07, 2021 12:27 pm

Could you provide us a small and self contained Prg to test here ?

Enviado desde mi SM-M325FV mediante Tapatalk
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41855
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Rectangle as bitmap

Postby Natter » Thu Oct 07, 2021 12:48 pm

I'll try to make an example, but it's difficult. Can use IE features ? This browser has both Print and Save As, however, I do not know how to address them
Natter
 
Posts: 1182
Joined: Mon May 14, 2007 9:49 am

Re: Rectangle as bitmap

Postby nageswaragunupudi » Thu Oct 07, 2021 5:07 pm

I tried using "Shell.Explorer.2" Activex.

For me oActivex:Print() is working. I do not have large printer, but it printed the google map on my A4 size paper.
You may try with Large paper printer and with a few trials and errors you may be able to print.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10465
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Rectangle as bitmap

Postby Natter » Fri Oct 08, 2021 6:40 am

I checked o Activex:Print(). Anyway, only the screen is printed.
Please give your example with oActivex:Print() and google map. Based on it, I will make a small example showing my problem
Natter
 
Posts: 1182
Joined: Mon May 14, 2007 9:49 am

Re: Rectangle as bitmap

Postby Natter » Sun Oct 10, 2021 12:32 pm

Could you provide us a small and self contained Prg to test here ?


In this example, I increase the size of the ActiveX according to the selected print format.
1. Download the Google Map
2. Select the format (size)
3. Print (to file)

Code: Select all  Expand view

#include "FiveWin.ch"

#DEFINE SM_CYBORDER 6
#DEFINE SM_CYMENU 15
#DEFINE SM_CYCAPTION 4

function Main()
private a_win:=ScrResolution()
private oWnd, oDk, oMen

  SET _3DLOOK ON

  set path to pth

  DEFINE DIALOG oWnd FROM 0,0 TO 0,0  COLOR CLR_BLACK, CLR_HGRAY ;
                 TITLE "AactiveX larger then the screen"  PIXEL  ;
                               STYLE nOR(WS_CAPTION, WS_SYSMENU )

  ACTIVATE DIALOG oWnd  ON INIT Win_Ini()
return nil

procedure Win_Ini()

  MENU oMen OF oWnd
    MENUITEM "Google map" ACTION Map_Viw()
    MENUITEM "Formats"
    MENU
       MENUITEM "A2" ACTION Big_Fmt(1)
       SEPARATOR
       MENUITEM "A1" ACTION Big_Fmt(2)
       SEPARATOR
       MENUITEM "A0" ACTION Big_Fmt(3)
    ENDMENU
    MENUITEM "Print Map" ACTION Prt_Map()
  ENDMENU

  oWnd:Move(0,0, a_win[1], GetSysMetrics(17)+ ;
         GetSysMetrics(SM_CYCAPTION)+GetSysMetrics(SM_CYBORDER)*2)

  oCl:=TActiveX():New(oWnd, "Shell.Explorer", ;
      2, 2, oWnd:nWidth-4, GetSysMetrics(17)-4)
  oCl:Silent:=.T.
return

procedure Map_Viw
local oObj:="oWnd:aControls[1]"

  &oObj:Do("Navigate2", "https://www.google.com/maps/@42.8674796,74.5708881,16z?hl=ru-KG")

  do while .T.
    oDk:=&oObj:GetProp("Document")

    if valtype(oDk)="U".or.oDk:ReadyState!="complete"
      WaitMessage()
      SysRefresh()
    else
      exit
    endif
  enddo
return

procedure Big_Fmt(fmt) && print to bitmap-file
local fl
local oObj:="oWnd:aControls[1]"
local dim:={}
local mas:={{594,420}, {841,594}, {1189,841}}
local siz:={}
** fmt - format 1-A2, 2-A1, 3-A0

    siz:={getdevicecaps(getDC(&oObj), 4), ; && horzsize
          getdevicecaps(getDC(&oObj), 6)}   && vertsize
    fl:=a_win[1]/siz[1] && number pix in 1 mm

    mas[fmt,1]*=fl && width ActiveX in pix
    mas[fmt,2]*=fl && height Activex in pix

    siz:={mas[fmt,1]-&oObj:nWidth, ; && the % of increase in width
          mas[fmt,2]-&oObj:nHeight}  && the % of increase in height

    ***********  new size ActiveX ***********
    dim:={&oObj:nTop-(siz[2]/2), &oObj:nLeft-(siz[1]/2), ;
                  &oObj:nWidth+siz[1], &oObj:nHeight+siz[2]}

    ***** change size ActiveX *****
    &oObj:Move(dim[1], dim[2], dim[3], dim[4])
return

procedure Prt_Map
local oObj:="oWnd:aControls[1]"
? oWnd:nWidth, oWnd:nHeight, &oObj:nWidth, &oObj:nHeight
  &oObj:Do( "ExecWB", 6, 1) &&OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER )
*  &oObj:Print()
return
Natter
 
Posts: 1182
Joined: Mon May 14, 2007 9:49 am

Re: Rectangle as bitmap

Postby nageswaragunupudi » Sun Oct 10, 2021 3:15 pm

Good. Is it working for you now?
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10465
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Rectangle as bitmap

Postby karinha » Sun Oct 10, 2021 4:03 pm

Great! Thank you very much.

Code: Select all  Expand view

#include "FiveWin.ch"

#define SM_CYBORDER 6
#define SM_CYMENU 15
#define SM_CYCAPTION 4

MEMVAR oDlg, a_win, oClActive, oDk, oMen, lImpMap

FUNCTION Main()

   LOCAL Path, aGrad, cTitle, oSkinB

   SET PATH TO Path := StrCapFirst( cFilePath( GetModuleFileName( GetInstance() ) ) + "C:\COPIA" )

   SET _3DLOOK ON

   oSkinB = TSkinButton():New()

   oSkinB:nClrBorder0_N := RGB( 249, 194, 179 )
   oSkinB:nClrBorder1_N := RGB( 181, 61, 29 )

   oSkinB:aClrNormal    := { { 0.2, RGB( 000, 128, 000 ), RGB( 000, 128, 000 ) }, ;
                             { 0.8, RGB( 109, 135, 100 ), RGB( 109, 135, 100 ) } }

   SkinButtons( oSkinB )

   IF .NOT. lIsDir( "C:\COPIA" )

      lMkDir( "C:\COPIA" )

   ENDIF

   a_win   := ScrResolution()
   lImpMap := .F.
   cTitle  := "ActiveX larger then the screen"
   aGrad   := { { 0.30, CLR_WHITE, CLR_WHITE },{ 0.50, CLR_WHITE, CLR_WHITE } }

   DEFINE DIALOG oDlg FROM 0, 0 TO 0, 0 GRADIENT aGrad TITLE cTitle PIXEL    ;
      STYLE nOR( WS_CAPTION, WS_SYSMENU )

   oDlg:lHelpIcon := .F.

   ACTIVATE DIALOG oDlg ON INIT( Win_Ini() )

RETURN NIL

FUNCTION Win_Ini()

   LOCAL oMenu

   MENU oMenu 2007 OF oDlg

      MENUITEM "Google map" ACTION( Map_View() )

      MENUITEM "Formats"

      MENU
         MENUITEM "A2" ACTION( Big_Fmt( 1 ) )

         SEPARATOR
         MENUITEM "A1" ACTION( Big_Fmt( 2 ) )

         SEPARATOR
         MENUITEM "A0" ACTION( Big_Fmt( 3 ) )

      ENDMENU

      MENUITEM "Print Map" ACTION( Prt_Map() ) WHEN( lImpMap ) // New

      MENUITEM "Exit" ACTION( oDlg:End(), CLOSE_PROGRAM() )

   ENDMENU

   oDlg:Move( 0, 0, a_win[ 1 ], GetSysMetrics( 17 ) + ;
      GetSysMetrics( SM_CYCAPTION ) + GetSysMetrics( SM_CYBORDER ) * 2 )

   oClActive := TActiveX():New( oDlg, "Shell.Explorer", ;
      2, 2, oDlg:nWidth - 4, GetSysMetrics( 17 ) - 4 )

   oClActive:Silent := .T.

RETURN( oMenu )

FUNCTION Map_View()

   LOCAL oObj := "oDlg:aControls[1]"

   &oObj:Do( "Navigate2", "https://www.google.com/maps/@42.8674796,74.5708881,16z?hl=ru-KG" )

   WHILE( .T. )

      SYSREFRESH() ; CURSORWAIT()

      oDk := &oObj:GetProp( "Document" )

      IF ValType( oDk ) = "U" .OR. oDk:ReadyState != "complete"

         // WaitMessage()
         SysWait( 1 )

      ELSE

         IF ValType( oDk ) != "U"

            lImpMap := .T.

         ELSE // no errors.

            lImpMap := .F.

         ENDIF

         EXIT

      ENDIF

   ENDDO

   CURSORARROW()

RETURN NIL

FUNCTION Big_Fmt( fmt ) // print to bitmap-file

   LOCAL fl
   LOCAL oObj := "oDlg:aControls[1]"
   LOCAL dim := {}
   LOCAL mas := { { 594, 420 }, { 841, 594 }, { 1189, 841 } }
   LOCAL siz := {}

   // * fmt - format 1-A2, 2-A1, 3-A0

   siz := { getdevicecaps( getDC( &oObj ), 4 ), ; // horzsize
      getdevicecaps( getDC( &oObj ), 6 ) }   // vertsize

   fl := a_win[ 1 ] / siz[ 1 ] // number pix in 1 mm

   mas[ fmt, 1 ] *= fl // width ActiveX in pix
   mas[ fmt, 2 ] *= fl // height Activex in pix

   siz := { mas[ fmt, 1 ] - &oObj:nWidth, ; // the % of increase in width
            mas[ fmt, 2 ] - &oObj:nHeight } // the % of increase in height

   // **********  new size ActiveX ***********
   dim := { &oObj:nTop - ( siz[ 2 ] / 2 ), &oObj:nLeft - ( siz[ 1 ] / 2 ), ;
            &oObj:nWidth + siz[ 1 ], &oObj:nHeight + siz[ 2 ] }

   // **** change size ActiveX *****
   &oObj:Move( dim[ 1 ], dim[ 2 ], dim[ 3 ], dim[ 4 ] )

RETURN NIL

FUNCTION Prt_Map()

   LOCAL oObj := "oDlg:aControls[1]"

   ? oDlg:nWidth, oDlg:nHeight, &oObj:nWidth, &oObj:nHeight

   &oObj:Do( "ExecWB", 6, 1 ) // OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER )

   // &oObj:Print()

RETURN NIL
// CLOSE ALL
FUNCTION CLOSE_PROGRAM()

   lImpMap := .F.

   HB_GCALL( .T. )

   CLEAR MEMORY

   PostQuitMessage( 0 )

RETURN NIL

// END / FIN
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7603
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: Rectangle as bitmap

Postby Natter » Mon Oct 11, 2021 6:08 am

In this version, we can print the map or save it as a pdf file. Is it possible to save the map as a bitmap file ?
Natter
 
Posts: 1182
Joined: Mon May 14, 2007 9:49 am

Re: Rectangle as bitmap

Postby Antonio Linares » Mon Oct 11, 2021 10:57 am

oDlg:aControls[ 1 ]:SaveToBmp( "test.bmp" )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41855
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 83 guests