lorenkinzel Posted February 25, 2011 Share Posted February 25, 2011 I managed to muddle my way through this one & was wondering if there is a better / easier way to accomplish: Input reading slider. I couldn't find any examples & only stumbled on 'dummy' because I sarcastically typed it into the help search-box when I was unable to get the input to read anything. Smoked turkey calculator expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=turkey_leg.ico #AutoIt3Wrapper_Res_Comment=time / temp calculator #AutoIt3Wrapper_Res_Description=time / temp calculator #AutoIt3Wrapper_Res_LegalCopyright=Lorens' S--T #AutoIt3Wrapper_Res_Language=1038 #AutoIt3Wrapper_Run_Tidy=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <SliderConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> ;#include <ButtonConstants.au3> #include <Constants.au3> HotKeySet("{ESC}", "Terminate");press esc to esc Local $Slider, $msg, $input, $dummy, $dummy2, $dummy3, $dummy4, $dummy5, $dummy6 $Form1 = GUICreate("Smoked Turkey time / temp calculator", 633, 447, 192, 124) ;GUISetBkColor(0x808080); will change background color, perhaps not for the better $Slider = GUICtrlCreateSlider(56, 304, 521, 33) GUICtrlSetLimit(-1, 275, 235) GUICtrlSetData(-1, 235) $Input1 = GUICtrlCreateInput("Enter Weight", 0, 0, 105, 24);how much the thing weighs GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") ;hours=((((temperature-275)*-.25)+22.5)/60)*$weight--only good within this temperature range ;tell no one or I must kill you ! (joking) $Label1 = GUICtrlCreateLabel("Bird Weight", 8, 32, 102, 24) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Label2 = GUICtrlCreateLabel("Temp °F", 144, 344, 63, 24) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Label3 = GUICtrlCreateLabel("Hours, cook time", 312, 344, 127, 24) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Input2 = GUICtrlCreateInput(GUICtrlRead($dummy), 144, 280, 73, 24, $ES_NUMBER);show temperature as dictated by slider GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Input3 = GUICtrlCreateInput(GUICtrlRead($dummy2), 328, 280, 89, 24, $ES_NUMBER);cook time in hours GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") $Label4 = GUICtrlCreateLabel("At 235 degrees F your turkey will take 30 to 35 minutes per pound.", 16, 80, 332, 17) $Label5 = GUICtrlCreateLabel("At 250 degrees F your turkey will take 25 to 30 minutes per pound.", 16, 112, 316, 17) $Label6 = GUICtrlCreateLabel("At 275 degrees F your turkey will take 20 to 25 minutes per pound.", 16, 144, 316, 17) $Label7 = GUICtrlCreateLabel("But you still need a meat thermometer, It's cooking-not manufacturing.", 16, 176, 336, 17) $Input4 = GUICtrlCreateInput(GUICtrlRead($dummy4), 368, 80, 121, 21, $ES_NUMBER);time at 235° $Input5 = GUICtrlCreateInput(GUICtrlRead($dummy5), 368, 112, 121, 21, $ES_NUMBER);time at 250° $Input6 = GUICtrlCreateInput(GUICtrlRead($dummy6), 368, 144, 121, 21, $ES_NUMBER);time at 275° GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $Slider $dummy = GUICtrlRead($Slider) GUICtrlSetData($Input2, $dummy) $dummy2 = GUICtrlRead($Input1);bird weight $dummy3 = ((((($dummy - 275) * - .25) + 22.5) / 60) * $dummy2);the whole shoot & shebang formula GUICtrlSetData($Input3, $dummy3) $dummy4 = (((((235 - 275) * - .25) + 22.5) / 60) * $dummy2) GUICtrlSetData($Input4, $dummy4) $dummy5 = (((((250 - 275) * - .25) + 22.5) / 60) * $dummy2) GUICtrlSetData($Input5, $dummy5) $dummy6 = (((((275 - 275) * - .25) + 22.5) / 60) * $dummy2) GUICtrlSetData($Input6, $dummy6) EndSelect WEnd Func Terminate() Exit 0 EndFunc ;==>Terminate Link to comment Share on other sites More sharing options...
rover Posted February 25, 2011 Share Posted February 25, 2011 (edited) I managed to muddle my way through this one & was wondering if there is a better / easier way to accomplish: Input reading slider. I couldn't find any examples & only stumbled on 'dummy' because I sarcastically typed it into the help search-box when I was unable to get the input to read anything. Smoked turkey calculator Edit: Forgot to add, Welcome to the forums! For realtime updating of the slider position you want to use a WM_HSCROLL/WM_VSCROLL message handler, I've added realtime slider updating, a cue banner for the weight input and realtime updating of the weight input. The cue banner only appears when the input is blank. you might want to add tooltips to the input and the slider This example uses the dummy control, so you were on the right track... expandcollapse popup#region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=turkey_leg.ico #AutoIt3Wrapper_Res_Comment=time / temp calculator #AutoIt3Wrapper_Res_Description=time / temp calculator #AutoIt3Wrapper_Res_LegalCopyright=Lorens' S--T #AutoIt3Wrapper_Res_Language=1038 #AutoIt3Wrapper_Run_Tidy=y #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <SliderConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> ;#include <ButtonConstants.au3> #include <Constants.au3> #include <GuiEdit.au3> HotKeySet("{ESC}", "Terminate");press esc to esc Local $hSlider, $Slider, $cSliderRet, $msg, $input, $iBuffer, $dummy2, $dummy3, $dummy4, $dummy5, $dummy6 Local $Form1 = GUICreate("Smoked Turkey time / temp calculator", 633, 447, 192, 124) ;GUISetBkColor(0x808080); will change background color, perhaps not for the better $Slider = GUICtrlCreateSlider(56, 304, 521, 33) GUICtrlSetLimit(-1, 275, 235) GUICtrlSetData(-1, 235) $hSlider = GUICtrlGetHandle($Slider) $cSliderRet = GUICtrlCreateDummy() ;cue banner always appears when input is blank ;in XP, cursor in edit control prevents banner from appearing If @OSVersion = "WIN_XP" Then $Input1 = GUICtrlCreateInput("Enter Weight", 0, 0, 105, 24, $ES_NUMBER);how much the thing weighs _GUICtrlEdit_SetCueBanner($Input1, "Enter Weight", False) Else $Input1 = GUICtrlCreateInput("", 0, 0, 105, 24);how much the thing weighs _GUICtrlEdit_SetCueBanner($Input1, "Enter Weight", True) EndIf GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") ;hours=((((temperature-275)*-.25)+22.5)/60)*$weight--only good within this temperature range ;tell no one or I must kill you ! (joking) Local $Label1 = GUICtrlCreateLabel("Bird Weight", 8, 32, 102, 24) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") Local $Label2 = GUICtrlCreateLabel("Temp °F", 144, 344, 63, 24) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") Local $Label3 = GUICtrlCreateLabel("Hours, cook time", 312, 344, 127, 24) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") Local $Input2 = GUICtrlCreateInput("", 144, 280, 73, 24, $ES_NUMBER);show temperature as dictated by slider GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") Local $Input3 = GUICtrlCreateInput("", 328, 280, 89, 24, $ES_NUMBER);cook time in hours GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") Local $Label4 = GUICtrlCreateLabel("At 235 degrees F your turkey will take 30 to 35 minutes per pound.", 16, 80, 332, 17) Local $Label5 = GUICtrlCreateLabel("At 250 degrees F your turkey will take 25 to 30 minutes per pound.", 16, 112, 316, 17) Local $Label6 = GUICtrlCreateLabel("At 275 degrees F your turkey will take 20 to 25 minutes per pound.", 16, 144, 316, 17) Local $Label7 = GUICtrlCreateLabel("But you still need a meat thermometer, It's cooking-not manufacturing.", 16, 176, 336, 17) Local $Input4 = GUICtrlCreateInput("", 368, 80, 121, 21, $ES_NUMBER);time at 235° Local $Input5 = GUICtrlCreateInput("", 368, 112, 121, 21, $ES_NUMBER);time at 250° Local $Input6 = GUICtrlCreateInput("", 368, 144, 121, 21, $ES_NUMBER);time at 275° GUIRegisterMsg($WM_COMMAND, "WM_HANDLER") GUIRegisterMsg($WM_HSCROLL, "WM_HANDLER") ;GUIRegisterMsg($WM_VSCROLL, "WM_HANDLER") _Slider($Slider, True) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $cSliderRet _Slider($cSliderRet) EndSelect WEnd Func _Slider($cSlider, $fBypass = False) Local $dummy $dummy = GUICtrlRead($cSlider); read dummy control for value of slider ;ConsoleWrite('+$dummy = ' & $dummy & @crlf) If $iBuffer <> $dummy Or $fBypass = True Then ; buffer the read slider value to prevent unnecessary updating at each end of the sliders range. $iBuffer = $dummy GUICtrlSetData($Input2, $dummy) $dummy2 = GUICtrlRead($Input1);bird weight $dummy3 = ((((($dummy - 275) * - .25) + 22.5) / 60) * $dummy2);the whole shoot & shebang formula GUICtrlSetData($Input3, $dummy3) $dummy4 = (((((235 - 275) * - .25) + 22.5) / 60) * $dummy2) GUICtrlSetData($Input4, $dummy4) $dummy5 = (((((250 - 275) * - .25) + 22.5) / 60) * $dummy2) GUICtrlSetData($Input5, $dummy5) $dummy6 = (((((275 - 275) * - .25) + 22.5) / 60) * $dummy2) GUICtrlSetData($Input6, $dummy6) ;ConsoleWrite('-Value = ' & $iBuffer & @CRLF) EndIf Return EndFunc ;==>_Slider Func WM_HANDLER($hWnd, $iMsg, $wParam, $lParam) ; Slider #forceref $hWnd, $iMsg, $wParam, $lParam Switch $iMsg Case $WM_HSCROLL, $WM_VSCROLL Switch $lParam Case $hSlider GUICtrlSendToDummy($cSliderRet, GUICtrlRead($Slider)) EndSwitch Case $WM_COMMAND Local $nNotifyCode = BitShift($wParam, 16) Local $nID = BitAND($wParam, 0xFFFF) Switch $nID Case $Input1 Switch $nNotifyCode Case $EN_CHANGE _Slider($Slider, True) EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_HANDLER Func Terminate() Exit 0 EndFunc ;==>Terminate ; #FUNCTION# ==================================================================================================================== ; Name...........: _GUICtrlEdit_SetCueBanner ; Description ...: Sets the cue banner text that is displayed for single line edit controls ; Syntax.........: _GUICtrlEdit_SetCueBanner($hWnd, $sText, $wParam = False, $iCodePage = 0, $iFlags = 0) ; Parameters ....: $hWnd - Handle to control ; $sText - String that contains the text ; $wParam - False: (Default) Cue banner disappears when control selected. ; - True: Display cue banner even when the edit control is selected.* ; $iCodePage - (Optional) See _WinAPI_MultiByteToWideChar() ; $iFlags - (Optional) See _WinAPI_MultiByteToWideChar() ; Return values .: Success - True ; Failure - False ; Author ........: rover 2k8 ; Modified.......: ; Remarks .......: The cue banner is text that is displayed in an edit control when there is no selection. ; You cannot set a cue banner on a multiline edit control or on a rich edit control. ; There is a problem with cue banners and Asian language support in XP, this issue has been fixed in Vista. ; * wParam TRUE - Vista only. (In XP cue text always disappears when the control gets focus). ; EM_SETCUEBANNER vs. international support in XP and Server 2003 ; https://blogs.msdn.com/michkap/archive/2006/02/25/538735.aspx ; EM_SETCUEBANNER Message, wParam TRUE - not working for XP. ; http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2799112&SiteID=1 ;+ ; Minimum Operating Systems: Windows XP ; Related .......: _GUICtrlEdit_GetCueBanner ; Link ..........; @@MsdnLink@@ EM_SETCUEBANNER Message ; Example .......; Yes ; =============================================================================================================================== Func _GUICtrlEdit_SetCueBanner($hWnd, $sText, $wParam = False, $iCodePage = 0, $iFlags = 0) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) If _WinAPI_GetClassName($hWnd) <> "Edit" Then Return False Local $iResult, $pMemory, $sBuffer_pointer, $struct_String, $struct_MemMap $struct_String = _WinAPI_MultiByteToWideChar($sText, $iCodePage, $iFlags) $sBuffer_pointer = DllStructGetPtr($struct_String) If _WinAPI_InProcess($hWnd, $_ghEditLastWnd) Then $iResult = _SendMessage($hWnd, $EM_SETCUEBANNER, $wParam, $sBuffer_pointer) Else $pMemory = _MemInit($hWnd, (StringLen($sText) + 1), $struct_MemMap) _MemWrite($struct_MemMap, $sBuffer_pointer) $iResult = _SendMessage($hWnd, $EM_SETCUEBANNER, $wParam, $pMemory) _MemFree($struct_MemMap) EndIf Return $iResult <> 0 EndFunc ;==>_GUICtrlEdit_SetCueBanner Edited February 25, 2011 by rover I see fascists... Link to comment Share on other sites More sharing options...
lorenkinzel Posted February 25, 2011 Author Share Posted February 25, 2011 Thanks. Especially for the commenting / description. Link to comment Share on other sites More sharing options...
lorenkinzel Posted February 25, 2011 Author Share Posted February 25, 2011 Thanks. Especially for the commenting / description. I can't seem to find any info on the WM_HSCROLL/WM_VSCROLL message handler in the 'help'. Could you point me in the right direction for this? The modified script does not allow a decimal point in the input. If I can get reading material & figure out the fix, I should end up with a really good grip on that process. Link to comment Share on other sites More sharing options...
rover Posted February 25, 2011 Share Posted February 25, 2011 (edited) Thanks. Especially for the commenting / description. I can't seem to find any info on the WM_HSCROLL/WM_VSCROLL message handler in the 'help'. Could you point me in the right direction for this? The modified script does not allow a decimal point in the input. If I can get reading material & figure out the fix, I should end up with a really good grip on that process. Sorry about that. Remove the $ES_NUMBER style I added to $Input1. I forgot about the limitation of integers only with that style. You want MSDN for info on messages: http://msdn.microsoft.com/en-us/default.aspx WM_HSCROLL http://msdn.microsoft.com/en-us/library/bb787575(VS.85).aspx The WM_COMMAND handler can be used to limit the Input control to integers or floating point numbers. There are many code examples on the forum of that. I see your using inputs instead of labels due to the limitation of static control styles with borders. In that case, use readonly style so the fixed values are not user editable. I've edited this version of your script to include hours/min string formatting. Edit: Added WS_TABSTOP style to slider Readonly inputs are no longer tabbable. expandcollapse popup#region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=turkey_leg.ico #AutoIt3Wrapper_Res_Comment=time / temp calculator #AutoIt3Wrapper_Res_Description=time / temp calculator #AutoIt3Wrapper_Res_LegalCopyright=Lorens' S--T #AutoIt3Wrapper_Res_Language=1038 #AutoIt3Wrapper_Run_Tidy=y #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <SliderConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> ;#include <ButtonConstants.au3> #include <Constants.au3> #include <GuiEdit.au3> HotKeySet("{ESC}", "Terminate");press esc to esc Local $hSlider, $Slider, $cSliderRet, $msg, $input, $iBuffer, $dummy2, $dummy3, $dummy4, $dummy5, $dummy6 Local $Form1 = GUICreate("Smoked Turkey time / temp calculator", 633, 447, 192, 124) ;GUISetBkColor(0x808080); will change background color, perhaps not for the better $Slider = GUICtrlCreateSlider(56, 304, 521, 33, BitOR($GUI_SS_DEFAULT_SLIDER, $WS_TABSTOP)) GUICtrlSetLimit(-1, 275, 235) GUICtrlSetData(-1, 235) $hSlider = GUICtrlGetHandle($Slider) $cSliderRet = GUICtrlCreateDummy() ;cue banner always appears when input is blank ;in XP, cursor in edit control prevents banner from appearing If @OSVersion = "WIN_XP" Then $Input1 = GUICtrlCreateInput("Enter Weight", 0, 0, 105, 24);how much the thing weighs _GUICtrlEdit_SetCueBanner($Input1, "Enter Weight", False) Else $Input1 = GUICtrlCreateInput("", 0, 0, 105, 24);how much the thing weighs _GUICtrlEdit_SetCueBanner($Input1, "Enter Weight", True) EndIf GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") ;hours=((((temperature-275)*-.25)+22.5)/60)*$weight--only good within this temperature range ;tell no one or I must kill you ! (joking) Local $Label1 = GUICtrlCreateLabel("Bird Weight", 8, 32, 102, 24) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") Local $Label2 = GUICtrlCreateLabel("Temp °F", 144, 344, 63, 24) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") Local $Label3 = GUICtrlCreateLabel("Hours, cook time", 312, 344, 127, 24) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") Local $Input2 = GUICtrlCreateInput("", 144, 280, 73, 24, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY, $ES_NUMBER));show temperature as dictated by slider GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFBFBFB) Local $Input3 = GUICtrlCreateInput("", 328, 280, 89, 24, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY, $ES_NUMBER));cook time in hours GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif") GUICtrlSetBkColor(-1, 0xFBFBFB) Local $Label4 = GUICtrlCreateLabel("At 235 degrees F your turkey will take 30 to 35 minutes per pound.", 16, 80, 332, 17) Local $Label5 = GUICtrlCreateLabel("At 250 degrees F your turkey will take 25 to 30 minutes per pound.", 16, 112, 316, 17) Local $Label6 = GUICtrlCreateLabel("At 275 degrees F your turkey will take 20 to 25 minutes per pound.", 16, 144, 316, 17) Local $Label7 = GUICtrlCreateLabel("But you still need a meat thermometer, It's cooking-not manufacturing.", 16, 176, 336, 17) Local $Input4 = GUICtrlCreateInput("", 368, 80, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY, $ES_NUMBER));time at 235° GUICtrlSetBkColor(-1, 0xFBFBFB) Local $Input5 = GUICtrlCreateInput("", 368, 112, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY, $ES_NUMBER));time at 250° GUICtrlSetBkColor(-1, 0xFBFBFB) Local $Input6 = GUICtrlCreateInput("", 368, 144, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_READONLY, $ES_NUMBER));time at 275° GUICtrlSetBkColor(-1, 0xFBFBFB) GUIRegisterMsg($WM_COMMAND, "WM_HANDLER") GUIRegisterMsg($WM_HSCROLL, "WM_HANDLER") ;GUIRegisterMsg($WM_VSCROLL, "WM_HANDLER") _Slider($Slider, True) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE Exit Case $msg = $cSliderRet _Slider($cSliderRet) EndSelect WEnd Func _Slider($cSlider, $fBypass = False) Local $dummy $dummy = GUICtrlRead($cSlider); read dummy control for value of slider ;ConsoleWrite('+$dummy = ' & $dummy & @crlf) If $iBuffer <> $dummy Or $fBypass = True Then ; buffer the read slider value to prevent unnecessary updating at each end of the sliders range. $iBuffer = $dummy GUICtrlSetData($Input2, $dummy) $dummy2 = GUICtrlRead($Input1);bird weight $dummy3 = ((((($dummy - 275) * - .25) + 22.5)) * $dummy2);the whole shoot & shebang formula Local $iHours = 0, $iMins = 0 $iHours = Floor($dummy3 / 60) $iMins = Mod($dummy3, 60) GUICtrlSetData($Input3, StringFormat("%01d:%02d", $iHours, $iMins)) $dummy4 = (((((235 - 275) * - .25) + 22.5)) * $dummy2) $iHours = Floor($dummy4 / 60) $iMins = Mod($dummy4, 60) GUICtrlSetData($Input4, StringFormat("%01d:%02d", $iHours, $iMins)) $dummy5 = (((((250 - 275) * - .25) + 22.5)) * $dummy2) $iHours = Floor($dummy5 / 60) $iMins = Mod($dummy5, 60) GUICtrlSetData($Input5, StringFormat("%01d:%02d", $iHours, $iMins)) $dummy6 = (((((275 - 275) * - .25) + 22.5)) * $dummy2) $iHours = Floor($dummy6 / 60) $iMins = Mod($dummy6, 60) GUICtrlSetData($Input6, StringFormat("%01d:%02d", $iHours, $iMins)) ;ConsoleWrite('-Value = ' & $iBuffer & @CRLF) Return 1 EndIf Return 0 EndFunc ;==>_Slider Func WM_HANDLER($hWnd, $iMsg, $wParam, $lParam) ; Slider #forceref $hWnd, $iMsg, $wParam, $lParam Switch $iMsg Case $WM_HSCROLL, $WM_VSCROLL Switch $lParam Case $hSlider GUICtrlSendToDummy($cSliderRet, GUICtrlRead($Slider)) EndSwitch Case $WM_COMMAND Local $nNotifyCode = BitShift($wParam, 16) Local $nID = BitAND($wParam, 0xFFFF) Switch $nID Case $Input1 Switch $nNotifyCode Case $EN_CHANGE _Slider($Slider, True) EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_HANDLER Func Terminate() Exit 0 EndFunc ;==>Terminate ; #FUNCTION# ==================================================================================================================== ; Name...........: _GUICtrlEdit_SetCueBanner ; Description ...: Sets the cue banner text that is displayed for single line edit controls ; Syntax.........: _GUICtrlEdit_SetCueBanner($hWnd, $sText, $wParam = False, $iCodePage = 0, $iFlags = 0) ; Parameters ....: $hWnd - Handle to control ; $sText - String that contains the text ; $wParam - False: (Default) Cue banner disappears when control selected. ; - True: Display cue banner even when the edit control is selected.* ; $iCodePage - (Optional) See _WinAPI_MultiByteToWideChar() ; $iFlags - (Optional) See _WinAPI_MultiByteToWideChar() ; Return values .: Success - True ; Failure - False ; Author ........: rover 2k8 ; Modified.......: ; Remarks .......: The cue banner is text that is displayed in an edit control when there is no selection. ; You cannot set a cue banner on a multiline edit control or on a rich edit control. ; There is a problem with cue banners and Asian language support in XP, this issue has been fixed in Vista. ; * wParam TRUE - Vista only. (In XP cue text always disappears when the control gets focus). ; EM_SETCUEBANNER vs. international support in XP and Server 2003 ; https://blogs.msdn.com/michkap/archive/2006/02/25/538735.aspx ; EM_SETCUEBANNER Message, wParam TRUE - not working for XP. ; http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2799112&SiteID=1 ;+ ; Minimum Operating Systems: Windows XP ; Related .......: _GUICtrlEdit_GetCueBanner ; Link ..........; @@MsdnLink@@ EM_SETCUEBANNER Message ; Example .......; Yes ; =============================================================================================================================== Func _GUICtrlEdit_SetCueBanner($hWnd, $sText, $wParam = False, $iCodePage = 0, $iFlags = 0) If Not IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) If _WinAPI_GetClassName($hWnd) <> "Edit" Then Return False Local $iResult, $pMemory, $sBuffer_pointer, $struct_String, $struct_MemMap $struct_String = _WinAPI_MultiByteToWideChar($sText, $iCodePage, $iFlags) $sBuffer_pointer = DllStructGetPtr($struct_String) If _WinAPI_InProcess($hWnd, $_ghEditLastWnd) Then $iResult = _SendMessage($hWnd, $EM_SETCUEBANNER, $wParam, $sBuffer_pointer) Else $pMemory = _MemInit($hWnd, (StringLen($sText) + 1), $struct_MemMap) _MemWrite($struct_MemMap, $sBuffer_pointer) $iResult = _SendMessage($hWnd, $EM_SETCUEBANNER, $wParam, $pMemory) _MemFree($struct_MemMap) EndIf Return $iResult <> 0 EndFunc ;==>_GUICtrlEdit_SetCueBanner Edited February 25, 2011 by rover I see fascists... Link to comment Share on other sites More sharing options...
lorenkinzel Posted February 26, 2011 Author Share Posted February 26, 2011 Thanks. The whole thing has a much smoother operation now, and the hour/min format really beats "5.62097584 hours". Next: I'll get proficient in how to post correctly So I can be promoted to 'newbie'. Looking forward to it. 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