Jump to content



Photo

How to erase and object and replace it with another via Function calls.


  • Please log in to reply
3 replies to this topic

#1 tommytx

tommytx

    Prodigy

  • Active Members
  • PipPipPip
  • 165 posts

Posted 08 April 2012 - 04:29 PM

I searched for erase commands but they all seemed to be related to erasing the entire GUI. Is it possible to erase the object and replace it? On my function calls i only show one button, however there would be many controls on each page when the final product is done. I only show one control button on each page just for simplification. I assume that once I know how to erase the object and replace it with another it will apply no matte how many controls the object applies to.. also is there a better objec to attach to other than $oIE since I really don't need to access the web, just files and buttons on my local computer... Thanks..
At this point when I select any drop down menu item it goes to the same "Close" option. I assume that is because all my options use the same object... so that is why I want to build and erase objects at menu selection.... or is there a much simpler way to do this...

AutoIt
Plain Text         
#include <IE.au3> #include <GuiMenu.au3> #include <GuiConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Global $oIE, $obj, $test, $hGeneral, $hOther, $hMain Global $idClose, $idMinimize, $idActivate, $idExit ; Global Enum $idClose = 1000, $idMinimize HotKeySet("{ESC}", 'Terminate') _Main() GUISetState()      ;Show GUI While 1 GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") WEnd Func Close() ; Erase the obj then write the new one ???? $obj = GUICtrlCreateObj ($oIE, 10, 40, 600, 360) $test = GUICtrlCreateButton("Close",20,20,100,20) GUISetState()      ;Show GUI EndFunc Func Minimize() ; Erase the obj then write the new one ???? $obj = GUICtrlCreateObj ($oIE, 10, 40, 600, 360) $test = GUICtrlCreateButton("Minimize",20,20,100,20) GUISetState()      ;Show GUI EndFunc Func Activate() ; Erase the obj then write the new one ???? $obj = GUICtrlCreateObj ($oIE, 10, 40, 600, 360) $test = GUICtrlCreateButton("Activate",20,20,100,20) GUISetState()      ;Show GUI EndFunc Func _Main() Local $hGUI, $hGeneral, $hOther ; Create GUI $hGUI = GUICreate("Menu", 400, 300) ; Create menu 1 $hGeneral = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($hGeneral, 0, "&Close", $idClose) _GUICtrlMenu_InsertMenuItem ($hGeneral, 1, "&Minimize", $idMinimize) _GUICtrlMenu_InsertMenuItem ($hGeneral, 2, "&Exit", $idExit) ; Create menu 2 $hOther = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($hOther, 0, "&Activate", $idActivate) ; Create Main menu $hMain = _GUICtrlMenu_CreateMenu () _GUICtrlMenu_InsertMenuItem ($hMain, 0, "&General", 0, $hGeneral) _GUICtrlMenu_InsertMenuItem ($hMain, 1, "&Other", 0, $hOther) ; Set window menu _GUICtrlMenu_SetMenu ($hGUI, $hMain) EndFunc ; Handle menu commands Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Switch _WinAPI_LoWord ($iwParam)   Case $idClose    Close()   Case $idMinimize    Minimize()   Case $idActivate    Activate()   Case $idExit    Terminate() EndSwitch Return $GUI_RUNDEFMSG EndFunc   ;==>WM_COMMAND Func Terminate() Exit EndFunc

AutoIt

Edited by tommytx, 08 April 2012 - 04:31 PM.








#2 tommytx

tommytx

    Prodigy

  • Active Members
  • PipPipPip
  • 165 posts

Posted 10 April 2012 - 01:15 PM

anyone have any thoughts or ideas for this.. I cannot move my project forward until i find a solution for this.. or another way to do it...'

#3 BrewManNH

BrewManNH

    באָבקעס מיט קודוצ׳ה

  • MVPs
  • 6,869 posts

Posted 10 April 2012 - 01:22 PM

Seems like an overly complicated way to add a button to a GUI, but you should probably be looking at GUICtrlDelete.

How to ask questions the smart way!

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.

Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.

_FileGetProperty - Retrieve the properties of a file SciTE Toolbar - A toolbar demo for use with the SciTE editorGUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.

GUIToolTip UDF Demo - Demo script to show how to use the GUIToolTip UDF to create and use customized tooltips.

Posted Image


#4 tommytx

tommytx

    Prodigy

  • Active Members
  • PipPipPip
  • 165 posts

Posted 10 April 2012 - 03:49 PM

Its not a button I want to delete, I simply want to update the 16 checkboxes.. when i look at that Tab.. you see the checkboxes appear only when a window is in existence and they come and go.. so at the very least I want to be able to erase and reprint the checkboxes depending in the windows status at any time..
But GuiCtrlDelete sounds like a possibility since all 16 check boxes are controls... will let you know if it works.. Thanks for the suggestion.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users