largo_winch
25-02-2013, 16:28
I have a problem with mouse over function. in any elder example this function worked (dialog show modeless) but not here:
' Basic Template for custom dialog
' Start Date 02-25-2013
' Created by
Uses "UI"
Type RECT
nLeft As Long
nTop As Long
nRight As Long
nBottom As Long
End Type
Type POINTAPI
x As Long
y As Long
End Type
Declare Function PtInRect Lib "USER32.DLL" Alias "PtInRect" (lpRect As RECT, ByVal ptx As Long, ByVal pty As Long) As Long
Declare Function SetCapture Lib "USER32.DLL" Alias "SetCapture" (ByVal hWnd As DWord) As Long
Declare Function ReleaseCapture Lib "USER32.DLL" Alias "ReleaseCapture" () As Long
Declare Function GetCursorPos Lib "USER32.DLL" Alias "GetCursorPos" (lpPoint As POINTAPI) As Long
Declare Function GetWindowRect Lib "USER32.DLL" Alias "GetWindowRect" (ByVal hWnd As DWord, lpRect As RECT) As Long
' -- ID numbers of controls
Begin ControlID
%bClose
%btn_OK
%txt_Result
End ControlID
Begin Const
%MAIN_WIDTH = 320
%MAIN_HEIGHT = 240
End Const
' -- Create dialog here
Function TBMain()
Local hDlg As DWord
Dim hBtn_OK As DWord
Dim pt As POINTAPI
Dim rc As RECT
Dim counts As Long
Dialog New Pixels, 0, "<Enter title here>",-1,-1, %MAIN_WIDTH, %MAIN_HEIGHT, _
%WS_POPUP Or %WS_VISIBLE Or %WS_CAPTION Or %WS_SYSMENU Or %WS_MINIMIZEBOX To hDlg
' -- Place controls here
Control Add Button, hDlg, %bClose, "Click to close", %MAIN_WIDTH-105, %MAIN_HEIGHT-30, 100, 25, Call cbCloseButton
Control Add Textbox , hDlg, %txt_Result , "" , 10, 10, 80, 18, %WS_TABSTOP
Control Add Button , hDlg, %btn_OK , "OK" , 25, 80, 50, 24, %WS_TABSTOP
Control Handle hDlg, %btn_OK To hBtn_OK
Dialog Show Modal hDlg, Call cbDialog
Do
Dialog DoEvents To Counts
Loop Until Counts = 0
End Function
CallBack Function cbDialog2() As Long
Select Case CBMSG
Case %WM_COMMAND
If CBWPARAM = %ButtonClose Then Dialog End CBHNDL
Case %WM_DESTROY
'MsgBox 0, "Window is to be destroyed."
End Select
End Function
' -- Callback for dialog
CallBack Function cbDialog()
Local hDlg As DWord,hBtn_OK As Long
Local pt As POINTAPI
Local rc As RECT
' -- Test for messages
Select Case CBMSG
Case %WM_INITDIALOG
' -- Put code to be executed after dialog creation here
Case %WM_MOUSEMOVE
SetCapture hDlg 'cbhndl
GetCursorPos pt
GetWindowRect hBtn_OK, rc '%btn_OK
'If ptInRect(rc,Str$(pt.x),Str$(pt.y)) Then
If ptInRect(rc,pt.x,pt.y) Then
Control Set Text hDlg, %txt_Result, "Bingo"
Else
Control Set Text hDlg, %txt_Result, ""
End If
ReleaseCapture
Case %WM_COMMAND
' -- You can handle controls here
If CBWPARAM = %btn_OK Then
MsgBox 0,"hello!"
End If
'SELECT CASE CBCTL
'
' CASE ...
' IF CBCTLMSG = ... THEN
'
' END IF
'
'END SELECT
Case %WM_CLOSE
' -- Put code to be executed before dialog end here
End Select
End Function
' -- Callback for close button
CallBack Function cbCloseButton()
If CBMSG = %WM_COMMAND Then
If CBCTLMSG = %BN_CLICKED Then
' -- Closes the dialog
Dialog End CBHNDL
End If
End If
End Function
do you can help?
this example works with antique ui mode:
http://www.thinbasic.com/community/showthread.php?8506-mouse-over
bye, largo
' Basic Template for custom dialog
' Start Date 02-25-2013
' Created by
Uses "UI"
Type RECT
nLeft As Long
nTop As Long
nRight As Long
nBottom As Long
End Type
Type POINTAPI
x As Long
y As Long
End Type
Declare Function PtInRect Lib "USER32.DLL" Alias "PtInRect" (lpRect As RECT, ByVal ptx As Long, ByVal pty As Long) As Long
Declare Function SetCapture Lib "USER32.DLL" Alias "SetCapture" (ByVal hWnd As DWord) As Long
Declare Function ReleaseCapture Lib "USER32.DLL" Alias "ReleaseCapture" () As Long
Declare Function GetCursorPos Lib "USER32.DLL" Alias "GetCursorPos" (lpPoint As POINTAPI) As Long
Declare Function GetWindowRect Lib "USER32.DLL" Alias "GetWindowRect" (ByVal hWnd As DWord, lpRect As RECT) As Long
' -- ID numbers of controls
Begin ControlID
%bClose
%btn_OK
%txt_Result
End ControlID
Begin Const
%MAIN_WIDTH = 320
%MAIN_HEIGHT = 240
End Const
' -- Create dialog here
Function TBMain()
Local hDlg As DWord
Dim hBtn_OK As DWord
Dim pt As POINTAPI
Dim rc As RECT
Dim counts As Long
Dialog New Pixels, 0, "<Enter title here>",-1,-1, %MAIN_WIDTH, %MAIN_HEIGHT, _
%WS_POPUP Or %WS_VISIBLE Or %WS_CAPTION Or %WS_SYSMENU Or %WS_MINIMIZEBOX To hDlg
' -- Place controls here
Control Add Button, hDlg, %bClose, "Click to close", %MAIN_WIDTH-105, %MAIN_HEIGHT-30, 100, 25, Call cbCloseButton
Control Add Textbox , hDlg, %txt_Result , "" , 10, 10, 80, 18, %WS_TABSTOP
Control Add Button , hDlg, %btn_OK , "OK" , 25, 80, 50, 24, %WS_TABSTOP
Control Handle hDlg, %btn_OK To hBtn_OK
Dialog Show Modal hDlg, Call cbDialog
Do
Dialog DoEvents To Counts
Loop Until Counts = 0
End Function
CallBack Function cbDialog2() As Long
Select Case CBMSG
Case %WM_COMMAND
If CBWPARAM = %ButtonClose Then Dialog End CBHNDL
Case %WM_DESTROY
'MsgBox 0, "Window is to be destroyed."
End Select
End Function
' -- Callback for dialog
CallBack Function cbDialog()
Local hDlg As DWord,hBtn_OK As Long
Local pt As POINTAPI
Local rc As RECT
' -- Test for messages
Select Case CBMSG
Case %WM_INITDIALOG
' -- Put code to be executed after dialog creation here
Case %WM_MOUSEMOVE
SetCapture hDlg 'cbhndl
GetCursorPos pt
GetWindowRect hBtn_OK, rc '%btn_OK
'If ptInRect(rc,Str$(pt.x),Str$(pt.y)) Then
If ptInRect(rc,pt.x,pt.y) Then
Control Set Text hDlg, %txt_Result, "Bingo"
Else
Control Set Text hDlg, %txt_Result, ""
End If
ReleaseCapture
Case %WM_COMMAND
' -- You can handle controls here
If CBWPARAM = %btn_OK Then
MsgBox 0,"hello!"
End If
'SELECT CASE CBCTL
'
' CASE ...
' IF CBCTLMSG = ... THEN
'
' END IF
'
'END SELECT
Case %WM_CLOSE
' -- Put code to be executed before dialog end here
End Select
End Function
' -- Callback for close button
CallBack Function cbCloseButton()
If CBMSG = %WM_COMMAND Then
If CBCTLMSG = %BN_CLICKED Then
' -- Closes the dialog
Dialog End CBHNDL
End If
End If
End Function
do you can help?
this example works with antique ui mode:
http://www.thinbasic.com/community/showthread.php?8506-mouse-over
bye, largo