Object on Form can be move by user

Discuss anything else that does not suite other forums.

Moderator: Rathinagiri

User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: Object on Form can be move by user

Post by bpd2000 »

mol wrote:you've missed IDE.PRG in attached sample
Included
Attachments
demo.rar
(10.93 KiB) Downloaded 213 times
BPD
Convert Dream into Reality through HMG
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: Object on Form can be move by user

Post 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
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Object on Form can be move by user

Post 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... :(
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Object on Form can be move by user

Post 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
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: Object on Form can be move by user

Post 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.
BPD
Convert Dream into Reality through HMG
User avatar
mol
Posts: 3825
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: Object on Form can be move by user

Post 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
User avatar
bpd2000
Posts: 1207
Joined: Sat Sep 10, 2011 4:07 am
Location: India

Re: Object on Form can be move by user

Post by bpd2000 »

mol wrote:You request, you get it!
Thank you, Mol
Very nice coding and useful to other user also
BPD
Convert Dream into Reality through HMG
Javier Tovar
Posts: 1275
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México

Re: Object on Form can be move by user

Post 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
Post Reply