Pierre40a Posted July 29, 2007 Share Posted July 29, 2007 Hello,I have two basic questions on this control :How can I change the position of the MonthCalendar on a window/dialog ?How can I detect when a user clicked ont it ?When I change the horizontal and vertical position, this control grows ...I already tried to use the simple code below to trap the $MCN_SELECT message , but it won't work ...#include <A3LMonthCal.au3> Global $hGUI, $hCal ; Create GUI $hGUI = GUICreate("Month Calendar", 400, 300) $hCal = _MonthCal_Create($hGUI, 4, 4, $WS_BORDER) GUISetState() ; Loop until user exits while 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $hCal msgbox(0,"Info","Clicked") EndSwitch WEndWhat am I missing ?Help would be appreciated.Pierre Link to comment Share on other sites More sharing options...
martin Posted July 29, 2007 Share Posted July 29, 2007 Hello, I have two basic questions on this control :How can I change the position of the MonthCalendar on a window/dialog ?How can I detect when a user clicked ont it ?When I change the horizontal and vertical position, this control grows ... I already tried to use the simple code below to trap the $MCN_SELECT message , but it won't work ... #include <A3LMonthCal.au3> Global $hGUI, $hCal ; Create GUI $hGUI = GUICreate("Month Calendar", 400, 300) $hCal = _MonthCal_Create($hGUI, 4, 4, $WS_BORDER) GUISetState() ; Loop until user exits while 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $hCal msgbox(0,"Info","Clicked") EndSwitch WEnd What am I missing ? Help would be appreciated. Pierre Maybe this shows what you want expandcollapse popup#include <A3LMonthCal.au3> #include <GUIConstants.au3> Global $hGUI, $hCal ; Create GUI $hGUI = GUICreate("Month Calendar", 400, 300) $hCal = _MonthCal_Create($hGUI, 4, 50, $WS_BORDER) $lab = GUICtrlCreateLabel("no clicks on cal",10,5,120,28) $but1 = GUICtrlCreateButton("move cal",160,5,100,28) GUISetState() $cw = WinGetClientSize("Month Calendar","") $ww = WinGetPos("Month Calendar") $borderw = ($ww[2] - $cw[0])/2 ConsoleWrite($borderw & @CRLF) $titleht= $ww[3] - $cw[1] - $borderw $clicks = 0 while 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $hCal msgbox(0,"Info","Clicked") Case $GUI_EVENT_PRIMARYDOWN If HWNDUnderMouse() = $hCal Then $clicks += 1 GUICtrlSetData($lab,$clicks & " clicks on cal") EndIf Case $but1 _MonthCal_move($hCal, 1, 1) EndSwitch WEnd Func _MonthCal_move($hWnd, $iX=0, $iY=0) Local $iH, $iW, $iN, $rRect $rRect = _GetWindowRect($hWnd) $iI = DllStructGetData($rRect, $RECT_LEFT) $iJ = DllStructGetData($rRect, $RECT_TOP) $iw = DllStructGetData($rRect, $RECT_RIGHT) - $iI $ih = DllStructGetData($rRect, $RECT_BOTTOM) - $iJ $wpos = WinGetPos($hGUI) _SetWindowPos($hWnd, 0, $iI + $ix-$wpos[0]-$borderw, $iJ + $iY-$wpos[1]-$titleht, $iW, $iH, $SWP_NOZORDER); EndFunc Func HWNDUnderMouse() Local $point, $hwnd $point = MouseGetPos() If @error Then Return SetError(1,0,0) $hwnd = DLLCall("user32.dll", "hwnd", "WindowFromPoint", "int", $point[0], "int", $point[1]) If Not @error Or $hwnd[0] <> 0 Then Return $hwnd[0] Return SetError(2,0,0) EndFunc Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Pierre40a Posted July 29, 2007 Author Share Posted July 29, 2007 Maybe this shows what you want expandcollapse popup#include <A3LMonthCal.au3> #include <GUIConstants.au3> Global $hGUI, $hCal ; Create GUI $hGUI = GUICreate("Month Calendar", 400, 300) $hCal = _MonthCal_Create($hGUI, 4, 50, $WS_BORDER) $lab = GUICtrlCreateLabel("no clicks on cal",10,5,120,28) $but1 = GUICtrlCreateButton("move cal",160,5,100,28) GUISetState() $cw = WinGetClientSize("Month Calendar","") $ww = WinGetPos("Month Calendar") $borderw = ($ww[2] - $cw[0])/2 ConsoleWrite($borderw & @CRLF) $titleht= $ww[3] - $cw[1] - $borderw $clicks = 0 while 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $hCal msgbox(0,"Info","Clicked") Case $GUI_EVENT_PRIMARYDOWN If HWNDUnderMouse() = $hCal Then $clicks += 1 GUICtrlSetData($lab,$clicks & " clicks on cal") EndIf Case $but1 _MonthCal_move($hCal, 1, 1) EndSwitch WEnd Func _MonthCal_move($hWnd, $iX=0, $iY=0) Local $iH, $iW, $iN, $rRect $rRect = _GetWindowRect($hWnd) $iI = DllStructGetData($rRect, $RECT_LEFT) $iJ = DllStructGetData($rRect, $RECT_TOP) $iw = DllStructGetData($rRect, $RECT_RIGHT) - $iI $ih = DllStructGetData($rRect, $RECT_BOTTOM) - $iJ $wpos = WinGetPos($hGUI) _SetWindowPos($hWnd, 0, $iI + $ix-$wpos[0]-$borderw, $iJ + $iY-$wpos[1]-$titleht, $iW, $iH, $SWP_NOZORDER); EndFunc Func HWNDUnderMouse() Local $point, $hwnd $point = MouseGetPos() If @error Then Return SetError(1,0,0) $hwnd = DLLCall("user32.dll", "hwnd", "WindowFromPoint", "int", $point[0], "int", $point[1]) If Not @error Or $hwnd[0] <> 0 Then Return $hwnd[0] Return SetError(2,0,0) EndFunc Thanks for your help, but this piece of code does'nt work for me. Here's the error message I get when executing it : C:\Projets perso\Micros 9700\test.au3(45,49) : WARNING: $RECT_LEFT: possibly used before declaration. $iI = DllStructGetData($rRect, $RECT_LEFT) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Projets perso\Micros 9700\test.au3(46,45) : WARNING: $RECT_TOP: possibly used before declaration. $iJ = DllStructGetData($rRect, $RECT_TOP) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Projets perso\Micros 9700\test.au3(47,47) : WARNING: $RECT_RIGHT: possibly used before declaration. $iw = DllStructGetData($rRect, $RECT_RIGHT) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Projets perso\Micros 9700\test.au3(48,50) : WARNING: $RECT_BOTTOM: possibly used before declaration. $ih = DllStructGetData($rRect, $RECT_BOTTOM) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Projets perso\Micros 9700\test.au3(45,49) : ERROR: $RECT_LEFT: undeclared global variable. $iI = DllStructGetData($rRect, $RECT_LEFT) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Projets perso\Micros 9700\test.au3(44,34) : ERROR: _GetWindowRect(): undefined function. $rRect = _GetWindowRect($hWnd) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Projets perso\Micros 9700\test.au3(50,111) : ERROR: _SetWindowPos(): undefined function. _SetWindowPos($hWnd, 0, $iI + $ix-$wpos[0]-$borderw, $iJ + $iY-$wpos[1]-$titleht, $iW, $iH, $SWP_NOZORDER) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~^ C:\Projets perso\Micros 9700\test.au3 - 3 error(s), 4 warning(s) There should missing an additional "include" command on top of it. Thinking of it, does this come from the autoitversion I'm using ? (v3.2.4.9). Cheers, Pierre Link to comment Share on other sites More sharing options...
martin Posted July 29, 2007 Share Posted July 29, 2007 @Pierre40a I don't really know what the difference is between the installation on the PC I wrote the code on and your PC and, come to that, the PC I'm using now which has the same problem you had. So try this, but you have to run it in the non-Beta version. (On the PC I used first the versions of A3LMonthCal.au3 and A3LConstants.au3 are in the Beta/includes as well but different to the standard includes.) expandcollapse popup#include <A3LMonthCal.au3> #include <GUIConstants.au3> #include <A3Lconstants.au3> Global $hGUI, $hCal Global Const $RECT_LEFT = 1 Global Const $RECT_TOP = 2 Global Const $RECT_RIGHT = 3 Global Const $RECT_BOTTOM = 4 ; Create GUI $hGUI = GUICreate("Month Calendar", 400, 300) $hCal = _MonthCal_Create($hGUI, 4, 50, $WS_BORDER) $lab = GUICtrlCreateLabel("no clicks on cal",10,5,120,28) $but1 = GUICtrlCreateButton("move cal",160,5,100,28) GUISetState() $cw = WinGetClientSize("Month Calendar","") $ww = WinGetPos("Month Calendar") $borderw = ($ww[2] - $cw[0])/2 ConsoleWrite($borderw & @CRLF) $titleht= $ww[3] - $cw[1] - $borderw $clicks = 0 while 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $hCal msgbox(0,"Info","Clicked") Case $GUI_EVENT_PRIMARYDOWN If HWNDUnderMouse() = $hCal Then $clicks += 1 GUICtrlSetData($lab,$clicks & " clicks on cal") EndIf Case $but1 _MonthCal_move($hCal, 1, 1) EndSwitch WEnd Func _MonthCal_move($hWnd, $iX=0, $iY=0) Local $iH, $iW, $iN, $rRect $rRect = _API_GetWindowRect($hWnd) $iI = DllStructGetData($rRect, $RECT_LEFT) $iJ = DllStructGetData($rRect, $RECT_TOP) $iw = DllStructGetData($rRect, $RECT_RIGHT) - $iI $ih = DllStructGetData($rRect, $RECT_BOTTOM) - $iJ $wpos = WinGetPos($hGUI) _API_SetWindowPos($hWnd, 0, $iI + $ix-$wpos[0]-$borderw, $iJ + $iY-$wpos[1]-$titleht, $iW, $iH, $SWP_NOZORDER); EndFunc Func HWNDUnderMouse() Local $point, $hwnd $point = MouseGetPos() If @error Then Return SetError(1,0,0) $hwnd = DLLCall("user32.dll", "hwnd", "WindowFromPoint", "int", $point[0], "int", $point[1]) If Not @error Or $hwnd[0] <> 0 Then Return $hwnd[0] Return SetError(2,0,0) EndFunc Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Pierre40a Posted July 29, 2007 Author Share Posted July 29, 2007 Thanks so much Martin ! :-))) Have a good night (her, it's 11:45 PM) ... Cheers, Pierre @Pierre40a I don't really know what the difference is between the installation on the PC I wrote the code on and your PC and, come to that, the PC I'm using now which has the same problem you had. So try this, but you have to run it in the non-Beta version. (On the PC I used first the versions of A3LMonthCal.au3 and A3LConstants.au3 are in the Beta/includes as well but different to the standard includes.) expandcollapse popup#include <A3LMonthCal.au3> #include <GUIConstants.au3> #include <A3Lconstants.au3> Global $hGUI, $hCal Global Const $RECT_LEFT = 1 Global Const $RECT_TOP = 2 Global Const $RECT_RIGHT = 3 Global Const $RECT_BOTTOM = 4 ; Create GUI $hGUI = GUICreate("Month Calendar", 400, 300) $hCal = _MonthCal_Create($hGUI, 4, 50, $WS_BORDER) $lab = GUICtrlCreateLabel("no clicks on cal",10,5,120,28) $but1 = GUICtrlCreateButton("move cal",160,5,100,28) GUISetState() $cw = WinGetClientSize("Month Calendar","") $ww = WinGetPos("Month Calendar") $borderw = ($ww[2] - $cw[0])/2 ConsoleWrite($borderw & @CRLF) $titleht= $ww[3] - $cw[1] - $borderw $clicks = 0 while 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit case $hCal msgbox(0,"Info","Clicked") Case $GUI_EVENT_PRIMARYDOWN If HWNDUnderMouse() = $hCal Then $clicks += 1 GUICtrlSetData($lab,$clicks & " clicks on cal") EndIf Case $but1 _MonthCal_move($hCal, 1, 1) EndSwitch WEnd Func _MonthCal_move($hWnd, $iX=0, $iY=0) Local $iH, $iW, $iN, $rRect $rRect = _API_GetWindowRect($hWnd) $iI = DllStructGetData($rRect, $RECT_LEFT) $iJ = DllStructGetData($rRect, $RECT_TOP) $iw = DllStructGetData($rRect, $RECT_RIGHT) - $iI $ih = DllStructGetData($rRect, $RECT_BOTTOM) - $iJ $wpos = WinGetPos($hGUI) _API_SetWindowPos($hWnd, 0, $iI + $ix-$wpos[0]-$borderw, $iJ + $iY-$wpos[1]-$titleht, $iW, $iH, $SWP_NOZORDER); EndFunc Func HWNDUnderMouse() Local $point, $hwnd $point = MouseGetPos() If @error Then Return SetError(1,0,0) $hwnd = DLLCall("user32.dll", "hwnd", "WindowFromPoint", "int", $point[0], "int", $point[1]) If Not @error Or $hwnd[0] <> 0 Then Return $hwnd[0] Return SetError(2,0,0) EndFunc Link to comment Share on other sites More sharing options...
martin Posted July 29, 2007 Share Posted July 29, 2007 Thanks so much Martin ! :-)))Have a good night (her, it's 11:45 PM) ...Cheers,PierreNo problem, glad you got it to work. Good night , it's only 11:05pm here so I'm still fresh! Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now