Archived

This topic is now archived and is closed to further replies.

Getting and putting text into a ListBox?

This topic is 5584 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im trying to create a program that will display the time in a list box however I can''t for the life of me seem to find out how I can send a variable to the listbox to be displayed. I also need a way to accept text from a list box and accept them as command like functions (i.e. "/addtime Variable1 20") I know how to check for the "/addtime" but Im not sure how I would extract the arguements I need from the rest of that string. would something like work?: case: astring == "/addtime" { AddTime(var,time); break; } Dont usually ask for so much help but im going in circles it seems here

Share this post


Link to post
Share on other sites
I don''t fully understand what you want to do, but if you''re programming for Windows API with C you can do something like this to add the time to a Listbox:


  
char* buf;
time_t t;
t = time(NULL);
buf = ctime(&t);
SendDlgItemMessage(hWnd, YOUR_LISTBOX,
LB_ADDSTRING, 0, (LPARAM)buf);


What is this question with the string, do you want to work with command line arguments?

Share this post


Link to post
Share on other sites
dunno if uve checked msdn, i was trying the same a while back, and this link really helped:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/indivcontrol.asp

Yratelev
Managing Director -

DarkArrow Systems


"Better Quality Russian Technology"

Share this post


Link to post
Share on other sites
Ah, Thanks for the info and that link is very helpful!

The command line I wanted to work somewhere along the lines of how you can send commands in IRC.

i.e.
if you type "/server irc.dal.net 6000"
it tries to connect to the server irc.dal.net and on port 6000.

I basically want to do the same with /addtime [Variable] [Time]
I want to be able to type in "/addtime Computer1 2"
Computer1 being the name of my Class and 2 being the number of hours to add to the time variable and have it add that 2 to the time variable.

Class goes like this:
Class CComputer
{
int time;
};

CComputer Computer1;

Sorry if this sounds confusing, let me know if you understand or not. Thanks for all the help by the way.

Share this post


Link to post
Share on other sites
Which IRC program are you talking about? mIRC? If so, there is a dll alias and identifier to send and retreive information from dlls. The mIRC help files have extensive information on how to write a dll that can interact with mIRC, just open mIRC help, click on search, and in the index type in dll. The topic 'DLL Support' should be made visible to you. All you have to do is make a mIRC script which uses either /dll or $dll to set local variables and then print them to some window using the appropriate functions.

If you wern't talking about mIRC then forget all that I have said...

[edited by - Shambles on September 1, 2002 6:55:45 PM]

Share this post


Link to post
Share on other sites
OK, it seems, that you want to splizt your string into its Parts, you may do this with the strtok function defined in string.h :


  
#include <string.h>

char* test = "/addtime Variable1 20";
char* buf;
buf = strtok(test, " ");
// buf = /addtime


buf = strtok(NULL, " ");
// buf = Variable1


buf = strtok(NULL, " ");
// buf = 20



This is an easy way but there are others...

Share this post


Link to post
Share on other sites
Sorry, my fault. Try this


  
#include <string.h>

char test[] = "/addtime Variable1 20";
char* buf;

buf = strtok(test, " ");
// buf = /addtime


buf = strtok(NULL, " ");
// buf = Variable1


buf = strtok(NULL, " ");
// buf = 20


Share this post


Link to post
Share on other sites