Jump to content

CreateListViewItem from another window?


james3mg
 Share

Recommended Posts

I've been working on a very complex GUI script where one of the features does not work. I wrote the simplest abstraction of the same task in another script and confirmed that it still doesn't work-there's nothing hiding in the complexity of the original script. Here is a copy of the simplified script: (also attached)

[start of Script]

#include <GuiConstants.au3>

;******MainWin and Control Creation******

Global $MainWin=GUICreate("Main Window","200","200");

GUISetState(@SW_SHOW,$MainWin)

Global $NumberList=GUICtrlCreateListView("Type|Number",5,5,190,150,$LVS_NOSORTHEADER+$LVS_SHOWSELALWAYS)

Global $Button=GUICtrlCreateButton("Button",5,160)

;******SubWin and Control Creation******

Global $SubWin=GUICreate("Sub Window","200","100",-1,-1,-1,$WS_EX_TOOLWINDOW,$MainWin);

Global $SubButton=GUICtrlCreateButton("Button2",5,5)

;****Event Control Section****

While 1

$msg=GUIGetMsg(1)

Select

Case $msg[0]=$GUI_EVENT_CLOSE AND $msg[1]=$MainWin

ExitLoop

Case $msg[0]=$GUI_EVENT_CLOSE AND $msg[1]=$SubWin

GUISetState(@SW_HIDE,$SubWin)

Case $msg[0]=$Button

GUISetState(@SW_SHOW,$SubWin)

Case $msg[0]=$SubButton

$StatusVar=GUICtrlCreateListViewItem("New|Data",$NumberList)

MsgBox(0,"Data",$StatusVar)

EndSelect

Wend

[End of script]

What this should do is, when you click the button on the sub-window, it creates a listviewitem in the listview element of the main window and alerts you with the control number (or 0 if an error-see autoit documentation). however, it always returns 0-an error in creating the control. Why doesn't this work? The listview name is a global variable, so it should be recognized throughout the script. Is it not possible to create a listview item from another window in the same script?

Thanks

RemoteListViewItemFAILS.au3

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
Link to comment
Share on other sites

Never fails...as soon as you post, you figure it out.

I added the command GUISwitch($MainWin) just above creating the ListViewItem, and it worked like a charm. Tried it in the actual script I'm working on, and it works as well.

Stupid, sorry :)

Have a good one

"There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...