|
Is there a way that i can set/change a control extended style at run time without having to create it again (Create(...),CreateEx(...))?
|
|
|
|
|
Some styles can be changed at run-time, some cannot.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
ModifyStyleEx
Regards,
Alvaro
Hey! It compiles! Ship it.
|
|
|
|
|
In general, ModifyStyle and ModifyStyleEx . However, the list control has its own extended styles that must be set through SetExtendedStyle .
ModifyStyle(Ex) works by calling SetWindowLong with the GWL_STYLE or GWL_EXSTYLE parameters as appropriate.
Some of the settings changed by this method won't take effect until either SetWindowPos is called, and some styles can't be changed after creation.
|
|
|
|
|
I was curious if writing code using more traditional C-like character parsing and handling is more efficient under high volume scenarios than using STL strings?
for instance, if we use strtok and all those string manipulation stuff that C and C++ offer, do they perform better than using STL string and its various functions, if efficiency is of critical concern?
thanks
|
|
|
|
|
To help answer, I'll let you know a little secret: The two words "STL" and "efficiency" are mutually exclusive.
|
|
|
|
|
The simplest answer has to be 'suck it and see'.
I seem to recall that Herb Sutter did some trials and discovered that STL tended to be rarely worse and sometimes a bit better than if you'd written it by hand. They're either on his site[^] or at C/C++ Users' Journal[^].
|
|
|
|
|
anonymous wrote:
I was curious if writing code using more traditional C-like character parsing and handling is more efficient under high volume scenarios than using STL strings?
They may be faster in error free situations.
However consider error handling and ease of coding / maintainance before you go away from STL strings. Use STL until your profiling shows you that STL is the bottleneck.
It's likely that algorithmic peformance for parsing may make a bigger impact. For parsing code look at boost::regex or boost::spirit, or depending on what you need maybe flex and bison (lex and yacc) or a scripting language.
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
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
|
|
|
|