[progress Communities] [progress Openedge Abl] Forum Post: Re: Trying To Return Column...

  • Thread starter Thread starter Patrick Tingen
  • Start date Start date
Status
Not open for further replies.
P

Patrick Tingen

Guest
Getting the column in wich the user clicked is a real pita. I have used a workaround in the DataDigger. It works along these lines: When user right-clicks, determine mouse coordinates with a windows api call Walk through the visible (!) columns of the browse and determine whether the mouse coordinates are on that column Create a window with a browse on it and paste the below code into the "MOUSE-MENU-CLICK" trigger. That includes the extra procedures. Just copy and paste it all in the section editor. You may need to change the name of the browse in the 3rd line of the code (the call to getClickedColumn). Then run the program and right-click a column. It should pop up with the name of the column you clicked on. DO: DEFINE VARIABLE hColumn AS HANDLE NO-UNDO. RUN getClickedColumn(INPUT {&BROWSE-NAME}:HANDLE,OUTPUT hColumn). MESSAGE hColumn:NAME VIEW-AS ALERT-BOX INFO BUTTONS OK. END. PROCEDURE GetCursorPos EXTERNAL "user32.dll" : DEFINE INPUT-OUTPUT PARAMETER lRect AS MEMPTR. END. PROCEDURE ScreenToClient EXTERNAL "user32.dll" : DEFINE INPUT PARAMETER hWnd AS LONG. DEFINE INPUT PARAMETER lpPoint AS MEMPTR. END PROCEDURE. PROCEDURE getClickedColumn: /* Return the handle of the column we clicked on */ DEFINE INPUT PARAMETER phBrowse AS HANDLE NO-UNDO. DEFINE OUTPUT PARAMETER phColumn AS HANDLE NO-UNDO. DEFINE VARIABLE iColumn AS INTEGER NO-UNDO. DEFINE VARIABLE iMouseX AS INTEGER NO-UNDO. DEFINE VARIABLE iMouseY AS INTEGER NO-UNDO. DEFINE VARIABLE hColumn AS HANDLE NO-UNDO. RUN getMouseXY(INPUT phBrowse:FRAME, OUTPUT iMouseX, OUTPUT iMouseY). findColumn: DO iColumn = 1 TO phBrowse:NUM-COLUMNS: hColumn = phBrowse:GET-BROWSE-COLUMN(iColumn). IF (iMouseX - phBrowse:X) > hColumn:X AND (iMouseX - phBrowse:X) < (hColumn:X + hColumn:WIDTH-PIXELS) THEN DO: phColumn = hColumn. LEAVE findColumn. END. END. END PROCEDURE. /* getClickedColumn */ PROCEDURE getMouseXY : /* Get the position of the mouse relative to the frame */ DEFINE INPUT PARAMETER phFrame AS HANDLE NO-UNDO. DEFINE OUTPUT PARAMETER piMouseX AS INTEGER NO-UNDO. DEFINE OUTPUT PARAMETER piMouseY AS INTEGER NO-UNDO. DEFINE VARIABLE lp AS MEMPTR NO-UNDO. SET-SIZE(lp) = 16. RUN GetCursorPos(INPUT-OUTPUT lp). /* Get the location of the mouse relative to the frame */ RUN ScreenToClient(INPUT phFrame:HWND, INPUT lp). piMouseX = GET-LONG(lp, 1). piMouseY = GET-LONG(lp, 5). SET-SIZE(lp) = 0. END PROCEDURE. /* getMouseXY */

Continue reading...
 
Status
Not open for further replies.
Back
Top