FireFly Visual Designer for FreeBASIC (Updated March 8, 2016)

User projects written in or related to FreeBASIC.
Post Reply
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

mouse click on form caption

Post by owen »

thanks, the large change setting was causing the error.
next question:
how can i detect mouse click on form title bar (caption area)
Function FORM1_WM_LBUTTONDOWN is used for form client area
need
Function FORM1_Caption_Area_WM_LBUTTONDOWN
or, maybe use WM_NCLBUTTONDOWN Message
how do i use this wm_nc message as a function in the form
ok... got it

Code: Select all

Function FORM1_CUSTOM ( _
                      hWndForm      As HWND, _      ' handle of Form
                      wMsg          As Integer,  _  ' type of message
                      wParam        As WPARAM, _    ' first message parameter
                      lParam        As LPARAM   _   ' second message parameter
                      ) As Integer
Select Case wMsg
    Case WM_NCLBUTTONDOWN
        End ' or do whatever
End Select
End Function
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

mouse wheel

Post by owen »

how do we handle mouse wheel (not middle mouse button up/down) in firefly?
Zippy
Posts: 1295
Joined: Feb 10, 2006 18:05

Re: mouse wheel

Post by Zippy »

owen wrote:how do we handle mouse wheel (not middle mouse button up/down) in firefly?
See this post:
http://www.freebasic.net/forum/viewtopic.php?p=38712

