OK, so I have a very large form (100 textboxes), and in FF editor, I can stretch the boundaries of the form so that all fields are visible. However, I have to use the editor's Vscrollbar to see the bottom controls...
But when I compile and execute, the main form displays, including both Hscroll and Vscroll bars (yes, I selected them in the form's extended properties), BUT although the scroll bars DO appear, they do nothing, and I cannot determine how to make them function.
???
-JohnM
The answer (well, the technique that I use) is not as easy as I think you would like it to be. I create a child form and place all my controls on that form. I respond to the WM_HSCROLL or WM_VSCROLL messages and use SetWindowPos api to move the child form left, right, up or down depending on what scroll is specified. For HSCROLL I handle %SB_LINELEFT, %SB_PAGELEFT, %SB_LINERIGHT, %SB_PAGERIGHT and %SB_THUMBTRACK. For VSCROLL I handle %SB_LINEUP, %SB_PAGEUP, %SB_LINEDOWN, %SB_PAGEDOWN and %SB_THUMBTRACK.
A sample, demo project showing how all of this works would be pretty cool. Wish I had one to share right now. The only code that I have is the code within FF that scrolls the design window so that you can design forms that are larger than the current screen size.
Anyone out there have something they can quickly share? If not, then I'll try to put something together. It's a bit of work for sure.
....100 textboxes? Why not use a grid control? Wait, I see some other posts from you about testboxes.... I better read those first.
zScrollBar works pretty good, you can find details here:
http://www.powerbasic.com/support/pbforums/showthread.php?t=51359&highlight=zScrollBar.inc
Wow, that's pretty amazing! Got it running in native PB, now need to figure out how to incorporate into my FF code...
Thanks a bunch, Ian, for that link! (And to Philip Zeller for that code!)
-JohnM
OK, so I copied the code from the PBMAIN function into my FF test project under frmMain's Create function, and just copied the callback into the frmMain too. In FF_AppStart I put the #INCLUDE, and
the sample code ran. When I closed it, my FF code ran.
So now that I know it doesn't conflict with FF, I'll have to take some time over the next few days to see how I can integrate it with the actual app... I hope to have it working over the weekend.
I'll let you know what I learn...
-JohnM
John,
Put something like this in the WM_Create section of the form:
'initailise the dialog size
zScrollbar hWndForm, %WM_INITDIALOG , screenwidth, screenheight 'provides more vertical work space
Where screenwidth and screenheight are your new sizes - bigger than your visible form.
You can use something like this to get the current viewable area (there might be better ways):
Local rc As Rect
SystemParametersInfo( %SPI_GETWORKAREA,ByVal 0, ByVal VarPtr(rc),ByVal 0) 'this retrieves the work area ie the area of the screen that isn't Task bar
screenwidth =rc.nright-rc.nleft
etc.........
Ian.
Thanks, Ian, I'll be trying out these suggestions over the weekend and report back...
-JohnM
I have the code working in PB, but I'm wondering where I'd put it in FF?
CallBack Function dlgProc_Main() As Long
Select Case Cb.Msg
Case %WM_MouseWheel : zScrollBar Cb.Hndl, Cb.Msg, Cb.WParam
Case %WM_InitDialog : zScrollbar Cb.Hndl, Cb.Msg, 2000, 1500
Case %WM_Size : zScrollBar Cb.Hndl, Cb.Msg
Case %WM_VScroll : zScrollBar Cb.Hndl, Cb.Msg, Cb.WParam
Case %WM_HScroll : zScrollBar Cb.Hndl, Cb.Msg, Cb.WParam
End Select
End Function
IOW, how do I tap into FF's callback for the form? I know about FF_AppStart and FF_WinMain, but I'm not sure how to adapt the above code for FF to see and use...
If this requires editing the CODEGEN files, then it's probably not an approach I want to take...
-JohnM
You should put that code in the CUSTOM message handler for the FORM.
FireFly does not use the DDT syntax so you would need to modify things like Cb.Hndl, Cb.Msg, etc...
Thanks Paul, and Ian, and everyone!!
This is working like a charm! For posterity, here's the code converted from above:
Function FRMMAIN_WM_CREATE ( _
hWndForm As Dword, _ ' handle of Form
ByVal UserData As Long _ ' optional user defined Long value
) As Long
'use something like this to get the current viewable area (there might be better ways):
Local rc As Rect
Local ScreenWidth, ScreenHeight As Long
SystemParametersInfo( %SPI_GETWORKAREA,ByVal 0, ByVal VarPtr(rc),ByVal 0)
'this retrieves the work area ie the area of the screen that isn't Task bar
ScreenWidth = rc.nright-rc.nleft
ScreenHeight = rc.nbottom-rc.ntop
'initialize the dialog size
zScrollbar hWndForm, %WM_INITDIALOG , ScreenWidth + 300, ScreenHeight + 500 'provides more work space
'Where ScreenWidth and ScreenHeight are your new sizes - bigger than your visible form.
End Function
'--------------------------------------------------------------------------------
Function FRMMAIN_CUSTOM ( _
hWndForm As Dword, _ ' handle of Form
wMsg As Long, _ ' type of message
wParam As Dword, _ ' first message parameter
lParam As Long _ ' second message parameter
) As Long
Select Case wMsg
Case %WM_MouseWheel : zScrollBar hWndForm, wMsg, wParam
Case %WM_InitDialog : zScrollbar hWndForm, wMsg, 2000, 1500
Case %WM_Size : zScrollBar hWndForm, wMsg
Case %WM_VScroll : zScrollBar hWndForm, wMsg, wParam
Case %WM_HScroll : zScrollBar hWndForm, wMsg, wParam
End Select
End Function
And remember to put these lines into FF_AppStart:
#INCLUDE "Win32api.inc
#INCLUDE "zScrollBar.inc"
We have progress!!! I still have a lot of tweaking to do, but the "get it working" hurdle is past!
Thanks again!
-JohnM
P.S. AND... I didn't have to ask where to find the CUSTOM handler -- I was able to click on the black text after searching... ;D
WM_INITDIALOG in a SDK application? :o
Jose,
This is the difference between someone like myself who uses programming in their work and
someone like yourself, who's work *is* programming.
I find a solution that works and stick with it until something better comes along.
So, if you can point me towards the proper way, I will be more than happy to use it.
Ian.