Mouse use

Mouse use

Mouse Use
I have a Modal dialog within a QuickWin application that has a button with a bmp and I am trying to check the status of the mouse button using Jugoslav instruction, within a callback routine:
Use DfWin
.
.
.
IF (IAND(GetKeyState(MK_LBUTTON), #8000).NE.0) THEN !Left button pressed
! Some procedure
ELSE
ENDIF

Although I do not get any error during compilation, the process is unable to take the information when I press the left mouse button.

I tried also
intret = WaitonMouseEvent(MOUSE$LBUTTONDOWN,Keystate,xposition,yposition)
But it did not work either.

Furthermore, I am trying to change the mouse cursor as follows

Integer Function ChangeCursor(ThisCursor)
Use Dflib
Use Dfwin
Integer hinstance
Integer cursor, oldcursor,ElCursor
hinstance = 0
cursor = LoadCursor(hinstance,ThisCursor)
oldcursor = SetMouseCursor(cursor)
ChangeCursor= oldcursor
Return
End Function CambieCursor

Then I call the function with:
oldcursor = CambieCursor(IDC_CROSS)
And it does not work.

What am I doing wrong?
Help! Please.
OPiedra

3 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.

Let us get something straight first (though perhaps organization of CVF docs and samples adds a little to the confusion): DFLOGM and QuickWin are two completely distinct things. For example, you can use DFLOGM in QuickWin, Win32 or even console application, but QuickWin is compatible only with itself. You can use one with another, but you can't expect that a routine that works with dialogs works with child windows and vice versa.

Having said that, let's go one topic by another:

1) The important thing with the first code is where it is located. It is supposed to work, but the problem is that it can only test whether the button is pressed at the moment when the callback is called. You didn't say which callback it is; if that's a button callback, note that it's called when button up event is registered on the button (try pushing any button and drag the cursor with button pressed out of its area, then release it -- nothing happens and that's how Windows work). Thus, chances are negligible that IF block will ever get executed.

2) WaitOnMouseEvent won't work for the reason I stated in the introduction -- it's a QuickWin routine and it will work only for QuickWin windows, not for dialog controls.

3) Same for SetMouseCursor.

Now, about solutions:

1) I'm not sure what exactly you're trying to achieve; if you want to change the bitmap when the button is being pushed, that won't be easy (but I wouldn't speculate until you post a more precise message). Note that you (maybe, depending on use) can use a push-like check box instead, which has state (checked/unchecked) which you can test for when deciding which bitmap to apply.

2) The "right" Windows way is to subclass the control and
handle WM_SETCURSOR message, then use SetCursor API within it. Note that SetCursor outside that won't work since it'll be changed back as soon as user moves the mouse. An alternative way is to use SetClassLong(GCL_HCURSOR) API; that does change the cursor permanently, but may lead to some problems (IIRC all buttons in the dialog will share that cursor, but I'm not sure) -- try it.

HTH
Jugoslav

Jugoslav
www.xeffort.com

I though that I could use QuickWin procedures within the dialogs, but now I realize that I can not. I was considering QuickWin a module with definitions, subroutines and functions that make easier the use of the APIs and that could be used anywhere. But it is not, at least with dflogm. Obviously, if I use dialogs with dflogm then the user interface can not use child windows. I have learned that ?the W32 functions cannot be used to draw on a QuickWin window because QwickWin keeps a window buffer, and the altered window would be destroyed on redraw?(Lawrance, N.,Compaq Visual Fortran,Digital Press, 2000, page 11). By the way, this is an excellent book that every one trying to learn Fortran Windows applications need to have. I hope we will have more books like this in the near future.
My problem:
I need to edit a bitmap and I have done it in a QuickWin window. My problem aroused when I put a dialog and tried to manipulate the screen as if I were in a child window. It does not work and I understand now why. It seems that the solution has to be to develop, not a QuickWin application, but a Fortran Window application and use the Win32 API routines, if I want to have the dialogs and at the same time the editing capability.
I have a button (or a picture) control with the property bmp and I draw it with the picture. What I want is being able to select an object (a portion of the bmp) by choosing two opposite corners of a rectangle, for example. I know how to do it if the bmp is not in a dialog, but is it possible to edit the bmp or get the cursor position when the file is displayed in a control of a dialog? (a button or a picture control).
Well, it seems it is time for me to study Fortran Window Applications and learn about subclassing and message processing. Fortunately Lawrence book is now available. It is sad that Mr. Jugoslav does not have enough free time to put in a book his excellent knowledge of Visual Fortran. I hope you can do it some day.
Thank you again.
OPiedra

Kommentar hinterlassen

Bitte anmelden, um einen Kommentar hinzuzufügen. Sie sind noch nicht Mitglied? Jetzt teilnehmen