itsky2 发表于 2019-8-10 10:45:17

【已解决】子窗口在调整分辨率后不跟随父窗口移动造成错位

本帖最后由 itsky2 于 2019-8-10 16:06 编辑


如图,目前想到的办法是用选项卡,但是想要使用图片来切换,所以没用它。
希望各位大佬帮忙解答,谢谢!

问题已经解决!
方法:GUICreate("", 440, 320, 100, 35, $WS_CHILD, -1, $Form_Main)
必须将代码内的全部子窗口都如上法创建

itsky2 发表于 2019-8-10 15:16:38

haijie1223 发表于 2019-8-10 11:55
代码发上来

#Region Form Main
Global $Form_Main = GUICreate("Easy IG", 550, 380, -1, -1, $WS_POPUP)
GUISetFont(10, 400, 0, "微软雅黑")
GUISetBkColor(0xFFFFFF)
GUICtrlCreateGraphic(0, 0, 1, 550)
GUICtrlSetBkColor(-1, 0x0078DD)
GUICtrlCreateGraphic(549, 0, 1, 550)
GUICtrlSetBkColor(-1, 0x0078DD)
GUICtrlCreateGraphic(0, 379, 550, 1)
GUICtrlSetBkColor(-1, 0x0078DD)
GUICtrlCreateGraphic(0, 0, 550, 1)
GUICtrlSetBkColor(-1, 0x0078DD)

GUICtrlCreateLabel('Easy IG', 0, 0, 469, 28, $SS_CENTERIMAGE, $GUI_WS_EX_PARENTDRAG)
GUICtrlSetBkColor(-1, 0x0078DD)
GUICtrlSetColor(-1, 0xFFFFFF)
Global $Close = GUICtrlCreateLabel('x', 509, 1, 40, 27, $SS_CENTER)
GUICtrlSetBkColor(-1, 0x0078DD)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 13)
Global $Min = GUICtrlCreateLabel('-', 469, 1, 40, 27, BitOR($SS_CENTER, $SS_CENTERIMAGE))
GUICtrlSetBkColor(-1, 0x0078DD)
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")

Global $Tab_Recover = GUICtrlCreatePic('', 1, 40, 100, 100)
Global $Tab_Backup = GUICtrlCreatePic('', 1, 140, 100, 100)
Global $Tab_More = GUICtrlCreatePic('', 1, 240, 100, 100)
_SetImgFromBin($Tab_Recover, $Recover_Checked)
_SetImgFromBin($Tab_Backup, $Backup_Unchecked)
_SetImgFromBin($Tab_More, $More_Unchecked)
#EndRegion Form Main

#Region Form Recover
Global $Form_Recover = GUICreate("", 440, 320, 100, 35, $WS_POPUP, $WS_EX_MDICHILD, $Form_Main)
GUISetFont(10, 400, 0, "微软雅黑")
GUISetBkColor(0xFFFFFF)

GUICtrlCreateLabel("恢复映像:", 9, 47)
GUICtrlSetColor(-1, 0x0078DD)
GUICtrlCreateLabel("映像索引:", 9, 90)
GUICtrlSetColor(-1, 0x0078DD)
GUICtrlCreateLabel("目标分区:", 9, 137)
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlCreateLabel("磁盘信息:", 9, 181)
GUICtrlSetColor(-1, 0xFF0000)
GUICtrlCreateLabel("卷标:", 146, 137)
GUICtrlSetColor(-1, 0xFF0000)
Global $Label_DriveLabel = GUICtrlCreateLabel("", 183, 137, 70, 30, 0x0C)
GUICtrlSetColor(-1, 0x0078DD)
GUICtrlCreateLabel("容量:", 255, 137)
GUICtrlSetColor(-1, 0xFF0000)
Global $Label_DriveSpaceTotal = GUICtrlCreateLabel("", 295, 137, 70, 30, 0x0C)
GUICtrlSetColor(-1, 0x0078DD)
Global $Label_DriveInfo = GUICtrlCreateLabel("", 80, 181, 300, 30, 0x0C)
GUICtrlSetColor(-1, 0x0078DD)

Global $ComboBox_RecoverImagePath = GUICtrlCreateCombo("", 82, 45, 310, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
Global $ComboBox_ImageIndex = GUICtrlCreateCombo("", 82, 87, 310, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE))
GUICtrlSetState($ComboBox_ImageIndex, $GUI_DISABLE)
Global $ComboBox_RecoverPartition = GUICtrlCreateCombo("", 82, 135, 50, 25, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_SIMPLE, $CBS_UPPERCASE))

Global $Checkbox_Re_Restart = GUICtrlCreateCheckbox("自动重启计算机", 17, 229, 113, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
Global $Checkbox_Re_FormatDestination = GUICtrlCreateCheckbox("格式化目标分区", 152, 229, 113, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
Global $Checkbox_Re_RebuildBoot = GUICtrlCreateCheckbox("尝试重建系统引导", 285, 229, 129, 17)
GUICtrlSetState(-1, $GUI_CHECKED)

Global $Button_BrowseFiles = GUICtrlCreateButton(". . .", 402, 45, 30, 25)
GUICtrlSetTip(-1, '选择映像文件')
Global $Button_StartRecovering = GUICtrlCreateButton("开始恢复", 140, 265, 150, 35)
GUICtrlSetColor(-1, 0x0078DD)
GUICtrlSetBkColor(-1, 0xFFFFFF)
#EndRegion Form Recover

haijie1223 发表于 2019-8-10 11:55:45

代码发上来

afan 发表于 2019-8-10 12:04:44

子窗口用内嵌样式不要用弹出样式

itsky2 发表于 2019-8-10 14:49:42

afan 发表于 2019-8-10 12:04
子窗口用内嵌样式不要用弹出样式

非常感谢A大回复!
内嵌样式具体指?是WS_CHILD吗?但是一移动就消失了...这是原来的代码:GUICreate("", 440, 320, 100, 35, $WS_POPUP, $WS_EX_MDICHILD, $Form_Main)

haijie1223 发表于 2019-8-10 18:24:24

GUIRegisterMsg(126, 'WM_DISPLAYCHANGE')
Func WM_DISPLAYCHANGE($hwnd, $msg, $wparam, $lparam)
        Local $array=WinGetPos($Form_Main)
        WinMove( $Form_Recover,'',$array +100 , $array + 35)
EndFunc   ;==>WM_DISPLAYCHANGE

itsky2 发表于 2019-8-10 21:12:37

haijie1223 发表于 2019-8-10 18:24
GUIRegisterMsg(126, 'WM_DISPLAYCHANGE')
Func WM_DISPLAYCHANGE($hwnd, $msg, $wparam, $lparam)
        Loc ...

谢谢大佬!貌似看不懂...
如果WS_CHILD解决了,就不用注册消息了...

tarcy118 发表于 2019-8-11 14:54:03

不错支持一下

IT爱好者 发表于 2019-8-16 01:37:40

不错支持一下
页: [1]
查看完整版本: 【已解决】子窗口在调整分辨率后不跟随父窗口移动造成错位