|
Always joke ah...!
Born to win...!
|
|
|
|
|
How can we create RadioButtons at runtime
Means i have recognised the COM Ports and those i need to display as radiobuttons for User Selection but Number of COM ports may differ sooo i some assistance to how to create radiobuttons dynamically depending on data we get at runtime.
for ex we COM1 COM2 ports
now i have to get those and create radiobutons
but data may change
it can only COM1 depending on connnection
usharani
|
|
|
|
|
I think you can use like this for example
CButton m_Button[3];
m_Button[0].Create(_T("Port1"),WS_CHILD|BS_RADIOBUTTON|WS_VISIBLE,CRect(0,0,100,23),this,1);
...
|
|
|
|
|
What about a list (or combo) box?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Create buttons on heap for this purpose.
CButton *pBtns = new CButton[nNumOfPorts];
pBtns[0].Create(....using radio button style);
pBtns[1].Create(....using radio button style);
pBtns[nNumOfPorts-1].Create(....using radio button style);
|
|
|
|
|
prasad_som wrote: CButton *pBtns = new CButton[nNumOfPorts];
pBtns->Create(....using radio button style);
That is wrong.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
|
I suggest you to suggest him ( ) the final cleanup too. Do you know, when dealing with dynamic allocation, newbies tend to forget it.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
He/She has not replied to my reply, obviouslu he has not followed m answer.
|
|
|
|
|
Who knows, maybe he silently has.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
In the same way as you would any other button, just use the BS_RADIOBUTTON style.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
<br />
int i = 10;<br />
int k = 100;<br />
switch(i)<br />
{<br />
case 0:<br />
cout << "case 0" <<endl;<br />
break;<br />
if(k == 100)<br />
{<br />
case 10:<br />
cout <<"The device type is 100 so attribute 10 is valid"<<endl;<br />
break;<br />
}<br />
else<br />
{<br />
case 100:<br />
cout <<"attribute 100 is there" << endl;<br />
break;<br />
}<br />
break;<br />
default:<br />
cout <<"default"<<endl;<br />
}<br />
Please confirm whether 'if' could be placed inside a switch statement.
Pratap
|
|
|
|
|
a. yes
b. no
c. maybe
d. none of the above
codito ergo sum
|
|
|
|
|
Thanks for the reply. Please post your choice.
|
|
|
|
|
Is this a real question? or you are new to c++?
|
|
|
|
|
I'm not new to C++ . Today I had to write some code which includes swith cases, but case lables are valid in only some conditions (depending on the device type). I was not completly sure that the code is invalid, and wrote a test pgm in vs2k3, and it worked fine. Before checking in, wanted a confirmation.
|
|
|
|
|
Raj Prathap wrote: Please confirm whether 'if' could be placed inside a switch statement.
and the reason behind this doubt for not using an 'if' in a switch block is ... !!!
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Raj Prathap wrote: Please confirm whether 'if' could be placed inside a switch statement.
Yes. But compile the following code and you'll know how much the compiler 'cares' about the IF statement.
int i=4;
switch(i)
{
if(false)
{
case 4:
AfxMessageBox("Whack my head with that oldskool keyboard");
break;
}
}
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Rutherford would say: "the switch statement targets its case condition passing the if block like as if you fired a 15-inch shell at a piece of tissue paper"
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Is it the encrypted version of some nice piece of code?
BTW on my system (VS2005) it compiles, but at runtime the switch condition overrides (breaks ) the if one: is it what you're expecting?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
yeah, it was encrypted with 128bit RSA algo. Its great that you could decrypt it .Just kidding..
Its neither encrypted nor a question from an interview. I had to write some code today and I re written the code in different way also. But I gor a doubt if this code is valid and wanted a confirmation.
|
|
|
|
|
The code compiles. But I doubt it works as you expect (i.e. avoid such misleading constructs).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Raj Prathap wrote: Please confirm whether 'if' could be placed inside a switch statement.
Why would you go to all the trouble of creating this post when you could have just compiled it to find out?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi EveryOne,
I am savitri here.I am using ODBC in VC++ programs.I am Inserting values in the tables.If i want to Edit/Update Those values how Can I do it.if i clicked on the values those are come on the text boxes in that i want to edit after clicking button those values should be updated.Please tell me How can i Do it.
I am not getting idea how to get back the values on text boxes.
PLEASE HELP ME.
THANKS IN ADVANCE,
savitri
|
|
|
|
|
Use SQL queries to edit/modify/delete/update your textbox values. you have to update your database through SQL UPDATE statement. Like:
<br />
UPDATE table<br />
SET column = expression<br />
Mukesh Kumar
Software Engineer
|
|
|
|