Prevent a window can be moved
Moderator: Rathinagiri
Prevent a window can be moved
Hi,
Is there any way (or trick) to prevent a user can not move a window by clicking on the title bar of the window (I hope I've explained).
Please I await your comments.
Best Regards
Javier
Is there any way (or trick) to prevent a user can not move a window by clicking on the title bar of the window (I hope I've explained).
Please I await your comments.
Best Regards
Javier
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Prevent a window can be moved
Hola Javierjparada wrote: Is there any way (or trick) to prevent a user can not move a window by clicking on the title bar of the window
AFAIK we haven't a NOMOVE keyword in DEFINE WINDOW statement. IMHO only you can use NOCAPTION for prevent user to use the title bar (if appropriate your need).
Saludos, Regards
--
Esgici
Viva INTERNATIONAL HMG
- Czarny_Pijar
- Posts: 172
- Joined: Thu Mar 18, 2010 11:31 pm
- Location: 19.2341 E 50.2267 N
Re: Prevent a window can be moved
jparada
For my own curiosity I've checked every available option in the HMG. Looks like at this time with this tool you can't do this.
For my own curiosity I've checked every available option in the HMG. Looks like at this time with this tool you can't do this.
Re: Prevent a window can be moved
You can prevent moving the window in this way:
1. Rememeber the position of window
2. When user moves window - move it programmatically to the previous position
1. Rememeber the position of window
2. When user moves window - move it programmatically to the previous position
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Prevent a window can be moved
You are gr8 Marek.
A creative and logical approach to the problem.
A creative and logical approach to the problem.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
Re: Prevent a window can be moved
Hi,
Thanks for your answers.
Esgici:
Czarny_Pijar
Marek
Thanks
Best Regards
Javier
Thanks for your answers.
Esgici:
The problem is I need the title bar.AFAIK we haven't a NOMOVE keyword in DEFINE WINDOW statement. IMHO only you can use NOCAPTION for prevent user to use the title bar (if appropriate your need).
Czarny_Pijar
I already knewFor my own curiosity I've checked every available option in the HMG. Looks like at this time with this tool you can't do this.
Marek
Sorry, I personally do not like this "trick"You can prevent moving the window in this way:
1. Rememeber the position of window
2. When user moves window - move it programmatically to the previous position
Thanks
Best Regards
Javier
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: Prevent a window can be moved
Hola Javierjparada wrote:Sorry, I personally do not like this "trick"Marek wrote:You can prevent moving the window in this way:
1. Rememeber the position of window
2. When user moves window - move it programmatically to the previous position
In my opinion, the suggestion of Marek is cool. Though you don't like, take a look at this :
Code: Select all
#include "minigui.ch"
FUNC Main()
nWindWidth := 500
nWindHeight := 400
nUnMWinCol := ( GetDesktopWidth() - nWindWidth ) / 2
nUnMWinRow := ( GetDesktopHeight() - nWindHeight ) / 2
DEFINE WINDOW frmUnMoveable ;
AT 0,0 ;
WIDTH 500 ;
HEIGHT 400 ;
TITle "Unmoveable Window" ;
MAIN
ON KEY ESCAPE ACTION frmUnMoveable.Release
DEFINE TIMER Timer_1 ;
INTERVAL 100 ;
ACTION { || thisWindow.Row := nUnMWinRow, thisWindow.Col := nUnMWinCol }
END WINDOW
frmUnMoveable.CENTER
ACTIVATE WINDOW frmUnMoveable
RETU
Saludos / Regards
--
Esgici
Viva INTERNATIONAL HMG
- srvet_claudio
- Posts: 2193
- Joined: Thu Feb 25, 2010 8:43 pm
- Location: Uruguay
- Contact:
Re: Prevent a window can be moved
Hi friend Esgici,
very nice your code
I would add
best regards,
Claudio Soto
very nice your code
I would add
Code: Select all
ON MAXIMIZE (thisWindow.restore)
best regards,
Claudio Soto
- srvet_claudio
- Posts: 2193
- Joined: Thu Feb 25, 2010 8:43 pm
- Location: Uruguay
- Contact:
Re: Prevent a window can be moved
Hola a todos,
les dejo un par de funciones generales para bloquear el movimiento de una determinada ventana, para un mejor funcionamiento seria preferible para no interferir con el botón de maximizar que la misma fuese difinida como NOMAXIMIZE o en su defecto con
ON MAXIMIZE (thisWindow.Restore), de lo contrario cuando pulsan el botón de maximizar la ventana permanece con el mismo tamaño
pero el sistema toma como que se maximizo y cambia dicho botón a RESTORE, y viceversa.
Pueden comprobarlo en el ejemplo que les dejo abajo.
Saludos,
Claudio Soto.
***************************************************************************************************
* SINTAXIS:
*
* MOVE_WINDOW_F (<cWindowName>) // BLOQUEA movimiento de la ventana
* MOVE_WINDOW_T (<cWindowName>) // DESBLOQUEA movimiento de la ventana
* MOVE_WINDOW (<cWindowName>) // Retorna .T. MOVIBLE --- Retorna .F. NOMOVIBLE
*
***************************************************************************************************
les dejo un par de funciones generales para bloquear el movimiento de una determinada ventana, para un mejor funcionamiento seria preferible para no interferir con el botón de maximizar que la misma fuese difinida como NOMAXIMIZE o en su defecto con
ON MAXIMIZE (thisWindow.Restore), de lo contrario cuando pulsan el botón de maximizar la ventana permanece con el mismo tamaño
pero el sistema toma como que se maximizo y cambia dicho botón a RESTORE, y viceversa.
Pueden comprobarlo en el ejemplo que les dejo abajo.
Saludos,
Claudio Soto.
***************************************************************************************************
* SINTAXIS:
*
* MOVE_WINDOW_F (<cWindowName>) // BLOQUEA movimiento de la ventana
* MOVE_WINDOW_T (<cWindowName>) // DESBLOQUEA movimiento de la ventana
* MOVE_WINDOW (<cWindowName>) // Retorna .T. MOVIBLE --- Retorna .F. NOMOVIBLE
*
***************************************************************************************************
Code: Select all
****************************************************************************
* PROGRAMA: NO MOVE WINDOW
* LENGUAJE: HARBOUR-MINIGUI 3.0.26
* FECHA: 28 MARZO 2010
* AUTOR: CLAUDIO SOTO
* PAIS: URUGUAY
* E-MAIL: srvet@adinet.com.uy
****************************************************************************
***************************************************************************************************
* SINTAXIS:
*
* MOVE_WINDOW_F (<cWindowName>) // BLOQUEA movimiento de la ventana
* MOVE_WINDOW_T (<cWindowName>) // DESBLOQUEA movimiento de la ventana
* MOVE_WINDOW (<cWindowName>) // Retorna .T. MOVIBLE --- Retorna .F. NOMOVIBLE
*
*******************************************************************************************************
****************************************************************************************************
* DEFINICION DE LOS COMANDOS
****************************************************************************************************
#xtranslate MOVE_WINDOW_FALSE (<cWindowName>);
=>;
MOVE_WINDOW_F (<cWindowName>)
#xtranslate MOVE_WINDOW_TRUE (<cWindowName>);
=>;
MOVE_WINDOW_T (<cWindowName>)
// MOVE_WINDOW (<cWindowName>)
#include "minigui.ch"
declare window form_2
Function Main
DEFINE WINDOW Form_1 ;
AT 0,0 ;
WIDTH 400 ;
HEIGHT 500 ;
TITLE 'NO MOVE WINDOW' ;
MAIN //ON MAXIMIZE (thisWindow.Restore)
@ 10,10 LABEL Label_1 VALUE IF (MOVE_WINDOW ("Form_1"),"MOVER SI","MOVER NO")
@ 100, 100 BUTTON boton_1 CAPTION "NO MOVER" ACTION {|| MOVE_WINDOW_FALSE ("Form_1"), Form_1.Label_1.Value := IF (MOVE_WINDOW ("Form_1"),"MOVER SI","MOVER NO")}
@ 100, 250 BUTTON boton_2 CAPTION "MOVER" ACTION {|| MOVE_WINDOW_TRUE ("Form_1"), Form_1.Label_1.Value := IF (MOVE_WINDOW ("Form_1"),"MOVER SI","MOVER NO")}
@ 200, 100 BUTTON boton_3 CAPTION "Ventana 2" ACTION ventana2 (1)
@ 200, 250 BUTTON boton_4 CAPTION "NO MOVER 2" ACTION ventana2 (2)
END WINDOW
Form_1.Center
Form_1.Activate
Return
*****************************************************************************************************
Procedure Ventana2 (n)
IF n = 1
IF IsWindowDefined (form_2)
RETURN
ENDIF
DEFINE WINDOW Form_2 ;
AT 10,10 ;
WIDTH 300 ;
HEIGHT 300 ;
TITLE 'Vent2' ;
CHILD
END WINDOW
Form_2.Activate
ENDIF
IF n = 2 .AND. IsWindowDefined (form_2)
MOVE_WINDOW_FALSE ("Form_2")
ENDIF
Return
******************************************************************************************************
****************************************************************************************************
* DEFINICION DE LAS FUNCIONES
****************************************************************************************************
Procedure MOVE_WINDOW_F (vent)
Local y := GetProperty (vent , "ROW")
Local x := GetProperty (vent , "COL")
Local h := GetProperty (vent , "HEIGHT")
Local w := GetProperty (vent , "WIDTH")
Local ctrl := "tmr_"+vent
IF .NOT. (IsControlDefined (&ctrl , &vent))
DEFINE TIMER &ctrl OF &vent INTERVAL 50 ACTION NO_MOV_WIN_C (GetFormHandle(vent), y, x, h, w)
ENDIF
Return
********************************************************************************************************
Procedure MOVE_WINDOW_T (vent)
Local ctrl := "tmr_"+vent
IF IsControlDefined (&ctrl , &vent)
DoMethod (vent ,ctrl ,"Release")
ENDIF
Return
*********************************************************************************************************************
Function MOVE_WINDOW (vent)
Local ctrl := "tmr_"+vent
Return .NOT.(IsControlDefined (&ctrl , &vent))
*#########################################################################################################################
* FUNCION EN C
*#########################################################################################################################
#pragma begindump
#include <shlobj.h>
#include <winuser.h>
#include <windows.h>
#include "hbapi.h"
//**********************************************************************************
// NO_MOV_WIN_C (hWND, y, x, h, w)
//**********************************************************************************
HB_FUNC (NO_MOV_WIN_C)
{
HWND hWND;
int x, y, h, w;
hWND = (HWND) hb_parnl (1);
y = hb_parni (2);
x = hb_parni (3);
h = hb_parni (4);
w = hb_parni (5);
SetWindowPos (hWND, HWND_TOP, x, y, w, h, SWP_NOZORDER | SWP_NOACTIVATE);
}
#pragma enddump