• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 641
  • Last Modified:

Window resize without using hard coded values

I have a window which has more than 15 controls and I need to add code that will work with any machine. I think that if I use the hard coded value it may not properly in some machines with different resolutions. Could anybody tell me whether there is any way I can achieve this?
0
lalitha_sabesan
Asked:
lalitha_sabesan
  • 3
1 Solution
 
michaelstoffelCommented:
Is your application PFC based.  The resize service makes it easy, even works with fields in DWs.  If it is not PFC based, there are some examples on CodeXchange.

Remember to design your GUI around the lowest resolution you'll support.

0
 
gafoor78Commented:
Hi lalitha,

If you are not using PFC, i have a user object, that you can use in any window.  this will dynamically resize and will work in any machine with any resolution.

i will past the exported syntax here as next comment... copy the whole code into a text file and save as some name.sru(eg : u_resize.sru) then import this file into ur pbl and check the 'constructor' event of the object to understand how it works

Regrads
Gaf
0
 
gafoor78Commented:
$PBExportHeader$u_resize.sru
forward
global type u_resize from nonvisualobject
end type
end forward

global type u_resize from nonvisualobject autoinstantiate
end type

type variables
private:

boolean ib_previewzoom = false
boolean ib_datazoom = false
end variables

forward prototypes
public subroutine of_resize (window aw_window)
public subroutine of_settag (window aw_window)
public subroutine of_setpreviewzoom (boolean ab_status)
public subroutine of_setdatazoom (boolean ab_status)
end prototypes

public subroutine of_resize (window aw_window);integer xx,found1,found2
decimal x,y,w,h, zf
windowobject control[]
control = aw_window.control

