|
Hi All,
Using Visual Studio 2005 C++ to create an WMP visualization.
I have an array of values id like to create checkboxes for dynamically.
i.e. the array contains the enumerated com ports on computer. i want to be able to select an checkbox and store the value.
Example
comports[5] = {"COM1","COM2","COM3","COM4","COM5"};
need to create an checkbox for each value in the array with the value as the dialog text
Any ideas?
p.s. using atl in the project
|
|
|
|
|
Something along these lines -
CButton buttons[5];
comports[5] = {"COM1","COM2","COM3","COM4","COM5"};
CRect rect;
for (int i = 0; i < 5; i++)
buttons[i].Create(comports[i], BS_AUTOCHECKBOX,&rect, this, FIRST_BUTTON_ID + i);
Alternatively, you can just use SetWindowText to ... errr ... set the window text. If you don't know ahead of time how many buttons there will be, use a dynamic array of CButtons and instantiate each individually before calling it's 'Create' member function.
And of course you'll have to initialize the CRect with appropriate values.L u n a t i c F r i n g e
|
|
|
|
|
So what exactly do you need help with? Creating the checkboxes, selecting one, or storing a value?
|
|
|
|
|
Bit of the first and last bits.
Need help creating the checkboxes from the array.
Then i need to store the dialog values in an array to be used later. I've got the basics of the array etc, My main problem is creating the checkboxes from the array
|
|
|
|
|
Steven Foxton wrote: Need help creating the checkboxes from the array.
Did you see here?"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Perhaps I should have used a larger font or something.
L u n a t i c F r i n g e
|
|
|
|
|
Trying your answer out now LunaticFringe.
Having an bit of difficulty in declaring the array in the header file though.
getting the below error
CPropertyDialog.obj : error LNK2005: "class ATL::CSimpleArray<class ATL::CStringT<char,class ATL::StrTraitATL<char,class ATL::ChTraitsCRT<char> > >,class ATL::CSimpleArrayEqualHelper<class ATL::CStringT<char,class ATL::StrTraitATL<char,class ATL::ChTraitsCRT<char> > > > > sPorts2" (?sPorts2@@3V?$CSimpleArray@V?$CStringT@DV?$StrTraitATL@DV?$ChTraitsCRT@D@ATL@@@ATL@@@ATL@@V?$CSimpleArrayEqualHelper@V?$CStringT@DV?$StrTraitATL@DV?$ChTraitsCRT@D@ATL@@@ATL@@@ATL@@@2@@ATL@@A) already defined in USBGlowLight.obj
1> Creating library C:\Users\sfoxton\Documents\Visual Studio 2005\Projects\USBGlowLight\Debug\USBGlowLight.lib and object C:\Users\sfoxton\Documents\Visual Studio 2005\Projects\USBGlowLight\Debug\USBGlowLight.exp
1>C:\Users\sfoxton\Documents\Visual Studio 2005\Projects\USBGlowLight\Debug\USBGlowLight.dll : fatal error LNK1169: one or more multiply defined symbols found
you can have an look at the header if you like
http://www.4shared.com/file/228257607/9cf3e5f/USBGlowLight.html
Problem seems to be the declaration on Line 14
CSimpleArray<CString> sPorts2;
Idea is to declare the array in the header file, have the .cpp file create the checkboxes. Then in my main Viz .cpp it can read the array values
|
|
|
|
|
Nvm got it working. was an stupid error where id used extern to carry an array over, and then looped it back on itself.... so was passing the array back and forth continuesly
|
|
|
|
|
Cool - sorry I didn't get back quicker. L u n a t i c F r i n g e
|
|
|
|
|
Question: How to I Debug a class that lockup during runtime usng the debug function in MS VS 6.0? At the "Start Debug" option there are "GO", "Step Into" and "Run Cursor".
I tied to click on the Go option and get a message saying the the FileName.exe not found. Although the project was complied without any errors.
Thanks!
|
|
|
|
|
you could start your DEBUG application directly from explorer and use the "attach to process" (if that existed in VC6) to start debugging it. Watched code never compiles.
|
|
|
|
|
Thanks, I can now run the debuger and see the error log bellow. How will I know which part of the code the application locks up? The step into is grayed out once the debuger startes. The logs dont really tell you where it locks up in the code It show the dll that are beening loaded at runtime.
Thanks again.
|
|
|
|
|
If I don't remember bad, when you are debugging you can press F11 and it will go deeper into the calls and code that it is being called although it may be not your own code (for instance the MFC code). In other words, if you run debugger with F10 you stay in the same class getting the return of a function but if you use F11 you get into the called function.Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
WSADATA wsd;
SOCKET cs = INVALID_SOCKET;
char ref[512];
char rb[512];
int iResult, ires, recvbuflen;
struct sockaddr_in sin;
char ctrl[3] = {'\r','\n','\0'};
string str;
str="";
iResult = WSAStartup(MAKEWORD(2,2), &wsd);
if(iResult!=0) { alert("Cannot init Winsock"); return; }
cs = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = inet_addr("127.0.0.1");
sin.sin_port = htons(27015);
bind(cs,(SOCKADDR *)&sin, sizeof(sin));
BOOL optval = TRUE;
int bOptLen = sizeof(optval);
int sokres = setsockopt(cs,SOL_SOCKET,SO_REUSEADDR, (char *)&optval,bOptLen);
txtMeans.setText("waiting...");
listen(cs,1);
int aks = accept(cs,NULL,NULL);
do {
ires = recv(cs,rb,512,0);
if(ires>0)txtMeans.setText(rb);
else if(ires==0)txtMeans.appText("Connection Closed");
else {
txtMeans.appText("Receive failed");
recvbuflen = WSAGetLastError();
getes(recvbuflen);
if(SOCKET_ERROR==ires)alert("yes");
alert(rb);
}
}while(ires>0);
closesocket(cs);
WSACleanup();
txtMeans.appText("Doni");
This is blocking and listening in the specified port...
i created another app which connects to that port and sends data.
as soon as the data is sent i the recv does its work and i get -1 but when i checked for
last error using wsagetlasterror it returns zero. then how am i supposed to find the problem?
for ease i created the sender using PHP by having appache in localhost
$cs = socket_create(AF_INET,SOCK_STREAM,SOL_TCP);
socket_connect($cs,'127.0.0.1',27015);
socket_write($cs,"hehehe");
socket_close($cs);
txtMeans is a wrapper to a multiline edit control
alert and pint are wrappers for msgbox
to be precise i run this program... it listens to that specified port.
blocking mode. then i run my php program it connects to that ip,port it sends the data
here in the server i get the alert like i have stated above.
-1 is returned but wasgetlasterror returns zero which mostly not supposed to.Today's Beautiful Moments are
Tomorrow's Beautiful Memories
modified on Monday, February 22, 2010 12:29 PM
|
|
|
|
|
I think you should be using recv on the "aks" socket returned from accept
|
|
|
|
|
haha, yes, exactly. thank you.
just now i found that and i was about to rejoice here to tell people that i made a little [misteyk]. now it is working. i should have refreshed the codeproject page so that i would have found the reply earlier and would have saved the time... Today's Beautiful Moments are
Tomorrow's Beautiful Memories
|
|
|
|
|
i want to know the code to add image in my c++ program
|
|
|
|
|
Where in your application ? on a button ? as the background of a dialog ? as a background of a CView derived class ?
Do you know how to load an image ?
Do you know how to display an image (in general)?Watched code never compiles.
|
|
|
|
|
|
How can i support MFC OLE drag and drop with image between two windows?
|
|
|
|
|
...with an aplication's mouse cursor[^]
|
|
|
|
|
|
when i change the digit substitution from "Control panel>Regional and Language Options>Regional Options>Customize" in (win xp), to "Natinal", all the numbers of my program change to other language.
How should i prevent changing the numbers of my program or how should i change the "digit substitution" to "Context" in mfc?
|
|
|
|
|
|