Author | Message | Time |
---|---|---|
FrOzeN | Atm, I'm working on a Chat Bot. One of the features it has is multiple tabs so you can have more than 1 connection open in a single form (not MDI). As you can only ever see (say one RichTextBox; chatscreen) at any given time. Would it be best (in VB6) to have a control array of RichTextBox's with each bots info, or a array in the background storing the other's information and it gets written in upon tabs changing focus. Thoughs? | February 13, 2006, 7:41 AM |
JoeTheOdd | I'd create a control array of classes which represent a connection, and in that class have a string that will hold rtb.TextRTF. Of course, then calling AddRTB on hidden bot's will be a pain, but it is nowhere near impossible. | February 13, 2006, 11:24 AM |
FrOzeN | I just thought a control array would be a bit ewy. I find there's no need to store anything in controls that arn't visible, when plain text in general arrays serves the same purpose. I can implement it with ease, just more wondering on other opinions as to all the open-source codes I've seen floating around just use Control Arrays. Not sure if it's there coding slacking off, or the best way.. | February 13, 2006, 11:36 AM |
Yegg | Why not just create a new RichTextBox control for each time a new tab is added? You can simply force all controls except for one to be invisible. And display only the RTB that corresponds with the selected tab. This may be more memory consuming, but it will also allow you to see the current text from each logged in account immediately as you switch tabs, without having to store anything in an array. | February 13, 2006, 2:57 PM |
MyStiCaL | RTB() LISTVIEW() are probley the best ways of going on about this then you can just store ur user information info a type, If you wanna store the data then when switching tabs and with all your loops its gunna hurt, loops and fors are just a bad idea when it comes to somthing of this size and when u could be switching constantly, gunna be alot more slower and use some memory, i released a few open sources on the differnce about this.. For a better idea of this, you can simpley load a new project, and load 100 new RTB()s and 100 LISTVIEW()s memusage only goes up like 113k, but if you put it in other arrays, your looking at alot more.... --- my lil post here was typed newbly, forgive me. | February 13, 2006, 3:35 PM |
LoRd | Obviously loading multiple objects results in multiplied memory usage and servere decrease in performance as well. Your only logical option is to store the text from the chat windows which are not in view. | February 13, 2006, 3:55 PM |
l2k-Shadow | I suppose the only two ways to tackle this would be to either create an index on the given RTB and then load new RTBs with new profiles.. or have one RTB and somehow store the text from all the profiles.. and unless you find an efficient way to store the text outside the program's memory, both ways will rape your memory pretty hard. | February 13, 2006, 4:20 PM |
Yegg | [quote author=l2k-Shadow link=topic=14246.msg145831#msg145831 date=1139847632] I suppose the only two ways to tackle this would be to either create an index on the given RTB and then load new RTBs with new profiles.. or have one RTB and somehow store the text from all the profiles.. and unless you find an efficient way to store the text outside the program's memory, both ways will rape your memory pretty hard. [/quote] Perhaps he could use your idea of keeping a single RTB, but store all the current text of the RTB in a .rtb file. Doing this, you could clear the RTB's text and reload it with the correct .rtb file for each time a different tab is pressed. | February 13, 2006, 4:27 PM |
Myndfyr | [quote author=Lord[nK] link=topic=14246.msg145830#msg145830 date=1139846139] Obviously loading multiple objects results in multiplied memory usage and servere decrease in performance as well. Your only logical option is to store the text from the chat windows which are not in view. [/quote] But typically since the controls that are hidden do not consume the working set, the change in memory usage is not particularly relevant beyond the stored text, which is being consumed anyway. Have you ever seen how much smaller the working set is of a program when it is minimized than when it is in use? And it's not that the time used to write to the pagefile will be significant for such a pithy amount of memory. I could see this being a problem if the controls took like, 25mb of memory each. But that's simply not the case. In a cursory test generating tab pages on the fly, my program started at 15mb of memory usage and never exceeded 17 after making 20 tab pages. | February 13, 2006, 5:28 PM |
Stealth | [quote author=Yegg link=topic=14246.msg145833#msg145833 date=1139848053] [quote author=l2k-Shadow link=topic=14246.msg145831#msg145831 date=1139847632] I suppose the only two ways to tackle this would be to either create an index on the given RTB and then load new RTBs with new profiles.. or have one RTB and somehow store the text from all the profiles.. and unless you find an efficient way to store the text outside the program's memory, both ways will rape your memory pretty hard. [/quote] Perhaps he could use your idea of keeping a single RTB, but store all the current text of the RTB in a .rtb file. Doing this, you could clear the RTB's text and reload it with the correct .rtb file for each time a different tab is pressed. [/quote] You would not want to do this. Disk access is highly inefficient, and unless you have hundreds of chat windows open to the point where your RAM is severely impacted by storing their contents in memory (by either method in the debate), there really is no reason to go to the hard drive. | February 13, 2006, 6:49 PM |
Zakath | Yes, as Myndfyre pointed out, the best solution here is to maintain separate controls and hide them. The ones not in the active display consume very little memory. As a quick illustration of this...this classic screenshot of a minimized application: [img]http://www.valhallalegends.com/zakath/rusage.png[/img] | February 13, 2006, 7:03 PM |
MyStiCaL | I kinda liked that idea of storing the rtb data into an .rtb, but then again, you'd have to continuously add to each .rtb for the tabs that are NOT selected so you don't lose track, but even though RTB() would be icky, its the best way of going about things.. What does everyone else do? because i know a few of you here have created a bot with atleast a Friends List, Clan Listings, Channel Users. So do you have seperate ListViews or Just one and store the rest of the data for each tab not Selected? | February 13, 2006, 8:24 PM |
Zakath | [quote author=MyStiCaL link=topic=14246.msg145869#msg145869 date=1139862255] I kinda liked that idea of storing the rtb data into an .rtb, but then again, you'd have to continuously add to each .rtb for the tabs that are NOT selected so you don't lose track, but even though RTB() would be icky, its the best way of going about things.. What does everyone else do? because i know a few of you here have created a bot with atleast a Friends List, Clan Listings, Channel Users. So do you have seperate ListViews or Just one and store the rest of the data for each tab not Selected? [/quote] ...Did you miss the bit where we explained why a .rtb was a HORRIBLE idea? Reading and writing to disk is SLOW. You do not want your application doing that constantly during execution! | February 13, 2006, 8:59 PM |
Myndfyr | [quote author=MyStiCaL link=topic=14246.msg145869#msg145869 date=1139862255] I kinda liked that idea of storing the rtb data into an .rtb, but then again, you'd have to continuously add to each .rtb for the tabs that are NOT selected so you don't lose track, but even though RTB() would be icky, its the best way of going about things.. What does everyone else do? because i know a few of you here have created a bot with atleast a Friends List, Clan Listings, Channel Users. So do you have seperate ListViews or Just one and store the rest of the data for each tab not Selected? [/quote] For the previous iteration of JinxBot (that never got finished), I had developed a user control that had a rich text box along with docked panes on the sides and a flat combobox. This is similar to how I'm doing the new JinxBot as well. I would then add one of these user controls to fill up the tab page. This had the added bonus of self-managing any kind of layout issues (resizing and whatnot). [quote author=Zakath link=topic=14246.msg145877#msg145877 date=1139864393] ...Did you miss the bit where we explained why a .rtb was a HORRIBLE idea? Reading and writing to disk is SLOW. You do not want your application doing that constantly during execution! [/quote] Are you referring to a file? In which case, are you being snobbish about technical terminology? :P | February 13, 2006, 9:03 PM |
MyStiCaL | that's why i still said the control and not .rtb file would be still better about do this. | February 13, 2006, 9:08 PM |
Myndfyr | [quote author=MyStiCaL link=topic=14246.msg145884#msg145884 date=1139864909] that's why i still said the control and not .rtb file would be still better about do this. [/quote] What Zak is trying to tell you is that you need to get your terminology together. RTB is an abbreviation for "Rich Text Box," which is the Windows control for editing and displaying rich text. A file is .RTF - "Rich Text Format." ".rtb" is inaccurate because you're confusing a file format (dot-three extention) with the abbreviation for RTB. | February 13, 2006, 9:22 PM |
FrOzeN | So overall the best solution breaking down from what you all said is, "Use a Control Array of the RichTextBox and have the one's not being used Invisible. Even though the the extra controls use a little extra storage, it is so minor it makes no difference and overall makes for faster handling rather than re-writing the text in back and fourth consecutively.". So Control Arrays it is. :) As for the ListView, I'm having a Control Array of the number of tabs open (plus 3 extra for Friends/Clan/Channels). Then have it just update the 3 extra one's upon tab change with information stored in a database. And the Channel will always regain focus and as being already there won't be a problem. Thanks. | February 14, 2006, 4:20 AM |
shadypalm88 | [quote author=FrOzeN link=topic=14246.msg145978#msg145978 date=1139890801] So overall the best solution breaking down from what you all said is, "Use a Control Array of the RichTextBox and have the one's not being used Invisible. Even though the the extra controls use a little extra storage, it is so minor it makes no difference and overall makes for faster handling rather than re-writing the text in back and fourth consecutively.". So Control Arrays it is. :) As for the ListView, I'm having a Control Array of the number of tabs open (plus 3 extra for Friends/Clan/Channels). Then have it just update the 3 extra one's upon tab change with information stored in a database. And the Channel will always regain focus and as being already there won't be a problem. Thanks. [/quote]What I've actually done with some success in Myriad 2 is create a class module with the controls declared WithEvents in them, so that instead of handling the events on the form, they're handled in the class module. I've been able to achieve better separation of elements that way. There's a base BnetBot class that handles the nitty gritty connection details and raises events when things happen. They are trapped by another class, which displays messages, updates the user list, etc. on the display object. (A bot may be "detached" and not have a display window/tab open, which is why the display elements are in a separate class.) Some of this OO stuff gets a tid bit ugly in VB6, but it's overall much cleaner than directly dealing with control arrays all the time. The bot is under the GPL so if the preceding paragraph didn't make much sense and it'd help to see some code, I can make a snapshot. | February 14, 2006, 4:51 AM |
MyStiCaL | [quote author=FrOzeN link=topic=14246.msg145978#msg145978 date=1139890801] So overall the best solution breaking down from what you all said is, "Use a Control Array of the RichTextBox and have the one's not being used Invisible. Even though the the extra controls use a little extra storage, it is so minor it makes no difference and overall makes for faster handling rather than re-writing the text in back and fourth consecutively.". So Control Arrays it is. :) As for the ListView, I'm having a Control Array of the number of tabs open (plus 3 extra for Friends/Clan/Channels). Then have it just update the 3 extra one's upon tab change with information stored in a database. And the Channel will always regain focus and as being already there won't be a problem. Thanks. [/quote] no control array doesn't take up as much memory as the other array would. i stated create a new project and see for ur self.. | February 14, 2006, 8:31 AM |