Thursday, August 5, 2010

Adaptive base class for window screen resolution



Adaptive screen resolution to make a window as an application base class of all forms. This entire process can be a good change to adapt to screen resolution. The principle is very simple to achieve, is to RESIZE the window to open when the control window and the window size, position. See the following source code, can easily understand.

1. Create a new window.

Write a function for the window f_resize () most of the work here.
No input parameters
Return value is shaping:

environment env
integer ii_ScreenWidth, ii_ScreenHeight
double WRadio, HRadio, Radio
integer ii_WinBolderWidth, ii_WinBolderHeight
getenvironment (env)
ii_WinBolderWidth = this.width - this.WorkSpaceWidth () / / get the border width of the form
ii_WinBolderHeight = this.height - this.WorkSpaceHeight ()
ii_ScreenWidth = env.screenwidth
ii_ScreenHeight = env.screenheight
/ / Compute the radio that need be resize

WRadio = ii_ScreenWidth/800 / / standard that the screen resolution of 800 * 600
HRadio = ii_ScreenHeight/600 / / calculate the relative 800 * 600 screen resolution variation
Radio = Min (WRadio, HRadio)
if Radio = 1.0 then / / if the screen is default 800 * 600
return 0
end if
this.hide ()
this.width = (this.width - ii_WinBolderWidth) * Radio + ii_WinBolderWidth
this.height = (this.height - ii_WinBolderHeight) * Radio + ii_WinBolderHeight
integer i
dragobject temp / / used to take a variety of control

for i = 1 to upperbound (this.control)
temp = this.control [i] / / adjust the size, location
temp.width = temp.width * Radio
temp.x = temp.x * Radio
temp.y = temp.y * Radio
temp.Height = temp.Height * Radio
choose case typeof (temp)
case tab!
tab mtab
mtab = temp
mtab.textsize = mtab.textsize * Radio / / set the font
case commandbutton!
commandbutton cb
cb = temp
cb.textsize = cb.textsize * Radio

case singlelineedit!
singlelineedit sle
sle = temp
sle.textsize = sle.textsize * Radio
case editmask!
editmask em
em = temp
em.textsize = em.textsize * Radio

case statictext!
statictext st
st = temp
st.textsize = st.textsize * Radio

case datawindow! / / datawindows get zoomed
datawindow dw
dw = temp
dw.Object.DataWindow.zoom = string (int (Radio * 100)) / / Note DATAWINDOW different from other control

case picturebutton!
picturebutton pb
pb = temp
pb.textsize = pb.textsize * Radio

case checkbox!
checkbox cbx
cbx = temp
cbx.textsize = cbx.textsize * Radio

case dropdownlistbox!
dropdownlistbox ddlb
ddlb = temp
ddlb.textsize = ddlb.textsize * Radio

case groupbox!
groupbox gb
gb = temp
gb.textsize = gb.textsize * Radio

case listbox!
listbox lb
lb = temp
lb.textsize = lb.textsize * Radio

case multilineedit!
multilineedit mle
mle = temp
mle.textsize = mle.textsize * Radio

case radiobutton!
radiobutton rb
rb = temp
rb.textsize = rb.textsize * Radio

end choose
next
this.show ()
return 0

Function written after the events in the form of OPEN can call the function.







Recommended links:



Mp4 to 3gp converter free



Media Player display track Time error



evaluation COVERT Surveillance



Icon Tools Wizard



Evaluate Trace And Ping Tools



Who won the dream of the vast cultural Kai



Liu Xu Micro Point: There Will Be More Soon To Be Opened Insider



convert mov to wmv free



Chang: The Heart of Love



With JSF + Spring + IBatis Build A Simple Framework



M4a to m4r



System Utilities Wizard



Guanqunjinchen Company Successfully Completed The Task The National Security



Senior Advanced: 12 strokes overall speed of your Firefox 3.5



World Cup Counterparts: Illustrator Drawing Three Cases Of Football



m4v



Dan Zhongshao: I want to lead by two years