for xx=1 to upperbound(control)
   if control[xx].tag<>"" then

     // extract tagged values

      found1=pos(control[xx].tag,"$",1);
            y=real(mid(control[xx].tag,1,found1 -1))
            
      found2=pos(control[xx].tag,"$",found1 +1)
            x=real(mid(control[xx].tag,found1 +1,found2 -(found1+1)))
            
      found1=pos(control[xx].tag,"$",found2+1)
            h=real(mid(control[xx].tag,found2+1,found1 - (found2+1)))
            
            
            IF control[xx].typeof() = DataWindow! THEN
                  found2=pos(control[xx].tag,"$",found1 +1)
                  w=real(mid(control[xx].tag,found1 +1,found2 -(found1+1)))
            zf=real(mid(control[xx].tag,found2+1,len(control[xx].tag)-(found2+1)))
                  
                  zf = aw_window.workspacewidth()*zf
            ELSE
            w=real(mid(control[xx].tag,found1+1,len(control[xx].tag)-(found1+1)))
            END IF

     // dynamically adjust control

      y=aw_window.workspaceheight()*y
      h=aw_window.workspaceheight()*h
      x=aw_window.workspacewidth()*x
      w=aw_window.workspacewidth()*w

   choose case control[xx].typeof()
      case Commandbutton!
         Commandbutton cb
         cb=create commandbutton
         cb=control[xx]
         cb.y=y;cb.x=x;cb.width=w;cb.height=h
                  
      case DropDownListBox!
         DropDownListBox ddlb
         ddlb=create dropdownlistbox
         ddlb=control[xx]
         ddlb.y=y;ddlb.x=x;ddlb.width=w;ddlb.height=h

      case CheckBox!
         CheckBox cbx
         cbx=create checkbox
         cbx=control[xx]
         cbx.y=y;cbx.x=x;cbx.width=w;cbx.height=h

      case GroupBox!
         GroupBox gb
         gb=create groupbox
         gb=control[xx]
         gb.y=y;gb.x=x;gb.width=w;gb.height=h

      case HScrollBar!
         HScrollBar hsb
         hsb=create hscrollbar
         hsb=control[xx]
         hsb.y=y;hsb.x=x;hsb.width=w;hsb.height=h

      case Oval!
         Oval GOval
         goval=create oval
         goval=control[xx]
         goval.y=y;goval.x=x;goval.width=w;goval.height=h

      case Picture!
         Picture GPicture
         gpicture=create picture
         gpicture=control[xx]
         gpicture.y=y;gpicture.x=x;gpicture.width=w;gpicture.height=h

      case PictureButton!
         PictureButton pb
         pb=create picturebutton
         pb=control[xx]
         pb.y=y;pb.x=x;pb.width=w;pb.height=h

      case RadioButton!
         RadioButton rb
         rb=create radiobutton
         rb=control[xx]
         rb.y=y;rb.x=x;rb.width=w;rb.height=h

      case Rectangle!
         Rectangle GRectangle
         grectangle=create rectangle
         grectangle=control[xx]
         grectangle.y=y;grectangle.x=x;grectangle.width=w;grectangle.height=h

      case RoundRectangle!
         RoundRectangle GRRectangle
         grrectangle=create roundrectangle
         grrectangle=control[xx]
         grrectangle.y=y;grrectangle.x=x;grrectangle.width=w;grrectangle.height=h


      case SingleLineEdit!
         SingleLineEdit sle
         sle=create singlelineedit
         sle=control[xx]
         sle.y=y;sle.x=x;sle.width=w;sle.height=h

      case StaticText!
         StaticText st
         st=create statictext
         st=control[xx]
         st.y=y;st.x=x;st.width=w;st.height=h

      case VScrollBar!
         VScrollBar vsb
         vsb=create vscrollbar
         vsb=control[xx]
         vsb.y=y;vsb.x=x;vsb.width=w;vsb.height=h

      case Datawindow!
         Datawindow dw
         dw=create datawindow
         dw=control[xx]
         dw.y=y;dw.x=x;dw.width=w;dw.height=h
                  
                  //  this instance variable can set or reset thru the function of_setpreviewzoom(ab_status)
                  if ib_previewzoom then
                        dw.Object.DataWindow.print.preview.Zoom = Integer(zf)
                  end if
                  
                  //  this instance variable can set or reset thru the function of_setdatazoom(ab_status)
                  if ib_datazoom then
                        dw.Object.DataWindow.Zoom = Integer(zf)
                  end if
                  
      case EditMask!
         EditMask em
         em=create editmask
         em=control[xx]
         em.y=y;em.x=x;em.width=w;em.height=h

      case Graph!
         Graph Gph
         gph=create graph
         gph=control[xx]
         gph.y=y;gph.x=x;gph.width=w;gph.height=h

      case Line!
         Line GLine
         gline=create line
         gline=control[xx]
         gline.beginy=y;gline.beginx=x;gline.endx=w;gline.endy=h

      case ListBox!
         ListBox lb
         lb=create listbox
         lb=control[xx]
         lb.y=y;lb.x=x;lb.width=w;lb.height=h

      case MultiLineEdit!
         MultiLineEdit mle
         mle=create multilineedit
         mle=control[xx]
         mle.y=y;mle.x=x;mle.width=w;mle.height=h
            
      case UserObject!
         UserObject uo
         uo=create UserObject
         uo=control[xx]
         uo.y=y;uo.x=x;uo.width=w;uo.height=h

   end choose

   end if
next
end subroutine

public subroutine of_settag (window aw_window);integer xx
windowobject obj
windowobject control[]

control = aw_window.control

//
// tag value saved in form: Y,X,Height,Width
//

//
// WE SCAN EVERY CONTROL ON THE CURRENT WINDOW AND BUILD UP A TAGS
// LIST FOR EACH OBJECT THAT WE WISH TO RESIZE DYNAMICALLY.
//

