Control array events and Karl's ObjArrayDemo

given a control array added via Load ctl(index+1)
events don't work

saw Karl's ObjArrays demo
having trouble figuring how to convert the demo to my situation...braindead!

I have a form with a "group of controls" that I call a ViewGroup
each ViewGroup consists of one each ( lable,combo,listview)
form at design time has one group with index 0
mlViewCount is howmany of these groups of 3 controls exist on form (at form 
load  = 1)

at runtime in a button click event i load new group (of 3 ctls)

Private Sub AddViewGroup()
 'first time this will = 1 (index 0)
  mlViewCount = GetViewCount

  'load next index (count is one higher than index)
      Load Label1(mlViewCount)
      Load Combo1(mlViewCount)
      Load List1(mlViewCount)
 End Sub

  that loads the controls i want and a resize positions everything

now I want to get events on each of those controls (or at least the combo 
and listview)
so i think i have to modify the AddViewGroup to use Karl's method
I added the cNotify.cls and MyObject.cls to project

I've modified form load  but don't think i'm doing it right
given sets of 3 controls how do i assign the notfy objects to my actual 
contols?

Private Sub Form_Load()

Set objNotify = New CNotify
 mlViewCount = GetViewCount

''sample
'For i = 0 To 5
'      Set obj(i) = New MyObject
'      Set obj(i).Notify = objNotify
'      obj(i).Tag = i
'   Next i
'
'first 3 controls
    ReDim Preserve obj(0 To (mlViewCount * 3) - 1) As MyObject


      Set obj((mlViewCount * 3) - 3) = New MyObject
      Set obj((mlViewCount * 3) - 3).Notify = objNotify
      obj((mlViewCount * 3) - 3).Tag = (mlViewCount * 3) - 3

      Set obj((mlViewCount * 3) - 2) = New MyObject
      Set obj((mlViewCount * 3) - 2).Notify = objNotify
      obj((mlViewCount * 3) - 2).Tag = (mlViewCount * 3) - 2

      Set obj((mlViewCount * 3) - 1) = New MyObject
      Set obj((mlViewCount * 3) - 1).Notify = objNotify
      obj((mlViewCount * 3) - 1).Tag = (mlViewCount * 3) - 1

     End Sub

thanks
mark


0
mp
12/13/2009 1:41:55 AM
vb.general.discussion 1016 articles. 0 followers. Follow

7 Replies
518 Views

Similar Articles

[PageSpeed] 10

"mp" <nospam@Thanks.com> wrote in message 
news:ein8yV5eKHA.4952@TK2MSFTNGP06.phx.gbl...
> given a control array added via Load ctl(index+1)
> events don't work
snip

on further reading googlegroups this ng, it appears people are saying that 
Load Ctl(index) should allow events to work
Since I'm using Load I don't understand why my click events arent' firing on 
listbox or combo boxes?

what am i missing?

now i notice that even on a simple form with one listbox - no control array 
the click event doesnt' fire????

lable click works
Private Sub Label1_Click()
MsgBox "click"

End Sub

list click doesn't work

Private Sub List1_Click()
MsgBox "click"

End Sub

what am i doing wrong?
thanks
mark


0
mp
12/13/2009 2:13:57 AM
"mp" <nospam@Thanks.com> wrotel...
> on further reading googlegroups this ng, it appears people are saying that 
> Load Ctl(index) should allow events to work
> Since I'm using Load I don't understand why my click events arent' firing 
> on listbox or combo boxes?
>
> what am i missing?

The click event only occurs when you *select* an item from the list.

David 


0
David
12/13/2009 12:34:59 PM
"mp" <nospam@Thanks.com> wrote in message 
news:uVgSsn5eKHA.2160@TK2MSFTNGP02.phx.gbl...
>
> "mp" <nospam@Thanks.com> wrote in message 
> news:ein8yV5eKHA.4952@TK2MSFTNGP06.phx.gbl...
>> given a control array added via Load ctl(index+1)
>> events don't work
> snip
>
> on further reading googlegroups this ng, it appears people are saying that 
> Load Ctl(index) should allow events to work
> Since I'm using Load I don't understand why my click events arent' firing 
> on listbox or combo boxes?
>
> what am i missing?
>
> now i notice that even on a simple form with one listbox - no control 
> array the click event doesnt' fire????

What are you doing that you expect Click to fire?

> lable click works
> Private Sub Label1_Click()
> MsgBox "click"
>
> End Sub
>
> list click doesn't work
>
> Private Sub List1_Click()
> MsgBox "click"
>
> End Sub

