How to detect owner of context menu?
Moderator: Rathinagiri
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: How to detect owner of context menu?
MoveControl and ResizeControl can be achieved using row, col, width, height properties. Isn't it?
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.
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
Re: How to detect owner of context menu?
Would be also useful to work with arrows keys of keyboard, in order to make fine adjustaments...
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
- esgici
- Posts: 4543
- Joined: Wed Jul 30, 2008 9:17 pm
- DBs Used: DBF
- Location: iskenderun / Turkiye
- Contact:
Re: How to detect owner of context menu?
Some like it low-levelRathinagiri wrote:MoveControl and ResizeControl can be achieved using row, col, width, height properties. Isn't it?
Viva INTERNATIONAL HMG
- srvet_claudio
- Posts: 2193
- Joined: Thu Feb 25, 2010 8:43 pm
- Location: Uruguay
- Contact:
Re: How to detect owner of context menu?
These are general functions to move and resize controls, I hope you find it useful !
Code: Select all
#include "HMG.ch"
FUNCTION MAIN
local i
Define window Form_1 At 0,0 width 600 height 400 main title "Move and Resize Control With Cursor"
DEFINE STATUSBAR Font "Arial" SIZE 8
STATUSITEM "F3 - Control Info"
END STATUSBAR
@ 300, 10 LABEL Label_1 VALUE "Put the cursor over control and press F5 (Move) or F9 (Resize), while Move or Resize ESC -> Undo" AUTOSIZE
DEFINE button MoveControl1
Row 120
Col 15
width 120
height 30
caption "New Form"
action New_Form()
END button
for i :=1 to 3
cLabelName := "LBL_"+HB_NTOS(i,1)
define label &cLabelName
PARENT Form_1
row 20
col 120*(i-1) + 40
value "Label no. "+ str(i,1)
Width 110
Height 40
Fontsize 10
tooltip "this is label no. "+str(i,1)
Alignment Center
BackColor {255,255,0}
TabStop .t.
end label
next i
End window
CREATE EVENT PROCNAME KeyControl()
Form_1.center
Form_1.activate
return nil
PROCEDURE New_Form
IF IsWindowDefined (Form_2) == .F.
aRows := ARRAY (9)
aRows [1] := {'Simpson','Homer','555-5555'}
aRows [2] := {'Mulder','Fox','324-6432'}
aRows [3] := {'Smart','Max','432-5892'}
aRows [4] := {'Grillo','Pepe','894-2332'}
aRows [5] := {'Kirk','James','346-9873'}
aRows [6] := {'Barriga','Carlos','394-9654'}
aRows [7] := {'Flanders','Ned','435-3211'}
aRows [8] := {'Smith','John','123-1234'}
aRows [9] := {'Pedemonti','Flavio','000-0000'}
DEFINE WINDOW Form_2 ;
AT 0,0 ;
WIDTH 800 ;
HEIGHT 600 ;
TITLE "Form2" ;
WINDOWTYPE STANDARD
@ 100,100 GRID Grid_1 ;
WIDTH 400 ;
HEIGHT 300 ;
HEADERS {'Last Name','First Name','Phone'} ;
WIDTHS {140,140,140};
ITEMS aRows ;
VALUE 1;
JUSTIFY { GRID_JTFY_LEFT,GRID_JTFY_LEFT, GRID_JTFY_RIGHT }
END WINDOW
ACTIVATE WINDOW Form_2
ENDIF
RETURN
****************************************************************
* GENERAL FUNCTIONS for Move and Resize Control With Cursor *
****************************************************************
FUNCTION KeyControl()
IF HMG_GetLastVirtualKeyUp() == VK_F3 // Info
HMG_CleanLastVirtualKeyUp()
HMG_InfoControlWithCursor()
ELSEIF HMG_GetLastVirtualKeyUp() == VK_F5 // Move
HMG_CleanLastVirtualKeyUp()
HMG_MoveControlWithCursor()
ELSEIF HMG_GetLastVirtualKeyUp() == VK_F9 // Resize
HMG_CleanLastVirtualKeyUp()
HMG_ResizeControlWithCursor()
ENDIF
RETURN NIL
PROCEDURE HMG_InfoControlWithCursor
LOCAL hWnd, nCol, nRow
LOCAL cFormName, cControlName
GetCursorPos (@nCol, @nRow)
hWnd := WindowFromPoint (nCol, nRow)
IF GetControlIndexByHandle (hWnd) > 0
GetControlNameByHandle (hWnd, @cControlName, @cFormName)
MsgInfo ({ cFormName +"."+ cControlName, HB_OSNEWLINE(),HB_OSNEWLINE(),;
"Row : ", GetProperty (cFormName, cControlName, "Row"), HB_OSNEWLINE(),;
"Col : ", GetProperty (cFormName, cControlName, "Col"), HB_OSNEWLINE(),;
"Width : ", GetProperty (cFormName, cControlName, "Width"), HB_OSNEWLINE(),;
"Height : ", GetProperty (cFormName, cControlName, "Height")},"Control Info")
ENDIF
RETURN
PROCEDURE HMG_MoveControlWithCursor
LOCAL hWnd, nCol, nRow
LOCAL cFormName, cControlName
GetCursorPos (@nCol, @nRow)
hWnd := WindowFromPoint (nCol, nRow)
IF GetControlIndexByHandle (hWnd) > 0
GetControlNameByHandle (hWnd, @cControlName, @cFormName)
DoMethod(cFormName, cControlName, "SetFocus")
HMG_InterActiveMove (hWnd)
nCol := GetWindowCol (hWnd)
nRow := GetWindowRow (hWnd)
ScreenToClient (GetFormHandle(cFormName), @nCol, @nRow)
SetProperty (cFormName, cControlName, "Col", nCol)
SetProperty (cFormName, cControlName, "Row", nRow)
ENDIF
RETURN
PROCEDURE HMG_ResizeControlWithCursor
LOCAL hWnd, nCol, nRow
LOCAL nWidth, nHeight
LOCAL cFormName, cControlName
GetCursorPos (@nCol, @nRow)
hWnd := WindowFromPoint (nCol, nRow)
IF GetControlIndexByHandle (hWnd) > 0
GetControlNameByHandle (hWnd, @cControlName, @cFormName)
DoMethod(cFormName, cControlName, "SetFocus")
HMG_InterActiveSize (hWnd)
nWidth := GetWindowWidth (hWnd)
nHeight := GetWindowHeight (hWnd)
SetProperty (cFormName, cControlName, "Width", nWidth)
SetProperty (cFormName, cControlName, "Height", nHeight)
ENDIF
RETURN
#pragma BEGINDUMP
#include <windows.h>
#include "hbapi.h"
HB_FUNC ( HMG_INTERACTIVEMOVE )
{
HWND hWnd = (HWND) hb_parnl (1);
if (! IsWindow(hWnd) )
hWnd = GetFocus();
keybd_event (VK_RIGHT, 0, 0, 0);
keybd_event (VK_LEFT, 0, 0, 0);
SendMessage (hWnd, WM_SYSCOMMAND, SC_MOVE, 0);
RedrawWindow (hWnd, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_ERASENOW | RDW_UPDATENOW);
}
HB_FUNC ( HMG_INTERACTIVESIZE )
{
HWND hWnd = (HWND) hb_parnl (1);
if (! IsWindow(hWnd) )
hWnd = GetFocus();
keybd_event (VK_DOWN, 0, 0, 0);
keybd_event (VK_RIGHT, 0, 0, 0);
SendMessage (hWnd, WM_SYSCOMMAND, SC_SIZE, 0);
RedrawWindow (hWnd, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN | RDW_ERASENOW | RDW_UPDATENOW);
}
#pragma ENDDUMP
-
- Posts: 1275
- Joined: Tue Sep 03, 2013 4:22 am
- Location: Tecámac, México
Re: How to detect owner of context menu?
Gracias Dr. Claudio Soto Funcinan muy bien!
Saludos
Saludos
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
How to detect owner of context menu?
Thank you Claudio. If is not much to ask to, could you tell me how is possible to make micro adjustments by arrows keys ?. This moving of row is 12 pixels per movement (upper/lower arrow keys) and for col is 9.
I try to change:
nCol := GetWindowCol (hWnd) -8
nRow := GetWindowRow (hWnd) -11
But movement on displaying is still moving so much...
I try to change:
nCol := GetWindowCol (hWnd) -8
nRow := GetWindowRow (hWnd) -11
But movement on displaying is still moving so much...
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Re: How to detect owner of context menu?
Thank you Dr. Caludio for nice codesrvet_claudio wrote:These are general functions to move and resize controls, I hope you find it useful !
Even Grid can be move and re-size by user at run time
Dear PabloPablo César wrote:Thank you Claudio. If is not much to ask to, could you tell me how is possible to make micro adjustments by arrows keys ?. This moving of row is 12 pixels per movement (upper/lower arrow keys) and for col is 9.
Try using Control+Arrow key
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG
- Pablo César
- Posts: 4059
- Joined: Wed Sep 08, 2010 1:18 pm
- Location: Curitiba - Brasil
How to detect owner of context menu?
Ops... I did not know that ...bpd2000 wrote:Try using Control+Arrow key
Thank you Dave, we can also thank you for you have submitted this source code and insisted on adapting to HMG.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Re: How to detect owner of context menu?
Dear Dr. Caludio, Pablo CésarPablo César wrote:Ops... I did not know that ...bpd2000 wrote:Try using Control+Arrow key
Thank you Dave, we can also thank you for you have submitted this source code and insisted on adapting to HMG.
Instead of using F_5 key
It is possible to move control using ON MOUSEDRAG with change of cursor shape to move while moving
Instead of using F_9 key
Similarly when mouse is at bottom position of control and user click mouse, Re-size Control procedure will active until mouse click up
BPD
Convert Dream into Reality through HMG
Convert Dream into Reality through HMG