Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Trap Right Button Click

rtsmith
Beginner
1,465 Views
I have developed a windows program which uses dlgmodal to display the window and which traps the leftmouse clicks (default). I want now to trap rightmouse clicks to produce a drop down floating menu. I have worked through the example in the examples file on disc but this uses createwindowex and a whole host of calls for menus and accelerators. I have got horribly confused. Is it possible to trap right mouse clicks with dlgmodal or do I have to rewrite my start-up like the example. In trying to do so using createwindowex, I have actually managed to get all the calls to work, except that it won't display my window (from script1.rc and called idd_toms). Can someone give me a bit of guidance. Obviously I would prefer to use the dlgmodal path, but if I have to use the createwindowex path, then how do I get the display from script1.rc to appear in my window so that I can use the code from the example?
0 Kudos
14 Replies
anthonyrichards
New Contributor III
1,465 Views

Have you tried the QuickWin function REGISTERMOUSEEVENT ? Consult CVF Help for more details...


Code:
REGISTERMOUSEEVENT
QuickWin Function: Registers the application-supplied
callback routine to be called when a
specified mouse event occurs in a specified window.

Module: USE DFLIB

Syntax

result = REGISTERMOUSEEVENT (unit, mouseevents, callbackroutine)


unit
(Input) INTEGER(4). Unit number of the window whose callback routine
on mouse events is to be registered.


mouseevents
(Input) INTEGER(4). One or more mouse events to be handled by the callback
routine to be registered. Symbolic constants (defined in DFLIB.F90 in the
DF98INCLUDE subdirectory) for the possible mouse events are:


MOUSE$LBUTTONDOWN - Left mouse button down
MOUSE$LBUTTONUP - Left mouse button up
MOUSE$LBUTTONDBLCLK - Left mouse button double-click
MOUSE$RBUTTONDOWN - Right mouse button down
MOUSE$RBUTTONUP - Right mouse button up
MOUSE$RBUTTONDBLCLK - Right mouse button double-click
MOUSE$MOVE - Mouse moved


callbackroutine
(Input) Routine to be called on the specified mouse event in the specified window.
It must be declared EXTERNAL. For a prototype mouse callback routine, see Using
QuickWin in the Programmer's Guide.

Message Edited by sblionel on 01-07-2005 09:41 PM

0 Kudos
rtsmith
Beginner
1,465 Views
Thanks Anthony for your reply. Unfortunately in the application I have written I am not (and cannot be) using Quickwin because of some of the functions I need. Can you help with a standard graphics window please?
0 Kudos
anthonyrichards
New Contributor III
1,465 Views
Can you not use DlgSetSub to set a call back for the WM_RBUTTONDOWN message?
0 Kudos
rtsmith
Beginner
1,465 Views
Anthony. Thanks again for your reply. I had tried dlgsetsub,and tried again but the return was false. The statement was:
retlog=dlgsetsub(dlg,wm_rbuttondown,dlg_lstall)
where dlg is got from dlginit and dlg_lstall is an entry routine for an event.
I am still finding my way around this type of coding being an engineer and writing engineering fortran.
I am using one of the examples to get this to work and there is a different question which might enable me to use the example's code rather than mine at this point. I am trying to use createwindowex to open a window. I have the file script1.rc and thiscontains IDD_TOMS. How do I open a window using createwindowex so that all the information in IDD_TOMS is displayed in the window. I don't seem to be able to put IDD_TOMS in the right place in the call to createwindowex, but I think that I probably need to do a call first to get a handle or something. Please can you guide me. Thanks
0 Kudos
anthonyrichards
New Contributor III
1,465 Views
Here is one way of opening a dialog, given the resources in SCRIPT.RC:


1) Include SCRIPT.RC in the project, then the dialog resources will be available. I assume your dialog is given the ID IDD_TOMS. In the example I will show, the dialog is given a character C-string identifier "ABOUTDLG". The screen shot given in the .GIF shows "ABOUTDLG". highlighted in the resource pane, the dialog itself desplayed in the edit pane and the dialog properties box is displayed showing the dialogs identifier.


2) When required, the dialog can be displayed using code similar to the following:


Code:

case (IDM_ABOUT)
lpszDlgName = "AboutDlg"C
ret = DialogBoxParam(ghInstance,LOC(lpszDlgName),hWnd,&
LOC(AboutDlgProc), 0)
MainWndProc=0
return


This code happens to be inside a window procedure called 'MainWndProc' 'hWnd' is the handle to the main window calling it. 'gHinstance' is the instance of the main program given as an argument to the WinMain function that is called to start a standard windows program (which I presume you understand). You must supply your own dialog box procedure, here called AboutDlgProc, to handle the dialog box messages, such as WM_RIGHTBUTTONDOWN or IDM_WHATEVER or such like using the standard SELECT CASE(msg)...END SELECT. In the example shown, the dialog procedure has the standard interface




Code:
interface
integer*4 function AboutDlgProc( hwnd, mesg, wParam, longParam )
!DEC$ IF DEFINED(_X86_)
!DEC$ ATTRIBUTES STDCALL, ALIAS : '_AboutDlgProc@16' :: AboutDlgProc
!DEC$ ELSE
!DEC$ ATTRIBUTES STDCALL, ALIAS : 'AboutDlgProc' :: AboutDlgProc
!DEC$ ENDIF