for xx=1 to upperbound(control)
   choose case control[xx].typeof()
      case Commandbutton!
         Commandbutton cb
         cb=create commandbutton
         cb=control[xx]
         cb.tag=string(cb.y/aw_window.workspaceheight())+"$"+&
                string(cb.x/aw_window.workspacewidth()) +"$"+&
                string(cb.height/aw_window.workspaceheight()) +"$"+&
                string(cb.width/aw_window.workspacewidth())
      case DropDownListBox!
         DropDownListBox ddlb
         ddlb=create dropdownlistbox
         ddlb=control[xx]
         ddlb.tag=string((ddlb.y/aw_window.workspaceheight()))+"$"+&
                  string((ddlb.x/aw_window.workspacewidth())) +"$"+&
                  string((ddlb.height/aw_window.workspaceheight())) +"$"+&
                  string((ddlb.width/aw_window.workspacewidth()))

      case CheckBox!
         CheckBox cbx
         cbx=create checkbox
         cbx=control[xx]
         cbx.tag=string((cbx.y/aw_window.workspaceheight()))+"$"+&
                 string((cbx.x/aw_window.workspacewidth())) +"$"+&
                 string((cbx.height/aw_window.workspaceheight())) +"$"+&
                 string((cbx.width/aw_window.workspacewidth()))


      case GroupBox!
         GroupBox gb
         gb=create groupbox
         gb=control[xx]
         gb.tag=string((gb.y/aw_window.workspaceheight()))+"$"+&
                string((gb.x/aw_window.workspacewidth())) +"$"+&
                string((gb.height/aw_window.workspaceheight())) +"$"+&
                string((gb.width/aw_window.workspacewidth()))


      case HScrollBar!
         HScrollBar hsb
         hsb=create hscrollbar
         hsb=control[xx]
         hsb.tag=string((hsb.y/aw_window.workspaceheight()))+"$"+&
                 string((hsb.x/aw_window.workspacewidth())) +"$"+&
                 string((hsb.height/aw_window.workspaceheight())) +"$"+&
                 string((hsb.width/aw_window.workspacewidth()))


      case Oval!
         Oval GOval
         goval=create oval
         goval=control[xx]
         goval.tag=string((goval.y/aw_window.workspaceheight()))+"$"+&
                string((goval.x/aw_window.workspacewidth())) +"$"+&
                string((goval.height/aw_window.workspaceheight())) +"$"+&
                string((goval.width/aw_window.workspacewidth()))


      case Picture!
         Picture GPicture
         gpicture=create picture
         gpicture=control[xx]
         gpicture.tag=string((gpicture.y/aw_window.workspaceheight()))+"$"+&
                string((gpicture.x/aw_window.workspacewidth())) +"$"+&
                string((gpicture.height/aw_window.workspaceheight())) +"$"+&
                string((gpicture.width/aw_window.workspacewidth()))



      case PictureButton!
         PictureButton pb
         pb=create picturebutton
         pb=control[xx]
         pb.tag=string((pb.y/aw_window.workspaceheight()))+"$"+&
                string((pb.x/aw_window.workspacewidth())) +"$"+&
                string((pb.height/aw_window.workspaceheight())) +"$"+&
                string((pb.width/aw_window.workspacewidth()))


      case RadioButton!
         RadioButton rb
         rb=create radiobutton
         rb=control[xx]
         rb.tag=string((rb.y/aw_window.workspaceheight()))+"$"+&
                string((rb.x/aw_window.workspacewidth())) +"$"+&
                string((rb.height/aw_window.workspaceheight())) +"$"+&
                string((rb.width/aw_window.workspacewidth()))


      case Rectangle!
         Rectangle GRectangle
         grectangle=create rectangle
         grectangle=control[xx]
         grectangle.tag=string((grectangle.y/aw_window.workspaceheight()))+"$"+&
                string((grectangle.x/aw_window.workspacewidth())) +"$"+&
                string((grectangle.height/aw_window.workspaceheight())) +"$"+&
                string((grectangle.width/aw_window.workspacewidth()))



      case RoundRectangle!
         RoundRectangle GRRectangle
         grrectangle=create roundrectangle
         grrectangle=control[xx]
         grrectangle.tag=string((grrectangle.y/aw_window.workspaceheight()))+"$"+&
                string((grrectangle.x/aw_window.workspacewidth())) +"$"+&
                string((grrectangle.height/aw_window.workspaceheight())) +"$"+&
                string((grrectangle.width/aw_window.workspacewidth()))



      case SingleLineEdit!
         SingleLineEdit sle
         sle=create singlelineedit
         sle=control[xx]
         sle.tag=string((sle.y/aw_window.workspaceheight()))+"$"+&
                string((sle.x/aw_window.workspacewidth())) +"$"+&
                string((sle.height/aw_window.workspaceheight())) +"$"+&
                string((sle.width/aw_window.workspacewidth()))


      case StaticText!
         StaticText st
         st=create statictext
         st=control[xx]
         st.tag=string((st.y/aw_window.workspaceheight()))+"$"+&
                string((st.x/aw_window.workspacewidth())) +"$"+&
                string((st.height/aw_window.workspaceheight())) +"$"+&
                string((st.width/aw_window.workspacewidth()))


      case VScrollBar!
         VScrollBar vsb
         vsb=create vscrollbar
         vsb=control[xx]
         vsb.tag=string((vsb.y/aw_window.workspaceheight()))+"$"+&
                string((vsb.x/aw_window.workspacewidth())) +"$"+&
                string((vsb.height/aw_window.workspaceheight())) +"$"+&
                string((vsb.width/aw_window.workspacewidth()))

      case Datawindow!
         Datawindow dw
         dw=create datawindow
         dw=control[xx]
         dw.tag=string((dw.y/aw_window.workspaceheight()))+"$"+&
                string((dw.x/aw_window.workspacewidth())) +"$"+&
                string((dw.height/aw_window.workspaceheight())) +"$"+&
                string((dw.width/aw_window.workspacewidth())) +"$"+&
                string((100/aw_window.workspacewidth()))


      case EditMask!
         EditMask em
         em=create editmask
         em=control[xx]
         em.tag=string((em.y/aw_window.workspaceheight()))+"$"+&
                string((em.x/aw_window.workspacewidth())) +"$"+&
                string((em.height/aw_window.workspaceheight())) +"$"+&
                string((em.width/aw_window.workspacewidth()))

      case Graph!
         Graph Gph
         gph=create graph
         gph=control[xx]
         gph.tag=string((gph.y/aw_window.workspaceheight()))+"$"+&
                string((gph.x/aw_window.workspacewidth())) +"$"+&
                string((gph.height/aw_window.workspaceheight())) +"$"+&
                string((gph.width/aw_window.workspacewidth()))


      case Line!
         Line GLine
         gline=create line
         gline=control[xx]
         gline.tag=string((gline.beginy/aw_window.workspaceheight()))+"$"+&
                string((gline.beginx/aw_window.workspacewidth())) +"$"+&
                string((gline.endy/aw_window.workspaceheight())) +"$"+&
                string((gline.endx/aw_window.workspacewidth()))


      case ListBox!
         ListBox lb
         lb=create listbox
         lb=control[xx]
         lb.tag=string((lb.y/aw_window.workspaceheight()))+"$"+&
                string((lb.x/aw_window.workspacewidth())) +"$"+&
                string((lb.height/aw_window.workspaceheight())) +"$"+&
                string((lb.width/aw_window.workspacewidth()))

      case MultiLineEdit!
         MultiLineEdit mle
         mle=create multilineedit
         mle=control[xx]
         mle.tag=string((mle.y/aw_window.workspaceheight()))+"$"+&
                string((mle.x/aw_window.workspacewidth())) +"$"+&
                string((mle.height/aw_window.workspaceheight())) +"$"+&
                string((mle.width/aw_window.workspacewidth()))

      case UserObject!
         UserObject uo
         uo=create UserObject
         uo=control[xx]
         uo.tag=string((uo.y/aw_window.workspaceheight()))+"$"+&
                string((uo.x/aw_window.workspacewidth())) +"$"+&
                string((uo.height/aw_window.workspaceheight())) +"$"+&
                string((uo.width/aw_window.workspacewidth()))

   end choose
next




end subroutine

public subroutine of_setpreviewzoom (boolean ab_status);ib_previewzoom = ab_status
end subroutine

public subroutine of_setdatazoom (boolean ab_status);ib_datazoom = ab_status
end subroutine

on u_resize.create
TriggerEvent( this, "constructor" )
end on

on u_resize.destroy
TriggerEvent( this, "destructor" )
end on

event constructor;///////////////////////////////////////////////////////////
//
//  Author --- Gafoor
//  Date   --- 14/09/2003
//
//
// do following codes to use this at any window
//
///////////////////////////////////////////////////////////

// 1. Declare an instance variable  

   // u_resize iuo_resize


// 2. In the open event of the window

   // iuo_resize = CREATE u_resize
   // iuo_resize.of_setTag(this)
      
// 3. In the resize event of the window

      // iuo_resize.of_resize(this)



// 4. In close event of the window

  //  DESTROY iuo_resize
 
// 5. to set or reset datawindow print preview zoom call of_setpreviewzoom(boolean)    
//    true -> set , false -> reset

// 6. to set or reset datawindow data zoom call of_setdatazoom(boolean)                  
//    true -> set , false -> reset        
end event

0
 
lalitha_sabesanAuthor Commented:
The above worked after I added Tab controls to the functions.
 Thanks.
Lalitha
0
 
gafoor78Commented:
Yes! i missed the tab control....

thanks for the grading and point.

0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now