Getting and putting text into a ListBox?
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
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:
What is this question with the string, do you want to work with command line arguments?
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?
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"
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"
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.
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.
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]
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]
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 :
This is an easy way but there are others...
#include <string.h>char* test = "/addtime Variable1 20";char* buf;buf = strtok(test, " ");// buf = /addtimebuf = strtok(NULL, " ");// buf = Variable1buf = strtok(NULL, " ");// buf = 20
This is an easy way but there are others...
Thats exactly what I need it to do! However, I can''t get your program to work, its crashing when it hits the strtok part.
Any suggestions?
Any suggestions?
Sorry, my fault. Try this
#include <string.h>char test[] = "/addtime Variable1 20";char* buf;buf = strtok(test, " ");// buf = /addtimebuf = strtok(NULL, " ");// buf = Variable1buf = strtok(NULL, " ");// buf = 20
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement