PowerBASIC Peer Support Forums
 

Go Back   PowerBASIC Peer Support Forums > User to user Discussions > Dynamic Dialog Tools (DDT)

Dynamic Dialog Tools (DDT) Discussion is limited to GUI development using DDT. Comments about SDK programming are allowed only for functionality which enhances DDT.

Reply
 
Thread Tools Display Modes
  #1  
Old Mar 8th, 2012, 07:29 PM
Frank Thomas Frank Thomas is offline
Member
 
Join Date: Jul 2005
Posts: 164
Resizing Windows

Good day all! I've been searching around and I'm kinda stuck somewhere else.

I'm working in powerbasic forms tool and I want to create a box for the program that can be resized. If someone drags the bottom right corner, lets say, it will allow me to resize the main window and dynamically resize teh textboxes within. I'm thinking that the textboxes will be a percentage of the main window in width and height, instead of a fixed pixel value.

Also, I'd like to make sure that the user doesn't shrink the main window below a certain pixel size.

Is this possible?

Frank
Reply With Quote
  #2  
Old Mar 8th, 2012, 07:53 PM
Gary Beene Gary Beene is offline
Administrator
 
Join Date: May 2008
Location: Dallas, Tx
Posts: 12,761
Hi Frank,
The control resizing as you've described it is not something I've done. Do a search on "AutoSize Controls" and you'll find a few links of interest, such as here and here.

But, you're saying you don't want to drag the main dialog to resize all of the controls inside? Instead, you want to drag on a box? Where would the box be - inside the main dialog or on a popup dialog? Can you clarify a bit on this?

As for this ...
Quote:
Also, I'd like to make sure that the user doesn't shrink the main window below a certain pixel size.
Here's one approach:
Code:
'Compilable Example:
#Compiler PBWin 9, PBWin 10  Uses Example#1 method
#Compile EXE
#Dim All
#Include "Win32API.inc"
Global hDlg As Dword

Function PBMain() As Long
   Dialog New Pixels, 0, "Test Code",300,300,200,200, %WS_OverlappedWindow To hDlg
   Control Add Button, hDlg, 100,"Push", 50,10,100,20
   Dialog Show Modal hDlg Call DlgProc
End Function

CallBack Function DlgProc() As Long
   Select Case CB.Msg
      Case %WM_GETMINMAXINFO
         Local MM As MINMAXINFO Ptr
         MM=CB.lParam
         @MM.ptMinTrackSize.x=150  '<-- Min X size of your window
         @MM.ptMinTrackSize.y=150  '<-- Min Y size of your window
         @MM.ptMaxTrackSize.x=500  '<-- Max X size of your window
         @MM.ptMaxTrackSize.y=500  '<-- Max Y size of your window
   End Select
End Function
__________________
Reply With Quote
  #3  
Old Mar 8th, 2012, 07:55 PM
Gary Beene Gary Beene is offline
Administrator
 
Join Date: May 2008
Location: Dallas, Tx
Posts: 12,761
Oh, I think I get it now. While working in PBForms, you'd like there to be a "Resize All" tool that can resize a dialog and all of it's children - within the PBForms environment. You're not asking to dynamically change controls sizing while the application is running.

If so, then my bad. The links I gave you were for dynamic, runtime sizing. I don't personally use PBForms, so I'm not at all sure if what you ask is possible.
__________________

Last edited by Gary Beene; Mar 8th, 2012 at 07:58 PM.
Reply With Quote
  #4  
Old Mar 8th, 2012, 08:36 PM
Dave Biggs Dave Biggs is offline
Member
 
Join Date: Feb 2001
Location: Australia
Posts: 2,279
In PB Forms, Select an appropriate style for the dialog and add code from Gary's demo as required.
(eg %WS_THICKFRAME OR %WS_CAPTION OR %WS_MINIMIZEBOX OR %WS_MAXIMIZEBOX OR %WS_SYSMENU).

Pierre also posted a nice example here that shows how to resize the controls along with the dialog.
__________________
Rgds, Dave
Reply With Quote
  #5  
Old Mar 9th, 2012, 10:52 AM
Frank Thomas Frank Thomas is offline
Member
 
Join Date: Jul 2005
Posts: 164
Thanks guys! I searched high and low and just needed a push in the right direction. I'll have to study it for a while, but I can definitely see the code that does the job.

Thanks again!

Frank
Reply With Quote
  #6  
Old Mar 9th, 2012, 12:22 PM
Gary Beene Gary Beene is offline
Administrator
 
Join Date: May 2008
Location: Dallas, Tx
Posts: 12,761
Hey Frank,
I'm still no clear on what you want. Do you want the user to resize the application, and have the controls resize proportionally? Or do you want to do the resizing in the design phase, within PBForms?

Another issue to remember, is that resizing the controls does not automatically resize the fonts the controls use. You could wind up a big control, but with the original font size - which might not be what you want.

Can you give a little more description of what your needs are?
__________________
Reply With Quote
  #7  
Old Mar 9th, 2012, 08:04 PM
Walt Thompson Walt Thompson is offline
Member
 
