aommaster Posted December 26, 2008 Posted December 26, 2008 Hey guys If you take a look at the page you get when you want to post a reply, you'll see 4 comboboxes on the page, relating to special items, font faces, sizes and colors. I've got a few questions regarding this: 1.How do I have a combobox display a title, but when opened, the title does not display as an option (like the "insert special item" combobox) 2.How do I replicate the font face combobox, where a font is displayed as a preview? 3.How do I replicate the font color combobox, where a colour swatch is displayed? Thanks guys!
Kip Posted December 27, 2008 Posted December 27, 2008 (edited) The ComboBox UDF will answer your first question. And you'll have to create custom GUIs as dropdown menu for your second and third question. Edited December 27, 2008 by Kip MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API.
aommaster Posted December 27, 2008 Author Posted December 27, 2008 Could you elaborate on both, the UDF and the custom GUI creation?
ProgAndy Posted December 27, 2008 Posted December 27, 2008 1 and 3 can be created with combobox UDF: 1: see example of _GUICtrlComboBox_SetEditText 3: ComboBoxEx and _GUICtrlComboBoxEx_SetItemImage / _GUICtrlComboBoxEx_CreateSolidBitMap example for 3: expandcollapse popup#include <GuiComboBoxEx.au3> #include <GuiImageList.au3> #include <GuiConstantsEx.au3> Opt('MustDeclareVars', 1) $Debug_CB = False ; Check ClassName being passed to ComboBox/ComboBoxEx functions, set to True and use a handle to another control to see it work Global $iMemo _Main() Func _Main() Local $hGUI, $hImage, $hCombo,$bmp ; Create GUI $hGUI = GUICreate("ComboBoxEx Set Image List", 400, 300) $hCombo = _GUICtrlComboBoxEx_Create ($hGUI, "", 2, 2, 394, 100) $iMemo = GUICtrlCreateEdit("", 2, 32, 396, 266, 0) GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New") GUISetState() $hImage = _GUIImageList_Create (20, 12, 5, 3) Local $List[7][2] = [ _ ["ROT",0xFF0000] , _ ["Grün",0x00FF00] , _ ["Blau",0x0000FF] , _ ["Gelb",0xFFFF00] , _ ["cyan",0x00FFFF] , _ ["Weiß",0xFFFFFF] , _ ["Schwarz",0x000000] ] ;Set Image List _GUICtrlComboBoxEx_SetImageList ($hCombo, $hImage) ; Add Items For $i = 0 To UBound($List)-1 $bmp = _IMGListAddColor($hImage,$List[$i][1],20,12) _GUICtrlComboBoxEx_AddString ($hCombo, $List[$i][0], $bmp, $bmp) Next Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>_Main ; Prog@ndy Func _IMGListAddColor($hImage,$Color,$W=16,$H=16) Local $bmp = _WinAPI_CreateSolidBitMap (_WinAPI_GetDesktopWindow(), $Color,$W,$H) Local $index = _GUIImageList_Add ($hImage,$bmp) _WinAPI_DeleteObject($bmp) Return $index EndFunc *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
Kip Posted December 27, 2008 Posted December 27, 2008 3: ComboBoxEx and _GUICtrlComboBoxEx_SetItemImage / _GUICtrlComboBoxEx_CreateSolidBitMapNot quite what he mean't. MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API.
aommaster Posted December 27, 2008 Author Posted December 27, 2008 1: see example of _GUICtrlComboBox_SetEditTextThe problem with this function is that once the data in the combobox has changed whatever was initially in the box is lost. That, and I need an edit control, which I do not have. Is there any way to keep the default value set?3: ComboBoxEx and _GUICtrlComboBoxEx_SetItemImage / _GUICtrlComboBoxEx_CreateSolidBitMapI'm confused... the example posted creates a column of different colors, but not a swatch (ie, more than one column of colors). Is there any way of defining how many columns of a combobox is displayed?Thanks!
ProgAndy Posted December 28, 2008 Posted December 28, 2008 To 1: every ComboBox that is not read-only has the edit-field. And why do you want the default value to be there after the user chose something? To 2: Sorry, If you really want a swatch, it is not possible with a combobox. You have to create it manually with a GUI. (My example has the same list style as in _ChooseFont ) *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
Kip Posted December 28, 2008 Posted December 28, 2008 To 1: every ComboBox that is not read-only has the edit-field. And why do you want the default value to be there after the user chose something?Click on "Add Reply" right here in this topic, then you'll see a combobox with "Insert Special Item". That's the kind of combo he/she want's to make. MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API.
aommaster Posted December 28, 2008 Author Posted December 28, 2008 Click on "Add Reply" right here in this topic, then you'll see a combobox with "Insert Special Item". That's the kind of combo he/she want's to make. That's the type of combobox I'd like to make.As for the swatch, I can see why I'd need to make a custom GUI for it. Could you provide me with any pointers on where to start, and what level of autoit programming is required of me to achieve it?
Kip Posted December 28, 2008 Posted December 28, 2008 As for the swatch, I can see why I'd need to make a custom GUI for it. Could you provide me with any pointers on where to start, and what level of autoit programming is required of me to achieve it?Advanced MailSpons: Fake SMTP server for safe email testing Dutch postcode & address API.
rasim Posted December 29, 2008 Posted December 29, 2008 @aommaster The problem with this function is that once the data in the combobox has changed whatever was initially in the box is lost.This? expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GUIComboBox.au3> GUICreate("Test", 300, 200) $hCombo = GUICtrlCreateCombo("", 50, 50, 200) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUISetState() _GUICtrlComboBox_BeginUpdate($hCombo) _GUICtrlComboBox_AddDir($hCombo, @WindowsDir & "\*.exe") _GUICtrlComboBox_EndUpdate($hCombo) _GUICtrlComboBox_SetEditText($hCombo, "Default text") While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $hCombo _GUICtrlComboBox_SetEditText($hCombo, "Default text") EndSwitch WEnd Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam) Local $iIDFrom = BitAND($wParam, 0x0000FFFF) Local $iCode = BitShift($wParam, 16) Switch $iIDFrom Case $hCombo Switch $iCode Case $CBN_CLOSEUP ConsoleWrite(GUICtrlRead($iIDFrom) & @LF) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc
aommaster Posted December 29, 2008 Author Posted December 29, 2008 ProgAndy: I took a look at your code for the colored comboboxes, and when I try to implement them on my script, the combobox appears on both tabs. Is there a reason for this? And how do I fix this? I tried using the GUISwitch function, but that doesn't seem to work. Thanks again!
martin Posted December 29, 2008 Posted December 29, 2008 ProgAndy: I took a look at your code for the colored comboboxes, and when I try to implement them on my script, the combobox appears on both tabs. Is there a reason for this? And how do I fix this? I tried using the GUISwitch function, but that doesn't seem to work. Thanks again!Without seeing your script we can only guess. My guess is that you forgot to end the tab defintion with GUICtrlCreateTabItem("") 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.
aommaster Posted December 29, 2008 Author Posted December 29, 2008 Without seeing your script we can only guess.Yeah Martin, I know exactly how hard it is but like I've said in many of my other posts, the script is huge and runs on several other files, making it impossible for me to post. Below is some of the code that shoudl allow you to replicate this: expandcollapse popup#include <GuiComboBoxEx.au3> #include <GuiImageList.au3> #include <GuiConstantsEx.au3> Opt('MustDeclareVars', 1) $Debug_CB = False ; Check ClassName being passed to ComboBox/ComboBoxEx functions, set to True and use a handle to another control to see it work Global $iMemo _Main() Func _Main() Local $hGUI, $hImage, $hCombo,$bmp, $tab, $tab1, $tab2, $tab3 ; Create GUI $hGUI = GUICreate("ComboBoxEx Set Image List", 400, 300) $tab=GUICtrlCreateTab (10,10,960,720) $tab1=GUICtrlCreateTabitem ("Canned Speech Editor") $hCombo = _GUICtrlComboBoxEx_Create ($hGUI, "", 2, 50, 394, 100) $hImage = _GUIImageList_Create (20, 12, 5, 3) Local $List[7] = _ [0xFF0000 , _ 0x00FF00 , _ 0x0000FF , _ 0xFFFF00 , _ 0x00FFFF , _ 0xFFFFFF , _ 0x000000] ;Set Image List _GUICtrlComboBoxEx_SetImageList ($hCombo, $hImage) ; Add Items For $i = 0 To UBound($List)-1 $bmp = _IMGListAddColor($hImage,$List[$i],20,12) _GUICtrlComboBoxEx_AddString ($hCombo, "", $bmp, $bmp) Next guisetstate() $tab2=GUICtrlCreateTabitem ("test") $tab3=GUICtrlCreateTabitem ("") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>_Main ; Prog@ndy Func _IMGListAddColor($hImage,$Color,$W=16,$H=16) Local $bmp = _WinAPI_CreateSolidBitMap (_WinAPI_GetDesktopWindow(), $Color,$W,$H) Local $index = _GUIImageList_Add ($hImage,$bmp) _WinAPI_DeleteObject($bmp) Return $index EndFunc
Andreik Posted December 30, 2008 Posted December 30, 2008 @rasim It would be a reason to not work your script on x64?
aommaster Posted December 30, 2008 Author Posted December 30, 2008 @rasimIt would be a reason to not work your script on x64?I'm running a Quad Core, with Vista 64bit and the script seems to run fine for me
ProgAndy Posted December 30, 2008 Posted December 30, 2008 ProgAndy: I took a look at your code for the colored comboboxes, and when I try to implement them on my script, the combobox appears on both tabs. Is there a reason for this? And how do I fix this? I tried using the GUISwitch function, but that doesn't seem to work. Thanks again!The Combobox_Ex is created with an UDF. AutoIt is not able to include an UDF-control in it's tab switsching routine, so you have to do it on your won: expandcollapse popup#include <GuiComboBoxEx.au3> #include <GuiImageList.au3> #include <GuiConstantsEx.au3> Opt('MustDeclareVars', 1) $Debug_CB = False ; Check ClassName being passed to ComboBox/ComboBoxEx functions, set to True and use a handle to another control to see it work Global $iMemo _Main() Func _Main() Local $hGUI, $hImage, $hCombo,$bmp, $tab, $tab1, $tab2, $tab3 ; Create GUI $hGUI = GUICreate("ComboBoxEx Set Image List", 400, 300) $tab=GUICtrlCreateTab (10,10,960,720) $tab1=GUICtrlCreateTabitem ("Canned Speech Editor") $hCombo = _GUICtrlComboBoxEx_Create ($hGUI, "", 2, 50, 394, 100) $hImage = _GUIImageList_Create (20, 12, 5, 3) Local $List[7] = _ [0xFF0000 , _ 0x00FF00 , _ 0x0000FF , _ 0xFFFF00 , _ 0x00FFFF , _ 0xFFFFFF , _ 0x000000] ;Set Image List _GUICtrlComboBoxEx_SetImageList ($hCombo, $hImage) ; Add Items For $i = 0 To UBound($List)-1 $bmp = _IMGListAddColor($hImage,$List[$i],20,12) _GUICtrlComboBoxEx_AddString ($hCombo, "", $bmp, $bmp) Next guisetstate() $tab2=GUICtrlCreateTabitem ("test") GUICtrlCreateTabitem ("") ; \/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/ If GUICtrlRead($tab,1) <> $tab1 Then ControlHide($hCombo,"","") ; /\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\ Local $MSG Do $MSG = GUIGetMsg() ; \/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/ Switch $MSG Case $tab If GUICtrlRead($tab,1) = $tab1 Then ControlShow($hCombo,"","") Else ControlHide($hCombo,"","") EndIf EndSwitch ; /\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\-/\ Until $MSG = $GUI_EVENT_CLOSE EndFunc ;==>_Main ; Prog@ndy Func _IMGListAddColor($hImage,$Color,$W=16,$H=16) Local $bmp = _WinAPI_CreateSolidBitMap (_WinAPI_GetDesktopWindow(), $Color,$W,$H) Local $index = _GUIImageList_Add ($hImage,$bmp) _WinAPI_DeleteObject($bmp) Return $index EndFunc *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes
ReFran Posted December 30, 2008 Posted December 30, 2008 It doesn't work for me after the first selection. Here a working one based on the Tab on Tab example (somewhere under examples) and what you have had. HTH, Reinhard ; Example of TAB in TAB ctrl #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <StatusBarConstants.au3> #include <TabConstants.au3> #include <GuiTab.au3> #include <WindowsConstants.au3> #include <GuiStatusBar.au3> #include <GuiComboBoxEx.au3> #include <GuiImageList.au3> Global $main_GUI,$ok_button,$cancel_button ; This window has 2 ok/cancel-buttons $main_GUI = GUICreate("Stab on TAB",260,250,-1,-1) $ok_button = GUICtrlCreateButton("OK",40,220,70,20) $cancel_button = GUICtrlCreateButton("Cancel",150,220,70,20) ; Create the first child window that is implemented into the main GUI $child1 = GUICreate("",230,170,15,35,BitOr($WS_CHILD,$WS_TABSTOP),-1,$main_GUI) $hCombo = _GUICtrlComboBoxEx_Create ($child1, "", 5, 50, 100, 100) $hImage = _GUIImageList_Create (20, 12, 5, 3) Local $List[7] = _ [0xFF0000 , _ 0x00FF00 , _ 0x0000FF , _ 0xFFFF00 , _ 0x00FFFF , _ 0xFFFFFF , _ 0x000000] ;Set Image List _GUICtrlComboBoxEx_SetImageList ($hCombo, $hImage) ; Add Items For $i = 0 To UBound($List)-1 $bmp = _IMGListAddColor($hImage,$List[$i],20,12) _GUICtrlComboBoxEx_AddString ($hCombo, "", $bmp, $bmp) Next $StatusBar1 = _GUICtrlStatusBar_Create($Child1) Dim $StatusBar1_PartsWidth[2] = [150, -1] _GUICtrlStatusBar_SetParts($StatusBar1, $StatusBar1_PartsWidth) _GUICtrlStatusBar_SetText($StatusBar1, " Panel 1", 0) _GUICtrlStatusBar_SetText($StatusBar1, "Panel 2", 1) GUISetState() ; Create the second child window that is implemented into the main GUI $child2 = GUICreate("",230,170,15,35,BitOr($WS_CHILD,$WS_TABSTOP),-1,$main_GUI) $listview2 = GUICtrlCreateListView("Col1|Col2",10,10,210,150,-1,$WS_EX_CLIENTEDGE) GUICtrlCreateListViewItem("ItemLong1|ItemLong12", $listview2) GUICtrlCreateListViewItem("ItemLong2|Item22", $listview2) ; Switch back the main GUI and create the tabs GUISwitch($main_GUI) $main_tab = GUICtrlCreateTab(10,10,240,200) $child1tab = GUICtrlCreateTabItem("Child1") $child2tab = GUICtrlCreateTabItem("Child2") GUICtrlCreateTabItem("") DIM $tabItemLast = 0 GUISetState() While 1 $msg = GUIGetMsg(1) Switch $msg[0] Case $GUI_EVENT_CLOSE, $cancel_button ExitLoop Case $main_tab $tabItem = GUICtrlRead($main_Tab) if $tabItem <> $tabItemLast then TabSwitch($tabItem) EndSwitch WEnd func TabSwitch($tabItem) GUISetState(@SW_HIDE,$child1) GUISetState(@SW_HIDE,$child2) if $tabItem = 0 then GUISetState(@SW_SHOW,$child1) if $tabItem = 1 then GUISetState(@SW_SHOW,$child2) $tabItemLast = $tabItem EndFunc Func _IMGListAddColor($hImage,$Color,$W=16,$H=16) Local $bmp = _WinAPI_CreateSolidBitMap (_WinAPI_GetDesktopWindow(), $Color,$W,$H) Local $index = _GUIImageList_Add ($hImage,$bmp) _WinAPI_DeleteObject($bmp) Return $index EndFunc
aommaster Posted December 30, 2008 Author Posted December 30, 2008 The Combobox_Ex is created with an UDF. AutoIt is not able to include an UDF-control in it's tab switsching routine, so you have to do it on your wonOh okay. Thanks
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