integer hwnd
integer mesg
integer wParam
integer longParam
end function
end interface


Message Edited by sblionel on 01-07-2005 09:37 PM

0 Kudos
anthonyrichards
New Contributor III
1,465 Views
I apologise for the way line-wrapping fails to occur - I have no control over it, it appears.
0 Kudos
Steven_L_Intel1
Employee
1,465 Views
The long lines in the earlier message set the margin for the whole thread. I edited the posts to help a bit. There were also some tabs in your later code sample.
0 Kudos
rtsmith
Beginner
1,465 Views
I am still having trouble getting my right click to work. I have tried to incorporate my code into the right-click example that came with CVF but I cannot get my script1.rc (IDD_TOMS) to be recognised. I have tried using dialogboxparam (above) but I do not have Hwnd available. If I put the code into the next function down from the main program where Hwnd is in the argument list, I cannot get it to recognise dialogboxparam.
I seem to be going round in circles where I expect that there is a very simple explanation, if only I could find it.
I am still learning about the intricacies of windows programming. I have everything working except my right-click.
Is it possible to have a small program (with a designed window in script1.rc) which will work and on which I can build?
0 Kudos
anthonyrichards
New Contributor III
1,465 Views
Define a global variable gHinst in a MODULE called, say, MyGlobals. Add the statement USE MyGlobals inany routine where you need the value, including the WinMain function that is called to start the program, where you would assign gHinst its value asusing the statementgHinst - Hinst.
Then it will be available to you when and wherever you need it, so long as you insert USE MyGlobals.
You can do the same with window handles, i.e. add gHwnd1 to MyGlobals and assign it a value when you obtain a window handle that you need to use later. It would help if you could post some (or all, if it is not to big) of your code, eitrher as text or as an attachment, so we can seee what you have.
regards.
0 Kudos
rtsmith
Beginner
1,465 Views
Anthony
Thanks for your comments. I understand what you are saying and I have seen equivalent code in the examples. I have tried the global route but still had no success. I have pared my program down to the bare minimum. This is the main program (tomsmn) with a call to inital to start the process (inital) and then a response to one button click (refrsh). I have removed everything else.It is build as a standard graphics window (Win32 (x86) application).In script1.rc are 2 menus (MENU2 and MENU3) which I want to become floating menus on a right mouse click. These operate on a panel in the window with stacks of information about theatre shows and stewards. It is not present at the moment in order to keep the size down. I have attached a file tomsmn.src with all the files required. Each file break is prefixed by @@filename. If you can help me by updating the code to make the menus work I would be extremely grateful. I don't mind what you do to the code because every operation is present and if you change the method of operation, then I can replicate it right through. If you want to send it to me direct, then my email address is rtsmith@fish.co.uk. Very many thanks.
0 Kudos
rtsmith
Beginner
1,465 Views
For some reason the attachment did not work so I am trying again. It is now toms.zip (having seen the error message)!
0 Kudos
anthonyrichards
New Contributor III
1,465 Views
Several things:
1) why have two menus?
2) you say you want 'floating menus'. As far as I can tell, what you CAN do is adda menu to its own dialog. Just set up a dialog bar (an empty dialog box large enogh to take your menu) and specify a menu for it in the properties box in Resource editor.
3) you can then open this dialog, giving access to its menu, by trapping the
WM_RBUTTONDOWN message sent to the TOMS dialog.
4) In order to trap this message, generated by right-clicking within the TOMS dialog ox, you will need to SUB-CLASS the main TOMS dialog. How to do this is explained in Jugoslav Dujic's MENUDIALOG example here http://www.geocities.com/jdujic/fortran/other/other.htm. ALso, you can search this mesage board for 'subclassing dialogs' and find plenty of references. Basically, in the callback called on initialising the TOMS dialog, you use SETWINDOWLONG to replace the default dialog procedure that handles the dialog box messages with your own procedure. you can then intercept all the messages sent to your TOMS dialog, including WM_RBUTTONDOWN of course. You can then load the dialog with the menu you want after its interception. On opening the menu dialog, you will specify a dialog box procedure (that you provide) to handle the messages that this dialog box and its menu provides. It sounds complicated, but it is fairly straightforward.
5) If I have time tomorrow I will post a sample that will display ONE of your menus in a dialog. You cannot, it appears , display both menus at once, if the dialogs are modal.
regards
AR
0 Kudos
rtsmith
Beginner
1,465 Views
Anthony
Just a quick reply before the day ends. I want 2 menus because different ones will appear under different conditions when I click on parts of my window.
0 Kudos
anthonyrichards
New Contributor III
1,465 Views
So you will need the mouse co-ordinates to select which of the menus to display?
Here is something for you to play with. It displays a TOMS menu and if you right-
click on it, a message box should appear showing the mouse co-ordinates relative to the top left corner of the dialog's client area (below the menu).
Clicking 'OK' to remove the message box should then display the menu at a pre-determined position, set in its properties page... HTH
0 Kudos
Reply