mIRC Homepage
Posted By: Riamus2 Combo Box questions in a dialog - 15/09/05 06:24 PM
Ok, I'm trying to make a chat box in a game I'm writing. It works very nicely except for a couple "problems."

So you know, the chat box is a combo box in a dialog (if you didn't read the subject laugh)

1) Vertical scrolling. I'm adding lines to the end of the previous text in the combo box. What happens is that when the text causes vertical scrolling, the bottom line of text isn't visible because the scollbar is at the top. I've done did -c $dname ID $did($dname,ID).lines, and that's okay, but I don't like it highlighted, and if I try to use -u afterwards, it doesn't seem to want to work. Also, as soon as you start typing again, it scrolls back up to the top. The question is, whether or not it is possible to directly control the scroll bar and make it "stick" to the bottom unless moved by a person? Or, would it be better to just use an edit box and a list box?

2) Wrapping text. Because I can't just wrap text with a command switch in a combo box, I have it splitting the line and wrapping that way. So far, so good. The issue isn't even really a problem, but an issue with making it better... I figured out that the largest width letter will fit 70 letters (plus the <nick> before the text) across the combo box. So, I am splitting the text at the 70 length. (I'll probably make it split by words using that as maximum length at a later point). Anyhow, because the letters are different widths, the line can take up anywhere from half the width of the box up to the entire width ("i" vs "X"). Now, most normal sentences I have tried do take up about 80% width, but is there some way to determine if the text line hits the border of a combo box rather than counting letters? Again, this isn't a big issue, just an issue with making it look nice. laugh
Posted By: Riamus2 Re: Combo Box questions in a dialog - 15/09/05 06:53 PM
If #2 isn't possible, perhaps I'll just use MDX and make the box use a fixed width font. We'll see. smile
Posted By: MikeChat Re: Combo Box questions in a dialog - 15/09/05 08:17 PM
try this:
$height(text,font,size)
Returns height of text in pixels for the specified font.

$width(text,font,size,B,C)
Returns width of text in pixels for the specified font.
Posted By: Riamus2 Re: Combo Box questions in a dialog - 15/09/05 08:31 PM
Ah! I didn't realize you could do that for the font width. Thanks. I'll have to try it out! laugh

Now to figure out what font/size is in a default combo box... smile

EDIT: Seems to be working ok, though I am not sure that I'm using the correct font since it seems to be off a bit from what I'd expect (I'm using "arial" in $width), but that's easy to work around. Much nicer, and it's splitting at the words very nicely also. laugh
Posted By: MikeChat Re: Combo Box questions in a dialog - 15/09/05 09:01 PM
I haven't poked around, but you might have to look in the registry, unless someone here has another way to see what the windows default font is ( I Think the dialogs use a font defined in windows somewhere)
Posted By: ClickHeRe Re: Combo Box questions in a dialog - 16/09/05 11:14 AM
Usually controls use predefined system fonts (if they aren't changed), if you could retreive what it is, then it would be easy.

Check the dll cwnd, maybe it has that function in it.
Posted By: Riamus2 Re: Combo Box questions in a dialog - 16/09/05 03:35 PM
Ok, well, the width works just fine now. I'm still wondering if there is a better way to handle the vertical scroll bar.

Right now, to get it to go to the bottom any time I enter something into the combo box, I have to select that line with the /did -c command. The result of that is the line is highlighted and the edit box on the combo box is filled with the text that was highlighted. This could mess up what one person is in the middle of typing, when the next person says something and it highlights what was said.

I just want the scroll bar to always be at the bottom unless the user manually scrolls (just like you see in a channel window). Is there a better way to do this? I'd like to be able to just do something like /scroll $dname ID -1 or something and have it scroll to the bottom without highlighting (selecting) anything.
Posted By: ClickHeRe Re: Combo Box questions in a dialog - 16/09/05 05:01 PM
you are talking about a combobox in simple list view with edit box on top ?

I know mIRC doesn't have that functionality and I'm curious to check in the API to see if that really exists too. Don't forget most of mIRC's dialog controls are custom made (for mIRC 16 bit compatibility) and thus don't necessary reflect what the API can do or does.

And /did -c followed by /did -u doesn't unselect the line ?
You can also clear the contents of the edit with a /did -? where there is a parameter that applies to the edit of a combo (usually 0 for line number.)
Posted By: Riamus2 Re: Combo Box questions in a dialog - 16/09/05 05:35 PM
Yeah, I'm not sure what -u wasn't working. Maybe somehow I had something wrong and didn't notice. And, yes, I know how to clear the edit line (it is 0). I do that when I send the text to the "list" box part of the combo box.

The problem with all of that is this...

This is being used for chatting inside the game. If you're typing something and the other person says something to you, it will select and deselect that line and clear your own text that you were typing. That's not very good. smile

Does anyone know of any DLL or any other method that will allow you to scroll to the bottom of a listbox or a combo box automatically. I suppose I could do a reverse method for adding lines (inserting new text at the top rather than the bottom), but I'd rather not since that can get confusing when people are used to seeing new text at the bottom in mIRC.
Posted By: ClickHeRe Re: Combo Box questions in a dialog - 16/09/05 10:46 PM
Well I'm currently in developement of a replacement for MDX. It's called DCX and it isn't finished yet though. As a chat window thing I would imagine you could use a richedit control (which supports mIRC control codes but isn't finished yet) with a regular edit under to type the text. The richedit is readonly and I could check for the scrolling part to be added with a command on the richedit if that may interest you.

The DLL is currently beta but fairly advanced in the dev cycle. I have lots of plans for it adding advanced UI controls letting the users build nice functional GUIs for their projects.

If you want the URL you can pmsg me or search the forums, I think it was already posted in the past, I wouldn't want to pollute it again with unecessary spam.
© mIRC Discussion Forums