|
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!
|
|
|
|
|
I've added message handlers for a ComboBox control to that combobox's class (a subclass of CComboBoxEx which I have defined) to handle messages such as WM_CHAR, etc. However, when I use that combobox in a Dialog, my message handlers are not triggered by the user interactions which they are supposed to respond to. Any ideas on what is going on or how i can solve this problem would be much appreciated.
Ben
|
|
|
|
|
did you subclass it?
in the oninitdialog... or somewhere useful
m_myCombo.SubClassWindow(IDC_MYCOMBO, this);
Bryce
|
|
|
|
|
As I understood you have your own class CComboBoxEx in which you have implemented a handler for WM_CHAR, right?
And more you want to use this combo in your dialog.
Then if this is correct then add a combobox to your dialog by dragging it from the resource editor and add a member variable to that combo of the type CComboBox. Then go where your variable was added and change the variable from type CComboBox to CComboBoxEx.
I hope I understood corectly your question...
|
|
|
|
|
I have my own combo-box subclass (CMyCombo) that extends CComboBoxEx in order to add some specific features to all combo boxes in my program. However, I do not know how to display combo boxes of my type in Dialogs. Is there any way to add a combo box control to a dialog box in the resource editor, but use my subclass to implement it, rather than the default CComboBoxEx ?
Ben
|
|
|
|
|
Add it as a normal combo box to the template. Then in class wizard add a control member for the combo box (not a value). This adds a CComboBox member to the class definition - you can then replace CComboBox with CMyCombo.
Dave
|
|
|
|
|
|
Hello,
I am a beginner trying to understand how to use an API (in this case HtmlHelp). I am not sure how to call an API method: I want to call a method HtmlHelp(...), which has four arguments, and I can see this in Intellisense if I put two colons before the methodname:
::HtmlHelp(HWND hwndCaller, LPCSTR pszFile, UINT uCommand, DWORD dwData) ;
However, all the examples I read show the method being called without the two colons, yet with four arguments. What does this mean?? Does this relate to namespaces?? When I take away the colons, the Intellisense shows only the CWinApp method:
virtual void HtmlHelp(DWORD_PTR dwData, UINT nCmd = 0x000F);
with two arguments. When I use the ::HtmlHelp(...) with four arguments, I get the following error message:
LPSEmail error LNK2019: unresolved external symbol _HtmlHelpA@16 referenced in function "public: int __thiscall CMainFrame::OnHelpInfo(struct tagHELPINFO *)" (?OnHelpInfo@CMainFrame@@QAEHPAUtagHELPINFO@@@Z)
I have placed the htmlhelp.lib file in the lib directory, and the htmlhelp.h at the top of this class. So what have I done wrong?? Do I need the colons??
Sincerely,
Trimtrom
|
|
|
|
|
The double colons force the compiler to look in the global namespace for the function - without them it will always look in the current class first, meaning that it finds the HtmlHelp() method rather than the global function.
To link with HtmlHelp.lib, you must add it to the list of libraries in the project settings (Project->Settings->Link) - it does not automatically link with all libraries in the lib directory.
Dave
|
|
|
|
|
I'm creating an SDI application using the CListView class as the base view, and I'm having a problem knowing when I should do things like InsertColumn(). If I use the OnInitialUpdate() method, columns get inserted every time that a new document gets created. When I try to use the OnCreate() method, I get an exception stating that the main frame has not yet been created (note that I'm getting a pointer to the main frame object to set some window "snap" settings).
Is there a method for a view that gets called only once upon program startup, but after all the windows have finished their creation state? I basically want to know where I should insert columns and do other, one-time initialization stuff.
Any ideas?
Thanks,
Jonah Bishop
Visit JGB Productions
|
|
|
|