With items in a control array there needs to be a "ByRef Index As Integer" 
argument in the events so the above events would generate an error that the 
event declaration does not match when you try to run.  Either your controls 
are not named "List1" or you didn't copy & paste the exact code from the app 
or both.

0
Bob
12/13/2009 2:41:23 PM
"Bob Butler" <noway@nospam.ever> wrote in message 
news:OzRRJKAfKHA.2164@TK2MSFTNGP02.phx.gbl...
>
> "mp" <nospam@Thanks.com> wrote in message 
> news:uVgSsn5eKHA.2160@TK2MSFTNGP02.phx.gbl...
>>
>> "mp" <nospam@Thanks.com> wrote in message 
>> news:ein8yV5eKHA.4952@TK2MSFTNGP06.phx.gbl...
>>> given a control array added via Load ctl(index+1)
>>> events don't work
>> snip
>>
>> on further reading googlegroups this ng, it appears people are saying 
>> that Load Ctl(index) should allow events to work
>> Since I'm using Load I don't understand why my click events arent' firing 
>> on listbox or combo boxes?
>>
>> what am i missing?
>>
>> now i notice that even on a simple form with one listbox - no control 
>> array the click event doesnt' fire????
>
> What are you doing that you expect Click to fire?
>
>> lable click works
>> Private Sub Label1_Click()
>> MsgBox "click"
>>
>> End Sub
>>
>> list click doesn't work
>>
>> Private Sub List1_Click()
>> MsgBox "click"
>>
>> End Sub
>
> With items in a control array there needs to be a "ByRef Index As Integer" 
> argument in the events so the above events would generate an error that 
> the event declaration does not match when you try to run.  Either your 
> controls are not named "List1" or you didn't copy & paste the exact code 
> from the app or both.

Right, the second example was not an array as mentioned above.
Yet the click does not fire when clicking in the textbox area of a combo box
Found that if a listbox or combo box are not yet filled, click does not fire
thanks
mark 


0
mp
12/14/2009 10:48:50 PM
"mp" <nospam@Thanks.com> wrote in message 
news:OH9Xc%23QfKHA.5228@TK2MSFTNGP06.phx.gbl...
<cut>
> Right, the second example was not an array as mentioned above.
> Yet the click does not fire when clicking in the textbox area of a combo 
> box
> Found that if a listbox or combo box are not yet filled, click does not 
> fire

Even if they are filled the "Click" doesn't fire when you click on it... the 
Click event fires when an item is selected from he list. 

0
Bob
12/14/2009 10:52:04 PM
"mp" <nospam@Thanks.com> wrote in message 
news:ein8yV5eKHA.4952@TK2MSFTNGP06.phx.gbl...
> given a control array added via Load ctl(index+1)
> events don't work
>
> saw Karl's ObjArrays demo
> having trouble figuring how to convert the demo to my 
> situation...braindead!

It seems that you are going about this the wrong way. You don't need that 
demo to get events from control arrays. That demo is for advanced stuff. 
When you first create a control that is not part of a control array, VB 
creates the event declaration for you without "Index As Integer". But if you 
later set Index property to any number, VB would complain about the current 
declaration. In that case, double-click on the control and select the event. 
VB in this case creates the event with "Index As Integer" as the first 
parameter, so copy and paste your code from the old event(under the General 
section) to the new event, or you can just add "Index As Integer" as the 
first parameter.


0
Nobody
12/15/2009 1:37:54 AM
"Nobody" <nobody@nobody.com> wrote in message 
news:%23z7x9cSfKHA.6000@TK2MSFTNGP06.phx.gbl...
> "mp" <nospam@Thanks.com> wrote in message 
> news:ein8yV5eKHA.4952@TK2MSFTNGP06.phx.gbl...
>> given a control array added via Load ctl(index+1)
>> events don't work
>>
>> saw Karl's ObjArrays demo
>> having trouble figuring how to convert the demo to my 
>> situation...braindead!
>
> It seems that you are going about this the wrong way. You don't need that 
> demo to get events from control arrays. That demo is for advanced stuff. 
> When you first create a control that is not part of a control array, VB 
> creates the event declaration for you without "Index As Integer". But if 
> you later set Index property to any number, VB would complain about the 
> current declaration. In that case, double-click on the control and select 
> the event. VB in this case creates the event with "Index As Integer" as 
> the first parameter, so copy and paste your code from the old event(under 
> the General section) to the new event, or you can just add "Index As 
> Integer" as the first parameter.
>
>

right, Thanks Bob and Nobody
I discovered the problem wasn't with events not exposed, but with the fact 
that combo
doesn't fire click when i click in it (the text area) (who'd a thunk it?)

