CONTEXT MENU on wrong Monitor

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

CONTEXT MENU on wrong Monitor

Post by AUGE_OHR »

hi,

i do have 2nd Monitor on "Left" Side so X Value become NEGATIVE

when run App on "Left" Side and call

Code: Select all

   DEFINE CONTEXT MENU OF WinLeft
it will display on "Right" Monitor :o

Question : can CONTEXT MENU have negative Value ?

---

as Popup Menu display at "GetCursorPos" i try to find it in Source ...

Code: Select all

HB_FUNC ( TRACKPOPUPMENU )
is that the Code to "Pop-Up" at Cursor Position :?:
have fun
Jimmy
User avatar
andyglezl
Posts: 1461
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Contact:

Re: CONTEXT MENU on wrong Monitor

Post by andyglezl »

Andrés González López
Desde Guadalajara, Jalisco. México.
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: CONTEXT MENU on wrong Monitor

Post by AUGE_OHR »

Hi,

thx for Answer.

i have used "IN WINDOW" so App work correct on 2nd Monitor with NEGATIVE Value
but i don´t "see" how to "manipulate" Position of CONTEXT MENU when it "Pop-Up" :idea:

---

i got in c:\hmg.3.4.4\SOURCE\c_windows.c

Code: Select all

HB_FUNC ( GETCURSORROW )
{
   POINT pt;
   GetCursorPos( &pt );
   hb_retni( pt.y );
}

Code: Select all

HB_FUNC ( GETCURSORCOL )
{
   POINT pt;
   GetCursorPos( &pt );
   hb_retni( pt.x );
}
but it is different in GETCURSORPOS

Code: Select all

HB_FUNC ( GETCURSORPOS )
{
   POINT pt;
   GetCursorPos( &pt );

   if (HB_ISBYREF(1))
       hb_stornl ((LONG) pt.x, 1);
   if (HB_ISBYREF(2))
       hb_stornl ((LONG) pt.y, 2);

   hb_reta( 2 );
   hb_storvni( pt.y, -1, 1 );
   hb_storvni( pt.x, -1, 2 );
}
what does

Code: Select all

   hb_storvni( pt.y, -1, 1 );
   hb_storvni( pt.x, -1, 2 );
do :?:
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: CONTEXT MENU on wrong Monitor

Post by AUGE_OHR »

hi,

i have make more Test with CONTEXT MENU

just have 1 x CONTEXT MENU in MAIN ( Win_1 )
have check GetCursorRow() / GetCursorCol() <-> GetCursorPos (@nCol, @nRow) -> OK and negative Value

now i place my App 50 % left Side and 50 % right Side so App is between both Monitor

if i right click on right Side it will work correct
if i right click on left Side Popup will show on right Monitor :evil:

---

i have try to manipulate HB_FUNC ( TRACKPOPUPMENU ) in c:\hmg.3.4.4\SOURCE\c_menu.c
i follow Sample from https://docs.microsoft.com/en-us/window ... kpopupmenu
i have try to enable this line

Code: Select all

   PostMessage(hDlg, WM_NULL, 0, 0);
but nothing help :(

as it work with my Xbase++ App there must be a Solution ... need Idea :idea:
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: CONTEXT MENU on wrong Monitor

Post by AUGE_OHR »

hi,

i "think" i got the Answer :

c:\hmg.3.4.4\SOURCE\h_windows.prg

Code: Select all

      CASE nMsg == WM_CONTEXTMENU
         _HMG_MouseRow := HIWORD( lParam )
         _HMG_MouseCol := LOWORD( lParam )

         _HMG_SYSDATA[ 191 ] := HIWORD( lParam )
         _HMG_SYSDATA[ 192 ] := LOWORD( lParam )
HIWORD and LOWORD return signed value -> NO NEGATIVE Value

i "think" we have to use POINT Structure like HB_FUNC ( GETCURSORPOS )
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: CONTEXT MENU on wrong Monitor

Post by AUGE_OHR »

hi,
GOT IT :D

use c:\hmg.3.4.4\SOURCE\h_windows.prg

search under WM_LBUTTONDOWN and WM_MOUSEMOVE for

Code: Select all

   _HMG_SYSDATA[ 191 ] := HIWORD( lParam )
   _HMG_SYSDATA[ 192 ] := LOWORD( lParam )
also under WM_CONTEXTMENU

Code: Select all

   _HMG_MouseRow := HIWORD( lParam )
   _HMG_MouseCol := LOWORD( lParam )
and replace it with

Code: Select all

   aPos := GETCURSORPOS()
   _HMG_SYSDATA[ 191 ] := aPos[1]
   _HMG_SYSDATA[ 192 ] := aPos[2]
or

Code: Select all

   aPos := GETCURSORPOS()
   _HMG_MouseRow := aPos[1]
   _HMG_MouseCol := aPos[2]
---

search for

Code: Select all

   TrackPopupMenu( _HMG_SYSDATA[ 74 ] [ i ], LOWORD( lparam ), HIWORD( lparam ), hWnd )
and replace it with

Code: Select all

   TrackPopupMenu( _HMG_SYSDATA[ 74 ] [ i ], aPos[ 1 ], aPos[ 2 ], hWnd )
---

use c:\hmg.3.4.4\SOURCE\c_windows.c

in HB_FUNC ( GETCURSORPOS )
change

Code: Select all

   hb_storvni( pt.y, -1, 1 );
   hb_storvni( pt.x, -1, 2 );
to

Code: Select all

   hb_storvni( pt.x, -1, 1 );
   hb_storvni( pt.y, -1, 2 );
rebuild LIB and it work with NEGATIVE Value :D

p.s. you can use attached Files to overwrite (!) c:\hmg.3.4.4\SOURCE\c_windows.c and c:\hmg.3.4.4\SOURCE\h_windows.prg but make BACKUP FIRST
Attachments
NOHIWORD.ZIP
(48.37 KiB) Downloaded 57 times
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: CONTEXT MENU on wrong Monitor

Post by AUGE_OHR »

hi,

Note : file NOHIWORD.ZIP is Version 3.4.4 :!:

it might be that in HMG 3.5 something have change but i can´t compare it (yet) as i have to CLICK it first.
please make those Change to c:\HMG.3.5\SOURCE\h_windows.prg "manual" to be sure not to brake Code.
have fun
Jimmy
User avatar
AUGE_OHR
Posts: 2093
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

Re: CONTEXT MENU on wrong Monitor

Post by AUGE_OHR »

hi,

it seems there is a "better" Way to get "negative" Value

i have read at
https://docs.microsoft.com/en-us/window ... sing-menus

Code: Select all

case WM_CONTEXTMENU: 
    if (!OnContextMenu(hwnd, GET_X_LPARAM(lParam),
                             GET_Y_LPARAM(lParam))) 
        return DefWindowProc(hwnd, uMsg, wParam, lParam); 
    break;
so instead of

Code: Select all

   _HMG_SYSDATA[ 191 ] := HIWORD( lParam )
   _HMG_SYSDATA[ 192 ] := LOWORD( lParam )
we can use ( not tested yet )

Code: Select all

   pt.x = GET_X_LPARAM(lParam); 
   pt.y = GET_Y_LPARAM(lParam); 
which is

Code: Select all

   _HMG_SYSDATA[ 191 ] := GET_X_LPARAM(lParam); 
   _HMG_SYSDATA[ 192 ] := GET_Y_LPARAM(lParam); 
have fun
Jimmy
Post Reply