Python How to keep MessageboxW on top of all other windows?

巧了我就是萌 提交于 2019-12-01 23:10:55
import ctypes

text = 'Using MB_SYSTEMMODAL'
title = 'Some Title'

ctypes.windll.user32.MessageBoxW(0, text, title, 0x1000)

MB_SYSTEMMODAL (0x1000) has the WS_EX_TOPMOST (0x40000) style.

The MessageBoxEx function seems to work good with using just the WS_EX_TOPMOST (0x40000) style.

import ctypes

text = 'Using WS_EX_TOPMOST'
title = 'Some Title'

ctypes.windll.user32.MessageBoxExW(0, text, title, 0x40000)

The MessageBox function has no parameters to change size. Perhaps an alternative like tkinter or another gui toolkit might be able to change messagebox size (though it maybe not if it just a wrapper for MessageBoxW) or you could perhaps create a custom window to use.

See MSDN MessageBox function for values to use.

See also MSDN MessageBoxEx function.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!