PB让窗口在不同的分辨率下自动调整大小+自动列宽.doc_第1页
PB让窗口在不同的分辨率下自动调整大小+自动列宽.doc_第2页
PB让窗口在不同的分辨率下自动调整大小+自动列宽.doc_第3页
PB让窗口在不同的分辨率下自动调整大小+自动列宽.doc_第4页
PB让窗口在不同的分辨率下自动调整大小+自动列宽.doc_第5页
已阅读5页,还剩11页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

武汉高达软件系统有限公司WUHAN GOLDEN SOFTWARE SYSTEM CO.,LTDPB让窗口在不同的分辨率下自动调整大小1.1.1 :/u/20070105/09/88f3c417-6882-4e26-b622-0f9a0a9a65e0.html2.1.1 /给你个通用函数,在窗口的OPEN事件中加句f_resize_object(this)即可。/f_resize_object(window va_window)/以下为内容:/定义环境变量3.1.1 environment ve_hjbldec vdec_width,vdec_height /宽度比率、高度比率integer vi_return /返回数值long vl_objectvi_return = GetEnvironment(ve_hjbl)vdec_width = ve_hjbl.ScreenWidth / 1024vdec_height = ve_hjbl.ScreenHeight / 768any vs_object_type4.1.1 CheckBox v_CheckBoxOLECustomControl V_OLECustomControlCommandButton v_commandButtonOval v_OvalDataWindow v_datawindowPicture v_pictureDropDownListBox v_DropDownListBoxPictureButton v_PictureButtonDropDownPictureListBox v_dropDownPictureListBoxPictureListBox v_picTureListBoxEditMask v_editmaskRadioButton v_radiobuttonGraph v_graphRectangle v_rectangleGroupBox v_groupboxRichTextEdit v_richtexteditHScrollBar v_HScrollBarRoundRectangle v_RoundRectangleLine v_lineSingleLineEdit v_SingleLineEditListBox v_ListBoxStaticText v_statictextListView v_listViewTab v_tabMultiLineEdit v_MultiLineEditTreeView v_TreeViewOLEControl v_OLEControlVScrollBar v_VSCrollBarmenu v_menu/调整窗口属性5.1.1 va_window.x = va_window.x * vdec_widthva_window.y = va_window.y * vdec_height/va_window.width = va_window.width * vdec_width/va_window.height = va_window.height * vdec_heightva_window.Resize(va_window.width * vdec_width,va_window.height * vdec_height)6.1.1 /处理窗口内对象for vl_object = 1 to upperBound(va_window.control)vs_object_type = va_window.controlvl_object.typeof()7.1.1 choose case vs_object_typecase CheckBox!v_CheckBox = va_window.controlvl_objectv_checkBox.x = v_checkBox.x * vdec_widthv_checkBox.y = v_checkBox.y * vdec_heightv_checkBox.width = v_checkbox.width * vdec_widthv_checkbox.height = v_checkbox.height * vdec_heightv_checkbox.textsize = v_checkbox.textsize * vdec_widthcase OLECustomControl!V_OLECustomControl = va_window.controlvl_objectV_OLECustomControl.x = V_OLECustomControl.y * vdec_widthV_OLECustomControl.y = V_OLECustomControl.y * vdec_heightV_OLECustomControl.width = V_OLECustomControl.width * vdec_widthV_OLECustomControl.height = V_OLECustomControl.height * vdec_heightcase CommandButton!v_commandButton = va_window.controlvl_objectv_commandButton.x = v_commandButton.x * vdec_widthv_commandButton.y = v_commandButton.y * vdec_heightv_commandButton.width = v_commandButton.width * vdec_widthv_commandButton.height = v_commandButton.height * vdec_heightv_commandButton.textsize = v_commandButton.textsize * vdec_widthcase Oval!v_Oval = va_window.controlvl_objectv_Oval.x = v_Oval.x * vdec_widthv_Oval.y = v_Oval.y * vdec_heightv_Oval.width = v_Oval.width * vdec_widthv_Oval.height = v_Oval.height * vdec_heightcase DataWindow!v_datawindow = va_window.controlvl_objectv_datawindow.x = v_datawindow.x * vdec_widthv_datawindow.y = v_datawindow.y * vdec_heightv_datawindow.width = v_datawindow.width * vdec_widthv_datawindow.height = v_datawindow.height * vdec_heightcase Picture!v_picture = va_window.controlvl_objectv_picture.x = v_picture.x * vdec_widthv_picture.y = v_picture.y * vdec_heightv_picture.width = v_picture.width * vdec_widthv_picture.height = v_picture.height * vdec_heightcase DropDownListBox!v_DropDownListBox = va_window.controlvl_objectv_DropDownListBox.x = v_DropDownListBox.x * vdec_widthv_DropDownListBox.y = v_DropDownListBox.y * vdec_heightv_DropDownListBox.width = v_DropDownListBox.width * vdec_widthv_DropDownListBox.height = v_DropDownListBox.height * vdec_heightv_DropDownListBox.textsize = v_DropDownListBox.textsize * vdec_widthcase PictureButton!v_PictureButton = va_window.controlvl_objectv_PictureButton.x = v_PictureButton.x * vdec_widthv_PictureButton.y = v_PictureButton.y * vdec_heightv_PictureButton.width = v_PictureButton.width * vdec_widthv_PictureButton.height = v_PictureButton.height * vdec_heightv_PictureButton.textsize = v_PictureButton.textsize * vdec_widthcase DropDownPictureListBox!v_dropDownPictureListBox = va_window.controlvl_objectv_dropDownPictureListBox.x = v_dropDownPictureListBox.x * vdec_widthv_dropDownPictureListBox.y = v_dropDownPictureListBox.y * vdec_heightv_dropDownPictureListBox.width = v_dropDownPictureListBox.width * vdec_widthv_dropDownPictureListBox.height = v_dropDownPictureListBox.height * vdec_heightv_dropDownPictureListBox.textsize = v_dropDownPictureListBox.textsize * vdec_widthcase PictureListBox!v_picTureListBox = va_window.controlvl_objectv_picTureListBox.x = v_picTureListBox.x * vdec_widthv_picTureListBox.y = v_picTureListBox.y * vdec_heightv_picTureListBox.width = v_picTureListBox.width * vdec_widthv_picTureListBox.height = v_picTureListBox.height * vdec_heightv_picTureListBox.textsize = v_picTureListBox.textsize * vdec_widthcase EditMask!v_editmask = va_window.controlvl_objectv_editmask.x = v_editmask.x * vdec_widthv_editmask.y = v_editmask.y * vdec_heightv_editmask.width = v_editmask.width * vdec_widthv_editmask.height = (v_editmask.height * vdec_height )/0.9v_editmask.textsize = v_editmask.textsize * vdec_widthcase RadioButton!v_radiobutton = va_window.controlvl_objectv_radiobutton.x = v_radiobutton.x * vdec_widthv_radiobutton.y = v_radiobutton.y * vdec_heightv_radiobutton.width = v_radiobutton.width * vdec_widthv_radiobutton.height = v_radiobutton.height * vdec_heightv_radiobutton.textsize = v_radiobutton.textsize * vdec_widthcase Graph!v_graph = va_window.controlvl_objectv_graph.x = v_graph.x * vdec_widthv_graph.y = v_graph.y * vdec_heightv_graph.width = v_graph.width * vdec_widthv_graph.height = v_graph.height* vdec_heightcase Rectangle!v_rectangle = va_window.controlvl_objectv_rectangle.x = v_rectangle.x * vdec_widthv_rectangle.y = v_rectangle.y * vdec_heightv_rectangle.width = v_rectangle.width * vdec_widthv_rectangle.height = v_rectangle.height * vdec_heightcase GroupBox!v_groupbox = va_window.controlvl_objectv_groupbox.x = v_groupbox.x * vdec_widthv_groupbox.y = v_groupbox.y * vdec_heightv_groupbox.width = v_groupbox.width * vdec_widthv_groupbox.height = v_groupbox.height * vdec_heightv_groupbox.textsize = v_groupbox.textsize * vdec_widthcase RichTextEdit!v_richtextedit = va_window.controlvl_objectv_richtextedit.x = v_richtextedit.x * vdec_widthv_richtextedit.y = v_richtextedit.y * vdec_heightv_richtextedit.width = v_richtextedit.width * vdec_widthv_richtextedit.height = v_richtextedit.height * vdec_heightcase HScrollBar!v_HScrollBar = va_window.controlvl_objectv_HScrollBar.x = v_HScrollBar.x * vdec_widthv_HScrollBar.y = v_HScrollBar.y * vdec_heightv_HScrollBar.width = v_HScrollBar.width * vdec_widthv_HScrollBar.height = v_HScrollBar.height * vdec_heightcase RoundRectangle!v_RoundRectangle = va_window.controlvl_objectv_RoundRectangle.x = v_RoundRectangle.x * vdec_widthv_RoundRectangle.y = v_RoundRectangle.y * vdec_heightv_RoundRectangle.width = v_RoundRectangle.width * vdec_widthv_RoundRectangle.height = v_RoundRectangle.height * vdec_heightcase Line!v_line = va_window.controlvl_objectv_line.beginx = v_line.beginx * vdec_widthv_line.beginy = v_line.beginy * vdec_heightv_line.endx = v_line.endx * vdec_widthv_line.endy = v_line.endy * vdec_height8.1.1 case SingleLineEdit!v_SingleLineEdit = va_window.controlvl_objectv_SingleLineEdit.x = v_SingleLineEdit.x * vdec_widthv_SingleLineEdit.y = v_SingleLineEdit.y * vdec_heightv_SingleLineEdit.width = v_SingleLineEdit.width * vdec_widthv_SingleLineEdit.height = v_SingleLineEdit.height * vdec_heightv_SingleLineEdit.textsize = v_SingleLineEdit.textsize * vdec_widthcase ListBox!v_ListBox = va_window.controlvl_objectv_ListBox.x = v_ListBox.x * vdec_widthv_ListBox.y = v_ListBox.y * vdec_heightv_ListBox.width = v_ListBox.width * vdec_widthv_ListBox.height = v_ListBox.height * vdec_heightv_ListBox.textsize = v_ListBox.textsize * vdec_widthcase StaticText!v_statictext = va_window.controlvl_objectv_statictext.x =v_statictext.x * vdec_widthv_statictext.y = v_statictext.y * vdec_heightv_statictext.width = v_statictext.width * vdec_widthv_statictext.height = ( v_statictext.height * vdec_height )/0.8v_statictext.textsize = v_statictext.textsize * vdec_widthcase ListView!v_listView = va_window.controlvl_objectv_listView.x = v_listView.x * vdec_widthv_listView.y = v_listView.y * vdec_heightv_listView.width = v_listView.width * vdec_widthv_listView.height = v_listView.height * vdec_heightv_listView.textsize = v_listView.textsize * vdec_width9.1.1 case MultiLineEdit!v_MultiLineEdit = va_window.controlvl_objectv_MultiLineEdit.x = v_MultiLineEdit.x * vdec_widthv_MultiLineEdit.y = v_MultiLineEdit.y * vdec_heightv_MultiLineEdit.width = v_MultiLineEdit.width * vdec_widthv_MultiLineEdit.height = v_MultiLineEdit.height * vdec_heightv_MultiLineEdit.textsize = v_MultiLineEdit.textsize * vdec_widthcase TreeView!v_TreeView = va_window.controlvl_objectv_TreeView.x = v_TreeView.x * vdec_widthv_TreeView.y = v_TreeView.y * vdec_heightv_TreeView.width = v_TreeView.width * vdec_widthv_TreeView.height = v_TreeView.height * vdec_heightv_TreeView.textsize = v_TreeView.textsize * vdec_widthcase OLEControl!v_OLEControl = va_window.controlvl_objectv_OLEControl.x = v_OLEControl.x * vdec_widthv_OLEControl.y = v_OLEControl.y * vdec_heightv_OLEControl.width = v_OLEControl.width * vdec_widthv_OLEControl.height = v_OLEControl.height * vdec_heightcase VScrollBar!v_VSCrollBar = va_window.controlvl_objectv_VSCrollBar.x = v_VSCrollBar.x * vdec_widthv_VSCrollBar.y = v_VSCrollBar.y * vdec_heightv_VSCrollBar.width = v_VSCrollBar.width * vdec_widthv_VSCrollBar.height = v_VSCrollBar.height * vdec_heightcase menu!10.1.1 end choose11.1.1 next/窗口居中long ll_ScreenH,ll_ScreenWll_ScreenH = PixelsToUnits(ve_hjbl.ScreenHeight, YPixelsToUnits!)ll_ScreenW = PixelsToUnits(ve_hjbl.ScreenWidth , XPixelsToUnits!)12.1.1 va_window.Y = (ll_ScreenH - va_window.Height) / 2va_window.X = (ll_ScreenW - va_window.Width ) / 2如何在DW中设置自动列宽作者华软raymen看到如何在DW中设置自动列宽,从我的类库中扣了一段代码回复了,后来又从旧硬盘中找到原来老外写的对象,上传给大家吧$PBExportHeader$n_dwautowidth.sru$PBExportComments$Performs autowidth on grid datawindow columnsforwardglobal type n_dwautowidth from nonvisualo b j e c tend typeend forwardtype os_size from structurelong cxlong cyend typeglobal type n_dwautowidth from nonvisualo b j e c t autoinstantiateend typetype prototypesFunction ulong GetDC(ulong hWnd) Library user32.dllFunction ulong SelectObject(ulong hdc, ulong hWnd) Library gdi32.dllFunction boolean GetTextExtentPoint32A(ulong hdcr, string lpString, long nCount, ref os_size size) Library gdi32.dllFunction long ReleaseDC(ulong hWnd, ulong hdcr) Library user32.dllend prototypestype variablesConstant Integer WM_GETFONT = 49Window iw_parentDatawindowidw_dataInteger ii_originalend variablesforward prototypespublic subroutine of_register (readonly window aw_parent, ref datawindow adw_datawindow)public function long of_resize (string as_colname)public function long of_resize (integer ai_colnbr)end prototypespublic subroutine of_register (readonly window aw_parent, ref datawindow adw_datawindow);/ -/ SCRIPT: n_dwautowidth.of_register/ PURPOSE: This function saves a reference to the window and datawindow/ in instance variables for use in the of_resize function. It/ also saves the initial width of all visible columns to use as/ minimum width./ CALLED BY: Usually called from Constructor event of the datawindow or right/ after setting the .DataObject property of the dw control./ ARGUMENTS: aw_parent - Window that the datawindow is on/ adw_datawindow -Datawindowwhose columns will be resized/ RETURN: Row containing the longest value/ DATE PROG/ID DESCRIPTION OF CHANGE / REASON/ - - -/ 11/25/2002 Roland S Initial creation/ -Integer li_col, li_max/ save references to parent window and datawindowiw_parent = aw_parentidw_data = adw_datawindow/ record column original sizeli_max = Integer(adw_datawindow.Object.DataWindow.Column.Count)FOR li_col = 1 TO li_maxii_originalli_col = Integer(adw_datawindow.Describe(# + String(li_col) + .Width)NEXTend subroutinepublic function long of_resize (string as_colname);/ -/ SCRIPT: n_dwautowidth.of_resize/ PURPOSE: This function will change the column width so that the longest/ value will fit. The minimum width is the initial width set in/ the datawindow painter./ CALLED BY: Usually called from RetrieveEnd event of the datawindow or/ just after inserting/modifying the values in the column./ ARGUMENTS: as_colname - Column to be resized/ RETURN: Row containing the longest value/ DATE PROG/ID DESCRIPTION OF CHANGE / REASON/ - - -/ 11/25/2002 Roland S Initial creation/ -Long ll_row, ll_max, ll_maxrowULong lul_Handle, lul_hDC, lul_hFontInteger li_maxwidth, li_rc, li_size, li_colnbrString ls_value, ls_format, ls_modifyStaticText lst_textos_size lstr_Sizeli_rc = iw_parent.OpenUserObject(lst_text)If li_rc = 1 Then/ get column numberli_colnbr = Integer(idw_data.Describe(as_colname + .ID)/ get column format stringls_format = idw_data.Describe(as_colname + .Format)/ give static text same font properties as columnlst_text.FaceName = idw_data.Describe(as_colname + .Font.Face)lst_text.TextSize = Integer(idw_data.Describe(as_colname + .Font.Height)lst_text.Weight = Integer(idw_data.Describe(as_colname + .Font.Weight)/ set italic propertyIf idw_data.Describe(as_colname + .Font.Italic) = 1 Thenlst_text.Italic = TrueElselst_text.Italic = FalseEnd If/ set charset propertyCHOOSE CASEidw_data.Describe(as_colname + .Font.CharSet)CASE0lst_text.FontCharSet = ANSI!CASE2lst_text.FontCharSet = Symbol!CASE 128lst_text.FontCharSet = ShiftJIS!CASE 255lst_text.FontCharSet = OEM!CASE ELSElst_text.FontCharSet = DefaultCharSet!END CHOOSE/ set family propertyCHOOSE CASE idw_data.Describe(as_colname + .Font.Family)CASE 1lst_text.FontFamily = Roman!CASE 2lst_text.FontFamily = Swiss!CASE 3lst_text.FontFamily = Modern!CASE 4lst_text.FontFamily = Script!CASE 5lst_text.FontFamily = Decorative!CASE ELSElst_text.FontFamily = AnyFont!END CHOOSE/ set pitch propertyCHOOSE CASE idw_data.Describe(as_colname + .Font.Pitch)CASE 1lst_text.FontPitch = Fixed!CASE 2lst_text.FontPitch = Variable!CASE ELSElst_text.FontPitch = Default!END CHOOSE/ create device context for statictextlul_Handle = Handle(lst_text)lul_hDC = GetDC(lul_Handle)/ get handle to the font used by statictextlul_hFont = Send(lul_Handle, WM_GETFONT, 0, 0)/ Select it into the device contextSelectObject(lul_hDC, lul_hFont)/ walk thru each row of datawindowll_max = idw_data.RowCount()FOR ll_row = 1 TO ll_max/ get value from datawindowls_value = RightTrim(String(idw_data.o b j e c t.datall_row, li_colnbr, ls_format)/ determine text widthIf Not GetTextExtentPoint32A(lul_hDC, ls_value, Len(ls_value), lstr_Size) ThenReleaseDC(lul_Handle, lul_hDC)iw_parent.CloseUserObject(lst_text)Return -1End If/ convert length in pixels toPBUnitsli_size = PixelsToUnits(lstr_Size.cx, XPixelsToUnits!)If li_size li_maxwidth Thenli_maxwidth = li_sizell_maxrow = ll_rowEnd IfNEXT/ release the device contextReleaseDC(lul_Handle, lul_hDC)/ modify the column widthIf li_maxwidth ii_originalli_colnbr

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论