|
or use crt function : mkdir
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|
|
Query regarding CTreeCtrl
how can we change the state of a icon placed in tree control . ie. on click of a button the icon should be changed to another state (2 states ON and OFF)
|
|
|
|
|
there are two kind of tree icons
TVSIL_NORMAL and TVSIL_STATE, see CTreeCtrl::SetImageList help,
second one you can change by
m_TreeCtrl.SetItemState(hTreeItem, INDEXTOSTATEIMAGEMASK(state), TVIS_STATEIMAGEMASK);
t!
|
|
|
|
|
CImageList* pImageList;
pImageList.Create(16,16,(ILC_MASK | ILC_COLOR32) ,0,0);
<br />
pImageList.Add(AfxGetApp()->LoadIcon(IDI_FOLDER));<br />
pImageList.Add(AfxGetApp()->LoadIcon(IDI_OPEN_FOLDER));<br />
m_pTree.SetImageList(&pImageList,TVSIL_NORMAL);
m_pTree.InsertItem("TEST",<big>0</big>,<big>1</big>,hItemRoot,TVI_LAST);
0 = select the icon "IDI_FOLDER" when your item is not selected.
1 = select the icon "IDI_OPEN_FOLDER" when your item is selected.
hope it's what you need
|
|
|
|
|
Anybody that knows me knows my math skills well umm.. suck.. so can somebody explain to me the difference. The first I came up with. the second is an example I took from a friend. What is the difference. The output is the same, but I need to know that my way (the first) correctly solves the equation.
----------------------------------------------
float dFirst;
float dSecond;
// My way
dFirst = (-b + sc) / (2 * a);
dSecond = (-b - sc) / (2*a);
cout <<"First: " << (int)dFirst <<endl;
cout <<"Second: " << (int)dSecond <<endl;
// his way
dFirst = (-b / (2*a)) + (sc / (2*a));
dSecond = (-b / (2*a)) - (sc / (2*a));
cout <<"First: " << (int)dFirst <<endl;
cout <<"Second: " << (int)dSecond <<endl;
-------------------------------------------------
IMHO: C# a poor attempt at bringing C++ to the VB masses
|
|
|
|
|
Assuming that in both versions that
sc = sqrt(pow(b,2) - (4 * a * c))
the difference is that the first combines additive terms before dividing by (2 * a), while the second performs the division on each term before adding. The two approaches are equivalent, and both will give the same wrong answer most of the time by casting a result that is very rarely an integer to int. Also, since dFirst and dSecond are declared as type float you lose precision, as the float type is limited to about 6 digits of precision. I'd stick to using double variables for the calculation, then convert to float for the output if necessary for some reason.
Ancient man conquered his rivals with the jawbone of an ass; modern man uses the jawbone of a politician.
|
|
|
|
|
Thank you for the insight. please excuse the casting and the float. If you notice the variables start with d because orginialy they were doubles. I changed to float for an output test. Other than that, it will ouput the correct answer? am I correct in assuming that?
-----
IMHO: C# a poor attempt at bringing C++ to the VB masses
-----
|
|
|
|
|
It's really the int cast that caught my eye - the root of a function is very rarely an integer, and I hate imprecise answers. As a rule, I try to use the greatest precision available in all internal calculations, then use a cast as the final step to limit the output to what the program needs to provide. You're correct in assuming that it will give the right answer, within the limits of the data types you've selected.
The short form of my answer, without my editorial comments, would be that the two implementations are equivalent. Yours may be more efficient, as it requires for each solution one addition and one division, while the other uses two divisions and one addition. Division requires more CPU cycles, generally, than addition, too.
Ancient man conquered his rivals with the jawbone of an ass; modern man uses the jawbone of a politician.
|
|
|
|
|
Thank you very much for the help. Seeings as how I did not even know what a quadratic equation was before I started this little project. I just got a hold of the formula, and kinda winged it from there to come up with an answer.
Thank you very much.
-----
IMHO: C# a poor attempt at bringing C++ to the VB masses
-----
|
|
|
|
|
You're very welcome... Quadratic equations are very useful, and you will probably encounter them often. As an entertaining exercise, try expanding your solution to include the common case where the radical (sc, in your code) is imaginary. Add a test for the case b2< 4ac. If this statement is true, solve the equation using the absolute value of the result before taking the square root and prefix the output of the radical with a 'j'. This gives a general solution of the form Re +/- jIm, which is valid for all equations in two-space. Your root solver will then be able to solve all cases, real and complex. Most important - have fun ith it!
Ancient man conquered his rivals with the jawbone of an ass; modern man uses the jawbone of a politician.
|
|
|
|
|
Is there a function to convert a CString value to an integer value?
|
|
|
|
|
|
try atoi()
regards
rishabhs
|
|
|
|
|
The following piece of code gives compilation error and i would like to get some ideas as to why.
fn_taking_2d_array(char[][MAX_WIDTH] array_arg)<br />
{<br />
}<br />
<br />
main()<br />
{<br />
char** list;
int length = getLength();
list = new char*[length]; <br />
for (int j = 0; j < length; j++)<br />
{<br />
list[j] = new char[MAX_WIDTH];<br />
}<br />
<br />
fn_taking_2d_array(list);
<br />
}
Aren't char** and char[][MAX_WIDTH] ultimately the same? pointer to pointer? It'd be great if i get some thoughts on this..
thanx,
natie.
|
|
|
|
|
natiekyle wrote:
Aren't char** and char[][MAX_WIDTH] ultimately the same?
Nope, char** is a pointer that points to a char pointer (an address that points to another address to hold a char ), while char[][] is only a two-dimensional array.
-Nick Parker
The true measure of a man is how he treats someone who can do him absolutely no good. - Samuel Johnson
|
|
|
|
|
If I have 400,000 sorted number in database like this
023F460B70F41323DBD1D2B49C
02C433C23F22D4498AFDCB9802
02E2C880757F813D0A0C067439
037502424D9A07383A1E6B73B1
.....
.....
.....
.....
A5183AA10FAC1DCCD581254A4
A6A7646433330474835DBAFE5
A7421081507B6CFAB19356F23
and I want to find this data "9DB831A9207DA9DE9F3E45525" is in database or not.
Do you know how to write program to do that?
Thank you for your answer.
|
|
|
|
|
I assume that you can use SQL in your program as a command to grab a certain criteria which would be
SELECT IDS FROM TABLE WHERE ID='9DB831A9207DA9DE9F3E45525';
If you returned a value then its there .
|
|
|
|
|
Anonymous, I never use SQL. Can I use SQL with Visual C++?
I use this below code but it is very slow. My database data is sorted number, so I think there may be the other ways to search quicker. If you know how to do that , please tell me.
<br />
<br />
m_Data = "9DB831A9207DA9DE9F3E45525";<br />
<br />
Found = 0;<br />
for (j=0; j<400,000; j++)<br />
{<br />
if (m_Data == Database_Data[j])<br />
{<br />
Found = 1;<br />
break;<br />
}<br />
}<br />
<br />
|
|
|
|
|
yeah u can use SQL using ADO (active x data objects ).
I was assumming u are working with some Database bridge such as ODBC. if u do not have something like that try using a STL map that will allow you to retrieve a value for a key .
The STL map is basically like a indexed table with a key value pair .
|
|
|
|
|
If they're sorted you can use a vector to hold them and use the std::binary_search ( or whatever it's called ).
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
Anonymous wrote:
OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window.
I think you are a good candidate for Visual Basic. - Nemanja Trifunovic
|
|
|
|
|
Christian Graus wrote:
use the std::binary_search ( or whatever it's called ).
Otherwise known as a thingy-ma-jig.
-Nick Parker
The true measure of a man is how he treats someone who can do him absolutely no good. - Samuel Johnson
|
|
|
|
|
Hello,
I am trying to implement context-sensitive HtmlHelp in my application using VC++ .Net. I have succeeded in implementing help using the F1 key, as follows:
BOOL CMainFrame::OnHelpInfo(HELPINFO* pHelpInfo)
{
//pHelpInfo gives me the ID
::HtmlHelp(this->GetSafeHwnd(),AfxGetApp()->m_pszHelpFilePath,HH_HELP_CONTEXT,pHelpInfo->iCtrlId);
//return CFrameWnd::OnHelpInfo(pHelpInfo);
return 1;
}
I am now trying to do the same for the help toolbar button that changes the cursor into a questionmark until you click on something.
What bothers me is that I can't find any convenient eventhandler like the one above to give me the ID of the menuitem or control that is being clicked upon. The eventhandler above doesn't seem to work for the toolbar. Any ideas? There must be a way to find the ID.
Help much appreciated.
Trimtrom
|
|
|
|
|
Try this:
ON_COMMAND(ID_CONTEXT_HELP, OnContextHelp)
You should save yourself and your company years of grief by shooting yourself through the head immediately. Believe me, in the long run it'll turn out better for everyone. - Tyto (at arstechnica)
Awasu 1.0[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
I need to write a function to copy data from COM Port 3 (COM3) to COM Port 1 (COM1).
Then, I need to write a function to copy data from COM Port 1 (COM1) to COM Port 3 (COM3).
Any help at all is welcome!!!!!
Me, wrong!?! Nah, you just need to change your thinking to make me right.
|
|
|
|
|
You can open a com port as a file under Win32. With minor restrictions, you can specify Read or Write attributes when opening such files to read from or write to. You can even try opening the ports as CFile using MFC. There is an example on Microsoft's site showing how to do this, including creating CArchive objects based on these files. After they are open, you can use standard file read and write routines or the << and >> operators. Look at MSDN.
Here is a link to start you off. This goes through the theory, anyway, plus it is non-mfc. Can't recall the MFC link, but you can look at the VCTERM sample for specs on using the Communication control as well..
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfiles/html/msdn_serial.asp
My personal experience: Do not try to do the copy in the same thread. Gets very messy. I spun off threads to read and write to and from the files. That worked well, except you now need synchronization between the threads.
Good Luck!
|
|
|
|