simple question about making a form a fixed size

Started by Patrick Harvey, November 23, 2004, 09:08:05 PM

Previous topic - Next topic

Patrick Harvey

Hello all:

I am new to FireFly and would like to know what property to choose to keep a form's size fixed....  I don't want people pulling the sides of the form/program larger when the program is running.  thanks

Patrick

Jose Roca


John Fitz

Patrick,

If you want to keep the WS_THICKFRAME style, you could also add this code to the %WM_GETMINMAXINFO message:

       ' Don't allow dialog resize
       Dim MinMaxPtr As MINMAXINFO Ptr
       MinMaxPtr = lParam
       @MinMaxPtr.ptMinTrackSize.x = FF_TwipsToPixels(7170)
       @MinMaxPtr.ptMinTrackSize.y = FF_TwipsToPixels(6930)
       @MinMaxPtr.ptMaxTrackSize.x = FF_TwipsToPixels(7170)
       @MinMaxPtr.ptMaxTrackSize.y = FF_TwipsToPixels(6930)

The values are the original form dimensions.

Art Araya

Total FF newbie here.  I need to do something like this.  But I only want to restrict the height from being changed.  How do I do that?  Where do I place your sample code John?  In the Form's WM_COMMAND?  Furthermore, where  is lParam coming from?  This is  not passed into WM_COMMAND.

I warned you that I was a total newbie!

:D

TechSupport

Place the following in the Form's CUSTOM message (because FireFly does not provide a separate message handler for WM_GETMINMAXINFO)


Function FORM1_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_GETMINMAXINFO

       ' Don't allow dialog resize
       Dim MinMaxPtr As MINMAXINFO Ptr
       MinMaxPtr = lParam
       @MinMaxPtr.ptMinTrackSize.x = 300
       @MinMaxPtr.ptMinTrackSize.y = 300
       @MinMaxPtr.ptMaxTrackSize.x = 10000
       @MinMaxPtr.ptMaxTrackSize.y = 300
                       
End Select

End Function


You need to play with the values (pixels) to suit what you need. If you don't want the height to change then simply set the ptMinTrackSize.y value equal to the ptMaxTrackSize.y value.

lParam is a pointer to the MINMAXINFO structure.

gian young

I had a similar and possibly related question answered for me some weeks ago by and courtesy of Roger Garstang. I thought it may be relavent to post the code here for anyone's interest.

Place the following in the Forms FORM_WM_CREATE command

Local lngSystemMenu As Long
   
'This code prevents the Form being resized or dragged by the user.
lngSystemMenu = GetSystemMenu(HWND_FORM1, 0)
RemoveMenu lngSystemMenu, %SC_SIZE, %MF_BYCOMMAND 'no resize
RemoveMenu lngSystemMenu, %SC_MOVE, %MF_BYCOMMAND 'no move



Gian Young
Dataman Barcode Systems Australia

Roger Garstang

Yeah, I think ever since I found out about GetSystemMenu I put it in all my apps in some way.  Works pretty slick to add items too like a Hide item to the menu like Tray Apps have, etc.  You just have to remember that the SysCommand messages are ANDed with a value on processing and the value you assign needs to work when ANDed.

John Dunbar

Gian, thank you very much for that code. I took that idea and added a general purpose System Menu toggle function for a program I'm working on. This allows various options to be set independently.  The code is below. Any comments or improvements?

Roger, what did you mean by menu HIDE in the SysTray?

John Dunbar

----

'AT TOP of FRMMAIN (my main form)

Global gNSwitches%


'INSIDE of FRMMAIN_WM_CREATE()

   gNSwitches = &H00   '0000 0000


'INSIDE of FRMMAIN_CHKBOX_BN_CLICKED()
   
   Bit Toggle gnSwitches,2 ' Xor &H2    '0000 ~~1~  No Resize

   'can have multiple of these or separate them out into various checkboxes
   Bit Toggle gnSwitches,4 ' Xor &H8    '0000 1~~~  No Move

   RepaintSysMenu


Sub RepaintSysMenu()
'see GetSystemMenu topics at msdn.microsoft.com for documentation.

   Local lngSystemMenu&
   'reset system menu to defaults (all functions on), returns NULL if successful, NOTE: this is not a handle
   lngSystemMenu = GetSystemMenu(HWND_FRMMAIN, %True)
   'get the handle to an untouched menu, returns handle if successful
   lngSystemMenu = GetSystemMenu(HWND_FRMMAIN, %False)
   If Bit(gnSwitches,1) Then            '~~~1 No Maximize
      RemoveMenu lngSystemMenu, %SC_MAXIMIZE, %MF_GRAYED Or %MF_BYCOMMAND 'no Maximize      
   ElseIf Bit(gnSwitches,2) Then         '~~1~ No Resize
      RemoveMenu lngSystemMenu, %SC_SIZE, %MF_GRAYED Or %MF_BYCOMMAND 'no Maximize      
   ElseIf Bit(gnSwitches,3) Then         '~1~~ No Minimize
      RemoveMenu lngSystemMenu, %SC_MINIMIZE, %MF_GRAYED Or %MF_BYCOMMAND 'no Maximize      
   ElseIf Bit(gnSwitches,4) Then         '1~~~ No Move
      RemoveMenu lngSystemMenu, %SC_MOVE, %MF_GRAYED Or %MF_BYCOMMAND 'no Maximize      
   End If   

End Sub

----

Roger Garstang

I meant using the handle returned to add an item to the System Menu, like a Hide Menu item, that way you click Minimize to minimize and Hide to have the window go to the Tray and no Taskbar icon, etc.  You'd have to process Hide and do those things of course as it isn't a built in function.  You can also add built in functions that are in the WinAPI inc files like starting the screensaver, etc.

Also, you don't use %MF_GRAYED with RemoveMenu.  There shouldn't be a reason to reset the menu if you only call the function once too, but for reusing the function it should.

John Dunbar

Roger, thanks for the further comments on Hide/Taskbar, etc.

You're right on not using the  %MF_GRAYED.  I had left that in there after playing with EnableMenuItem(). I wanted to allow the user to switch back and forth and that's why I wrote the routine, and as you mentioned that's why I had to reset the menu. Otherwise it didn't work.

John