and list dont' fire click if not filled

I mistakenly assumed click  would fire when control was clicked, not some 
entry inside control
live an learn
:-)
mark 


0
mp
12/19/2009 6:54:19 PM
Reply:

Similar Artilces:

bound control or inbound control
Hi Katherine, There are differences between using bound versus unbound controls. Where on the form do you want to use an unbound control? Jeanette Cunningham "Katherine" <Katherine@discussions.microsoft.com> wrote in message news:23BBC192-0A74-4B9F-9513-5E5923A76658@microsoft.com... > ...

why won't word 2007 release control of a .rtf file after exiting w
I AM HAVING TROUBLE WITH ACCESS TO RICH TEXT FILES BY PROGRAMS OTHER THAN WORD------ AFTER THE FILE OPEN IN WORD IS CLOSED AND EVEN AFTER WORD HAS BEEN SHUT DOWN (EXITED) ---------- I GET THE ERROR MESSAGE THAT THE FILE IS "IN USE" BY WORD WHEN (FOR EXAMPLE) AN ATTEMPT IS MADE TO DELETE IT ---- SOMETIMES WHEN RE-OPENING THE FILE AFTER RE-STARTING WORD THE FILE CANNOT BE SAVED BECAUSE IT IS IN "READ ONLY" MODE ------- AFTER MUCH FIDDLING AROUND I FINALLY MANAGED TO DELETE THE PROBLEM FILE ONLY TO HAVE THE SAME PROBLEM RETURN WITH A DIFFERNT FILE ----- WORD 200...

RE: Control
Can some one point me right direction to achive this following. Need to dispaly a data in a table format. some of the column data may have to display a image/icon based on a value from the table (1 :- Red color icon, 2:-yellow color icon...) Once the data is loaded and displayed on the format , able to search particular row by column index and update the values including the images(change different image). I tried with Listview control, with the report view I am not able to search row and update the columns with the List vew I am not able to show the image/icon. do not want to use ...

event ID 9234
I have a strange event ID I've been unable to find any information on: Event Type: Warning Event Source: MSExchangeSA Event Category: RFR Interface Event ID: 9234 Date: 11/19/2004 Time: 8:20:49 AM User: N/A Computer: BCCEX0101 Description: Referral Interface was not able to find an msExchExchangeServer object with legacyExchangeDN '/o=Collier County Gov./ou=ITDOMAIN/cn=Configuration/cn=Servers/cn=CWW1' in the Active Directory. For more information, click http://www.microsoft.com/contentredirect.asp. Why this concerns me is because 'CWW1' is the name of our old...

MSCRM login and the Users Control Panel
Is anyone aware of any way that the settings stored under Control Panel - Users - Password Management might interfere with the process of Single Sign On into MSCRM? It seemed to have somehow cached someones login and prevented logging in as the logged in user, until cached credentials had been "deleted". However I have never seen this mentioned as being relevant. I am not too sure what the architecture model is there, but it appears to be a single domain. If this area has any relevance, it would be useful to know....thanks ...

Adding a control variable
Hello all, Under VC++ 7.1, I've added a checkbox to a dialog. Using the dialog editor, I am not trying to add a control variable for this check box. However, when I right-click on the check box and select "Add Variable", the resulting wizard dialog does not allow me to select "Control Variable" (it is grayed out). What do I need to do to get a control variable for this check box added to my class? Thanks, Dave I've never seen that before - are you able to duplicate this problem with other projects too? -- Regards, Nish [VC++ MVP] "Dave" <bett...

Spam control - MS Outlook
Hi! I am using MS Outlook 2000 and use 2 profiles. I recently installed a firewall package (Fsecure = Telia S�ker Surf), including Spam control. After install, MSO hangs and I cannot change to the other profile (if I not removed MSO by ctrl/alt/del) Somebody want to comment this? /Sven-Erik Intergrated AV/Spam is the cause of frequent issues in Outlook Is the FSecure you installed compatible with this old version of Outlook? "Storfille" <storfille@ebrev.net> wrote in message news:b1Ixm.11987$U5.164765@newsb.telia.net... > Hi! > > I am using MS Outlook 200...