Join Date: Jan 2004
Location: San Jose, CA
Posts: 501
Hi Frank;

Quote:
Another issue to remember, is that resizing the controls does not automatically resize the fonts the controls use. You could wind up a big control, but with the original font size - which might not be what you want.
The corollary to Gary's statement; Is you could wind up with a small control whose font is too large to fit on the control.

If you are trying to create a user re-sizable GUI, try creating the user controls as bitmaps. That way the control and its text are re-sized simultaenously and proportionately.
Reply With Quote
  #8  
Old Apr 1st, 2012, 11:03 PM
Ingo Maurischat Ingo Maurischat is offline
Member
 
Join Date: Aug 2005
Posts: 9
extendet auto size

Here is another solution to resize the dialog and the controls within the dialog. Also the fonts of the buttons will be resized.

1. creating the controlls e.g.

CONTROL ADD BUTTON, hDlg, %IDC_BUTTON1, "Button 1", 1,1,1,1
CONTROL ADD BUTTON, hDlg, %IDC_BUTTON2, "Button 2", 1,1,1,1
CONTROL ADD BUTTON, hDlg, %IDC_BUTTON3, "Button 3", 1,1,1,1
CONTROL ADD TEXTBOX, hDlg, %IDC_TEXTBOX, "auto-size sample ", 1,1,1,1

2. in CASE %WM_SIZE
IF CB.WPARAM <> %SIZE_MINIMIZED THEN
ResizeDialog ( CB.HNDL )
END IF

3. ResizeDialog

ResizeControl (hDlg, %IDC_TEXTBOX,3, 4, 45,38, 2)
ResizeControl (hDlg, %IDC_BUTTON1,85, 35, 10,6 , 1.1)
ResizeControl (hDlg, %IDC_BUTTON2,85, 42, 10,6 , 1.3)
ResizeControl (hDlg, %IDC_BUTTON3,85, 49, 10,6, 1.5 )

4. The ResizeControl function

SUB ResizeControl ( BYVAL hDlg AS DWORD, _
control_id AS INTEGER, _
control_col_upper_left_corner_in_percent AS INTEGER, _
control_row_upper_left_corner_in_percent AS INTEGER, _
control_width_factor_in_percent AS INTEGER, _
control_height_factor_in_percent AS INTEGER, _
new_font_size_factor AS DOUBLE )


LOCAL new_fontSize AS INTEGER

DIALOG GET SIZE hDlg TO global_var.dialog_window_new_width, global_var.dialog_window_new_height


global_var.percent = ( global_var.dialog_window_new_height - global_var.dialog_window_init_height ) / _
( global_var.dialog_window_init_height / 100 )

new_fontSize = global_var.fontSize + (( global_var.fontSize / 100 ) * global_var.percent )
new_fontSize *= new_font_size_factor

CONTROL SET LOC hDlg, control_id, _
global_var.dialog_window_new_width - ( global_var.dialog_window_new_width / 100 ) * ( 100 - control_col_upper_left_corner_in_percent ), _
global_var.dialog_window_new_height - ( global_var.dialog_window_new_height / 100 ) * ( 100 - control_row_upper_left_corner_in_percent )

CONTROL SET SIZE hDlg, control_id, _
global_var.dialog_window_new_width - ( global_var.dialog_window_new_width / 100 ) * ( 100 - control_width_factor_in_percent ), _
global_var.dialog_window_new_height - ( global_var.dialog_window_new_height / 100 ) * ( 100 - control_height_factor_in_percent )


FONT NEW "Times New Roman", new_fontSize, 0 TO global_var.hFont

IF global_var.percent > 50 THEN
FONT NEW "Lucida Console", 20, 0 TO global_var.gFont
ELSE
FONT NEW "Lucida Console", 10, 1 TO global_var.gFont
END IF

CONTROL SET FONT hDlg, control_id, global_var.hFont
GRAPHIC SET FONT global_var.gFont

END SUB


I put the whole sample in the source code section here http://www.powerbasic.com/support/pb...ad.php?t=50020

Last edited by Ingo Maurischat; Apr 1st, 2012 at 11:15 PM.
Reply With Quote
  #9  
Old Apr 1st, 2012, 11:55 PM
Gary Beene Gary Beene is offline
Administrator
 
Join Date: May 2008
Location: Dallas, Tx
Posts: 12,761
Hi Ingo,
Thanks for the code you posted.

Just in case you weren't aware, the "#" symbol on the forum page when in reply edit mode will paste code tags into the edit field around any selected text. That will give you this look on the post, which is easier for us to read:
Code:
Test Code Line
__________________
Reply With Quote
  #10  
Old Apr 6th, 2012, 06:23 PM
Fred Buffington Fred Buffington is offline
Member
 
Join Date: Dec 2003
Location: Oklahoma USA
Posts: 1,388
Great code guys.

If anyone is interested, (probably not) but I copied the example also into my 6.0 version and made it pretty much compatible with that too.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:10 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 1999-2011 PowerBASIC, Inc. All Rights Reserved.
Error in my_thread_global_end(): 1 threads didn't exit