show a popup menu when I left click on a button in oracle form - oracle

I have created a popup menu and assigned it into a button,when i right click
the button the popup menu will be displayed.Now i want if i normally click the
button that is left click the popup menu to be displayed

It works in Oracle Forms 6:
declare
w_id pls_integer;
begin
w_id := GET_ITEM_PROPERTY(Find_Item('CONTROL.B_REPORTS'), WINDOW_HANDLE);
WIN_API_SHELL.SendMessage( w_id, 516 ); -- WM_RBUTTONDOWN
WIN_API_SHELL.SendMessage( w_id, 517 ); -- WM_RBUTTONUP
end;

I completely agree with #APC above; this is not a standard UI convention. And it is not possible to override the default functionality of the right click menu within Forms. You could however, build a small window/canvas/block made to look like the right click menu and default it's starting window position to be the mouse X,Y coordinate.

Related

Delphi FMX TMainMenu first menu item doesn't show in OSX, OK in WIndows

I created a Multi-Device Application in Delphi Seattle and added a TMainMenu with MenuItem1 and MenuItem2 (nothing else). Building and running for OSX, only MenuItem2 shows. Building and running for Windows, both menu items show. I didn't treat the two menu items any differently. Both were just added and not customized in any way. Anyone else experience this?
The top level items in a Mac menu bar typically look like this:
Apple/system menu ('About this Mac', 'System Preferences...', etc.)
Application menu ('About XXX', 'Services', 'Hide XXX', 'Hide Others',
'Show All', 'Quit XXX')
File menu
Edit Menu
...
In FMX (excepting the very first version), the first top level item in a TMainMenu represents the application menu. As such, you need to add an item before File (or whatever is your current first item) that is only show on OS X; its sub-items should then include the usual items of a Mac application menu. To implement those items' behaviour, you can utilise standard actions (TFileHideApp, TFileHideAppOthers, TFileExit). Or, in more detail:
If there isn't one already, add a TActionList component to the form
Double click the action list to bring up the action list editor
Click on the add button's dropdown arrow, and select New Standard Action...
Select all of TFileHideApp, TFileHideAppOthers and TFileExit, and click OK
Back on the form, open up the menu editor by double clicking on the TMainMenu component
Add an item immediately before the first one that currently exists; in the Object Inspector, call it (say) mnuApp
Add at least four child items to mnuApp; using the Object Inspector, assign the Action property of the first to FileHideApp1, the second to FileHideAppOthers, and the fourth to FileExit1; set the Text of the third to a hyphen (-) to make it a separator
Close the menu editor
If one doesn't already exist, create a OnCreate handler for the form by double clicking its entry in the Object Inspector
Add to FormCreate a line to hide mnuApp if not running on OS X. Conversely, if you already have a menu item for File|Exit, this should be hidden if running on OS X since the functionality is now Quit under the application menu:
...
procedure TForm1.FormCreate(Sender: TObject);
begin
mnuApp.Visible := (TOSVersion.Platform = pfMacOS);
itmExit.Visible := (TOSVersion.Platform <> pfMacOS);
end;

How can I make a CMenu TrackPopupMenu SubMenu menu-item clickable?

