Does anyone know if it is possible to center the button in a single button MESSAGEBOX, please?
(see code below)
'-------------------------------------------------------------------------------------
' SkeletonWin.iwb
'-------------------------------------------------------------------------------------
'
AutoDefine "Off"
def win:window
def run,wstyle:int
'wstyle = @minbox|@maxbox|@size ' thick borders - resizeable window
wstyle = @minbox ' thin borders - window NOT resizeable
OpenWindow win,-480,0,480,300,wstyle,0," Skeleton Window",&messages
MOVE win,130,100
PRINT win,"Right-Click for MESSAGEBOX"
run = 1
WAITUNTIL run = 0
CLOSEWINDOW win
END
'
SUB messages(),int
'-------------------------------------------------------------------------------------
' Main Loop
'-------------------------------------------------------------------------------------
'
SELECT @CLASS
CASE @IDRBUTTONUP
MESSAGEBOX win," Information "," Caption Text",@MB_ICONINFORMATION
CASE @IDCREATE
centerwindow win
CASE @IDCLOSEWINDOW
run = 0
ENDSELECT
RETURN 0
EndSub
not that I'm aware of Egil
you can change just about anything else with some extended functions but I haven't neen able to find where you can change the location of the buttons.
Sorry
Thanks Larry!
Did not find anything myself either. But it is possible to achieve, because I saw it on a pc screen in Trondheim. Maybe the developer of that software had made his own "messagebox".
Quote from: Egil on May 06, 2016, 12:00:07 PM
Maybe the developer of that software had made his own "messagebox".
That would be extremely easy to do if one owned a copy of IWB+ ::) ::) (one has no shame ;D )
to more important things
how's your hip and your other treatment?
Quote from: LarryMc on May 06, 2016, 12:09:27 PM
That would be extremely easy to do if one owned a copy of IWB+
A nice piece of software, which I am a proud owner of...
The hip is now almost back to normal. Only notice it when I am working out very hard. The other treatment also show good results. Another week with frequent treatment, and after that just regular checks to assure that I have got rid of it.
You should be able to do it using the SetWindowsHookEx.
Quote from: zappa52 on May 06, 2016, 01:20:31 PM
You should be able to do it using the SetWindowsHookEx.
That's good news. Thanks!
and based upon the good news above I found this:
AutoDefine "Off"
Dialog d1,mbhwnd
UINT hMsgBoxHook,counter,mbret
String debug
Type CREATESTRUCT
Def lpCreateParams:Int
Def hInstance:Int
Def hMenu:Int
Def hWndParent:Int
Def cy:Int
Def cx:Int
Def y:Int
Def x:Int
Def style:Int
Def lpszName:Pointer
Def lpszClass:Pointer
Def ExStyle:Int
EndType
Type CBT_CREATEWND
Def lpcs:CREATESTRUCT
Def hWndInsertAfter:Int
EndType
Declare "User32.dll",SetWindowsHookEx Alias "SetWindowsHookExA"(idHook:Int,lpfn:Int,hmod:Int,dwThreadId:Int),Int
Declare "User32.dll",CallNextHookEx(hHook:Int,ncode:Int,wParam:Int,lParam:Pointer),Int
Declare "User32",SetWindowPos(hwnd:Int,hWndInsertAfter:Int,x:Int,y:Int,cx:Int,cy:Int,wFlags:Int),Int
Declare "User32.dll",GetClassNameA(hwnd:Int,lpClassName:String,nMaxCount:Int),Int
Declare "User32.dll",GetDlgItem(hDlg:Int,nIDDlgItem:Int),Int
Declare "User32.dll",UnhookWindowsHookEx(hHook:Int),Int
DECLARE "user32.dll",IsWindow(hwnd:Int),Int
Declare "Kernel32.dll",GetCurrentThreadId(),Int
Const WH_CBT = 5
Const HCBT_CREATEWND = 3
Const HCBT_ACTIVATE = 5
Const WM_SETTEXT = 0xC
CreateDialog d1,0,0,295,168,0x80C80080,0,"Caption",&handler
Control d1,@Button,"Hook",114,62,70,20,0x50000000,1
Control d1,@Button,"No Hook",114,92,70,20,0x50000000,2
Domodal d1
End
Sub handler(),int
Select @Class
Case @IDControl
If @ControlID=1
mbret=MsgBoxEx(d1,"Test Message","Test Caption",@MB_OKCANCEL)
Else
mbret=MessageBox(d1,"Test Message","Test Caption",32)
EndIf
SetCaption d1,"MessageBox Return Code = "+Str$(mbret)
Case @IDInitDialog
CenterWindow d1
Case @IDCloseWindow
CloseDialog d1,@IDCancel
EndSelect
Return 0
EndSub
Sub MsgBoxEx(win:Window,szText:String,szCaption:String,uType:UINT),Int
Int ret:debug=""
' Install a Window hook, so we can intercept the message-box
' creation, and customize it only install For this thread.
hMsgBoxHook = SetWindowsHookEx(WH_CBT,&CBTProc,NULL,GetCurrentThreadId())
' Display a standard message box
ret = MessageBox(win,szText,szCaption,uType)
' remove the Window hook
UnhookWindowsHookEx(hMsgBoxHook)
Return ret
EndSub
Sub CBTProc(nCode:Int,wParam:UINT,lParam:UINT),Int
Window tmp
String class1
class1=GetClass(wParam)
If nCode >= 0 AND (class1="#32770" OR class1="Button" OR class1="Static")
Select nCode
Case HCBT_ACTIVATE
' Get handle To the message box
tmp.hwnd=wParam
' change the MessageBox size and position
SetWindowPos(wParam,0,10,100,400,400,4)
' change the caption text
SendMessage(tmp,WM_SETTEXT,0,"Reboot Now ??")
' Get the handle To the Ok Button
tmp.hwnd = GetDlgItem(wParam,@IDOK)
' change the button size and position
SetWindowPos(tmp.hwnd,0,100,250,200,40,4)
' change the button text
SendMessage(tmp,WM_SETTEXT,0,"Yes Please")
' Get the handle To the Cancel Button
tmp.hwnd = GetDlgItem(wParam,@IDCANCEL)
' change the button size and position
SetWindowPos(tmp.hwnd,0,100,300,200,40,4)
' change the button text
SendMessage(tmp,WM_SETTEXT,0,"No Thanks")
mbhwnd.hwnd=wparam
counter=5
StartTimer d1,1000,1,&mbcallback
StartTimer d1,5000,5,&mbcallback
Return 0
Case HCBT_CREATEWND
' Pointer p,d
' p=&lparam
' d=#<CBT_CREATEWND>p.lpcs.lpszName
' debug=#<String>d
' SetCaption d1,debug
EndSelect
EndIf
' Call the Next hook, If there is one
Return CallNextHookEx(hMsgBoxHook,nCode,wParam,lParam)
EndSub
Sub mbCallback(hwnd:UINT,msg:UINT,idEvent:UINT,dwTime:UINT)
If IsWindow(mbhwnd.hwnd)
If idEvent = 1
counter--
SetCaption mbhwnd,"Closing In "+Str$(counter)
Else
SendMessage mbhwnd,0x10,0,0
EndIf
Else
StopTimer d1,1
StopTimer d1,5
EndIf
Return
EndSub
Sub GetClass(win:UINT),String
String ClassName:ClassName=""
GetClassNameA(win,ClassName,254)
Return ClassName
EndSub
The notification email arrived the same moment I was going to shut down my pc and go to bed...
Thanks Larry!