Releasing memory after creating OCX control
Hi, I try to create an instance of an activex control in my MFC dialog based app. Though my application works with out any error, if i check the memory after calling "delete pMyControl" it keeps on occupying the same memory it occupied when the control was alive. Could anyone help me where I am missing to clear the memory? Thank you. My Code here ---------------m_pxWmp= new CWMPPlayer4();if( m_pxWmp->Create("replay", WS_CHILD | WS_BORDER | WS_VISIBLE , CRect(100, 100,320,240), this, 2)){ m_replay = true; m_pxWmp->SetUrl("C:\\video.avi"); m_pxWmp->Set...

what control can display characters from txt files in a dialog?
I want to read lines from txt files and display them on a dialog.I wonder which control can be put into the dialog to hold the characters from txt? Something like :- while(m_file.ReadString(tmpstr)) { str += tmpstr; } m_edit.SetWindowText(str); -- Regards, Nish [VC++ MVP] "liao_xf" <sclxf@sina.com> wrote in message news:001401c3652f$177b9830$a001280a@phx.gbl... > Thanks first! > I know that Edit control can receive and edit input. > and I know the filestdio can read lines from txt. > but can you tell me how to attatch the lines to the edit? > Thanks!...

stock control system
trying to see up a 'basic stock control sytem' for a warehouse that contains building materials. -- Thank you. You can use multiple ways of doing, there's 3 ways to come to m head... 1) Use a worksheet as database an save all the information on the cell of that worksheet using some macros to access it and handle. 2) You might want to use Access instead of Excel, I think would b easier to handle the database portion and you still have the Macro available. 3) You can use VB with an Access to create an application -- fanay ------------------------------------------------------...

Creating dialog controls at run-time
I've been researching how to do this, but whenever I try what other people do, I get very bad results. But my challenge doesn't end there. The number of controls I want to create is only known at run-time. The problems I face are manifold: 1. The code most people use fails badly. Not only is the font unconventionally big, but when I click the checkbox I create, the whole dialog disappears. If that's not enough, the pointer to the control is NULL when the dialog's destructor is called, so I can't delete the instance, and get a memory leak message when the program ends: CADi...

MDI support in ATL composite control
Hi, I have components created in ATL. The components are ATL composite controls. Entire work has been done till now using ATL, however I now need to give MDI type of work area (based o doc-view architecture) within the control. I have class derived from CMDIFrameWnd. However when I try to initialize instance of this class by calling "Create" method of CFrameWnd (base class in CMDIFrameWnd), I get error and creation fails. Tracing the code, I found that base class create method calls "AfxGetInstanceHandle" to get handle to the DLL. Now since this is ATL Composite control, ...

Waiting for event
I have a VB.NET 2005 application - actually a compactframework application running on a CE5 device, but I guess this is more of a VB question rather than compactframework specific. What I want to do is connect to a GPRS network. I have an SDK supplied by the device manufacturer to communicate with the GPRS module. The way the SDK sends my application information back from the GPRS module is by firing an event, called OnGPRSResultMsg, with a string containing the information - when it initialises I get "WM_GPRS_INIT", when it connects I get "WP_CONNECTED" etc. ...

View Filtering and Access Controls for Business Units
I am trying to implement MS-CRM for my company. We have multiple Business Units . I need to give views to each Business Units so that they see only their own Contacts/Accounts/Opp lists. How do I accomplish this ? Also, If I gave inter business unit acesses , how do I make sure that the one business unit users can not modify any fields on other's Business Unit's records ? Thanks in advance for any help, Kishore This is quite easy to do with CRM. Assuming you have already created your Business Units in CRM, you can view a security role within one of the Business Units and a...

Tab Control Problems
I previously worked in VC++ 6.0, and have several applications that have either custom shadebox controls, or tab controls or group boxes. In all cases, when I moved the applications over to VS.NET 2003, everything was fine, except in the resource editor, I cannot see any of the controls that have been overlayed on a tab control, or a custom shadebox control and in some cases group boxes. I can tab to them and see the outline, but I cannot see the actual controls. If I drag a new control onto the tab control, I can see the control, but once it is saved, I can no longer access the cont...

FindRecord Control Button
i built a find record control button so a user can type in the form number and go there but it only searches the field that the cursor is in and the form # is not on the tab order(purposely). How can i specify where the find record function searches? thanks Ryan, usually people use an unbound combo box or an unbound text box for searching. There is a sample download with code of a search form at http://www.allenbrowne.com/ser-62.html If you need help to get it working, post back. You can also use the wizard to put a combo for searching on your form. On the form in design view, click the...

Moving array formulas
I have the following formular that is working. However, it needs to be the same for 6 rows but then moving the references accordingly. B needs to be increased by 6 every 6 rows. H & F need to be increased by 1 every 6 rows (see below for how it needs to be) ie Rows A1 to A6 {=if($B$2=H3,F3)} Rows A7 to A12 {=if($B$8=H4,F4)} Rows A13 to A18 {=if($B$14=H5,F5)} How can I acheive this? One way .. Put in A1: =IF(INDIRECT("B"&(INT((ROW(A1)+5)/6)-1)*6+2)=INDIRECT("H"&INT((ROW(A1)+5)/6) +2),INDIRECT("F"&INT((ROW(A1)+5)/6)+2),"") (j...

Controls coordinates
Hi everyone, Could somebody give me a simple example of getting a controls coordinates and then using them to put the control back where it was. So basicaly the control hasn't moved. Here's what I'm doing: m_cQuality.GetWindowRect(&qualityRC); ClientToScreen(&qualityRC); // int temp=qualityRC.Height(); // qualityRC.top=unyteRC.bottom-temp; // qualityRC.right=qualityRC.Width(); // qualityRC.left=0; // qualityRC.bottom=qualityRC.top+temp; // m_cQuality.MoveWindow(&qualityRC); m_cQuality.SetWindowPos(this, qualityRC.left, qualityRC.top, qualityRC.Width(), qualityRC.He...

event id 1202
Hi the following error is appearing on our server: Source:scecli Event ID:1202 Security policies are propagated with warning 0x4b8.An extended error has occurred. Does anybody know what might have caused this and how it can be eradicated? Thanks Patrick Here is an article that may assist in trouble shooting the issue: Q324383 Troubleshooting SCECLI 1202 Events -- Tyrone Cowart Microsoft PSS Please do not send email directly to this alias. This alias is for newsgroup purposes only. This posting is provided "AS IS" with no warranties, and confers no rights. "Patrick"...

Ploting dates against a calendar and not as a simple events
Probably a simple solution....and staring me in the face. I have a table containing dates and values. The dates may progress but the day interval is variable depending when the values were recorded. I need to plot the values with the dates on the x axis. So far I can only get the graph to treat each date as an event, thus the true date interval is not reflected. This distorts the graph. How does one configure Excel to plot against a calendar interval on the x axis? Many thanks G I suspect you want to plot an XY Scatter chart. The dates need to be in a numeric format to do that. &qu...

User Control to Control Other User Control
Has anyone here created a control that controlled the content of other controls? I have my own custom ad control (for displaying space ads). I may have several on a page. What I'd like it to create another control that could determine how many instances of the first control existed on the current page, build a list of ads, and then set each control to show a particular ad. Is this practical? Suggestions? Thanks. Jonathan "Jonathan Wood" <jwood@softcircuits.com> wrote in message news:uQ5stZRnKHA.1552@TK2MSFTNGP05.phx.gbl... > Has anyone...

Need more than 1208 controls per sheet
Hi, Does anyone know how to go around the limitation of MS Excel, which doesn't let the user, through automation, to create more than 1208 controls (checkboxes, buttons, or combination of two for example) on one sheet?? Thanks much! -- mowali ------------------------------------------------------------------------ mowali's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=20886 View this thread: http://www.excelforum.com/showthread.php?threadid=491476 I don't know whether it is possible to overcome the limit, but I would not use a worksheet where the ...

Can't open this item. Array index out of bounds
When trying to open a task reply in Outlook 2003, I get the following errors: "Can't open this item. Array index out of bounds." In the reading pane, there's also the following message: "This message with restricted permisison cannot be viewed in the reading pane until you verify your credentials". I went to http://support.microsoft.com/default.aspx?scid=kb;en-us;836558 and followed all of the steps but I still have the same problem. I also can not delete the items. Please help. Regards, Stormin ...

Controlling drawing objects in Excel . . .
i m trying to do the following. 1) i draw 10 circles, 10 rectangles and 10 ellipses (all are scattering here & there) in excel. 2) i would like to change all the sizes of circles with minimum steps. [Is it possible to control in such a way that a circle is drawn as a master one, and that circle will be copied and copied until required number. When we want to change something to all circles, we will change the master circle, and all other circles will be automatically changed.] If someone knows, kindly explain to me. Thanks & Have a nice day!!! Thaw Htin Oo. Thaw, (Oo?) One...

MFC Table control or similar control
Hi, I have a MFC dialog database application that returns data which i then put into an excel spreadsheet and display onscreen. Due to license issues i would like to write the data to a user defined control. I would like this control to have a similar tabular look like the excel spreadsheet. It should also have the option on control to print out what data is in the control. I would also like to be able to put a bitmap on the control (Showing a logo). Can anyone give me advice on how what control(s) i should use to accomplish this? Thanks In Advance Macca You could buy a third party ...