Normally when you hover over a sub-menu (with the little arrow) on a CMenu menu item it delays briefly then shows the sub-menu items. Also, if you click the item before the delay timeout, it shows the sub menu items. I want the delay behavior, but I want a different behavior for the click. That is, I want the sub-menu itself (the one with the arrow) to be a clickable entity too, i.e. it has an ID and results in a WM_COMMAND and menu dismissal.
The idea is, the main sub-menu menu item is a "default", and the sub-menu items are modified versions, e.g. "print->" (defaulting to default printer), and sub-menu items like "print preview" "print to file" etc. Thanks for thoughts/suggestions.
edit:
IDR_MY_MENU MENUEX
BEGIN
POPUP "menu"
BEGIN
MENUITEM "&Something Else", ID_MENU_SOMETHING_ELSE
POPUP "&Print", ID_MENU_PRINT
BEGIN
MENUITEM "Print Pre&view", ID_MENU_PRINT_PREVIEW
MENUITEM "Print to &File", ID_MENU_PRINT_TO_FILE
END
MENUITEM "", -1, MFT_SEPARATOR
MENUITEM "&Bottom", ID_MENU_BOTTOM
MENUITEM "&Done", ID_MENU_DONE
END
END
I dont know if theres a better way as I last did this 2 years ago, but the way I solved the problem had one constraint: that you own the whole menu. If you do own the whole menu what you can do is create two columns (two columns in the menu/submenu that is, not a new submenu) and use the right column as a submenu and the left column as the default.
For future StackOverflowers, here's what I did...
Added a handler for OnInitMenuPopup and corresponding
ON_WM_INITMENUPOPUP(), although doing this messed up my UPDATE_COMMAND_UI handler but I was able to resolve that by moving that code into the OnInitMenuPopup handler.
In the OnInitMenuPopup handler, set a hook for the mouse SetWindowsHookEx(WH_MOUSE,...) (checking if one isn't already set because sub-menus can cause multiple calls)... and for each menu that initializes during the hook, push the HMENU onto a linked list.
In the mouse hook proc, checking the end of the list and working toward the front, verify each HMENU is still and active menu via IsMenu and remove it if it isn't. If there are no menus left, UnhookWindowsHook.
If there are menus left in the hook proc, check for WM_LBUTTONUP or WM_RBUTTONUP and see if happened over one of your menu items (because of coordinate mapping of screen versus sub-menu that I couldn't figure out I ended up simply cycling through the menu items via GetMenuItemRect and checking PtInRect to determine this).
If there is a click hit, do GetMenuItemInfo on the item, and if there's a hSubMenu for that item and it has an wID (and the wID doesn't match the sub-menu handle), simply post the id as a WM_COMMAND, post a WM_CANCELMODE to dismiss the menu, and disable the hook... Bingo!
So, seems to work fine and everything else functions like normal. The only issue at this point is a keyboard handler for selecting the item instead opening the sub-menu but I suspect the same idea works there as well.
Also, I added the main sub-menu text as the first item in the sub-menu list with a separator which added some clarity to what the menu was doing.

VB6 + how to switch between windows/frame in form by buttons

I am very new beginner with VB6 and I hope I explain the things right
I want to create form with 2 buttons (the buttons are located on the top form position )
So each button will switch to other form/window/frame
For example
The first button will show window 1 (there I can set only parameters)
The second button will show window 2 (there I can set only IP address)
Please advice if we can do that by VB6 ?
And if yes how to do that ( step by step )
Remark - Similar example but with multiple windows in the same form is the system properties ( right click on my computer and properties ) , the we can see each button will view different window
Create a form with 2 buttons, Command1 and Command2.
On this form, create 2 frames, Frame1 and Frame2. hide Frame2 and make sure to line up both framesso that they are of the same size and located right on top of each other (Top, Left, Width and Height properties must be the same)
Now put this code in:
Private Sub Command1_Click()
Frame1.Visible = True
Frame2.Visible = False
End Sub
Private Sub Command2_Click()
Frame1.Visible = False
Frame2.Visible = True
End Sub
Now each the first button shows the first frame while hiding the 2nd. The second button hides the first frame and shows the seconds. I think this is the simplest way to implement your task.
PS: don't forget to name your objects properly, it's not a good idea to have default names like Command1 or Frame2 - should be more descriptive than that.
It sounds like you are asking about the tabbed dialog control. To use a tabbed dialog control in VB6:
Click Project -> Components
Scroll down to "Microsoft Tabbed Dialog Control 6.0" and select it.
Click the Apply button.
You should notice a new control in the component tool box. If you do not see the toolbox, click View -> ToolBox. This is the same area of the IDE where you first click to add a button to a form. The tabbed dialog control looks like the top tab of several file folders. When you hover your mouse over the control in the toolbox, you will see a tool tip text of "SSTab". Click this control and then draw a rectangle on your form.
By default, this will add a tabbed dialog control with 3 tabs, but you can change this in the properties window. You can now create any control on top of a tab of the tabbed dialog control and interact with the control exactly the same way you would if the control was placed on the form itself.
What you want is called an MDI Form. It's a form that contains other forms.
You can find a full tutorial on them here, but here's the gist of what you want to do:
Set the "MDIChild" property of all your subforms you want to use to True. Disable their minimize, maximize, and resize functions as well.
Create an MDIForm. Disable its AutoShowChildren property.
Add a toolbar to the MDIForm. Add buttons to the toolbar corresponding to the forms you'll be switching between.
Implement each button's click event, to create child form as expected (or switch to an existing one).

checkbox - change notification

What notification code is sent with the wm_command message to the dialog box procedure when a check box changes state?
And more importantly, where would I look in the msdn to find the notification codes for various controls?
Note that Check boxes and Radio buttons are Buttons. So they send click and double click messages, BN_CLICKED and BN_DOUBLECLICKED.
If you use MFC, then you can examine the check state with CButton::GetCheck method.
Otherwise you send the BM_GETCHECK message to the control: SendMessage(button_handle, BM_GETCHECK, 0, 0);
SendMessage can return
BST_CHECKED Button is checked.
BST_INDETERMINATE Button is grayed, indicating an indeterminate state
(applies only if the button has the BS_3STATE or BS_AUTO3STATE style).
BST_UNCHECKED Button is cleared
If the button has a style other than those listed, the return value is zero.
If you use the Visual Studio, the easiest way to get a list of events/messages a control can send is to go to Resource/Design view, right click a control and select Events.
For a list of common controls see: Control Library
(in the page you'll see a popup menu with the controls if you hover the cursor on the Control Library link)
It's BN_CLICKED. The bottom of the page links to the button messages.

Creating a menu button in Windows

Microsoft's User Experience Interaction Guidelines give some UI guidelines for when to use a menu button:
http://i.msdn.microsoft.com/Aa511453.command51(en-us,MSDN.10).png
How do I create one of these menu buttons? I've found information on
how to create a split button in Vista and above
how to create a toolbar button with a dropdown menu
how to create a regular pushbutton and manually wire up an OnClick event handler that pops up a menu
But is there any standard way to create a button, not in a toolbar, with the little down triangle, that automatically pops up a menu when clicked?
(I'm using Delphi / C++Builder, but other solutions are welcome.)
You can use the OnClick to force the popup, and for consistency don't use the cursor position, but rather the control position.
procedure TForm1.Button1Click(Sender: TObject);
var
pt : TPoint;
begin
Pt.X := Button1.Left;
Pt.Y := Button1.Top+Button1.Height;
pt := ClientToScreen(Pt);
PopupMenu1.Popup(pt.x,pt.y);
end;
You can then add the "glyph" using either a Delphi 2010 button, or a previous version TBitBtn and assign the bitmap/glyph property to an appropriate image and align right.
You don't mention which version of Delphi you are using, but in Delphi 2010 TButton has new properties for this: DropDownList which can be associated with a TPopupMenu to define the menu items, and Style which can be set to bsSplitButton.
This produces a button that you can press that also has a dropdown arrow on the right of it, To make the menu popup when you click to the left of the arrow this code in the button click handler should do the job.
procedure TForm1.Button1Click(Sender: TObject);
var
CursorPos: TPoint;
begin
GetCursorPos(CursorPos);
PopupMenu1.Popup(CursorPos.X, CursorPos.Y);
end;
in previous versions of Delphi I think you had to use TToolBar.

Resources