在使用如下语句调用SetWindowPos,该语句的本来目的是要将当前窗口设为最前面,且处于屏幕中心位置,但该语句执行后窗口就跑到了屏幕之外,不知道什么地方去了。
Call SetWindowPos(Me.hwnd, HWND_TOPMOST, (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2, 0, 0, SWP_NOSIZE)
请问问题出在什么什么地方,如何解决?谢谢!
Call SetWindowPos(Me.hwnd, HWND_TOPMOST, (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2, 0, 0, SWP_NOSIZE)
请问问题出在什么什么地方,如何解决?谢谢!
解决方案 »
- COM接口传时间怎样传 精度能达到多少 要在vb里面用
- 有什么办法可以在代码中给水晶报表设定自定义纸张?
- 关于windows的使用问题:误删了系统文件,系统无法正常启动,在不重装系统的情况下如何恢复呢 ?
- 这条SQL语句怎么老出错
- 真正的程序员(请你来续)
- vb中文超级模块1.1
- 为什么我这样总是陷入死循环呢?我想判断在插入记录之前是否有重复的工作人员ID号?
- 為什麼我在給report.Database.SetDataSource時老是說"陣列索引超出范圍"呢??我是用水晶報表7,請各位幫忙看看。
- 在com中怎么返回数据集,并在asp中调用
- 关于floodfill
- 关于设置密码的一个问题
- 请问怎么样来让图片框根据选择来显示图片
HWND hWnd, // handle to window
HWND hWndInsertAfter, // placement-order handle
int X, // horizontal position
int Y, // vertical position
int cx, // width
int cy, // height
UINT uFlags // window-positioning options
);
----------------
SetWindowPos(Me.hwnd, HWND_TOPMOST, (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2, 0, 0, SWP_NOSIZE)
----------------注意:原型中的X和Y坐标的单位是象素,而你的Width和Height的单位也要是象素;
原型中的cx和cy是窗体的宽和高,你的0,why?(Me.Width,Me.Height才对)
楼上正解
SetWindowPos(Me.hwnd, HWND_TOPMOST,(Screen.Width - Me.Width) / 2 / Screen.TwipsPerPixelX, (Screen.Height - Me.Height) / 2 / Screen.TwipsPerPixelY, 0, 0, SWP_NOSIZE)另,窗体的宽和高,你的0,why?(Me.Width,Me.Height才对)
加了SWP_NOSIZE就不理会前面对宽高的设置了~