Page 2 of 3

Re: Object on Form can be move by user

Posted: Wed Apr 16, 2014 11:38 am
by mol
you've missed IDE.PRG in attached sample

Re: Object on Form can be move by user

Posted: Wed Apr 16, 2014 11:45 am
by bpd2000
mol wrote:you've missed IDE.PRG in attached sample
Included

Re: Object on Form can be move by user

Posted: Wed Apr 16, 2014 6:04 pm
by Javier Tovar
Hola bpd2000,

Pues si esta excelente la aplicación :D , pero no creo poder ayudar, :( , todavia mis conocimientos son escasos!

Pero seria buena aplicación.

Saludos

Re: Object on Form can be move by user

Posted: Thu Apr 17, 2014 6:31 am
by mol
bpd2000 wrote:Dear Javier Tovar,
Thank you for code
I have created attached sample code that can be compile in minigui
I want same code to compile in HMG
Any help
Some years ago Roberto decided to not publish IDE code... :(

Re: Object on Form can be move by user

Posted: Thu Apr 17, 2014 7:04 am
by mol
Try this sample, you can remove msgdebug mesages...

Code: Select all

/*
 * MINIGUI - Harbour Win32 GUI library Demo
 * bpd2000@gmail.com
*/

/* modified by Marek Olszewski MOL (2014.04.17)
*  mol@pro.onet.pl
*/

#include "minigui.ch"
function main


Define window oEdit At 0,0 width 600 height 400 main title "Move & Resize Control?" 

   // Public nTextBoxCounter := 0
   Public nTitleBarHeight := GetTitleHeight()
   Public nBorderWidth := GetBorderWidth()
	
   DEFINE STATUSBAR Font "Arial" SIZE 8
			STATUSITEM "" 
		END STATUSBAR

      DEFINE button moveControl1
         Row 120
         Col 15
         width 80
         caption "Move_Me"
       action moveControl( this.name )
       END button
    /*   
       DEFINE button resizeControl1
         Row 120
         Col 115
         width 100
         caption "Resize_Me"
         action resizeControl( _HMG_aControlNames[ 1 ] )
      END button
     */
End window

oEdit.center
oEdit.activate

return nil

************************************


PROCEDURE MoveControl( cControlName )
   LOCAL ControlHandle := GetControlHandle( cControlName, 'oEdit' )
   LOCAL z

	ControlHandle := GetControlHandle(cControlName, thisWindow.Name)

		nCurrentCol := this.Col //- oEdit.Col - nBorderWidth
		nCurrentRow := this.Row //- oEdit.Row - nTitleBarHeight - nBorderWidth

msgdebug(nCurrentCol, nCurrentRow)
	
	InterActiveMove()

	nCurrentCol := GetWindowCol( ControlHandle ) - oEdit.Col - nBorderWidth
	nCurrentRow := GetWindowrow( ControlHandle ) - oEdit.Row - nTitleBarHeight - nBorderWidth

msgdebug(nCurrentCol, nCurrentRow)

		nCurrentCol := int(nCurrentCol / 10) * 10
		nCurrentRow := int(nCurrentRow / 10) * 10

		this.col := nCurrentCol
		this.row := nCurrentRow

RETURN

*******************************************************

PROCEDURE DrawFocusRect( oControl )

	//ERASE WINDOW oEdit

	//DRAW RECTANGLE IN WINDOW oEdit AT oEdit.&(oControl).row - 1 , oEdit.&(oControl).col - 1 TO oEdit.&(oControl).row + oEdit.&(oControl).height + 1 , oEdit.&(oControl).col + oEdit.&(oControl).width + 1 PENCOLOR { 128, 128, 128 } PENWIDTH 2

  	//DRAW RECTANGLE IN WINDOW oEdit AT oEdit.&(oControl).row + oEdit.&(oControl).height + 2 , oEdit.&(oControl).col + oEdit.&(oControl).width + 2 TO oEdit.&(oControl).row + oEdit.&(oControl).height - 6 , oEdit.&(oControl).col + oEdit.&(oControl).width - 6 PENCOLOR { 128, 128, 128 } PENWIDTH 2 FILLCOLOR {192,192,192}

RETURN

*******************************************************

#pragma BEGINDUMP

#include <windows.h>

#include "hbapi.h"

HB_FUNC( SETPIXEL )
{
   hb_retnl( (ULONG) SetPixel( (HDC) hb_parnl( 1 ) ,
				hb_parni( 2 )      ,
				hb_parni( 3 )      ,
			(COLORREF) hb_parnl( 4 ) ) );
}

HB_FUNC( SETCROSSCURSOR )
{
   SetClassLong( ( HWND ) hb_parnl(1), GCL_HCURSOR, ( LONG ) LoadCursor(NULL, IDC_CROSS) );
}

HB_FUNC( INTERACTIVEMOVE )
{
   keybd_event(
      VK_RIGHT,  // virtual-key code
      0,         // hardware scan code
      0,         // flags specifying various function options
      0          // additional data associated with keystroke
      );

   keybd_event(
      VK_LEFT,   // virtual-key code
      0,         // hardware scan code
      0,         // flags specifying various function options
      0          // additional data associated with keystroke
      );

   SendMessage( GetFocus(), WM_SYSCOMMAND, SC_MOVE, 10 );
   RedrawWindow( GetFocus(), NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_ERASENOW | RDW_UPDATENOW );
}

HB_FUNC( INTERACTIVESIZE )
{
   keybd_event(
      VK_DOWN,
      0,
      0,
      0
      );

   keybd_event(
      VK_RIGHT,
      0,
      0,
      0
      );

   SendMessage( GetFocus(), WM_SYSCOMMAND, SC_SIZE, 0 );
}

#pragma ENDDUMP

Re: Object on Form can be move by user

Posted: Thu Apr 17, 2014 8:29 am
by bpd2000
mol wrote:Try this sample, you can remove msgdebug mesages...
Thank you, Mol
Excellent coding extension
Regarding re-size of Object, Hint
With the use of Move & Re-size of object we can design application to Crop Image etc.

Re: Object on Form can be move by user

Posted: Thu Apr 17, 2014 8:57 am
by mol
I'll try to adapt resize function

Re: Object on Form can be move by user

Posted: Thu Apr 17, 2014 9:27 am
by mol
You request, you get it!

Code: Select all

/*
 * MINIGUI - Harbour Win32 GUI library Demo
 * bpd2000@gmail.com
*/

#include "minigui.ch"

FUNCTION MAIN

Define window oEdit At 0,0 width 600 height 400 main title "Move & Resize Control?" 

   Public nTitleBarHeight := GetTitleHeight()
   Public nBorderWidth := GetBorderWidth()
	
   DEFINE STATUSBAR Font "Arial" SIZE 8
			STATUSITEM "" 
		END STATUSBAR

      DEFINE button MoveControl1
         Row 120
         Col 15
         width 120
		 height 30
         caption "TEST BUTTON"
       action MsgBox( "Call context menu of this button to move or resize control" )
       END button

	   DEFINE CONTROL CONTEXTMENU  MoveControl1
			MenuItem "Move button"	action moveControl( "MoveControl1" )
			MenuItem "Resize button"	action ResizeControl( "MoveControl1" )
		END MENU
End window

oEdit.center
oEdit.activate

return nil

************************************

PROCEDURE MoveControl( cControlName )
   LOCAL ControlHandle

	DoMethod(ThisWindow.Name, cControlName, "SetFocus")

	ControlHandle := GetControlHandle(cControlName, thisWindow.Name)

	InterActiveMove()
	nCurrentCol := GetWindowCol( ControlHandle ) - oEdit.Col - nBorderWidth
	nCurrentRow := GetWindowrow( ControlHandle ) - oEdit.Row - nTitleBarHeight - nBorderWidth
	//nCurrentCol := int(nCurrentCol / 10) * 10
	//nCurrentRow := int(nCurrentRow / 10) * 10


	SetProperty(ThisWindow.Name, cControlName,"Col", nCurrentCol)
	SetProperty(ThisWindow.Name, cControlName,"Row", nCurrentRow)

RETURN

/*----------------------------------------------------------------------*/

PROCEDURE ResizeControl( cControlName )
	LOCAL ControlHandle := GetControlHandle( cControlName, 'oEdit' )
	local nNewWidth, nNewHeight
	
	DoMethod(ThisWindow.Name, cControlName, "SetFocus")
	ControlHandle := GetControlHandle(cControlName, thisWindow.Name)
	InterActiveSize()
	nNewWidth	:= GetWindowWidth( ControlHandle )
	nNewHeight	:= GetWindowHeight( ControlHandle )
	SetProperty(ThisWindow.Name, cControlName,"Width",nNewWidth)
	SetProperty(ThisWindow.Name, cControlName,"Height", nNewHeight )

RETURN

/*----------------------------------------------------------------------*/

*******************************************************

#pragma BEGINDUMP

#include <windows.h>

#include "hbapi.h"

HB_FUNC( SETPIXEL )
{
   hb_retnl( (ULONG) SetPixel( (HDC) hb_parnl( 1 ) ,
				hb_parni( 2 )      ,
				hb_parni( 3 )      ,
			(COLORREF) hb_parnl( 4 ) ) );
}

HB_FUNC( SETCROSSCURSOR )
{
   SetClassLong( ( HWND ) hb_parnl(1), GCL_HCURSOR, ( LONG ) LoadCursor(NULL, IDC_CROSS) );
}

HB_FUNC( INTERACTIVEMOVE )
{
   keybd_event(
      VK_RIGHT,  // virtual-key code
      0,         // hardware scan code
      0,         // flags specifying various function options
      0          // additional data associated with keystroke
      );

   keybd_event(
      VK_LEFT,   // virtual-key code
      0,         // hardware scan code
      0,         // flags specifying various function options
      0          // additional data associated with keystroke
      );

   SendMessage( GetFocus(), WM_SYSCOMMAND, SC_MOVE, 10 );
   RedrawWindow( GetFocus(), NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_ERASENOW | RDW_UPDATENOW );
}

HB_FUNC( INTERACTIVESIZE )
{
   keybd_event(
      VK_DOWN,
      0,
      0,
      0
      );

   keybd_event(
      VK_RIGHT,
      0,
      0,
      0
      );

   SendMessage( GetFocus(), WM_SYSCOMMAND, SC_SIZE, 0 );
}

#pragma ENDDUMP

Re: Object on Form can be move by user

Posted: Thu Apr 17, 2014 12:25 pm
by bpd2000
mol wrote:You request, you get it!
Thank you, Mol
Very nice coding and useful to other user also

Re: Object on Form can be move by user

Posted: Thu Apr 17, 2014 4:03 pm
by Javier Tovar
mol wrote:You request, you get it!
:D :D :D Excelente frase!

Gracias Mol, en verdad Felicidades!!! :D :D :D

Buena aplicación,

Saludos