NassauSky Posted November 17, 2020 Share Posted November 17, 2020 Is there a trick or alternative to displaying a selectable calendar on just the first tab. Using the sample tab script: (The problem here is it shows up on all tabs since it's associated a window handle not a tab) #include <GUIConstantsEx.au3> #include <GuiMonthCal.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Built-In Tab Example", 500, 500) $hTab = GUICtrlCreateTab(10, 10, 480, 480) ; Create tabitems For $i = 0 To 2 GUICtrlCreateTabItem("Tab " & $i) If $i = 0 Then;If this is the first tab insert the calendar Global $g_hMonthCal = _GUICtrlMonthCal_Create($hGUI, 20, 200, $WS_BORDER) EndIf GUICtrlCreateButton("Button " & $i, 20 + ($i * 100), 40 + ($i * 50), 80, 30) Next ; Close Tab definiton GUICtrlCreateTabItem("") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
GokAy Posted November 17, 2020 Share Posted November 17, 2020 (edited) Hey, * Haven't used a Tab or Calender before. Just an idea here What if you look for GUI message for a tab activate/change/whatever and Set Calender state accordingly? You will have to search for how to implement though, until someone else provides a better answer/approach https://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreateTabItem.htm (look at the example) https://www.autoitscript.com/autoit3/docs/functions/GUIGetMsg.htm https://www.autoitscript.com/autoit3/docs/functions/GUICtrlSetState.htm $GUI_SHOW (16) Control will be visible. On Tabitem control will select the first tab to be displayed. $GUI_HIDE (32) Control will not be visible. Scratch the next comment: You are using "if" Also, if Calender can only be created on the GUI, as it is you may be creating 3 of them, and only using the last one created. Edited November 17, 2020 by GokAy Link to comment Share on other sites More sharing options...
NassauSky Posted November 17, 2020 Author Share Posted November 17, 2020 (edited) Thanks @GokAy but no luck if you mean something like this: #include <GUIConstantsEx.au3> #include <GuiMonthCal.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("Built-In Tab Example", 500, 500) $hTab = GUICtrlCreateTab(10, 10, 480, 480) ; Create tabitems For $i = 0 To 2 GUICtrlCreateTabItem("Tab " & $i) If $i = 0 Then;If this is the first tab insert the calendar Global $g_hMonthCal = _GUICtrlMonthCal_Create($hGUI, 20, 200, $WS_BORDER) EndIf GUICtrlCreateButton("Button " & $i, 20 + ($i * 100), 40 + ($i * 50), 80, 30) Next ; Close Tab definiton GUICtrlCreateTabItem("") GUISetState() $prevTab = GUICtrlRead($hTab) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch If GUICtrlRead($hTab) <> $prevTab Then $prevTab = GUICtrlRead($hTab) MsgBox(0,"Switched Tabs", $prevTab & " Visible state: " & GUICtrlGetState($g_hMonthCal)) If $prevTab = 0 Then GUICtrlSetState($g_hMonthCal, $GUI_SHOW) Else GUICtrlSetState($g_hMonthCal, $GUI_HIDE) EndIf EndIf WEnd It isn't hiding the tab. Edited November 17, 2020 by NassauSky Link to comment Share on other sites More sharing options...
GokAy Posted November 17, 2020 Share Posted November 17, 2020 I would guess more like (looking at the example) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hTab if GUICtrlRead($hTab) = 0 then GUICtrlSetState($g_hMonthCal, $GUI_SHOW) else GUICtrlSetState($g_hMonthCal, $GUI_HIDE) endif EndSwitch WEnd Link to comment Share on other sites More sharing options...
NassauSky Posted November 17, 2020 Author Share Posted November 17, 2020 Thanks again @GokAy but that is functionally equivalent to what I did. It doesn't work but thanks. It doesn't seem to be reading the state (nor setting the state) of the calendar. Link to comment Share on other sites More sharing options...
Nine Posted November 17, 2020 Share Posted November 17, 2020 Try this : #include <GUIConstantsEx.au3> #include <GuiMonthCal.au3> #include <WindowsConstants.au3> #include <WinAPIGdi.au3> $hGUI = GUICreate("Built-In Tab Example", 500, 500) $hTab = GUICtrlCreateTab(10, 10, 480, 480) ; Create tabitems For $i = 0 To 2 GUICtrlCreateTabItem("Tab " & $i) If $i = 0 Then ;If this is the first tab insert the calendar Global $g_hMonthCal = _GUICtrlMonthCal_Create($hGUI, 20, 200, $WS_BORDER) EndIf GUICtrlCreateButton("Button " & $i, 20 + ($i * 100), 40 + ($i * 50), 80, 30) Next ; Close Tab definiton GUICtrlCreateTabItem("") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hTab If GUICtrlRead($hTab) = 0 Then If Not $g_hMonthCal Then $g_hMonthCal = _GUICtrlMonthCal_Create($hGUI, 20, 200, $WS_BORDER) _WinAPI_RedrawWindow($hGUI) ElseIf $g_hMonthCal Then _GUICtrlMonthCal_Destroy($g_hMonthCal) $g_hMonthCal = 0 EndIf EndSwitch WEnd “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
GokAy Posted November 17, 2020 Share Posted November 17, 2020 @Nine Wouldn't this also loose the current date value in case it may be needed? Maybe assign last date value to a variable before destroying, and re-assign after creation? Not sure about this part: Change code to read that variable instead (but it would require to set it each time a new date is selected?) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 17, 2020 Moderators Share Posted November 17, 2020 NassauSky, Please read the Tabs tutorial in the Wiki - then you will find out how to keep the calendar on the correct page. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Nine Posted November 17, 2020 Share Posted November 17, 2020 Alright here another way : #include <GUIConstantsEx.au3> #include <GuiMonthCal.au3> #include <WindowsConstants.au3> #include <WinAPIGdi.au3> #include <WinAPISysWin.au3> $hGUI = GUICreate("Built-In Tab Example", 500, 500) $hTab = GUICtrlCreateTab(10, 10, 480, 480) ; Create tabitems For $i = 0 To 2 GUICtrlCreateTabItem("Tab " & $i) If $i = 0 Then ;If this is the first tab insert the calendar Global $g_hMonthCal = _GUICtrlMonthCal_Create($hGUI, 20, 200, $WS_BORDER) EndIf GUICtrlCreateButton("Button " & $i, 20 + ($i * 100), 40 + ($i * 50), 80, 30) Next ; Close Tab definiton GUICtrlCreateTabItem("") GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hTab If GUICtrlRead($hTab) = 0 Then _WinAPI_ShowWindow ($g_hMonthCal, @SW_SHOW) Else _WinAPI_ShowWindow ($g_hMonthCal, @SW_HIDE) EndIf EndSwitch WEnd Should work better NassauSky 1 “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
GokAy Posted November 17, 2020 Share Posted November 17, 2020 (edited) Also this works, after checking out (not reading throughly) the tab wiki @Melba23 linked Edit: Notice that I pulled MonthCal creation outside the loop, since it is not tied to the tab Edit2: and also forgot the Window Style I tried earlier in there. Fixed according to the original post. expandcollapse popup#include <GUIConstantsEx.au3> #include <GuiMonthCal.au3> #include <WindowsConstants.au3> test_gui() func test_gui() Local $hGUI = GUICreate("Built-In Tab Example", 500, 500) Local $hTab = GUICtrlCreateTab(10, 10, 480, 480) Local $g_hMonthCal = _GUICtrlMonthCal_Create($hGUI, 20, 200, $WS_BORDER) ; Create tabitems For $i = 0 To 2 GUICtrlCreateTabItem("Tab " & $i) GUICtrlCreateButton("Button " & $i, 20 + ($i * 100), 40 + ($i * 50), 80, 30) Next ; Close Tab definiton GUICtrlCreateTabItem("") GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hTab ConsoleWrite($hTab & " > " & GUICtrlRead($hTab) & @crlf) if GUICtrlRead($hTab) = 0 then ControlShow($hGUI,"",$g_hMonthCal) else ControlHide($hGUI,"",$g_hMonthCal) endif EndSwitch WEnd EndFunc Edited November 17, 2020 by GokAy NassauSky 1 Link to comment Share on other sites More sharing options...
Nine Posted November 17, 2020 Share Posted November 17, 2020 Oh ya, forgot about those control command “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Screen Scraping Multi-Threading Made Easy Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 17, 2020 Moderators Share Posted November 17, 2020 GokAy, Quote not reading throughly I do recommend reading all the tutorials I wrote thoroughly - there are often some other hints hidden within them as a bonus for attentive readers. M23 Jos and GokAy 2 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
GokAy Posted November 17, 2020 Share Posted November 17, 2020 @Melba23 You are definitely right, no argument there. I usually check out a function/udf page to get an initial idea (if I know about the function), and/or ask google what I am trying to achieve with "autoit" prepended (usually lend in the forums, and sometimes in StackOverflow). Read all I find relevant, get an idea of which functions are needed (go to their pages and read all) Try to solve each step until I hit a bump, search/read some more. Rinse/repeat until I achieve what I am trying to do. However, when it comes to wikis I only read when someone mentions it in the topic. Maybe because they don't get listed all that often on my Google searches. Link to comment Share on other sites More sharing options...
NassauSky Posted November 17, 2020 Author Share Posted November 17, 2020 (edited) OMG @Nine and @GokAy both great! Too funny though at @Nine I tried it that way but using GUISetState() instead of the 2 functions: _WinAPI_RedrawWindow($hGUI) & _GUICtrlMonthCal_Destroy($g_hMonthCal) Thanks very much. You both are very fast! Edited November 17, 2020 by NassauSky 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