|
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
|
|
|
|
|
How about just using a flag bListCtrlInitialized in OnInitialUpdate() to ensure it gets done just once?
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Yes - I've thought of that, and it certainly would work. But it just seems so cheap...
Jonah Bishop
Visit JGB Productions
|
|
|
|
|
I am trying to create a color palette that will allow someone to pick what color of text they want. I can't seem to find anything to help me out on this. Any ideas?
|
|
|
|
|
Use the ChooseColor function to create a dialog box where you can pick a color.
|
|
|
|
|
I have a string that is :
string myString ="Appliance.Oven.Heater";<br />
string commandString="Run:appladdr:TurnOn:150seconds"; In commandString I want to replace "appladdr" with myString .
for the final string to be
Run:Appliance.Oven.Heater:TurnOn:150seconds
I was getting a memory error using CString .
when I did
CString finalString = commandString.c_str();<br />
finalString.replace("appladdr",myString.c_str());
What am i doing wrong ?
I would like to do this using STL itself.
|
|
|
|
|
act_x wrote:
What am i doing wrong ?
I would like to do this using STL itself.
My good deed of the day:
#include <iostream.h>
#include <string>
using namespace std;
void main()
{
string myString ="Appliance.Oven.Heater";
string commandString="Run:appladdr:TurnOn:150seconds";
commandString.insert(4, myString.c_str());
commandString.replace(24, 8, "");
cout << commandString.c_str() << endl;
}
-Nick Parker
The true measure of a man is how he treats someone who can do him absolutely no good. - Samuel Johnson
|
|
|
|
|
Using STL:
int nPos = commandString.find( "appladdr" );
if ( nPos != string::npos ) {
commandString.replace( nPos, strlen("appladdr"), myString );
}
The MFC code looks right though - what exactly is the memory error that you are getting, and on which line?
Dave
|
|
|
|
|
I am doing all of the MFC in thread functions . I do not know if that is a problem . I am getting memory read errors .
|
|
|
|