"Case WM_MOUSEWHEEL"
If you execute ('option explicit) that code you'll see what's passed. I'm guessing that this too would go in _CUSTOM (for the form) or wherever you have a uMsg (wMsg) from/for a control.
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

wm_mousewheel

Post by owen »

that's what i was hoping i could do (use case wm_mousewheel in custom function) but it didn't work.
PaulSquires
Posts: 1037
Joined: Jul 14, 2005 23:41

Post by PaulSquires »

In order to receive the MouseWheel message, I think that the focus should be on a control that receives keyboard input? NOt sure, but in your CAD program the MouseWheel was received for your two popup windows but not for the main MDI window itself.

Here is code that I adapted from the custom code editor that FF3 uses. In this example I am getting the message through the FF_PumpHook rather than dealing with it in every CUSTOM handler for every control. I test for the Windows setting to see what the defined number of lines Windows says that we should scroll, and then I send that many scroll messages to my window/control of choice (in my case it was the FF3 code editor).

Code: Select all


#Define SPI_GETWHEELSCROLLCHARS     &H006C
'#Define SPI_GETWHEELSCROLLLINES     &H0068


Function FF_PUMPHOOK( uMsg As Msg ) As Integer


   ' If this function returns FALSE (zero) then the processing of the regular
   ' FireFly message pump will continue. Returning TRUE (non-zero) will bypass
   ' the regular message pump.

   Function = False    ' return TRUE if you need to bypass the FireFly message pump
   
  
   ' Trap the mousewheel for all forms/controls in the application
    
   Select Case uMsg.Message
      Case WM_MOUSEWHEEL

         Dim nDelta       As word 
         Dim nScrollCount As Integer
         Dim y            As Integer
        
         nDelta       = HiWord(uMsg.wParam)
         nScrollCount = 3
        
         If (LoWord(uMsg.wParam) And MK_MBUTTON) = MK_MBUTTON Then 
            ' horizontal scroll
            SystemParametersInfo SPI_GETWHEELSCROLLCHARS, 0, nScrollCount, 0
        
           ' For y = 1 To nScrollCount
           '    SendMessage hWnd, WM_HSCROLL, _
           '                     Makelong( IIf(nDelta > 1, SB_LINELEFT, SB_LINERIGHT), 0), _
           '                     0
           ' Next
         
         Else                                                  
            ' vertical scroll
            SystemParametersInfo SPI_GETWHEELSCROLLLINES, 0, nScrollCount, 0
         
            ' DEBUG
            MessageBox 0, "Vertical scroll " & nScrollCount & " lines.", "scroll", 0
          
           ' For y = 1 To nScrollCount
           '    SendMessage hWnd, WM_VSCROLL, _
           '                    Makelong( IIf(nDelta > 1, SB_LINEUP, SB_LINEDOWN), 0), _
           '                    0
           ' Next
         End If
       
   End Select
     
     
End Function
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

mouse wheel example

Post by owen »

http://htwif.com/owen/FB_examples_for_f ... _wheel.zip
scrolling the mouse wheel up increments mouse and down decrements mousew

mousew starts out as zero
scroll the mouse wheel and the value of mousew is shown in the textbox
in FF_AppStart i dim shared mousew=0 to start out
i think to use this to scroll anything with the mouse wheel, just reset mousew=0 when the control receives focus. in the case of a horizontal or vertical scroll bar, upon receiving focus, set mousew = to what ever the scroll bar's current value is. and then scroll away using the mouse wheel

in the FF_PumpHook i added:

Code: Select all

Select Case uMsg.Message
Case WM_MOUSEWHEEL
If HiWord(uMsg.wParam)>120 Then mousew=mousew-1 Else mousew=mousew+1
'update a textbox with the value of mousew for illustration purposes
FF_TextBox_SetText( HWND_FORM1_TEXT1, Str(mousew) )
End Select
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

scrollbar mouse wheel

Post by owen »

http://htwif.com/owen/FB_examples_for_f ... _wheel.zip
to scroll scroll bar with mouse wheel, position the mouse over the scroll bar and scroll away via the mouse wheel
interesting thing is that scroll bar continues to scroll by using the mouse wheel even if mouse is not over scroll bar.
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

demo of mouse wheel scrolling

Post by owen »

if you put the mouse over the axes vertical scroll bars and scroll the mouse wheel it rotates the 3d cube.
note: still hoping to be able to grab the mouse wheel for midi's

http://htwif.com/owen/FB_examples_for_f ... ad-1-8.zip
PaulSquires
Posts: 1037
Joined: Jul 14, 2005 23:41

Re: scrollbar mouse wheel

Post by PaulSquires »

owen wrote:http://htwif.com/owen/FB_examples_for_f ... _wheel.zip
to scroll scroll bar with mouse wheel, position the mouse over the scroll bar and scroll away via the mouse wheel
interesting thing is that scroll bar continues to scroll by using the mouse wheel even if mouse is not over scroll bar.
Hi owen,

If you want to limit the mousewheel messages to a single control then the best place would be to test for that message is in the scrollbar's CUSTOM message handler. In the code below, I intercept the WM_MOUSEWHEEL message and then send a WM_VSCROLL message to the scrollbar (via the parent form) to do the scrollbar scrolling. Works perfectly.

This is code modified from the project you posted in your link.

Code: Select all

'--------------------------------------------------------------------------------
Function FORM1_VSCROLL1_CUSTOM ( _
                               ControlIndex  As Integer,  _  ' index in Control Array
                               hWndForm      As HWND, _      ' handle of Form
                               hWndControl   As HWND, _      ' handle of Control
                               wMsg          As Integer,  _  ' type of message
                               wParam        As WPARAM, _    ' first message parameter
                               lParam        As LPARAM   _   ' second message parameter
                               ) As Integer
Select Case wMsg
    Case WM_MOUSEWHEEL

       Dim nScrollCount As Integer = 3 
       Dim y As Integer 

       If (LoWord(wParam) And MK_MBUTTON) <> MK_MBUTTON Then 
          ' vertical scroll
          For y = 1 To nScrollCount
             ' Are we scrolling up or down?
             If HiWord(wParam) > 120 Then    
                 ' scroll down
                 SendMessage hWndForm, WM_VSCROLL, MakeLong(SB_LINEDOWN,  0), HWND_FORM1_VSCROLL1
             Else
                 ' scroll up
                 SendMessage hWndForm, WM_VSCROLL, MakeLong(SB_LINEUP,  0), HWND_FORM1_VSCROLL1
             End If
                 
          Next
       End If

    Case 512
        mousew=0
        FF_Control_SetFocus( HWND_FORM1_VSCROLL1 )    
    Case 522
        Dim As Integer sbp
        sbp=FF_ScrollBar_GetPos( hWndControl )
        Select Case mousew
            Case Is > 0
                sbp=sbp-1
            Case Is < 0
                sbp=sbp+1
        End Select
        FF_ScrollBar_SetPos( hWndControl, sbp, True )
        mousew=0
End Select
FF_TextBox_SetText( HWND_FORM1_TEXT1, "vertical scroll bar" )
End Function
 
spodhaje
Posts: 38
Joined: Oct 25, 2007 14:05

Post by spodhaje »

Nice work. The visual designer works well. I do have a question regarding the code generator. Actually, I'm not sure if this is a problem with Firefly 3.09 or FB 0.21.1, but the FireFly generated code for the LVN_ITEMCHANGED function uses NM_LISTVIEW which is not defined in commctl.bi.

Code: Select all

Function FORM1_LISTVIEW1_LVN_ITEMCHANGED ( _
     ControlIndex  As Integer,         _  ' index in Control Array
     hWndForm      As HWND,            _  ' handle of Form
     hWndControl   As HWND,            _  ' handle of Control
     ByVal lpNMV   As NM_LISTVIEW Ptr  _  ' pointer to NM_LISTVIEW
     ) As Integer

End Function
I added the following line in FF_AppStart to resolve my problem.

Code: Select all

#Define NM_LISTVIEW NMLISTVIEW
John Spikowski
Posts: 453
Joined: Dec 24, 2005 2:32
Location: WA - USA
Contact:

Post by John Spikowski »

Hi Paul,

Have you seen this? Did you trademark the name?

FireFly
PaulSquires
Posts: 1037
Joined: Jul 14, 2005 23:41

Post by PaulSquires »

Hi John,

Yes, there are several software programs out there that use the "FireFly" moniker. That's no big deal as long as the software itself is not directly related to the area that FireFly3 is developed for (ie. visual design GUI development tools for programmers).
Jim Barlow
Posts: 43
Joined: Sep 23, 2005 0:37

Post by Jim Barlow »

I just want to say "thanks" again for making this RAD IDE and making it freely available to this community.
PaulSquires
Posts: 1037
Joined: Jul 14, 2005 23:41

Post by PaulSquires »

Jim Barlow wrote:I just want to say "thanks" again for making this RAD IDE and making it freely available to this community.
You are very welcome! :-) Happy that I can give back to the community. I still need to do more understanding of the compiler source code.....I would really like to be able to contribute more with the compiler development itself.
PaulSquires
Posts: 1037
Joined: Jul 14, 2005 23:41

Post by PaulSquires »

I will be releasing a new update very soon for FireFly Visual Designer.

If you have any bug reports then please post them now.
Post Reply