RichardRussell Full Member
Joined: 28 Jan 2012 Posts: 57 Location: Downham Market, UK
|
Posted: Feb 27th, 2012, 2:21pm Post subject: Absolutely positioned Confirm and Notice boxes |
|
|
Here's an alternative to the method given in 'Code Snippets 2' for creating an absolutely-positioned Notice box. This one doesn't use hooks or callbacks, and gives some more control over the appearance of the box (for example it can have a custom icon):
Code: | Call NoticeAt 0, 0, "Hello from the top-left corner!"
End
Sub NoticeAt X, Y, Msg$
struct mbp, _
cbSize as long, hwndOwner as long, hInstance as long, _
lpszText as ptr, lpszCaption as ptr, dwStyle as long, _
lpszIcon as long, dwContextHelpID as long, _
lpfnMsgBoxCallback as long, dwLanguageId as long
mbp.cbSize.struct = len(mbp.struct)
mbp.lpszText.struct = Msg$
mbp.lpszCaption.struct = "- Notice -"
mbp.dwStyle.struct = _MB_ICONEXCLAMATION
call MsgboxAt X, Y, Msg$
End Sub
Sub MsgboxAt X, Y, Msg$
calldll #kernel32, "GetModuleHandleA", "user32" as ptr, _
user32 as long
calldll #kernel32, "GetProcAddress", user32 as long, _
"MessageBoxIndirectA" as ptr, MessageBoxIndirect as long
calldll #kernel32, "CreateThread", 0 as long, 0 as long, _
MessageBoxIndirect as long, mbp as struct, _
0 as long, 0 as long, hthread as long
caption$ = winstring(mbp.lpszCaption.struct)
do
scan
calldll #kernel32, "Sleep", 1 as long, res as long
calldll #user32, "FindWindowA", 0 as long, _
caption$ as ptr, hw as long
loop until hw<>0
flags = _SWP_NOZORDER or _SWP_NOSIZE or _SWP_NOACTIVATE
calldll #user32, "SetWindowPos", hw as long, 0 as long, _
X as long, Y as long, 0 as long, 0 as long, _
flags as long, res as long
calldll #kernel32, "WaitForSingleObject", hthread as long, _
_INFINITE as long, res as long
calldll #kernel32, "CloseHandle", hthread as long, _
res as long
End Sub |
This can easily be adapted to create a Confirm box instead.
Richard. |
|