Page 1 of 2

Windows context menu

Posted: Thu Jan 28, 2016 12:07 pm
by Piotr D
Hi,
In my application I must send XML files generated from Xbase program signed with an electronic signature (XAdES).
These I can add with another, installed on computer, program. In this case I must run this program, choice directory
and file, and add signature. However, this program add to the Windows context menu option "Sign", which is
available, when I right click on this file. In this case signature program is already invoked for this file. My question is:
how, if is possible, can I implement/add these context menu in Xbase program (or run this, what is made under "Sign"
option)?

Regards
Piotr

Re: Windows context menu

Posted: Thu Jan 28, 2016 12:31 pm
by rdonnay
I don't know what you mean by "Windows context menu"

Re: Windows context menu

Posted: Thu Jan 28, 2016 12:38 pm
by Piotr D
Roger,
I mean "Menu which is displayed under Windows on Desktop or disk explorer, when right click on file"
here is screenshot:
https://onedrive.live.com/redir?resid=D ... hoto%2cpng

Piotr

Re: Windows context menu

Posted: Thu Jan 28, 2016 5:03 pm
by Auge_Ohr
hi,

when left click on Desktop and than right click -> Menu.
Menu Item are in Registry under

Code: Select all

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\
you have to create a new Item e.g. "USB Eject" and add "Command".

Code: Select all

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\USB Eject]
"ICON"="hotplug.dll,-100"

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\USB Eject\Command]
@="D:\\ALASKA\\USB\\LBDRIVE.EXE"
USB_Eject_Kontext-Menu.jpg
USB_Eject_Kontext-Menu.jpg (101.06 KiB) Viewed 21578 times
edit : have re-read your Msg ... you already have that Menu Entry as you say.

so look at your HKEY_CLASSES_ROOT\DesktopBackground\Shell\ for your search Key and if it have a "Command" String which can use with Runshell()

Re: Windows context menu

Posted: Fri Jan 29, 2016 2:08 am
by Piotr D
Jimmy,
thanks for your answer. In registry these options don't have a command - in this case I don't know an command for RunShell().
When I use XbpFileDialog(), I can display this menu, but... don't have all option. This Windows component is not so "rich" like f.e. explorer.exe. Using explorer.exe the menu is the same like on desktop. It's possible make XbpFileDialog() more "rich"?

Piotr

Re: Windows context menu

Posted: Fri Jan 29, 2016 4:18 am
by Tom
Hi, Piotr.
It's possible make XbpFileDialog() more "rich"?
1. Create your own with Directory() and so on.

2. Use a component.

The XbpFileDialog uses the standard API dialog and shows different behaviours depending on the OS.

Re: Windows context menu

Posted: Fri Jan 29, 2016 8:39 am
by rdonnay
You could write your own replacement for XbpFileDialog() but that would take some time.

Do you need all the functionality of XbpFileDialog()?

Does it need to provide navigation to any folder?

Re: Windows context menu

Posted: Fri Jan 29, 2016 11:09 am
by Piotr D
Roger,
I don't need navigation. All I need, is only select file (files) from one directory (using pattern, like Test_*.XML) and
have possibility run (with right mouse button) full "context menu" which is available normally on desktop with this right button.
The directory and file (files pattern) is know before.

Piotr

Re: Windows context menu

Posted: Fri Jan 29, 2016 11:38 am
by rdonnay
This can easily be written using @..DCBROWSE.. RBSELECT .. RBDOWN

Code: Select all

FUNCTION MyFolderBrowse()

LOCAL GetList[0], GetOptions, aDir, aHeadings, i, oBrowse

DC_AutoRestoreWindow( { HKEY_LOCAL_MACHINE, ;
aDir := Directory()

aHeadings := { 'File;Name', ;
               'File;Size', ;
               'Date;Last;Write', ;
               'Time;Last;Write', ;
               'File;Attr', ;
               'Size;Extend;Attr', ;
               'Create;Date', ;
               'Create;Time', ;
               'Date;Last;Access', ;
               'Time;Last;Access' }

@ 0,0 DCSAY 'Click Right Button in a Column for menu' ;
      SAYSIZE 50 COLOR GRA_CLR_BLUE

@ 1,0 DCBROWSE oBrowse DATA aDir PRESENTATION DC_BrowPres() ;
      SIZE 40,20 FIT ;
      ID 'DIRECTORY_BROWSE' ;
      HEADLINES 3 ;
      RBSELECT ;
      RBDOWN BrowseMenuBlock(@oBrowse)

FOR i := 1 TO Len(aHeadings)
  DCBROWSECOL ELEMENT i HEADER aHeadings[i] ;
     WIDTH 6 PARENT oBrowse ;
     SORT _SortBlock(i,aDir)
NEXT

DCGETOPTIONS ;
   NOMINBUTTON ;
   NOMAXBUTTON ;
   AUTORESIZE ;
   BUTTONALIGN DCGUI_BUTTONALIGN_CENTER

DCREAD GUI ;
   FIT ;
   BUTTONS DCGUI_BUTTON_OK ;
   OPTIONS GetOptions ;
   TITLE 'Directory Browse' ;
   MODAL ;
   SETAPPWINDOW

RETURN nil

* -------------

STATIC FUNCTION _SortBlock( i, aDir )

RETURN {||ASort(aDir,,,{|a,b|a[1]<b[1]})}

* -------------

STATIC FUNCTION BrowseMenu( oBrowse )

STATIC soMenu, soBrowse

LOCAL GetList[0], i

IF Valtype(soMenu) # 'O' .OR. soMenu:status()<=0 .OR. soBrowse # oBrowse

  IF Valtype(soMenu) = 'O'
    soMenu := nil
  ENDIF

  soBrowse := oBrowse

  DCSUBMENU soMenu

    DCMENUITEM 'Run a program' PARENT soMenu ACTION {||RunShell(oBrowse:dataSource[oBrowse:arrayElement[1]],'MyProgram.Exe')}

  DCREAD GUI ;
    PARENT oBrowse ;
    EXIT

ENDIF

RETURN soMenu

* --------------

STATIC FUNCTION BrowseMenuBlock( oBrowse )

RETURN {|x,y,z,o|o := BrowseMenu( oBrowse ), ;
                                o:popup( nil, x, 1 , ;
                                XBPMENU_PU_DEFAULT + XBPMENU_PU_MOUSE_RBDOWN ) }

Re: Windows context menu

Posted: Fri Jan 29, 2016 1:40 pm
by Auge_Ohr
Piotr D wrote:thanks for your answer. In registry these options don't have a command - in this case I don't know an command for RunShell().
how does it look like ?
Piotr D wrote:When I use XbpFileDialog(), I can display this menu, but... don't have all option. This Windows component is not so "rich" like f.e. explorer.exe. Using explorer.exe the menu is the same like on desktop. It's possible make XbpFileDialog() more "rich"?
XbParts often does not offer "all" Property ... try this Ot4xb Version.
GetOpenFileName.zip
need ot4xb
(1.39 KiB) Downloaded 1017 times