Re: Object on Form can be move by user
Posted: Wed Apr 16, 2014 11:38 am
you've missed IDE.PRG in attached sample
Exclusive forum for HMG, a Free / Open Source xBase WIN32/64 Bits / GUI Development System
http://mail.hmgforum.com/
Includedmol wrote:you've missed IDE.PRG in attached sample
Some years ago Roberto decided to not publish IDE code...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
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
Thank you, Molmol wrote:Try this sample, you can remove msgdebug mesages...
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
Thank you, Molmol wrote:You request, you get it!
mol wrote:You request, you get it!