当以像素为单位给出测量值时,我不确定如何布局 GUI,例如按钮、编辑框、文本等。
正如在微软的 GUI 指南中一样,所有细节都以像素距离给出。使用 Microsoft 编辑器以外的其他编辑器时,如何将其转换为实际距离?
谢谢
当以像素为单位给出测量值时,我不确定如何布局 GUI,例如按钮、编辑框、文本等。
正如在微软的 GUI 指南中一样,所有细节都以像素距离给出。使用 Microsoft 编辑器以外的其他编辑器时,如何将其转换为实际距离?
谢谢
对话窗口的尺寸、对话窗口内的所有元素及其位置均以对话单位 (DLU) 而非像素为单位定义,请参阅关于对话框。
因此,对话框不是以像素为单位的固定大小。大小取决于为对话框设置的字体。在 *.rc 文件中,您可以在关键字BEGIN的行上方看到对话框的字体。
另请参阅如何根据 Visual C++ 中的当前字体计算对话框单位和DPI 与对话框单位之间的相关性
因此,如果您不使用资源编辑器而是使用文本编辑器直接在 *.rc 文件中编辑对话框资源,那么您肯定会遇到问题。我只能建议不要这样做。
对于 LabWindows/CVI:
编辑以更正函数名称:
在 LabWindows/CVI 开发环境中,您可以使用一系列函数(也可通过函数面板访问),它们提供面板和控件的状态和控制(例如位置/大小/颜色...等),称为 用户界面库。GetCtrlAttribute()
、SetCtrlAttribute()
、GetPanelAttribute()
和等函数SetPanelAttribute()
。其中每一个都使用预定义参数的枚举列表来访问您想要控制的众多属性中的哪一个。
例如,要设置面板在显示器上显示时的大小和位置,您可以使用以下内容:
SetPanelAttribute(panelHandle, ATTR_HEIGHT, height);//where height is in pixels, 0 to 32767
SetPanelAttribute(panelHandle, ATTR_WIDTH, width);//where width is in pixels, 0 to 32767
SetPanelAttribute(panelHandle, ATTR_TOP, top);//in pixels, 0 to 32767
//The vertical offset (in pixels) of the panel
//relative to the origin of the screen
//(for top-level windows) or the parent panel (for child panels).
//The screen origin is the upper-left corner of the screen.
//The origin of a parent panel is the upper-left corner of
//the panel below the title bar and to the right of the panel frame.
SetPanelAttribute(panelHandle, ATTR_LEFT, left);//in pixels, 0 to 32767
//The horizontal offset (in pixels) of the panel relative to
//the origin of the screen (for top-level windows) or the
//parent panel (for child panels).
//The screen origin (0,0) is the upper-left corner of the screen.
//The origin of a parent panel is the upper-left corner of the
//panel below the title bar and to the right of the panel frame.
使用这四个功能可以设置或检索更多属性(属性),例如背景颜色,面板/控件是否处于活动状态,或变灰,框架颜色等。
如前所述,在同一家族中有一组类似的函数,用于(Get/Set)CtrlAttribute()
为所有控件属性提供控制的控件。