Bay Six Software Forum Index Bay Six Software
Beyond the Basics
 
 FAQFAQ   SearchSearch   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Absolutely positioned Confirm and Notice boxes

 
Post new topic   Reply to topic    Bay Six Software Forum Index -> General Discussions
View previous topic :: View next topic  
Author Message
RichardRussell
Full Member


Joined: 28 Jan 2012
Posts: 57
Location: Downham Market, UK

PostPosted: Feb 27th, 2012, 2:21pm    Post subject: Absolutely positioned Confirm and Notice boxes Reply with quote

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.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Bay Six Software Forum Index -> General Discussions All times are GMT
Page 1 of 1
Jump to:  
Quick Reply
Username:
Message:
   Shortcut keys: Alt+Q to activate, Alt+P to preview, Alt+S to submit
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum



Lo-Fi Version
Powered by phpBB © 2001, 2005 phpBB Group