|
If efficiency is critical, I wouldn't use neither STL nor STL C++ library. As suggested before, I would go for a library or parsing generator toolkit capable of generating a FSA parser.
You can do it on anything you choose - from .bat to .net - A customer
|
|
|
|
|
When you get down to it, you can not know which is better until you test it. Try to do some small scale mock ups of the code and test the speed.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hi,
I'm trying to give a list box on a dialog a tool tip using CToolTipCtrl.
Here's the code I used:
CToolTipCtrl tooltip;
tooltip.Create(this,TTS_ALWAYSTIP); //this is the dialog having the dialog
listbox=(CListBox *)GetDlgItem(ID_LISTBOX);
//Get client area of list box relative to the dialog
::GetWindowRect(listbox->m_hWnd,&rect);
BOOL b=tooltip.AddTool(this, IDS_STRING1, &rect, ID_LISTBOX);
tooltip.Activate(TRUE);
tooltip.SetDelayTime(1);
However, when I move the mouse over the list box, no tool tip comes up.
Any suggestions would appreciated.
Thanks.
Martin
|
|
|
|
|
The reason is most likely because your tooltip object is being constructed on the stack, right inside your function, and then it goes away as soon as the function exits. Two suggestions:
1. Make the tooltip object a member of the class, instead of a local variable.
OR
2. If your function is only called ONCE in the entire program, make your tooltip object static so that it doesn't go away (until the program exits):
static CToolTipCtrl tooltip;
I don't know if the rest of the code is fine, but you can start with this.
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
I think Alvaro is right!!!
This cud be the reason. If the problem still persists, use the 2 parameter form of AddTool(...). Dont the specify the CRect. Once you specify the CRect attribute, then the tooltip is binded to that rectangle.
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
Hi guys,
I want to implement in C++ an octree data structure. This should look like a binary tree data structure, however instead of having 2 children, every node should have 8.
Does any of you has this thing already implemented and can pass on to me the source code? Or do you know somebody that can help with writing my source code?
Thanks a lot,
|
|
|
|
|
I haven't written a binary tree since undergraduate school so here is a high-level overview of what might be required:
struct Node
{
Node *p1;
Node *p2;
Node *p3;
Node *p4;
Node *p5;
Node *p6;
Node *p7;
Node *p8;
} *pRoot = NULL;
void _Add( Node *pNode, Datum *pDatum )
{
if (NULL == pNode)
{
pNode = new Node;
pNode->p1 = NULL;
pNode->p2 = NULL;
...
}
else if (...)
_Add(pNode->p1, pDatum);
else if (...)
_Add(pNode->p2, pDatum);
else if (...)
_Add(pNode->p3, pDatum);
else if (...)
_Add(pNode->p4, pDatum);
else if (...)
_Add(pNode->p5, pDatum);
else if (...)
_Add(pNode->p6, pDatum);
else if (...)
_Add(pNode->p7, pDatum);
else if (...)
_Add(pNode->p8, pDatum);
else
assert(FALSE);
}
void Add( Datum *pDatum )
{
_Add(pRoot, pDatum);
}
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Excuse me, but is your code somehow better than the following?
struct Node { Node * children[8]; } *pRoot = 0;
void _Add( Node *pNode, Datum* pDatum )
{
if ( 0 == pNode )
{
pNode = new Node;
memset( pNode->children, 8*sizeof(Node*) );
return;
}
if (...) { _Add(pNode->children[0], pDatum); return; }
}
Hosam Aly Mahmoud
|
|
|
|
|
I'm trying to open my About dialog from a menu item, but it does not seem to work. I've tried putting the about dialog id in the menu about id field, that didn't work. I've tried making an event handler but that doesn't even go to the fuction that was created (I put in a messagebox to pop up when it called that function).So how do I do this?
Thanks for any help
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
First, you need to create a new dialog box:
HWND dlg = CreateDialog (application_instance, MKINTRESOURCE (IDD_DIALOG_NAME),
parent_window, DefDlgProc);
Now show the window:
ShowWindow (dlg, SW_SHOW);
If it does not show properly, then update the window, and force it into focus:
UpdateWindow (dlg);
SetForegroundWindow (dlg);
When the use clicks your okay button, if you have set the resource ID for the Okay button to IDOK, the dialog will close are DefDlgproc (defined by Microsoft) will close the window.
Managing Director of Oiginal Sin Software
www.originalsinsoftware.com
|
|
|
|
|
I guess I'm not making myself very clear. I have a dialog app that has a menu. In the menu is a menu item called "Help" with a sub-item "About" I want to have my menu sub-item "About" to open the about box that was created when I first created my dialog app. The same about box that comes up when I right click on the title bar and choose "About".
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Ah, MFC, yes?
If so, MFC will have created something like CAboutDlg. In which case you can just do:
CAboutDlg *dlg=new CAboutDlg;
dlg->DoModal();
delete dlg;
Managing Director of Oiginal Sin Software
www.originalsinsoftware.com
|
|
|
|
|
okay but how do I call this from my menu sub-item "About"? I've tried creating an event handler but it never drops in to the fuction I created when I choose "About".
MFC....yes
And thanks again for all the help
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Okay, when you edit the menu in the resource editor, use the class viewer (CTRL+W) to add a message handler and add the code there.
Managing Director of Oiginal Sin Software
www.originalsinsoftware.com
|
|
|
|
|
Thanks....I think my problem is that I rush. I kept making the event handler but choosing the wrong class. I kept choosing the CAboutDialog class instead of my main app dialog class. After I choose the correct class it worked fine. Thanks for all the help.
Tom
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
You'll need an entry in the (App's) message map:
BEGIN_MESSAGE_MAP(CMyApp, CWinApp)
ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
END_MESSAGE_MAP() Then the handler function:
void CMyApp::OnAppAbout()
{
CAboutDlg aboutDlg;
aboutDlg.DoModal();
}
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I need a ComboBox smaller than the standard minimum size that VC7 offers. Is this possible with CComboBox?
Monica
|
|
|
|
|
Can you not edit the .RC file manually, bypassing the resource editor?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Yes, but if I change the size there the list of the combo is resized. I need a combo with the edit control very small (hight very small).
|
|
|
|
|
You could try making it variable-height owner-draw, and implementing the measure item stuff, although of course you might also need to change the font it's using.
Steve S
|
|
|
|
|
Hi,
in case this is still relevant:
i encountered the same problem and wish to trade my solution in return to your advice;).
to control the edit box height, i simply changed the combobox font size. e.g. (12==font height in points):
<code>CFont font;
LOGFONT lf;
font.CreateFont(12, 0, 0, 0, FW_NORMAL, FALSE,
FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH | FF_SWISS, "Arial");
font.GetLogFont(&lf);
m_newFont.CreateFontIndirect(&lf);
m_ccombobox.Create(WS_CHILD | WS_VSCROLL |CBS_DROPDOWN
, rect, this, 0);
m_ccombobox.SetFont(&m_newFont); </code>
and now for my question: how do you get the size the rectangle wrapping the edit box + the arrow box?
thank you.
<small><b>mstanciu2000 wrote:</b></small>
<i>I need a combo with the edit control very small (hight very small). </i>
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Email: y_becker@netvision.net.il
|
|
|
|
|
Thankyou for the solution but I already found something else to do. Unfortunately, both my solution and yours have the following problem: If the size is smaller than 12 the text in the combo is no longer entierly visible.
As for your question...I am not sure that I understand well but a quick solution would be GetClientRect(&rect).
|
|
|
|
|
Shalom,
sorry for insisting, but the text size is fully visible (i tried 10pt, 8 pt. hell even 6pt.), though at some point a microscope should be attached to the application. you may have some fixed list box style still present at your app.
as for your suggestion: though it is this which is self-evident that is frequently ignored, that is not the case this time. the problem is that i keep on getting the same combo client size, no matter what the actual visible client size is.
Thank you for your quick reply.
Anonymous wrote:
If the size is smaller than 12 the text in the combo is no longer entierly visible.
As for your question...I am not sure that I understand well but a quick solution would be GetClientRect(&rect).
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Email: y_becker@netvision.net.il
|
|
|
|
|
i used the following and got stuck after the recset.GetFieldValue("Address ID",sID);
recset.GetFieldValue("Last Name",sLastname);
coz nt sure how to make my edit box display the data of Address ID and Last name.
the code goes:
void CAccessdbDlg::OnButton2()
{
CDatabase database;
CString SqlString;
CString sID, sLastname;
CString sDriver = "MICROSOFT ACCESS DRIVER (*.mdb)";
CString sDsn;
CString sFile = "e:\\fyp_2003\\database_sample.mdb";
// Build ODBC connection string
sDsn.Format("ODBC;DRIVER={%s};DSN='';DBQ=%s",sDriver,sFile);
TRY
{
// Open the database
database.Open(NULL,false,false,sDsn);
// Allocate the recordset
CRecordset recset( &database );
// Build the SQL statement
SqlString = "SELECT Address ID, Last Name "
"FROM Categories";
// Execute the query
recset.Open(CRecordset::forwardOnly,SqlString,CRecordset::readOnly);
// Copy each column into a variable
recset.GetFieldValue("Address ID",sID);
recset.GetFieldValue("Last Name",sLastname);
????????????
database.Close();
}
CATCH(CDBException, e)
{
// If a database exception occured, show error msg
AfxMessageBox("Database error: "+e->m_strError);
}
END_CATCH;
}
and is this code correct?
|
|
|
|
|
coda_x wrote:
recset.GetFieldValue("Last Name",sLastname);
Now you simply need to call the SetWindowText(sLastname) method of one of the edit control variables.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|