|
What kind of tooltip it is? Do you have your own CToolTipCtrl object or it's the one mainained by MFC?
Tomasz Sowinski -- http://www.shooltz.com
Never argue with an idiot, he'll bring you to his level and beat you with experience.
|
|
|
|
|
I would like to use CToolTipCtrl if such it is possible.
At me is the control similar to a grid and for each column and a line I need to draw the individual text.
What can you advise me?
Best regards,
Eugene Pustovoyt
|
|
|
|
|
|
Yes but message TTN_NEEDTEXT is sent once for all control. That this message is sent second time to me it was necessary to leave a control and then again to go on him. Such approach bad.
How to force the message to be sent at change of a line and a column inside a control.
Best regards,
Eugene Pustovoyt
|
|
|
|
|
You need to check mouse cursor position in OnMouseMove. If you want to display tooltip, call m_tooltip.Activate(TRUE). If you want to turn off tooltip, call m_tooltip.Activate(FALSE). If you want to change the text of the tooltip, call Activate(FALSE), then Activate(TRUE).
Tomasz Sowinski -- http://www.shooltz.com
Never argue with an idiot, he'll bring you to his level and beat you with experience.
|
|
|
|
|
Many thanks. All seems works.
One more small question how to force to be displayed the balloon tooltip
Best regards,
Eugene Pustovoyt
|
|
|
|
|
In the sample, message 1 will be the expected return
message 2 always returns "Help Dir", what am i not doing right.
any helps always appreciated.
CString mDest;
1. AfxMessageBox(m_FileObject[t].m_Dest);
if (m_FileObject[t].m_Dest = "AppDir")
mDest = "App Dir";
if (m_FileObject[t].m_Dest = "SysDir")
mDest = "System Dir";
if (m_FileObject[t].m_Dest = "WinDir")
mDest = "Windows Dir";
if (m_FileObject[t].m_Dest = "HlpDir")
mDest = "Help Dir";
2. AfxMessageBox(mDest);
shotgun
frustrations just a way of knowing your alive...
|
|
|
|
|
You are not comparing, you are assigning!
Change the single "=" inside the parens to "==".
|
|
|
|
|
nope tried that, thanks anyways
this works
int r;
sDest = m_FileObject.GetAt(t).m_Dest;
r = sDest.Find("AppDir");
if (r != -1)
AfxMessageBox(sDest);
r = sDest.Find("SysDir");
if (r != -1)
AfxMessageBox(sDest);
r = sDest.Find("WinDir");
if (r != -1)
AfxMessageBox(sDest);
r = sDest.Find("HlpDir");
if (r != -1)
AfxMessageBox(sDest);
but, now is there a better way?
shotgun
|
|
|
|
|
shotgun wrote:
nope tried that, thanks anyways
You can't have, because what Mike said was dead right.
if (s = "s")
will assign "s" to s and return true.
You should use your first method, with the == corrected, and make them else-if's so that once one comes back successful the rest of the checks are not made for no reason.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
I have a question about menus. I have just started learning Visual C++ .net. I am reading Teach yourself visual c++ 6 in 21 days. There are some things that are different like the class wizard. The problem i am having is how do you attach the menu after you have created it to the CMenuDlg class. What i have right now is I can see the menu on the dialog but when i try to add a function to it none of my things work, i get errors like OnOK() function is not defined
Thanks
|
|
|
|
|
Hi there, I was on the same way like you, learning from Teach Yourself Visual C++ 6. But it does not work well i think. I chosen another book by Jonathan Betus. It is a black book. I don't bring the book today to office so I cannot give you the name today. Perhaps tomolo. Anyway, I think the error that you have got is becoz you change the wizard generated code. But if you want to add function, you should edit the menu and go to class wizard to add an event handler for the menu. Good luck
|
|
|
|
|
Hi there, I was on the same way like you, learning from Teach Yourself Visual C++ 6. But it does not work well i think. I chosen another book by Jonathan Betus. It is a black cover book.
Anyway, I think the error that you have got is becoz you change the wizard generated code. But if you want to add function, you should edit the menu and go to class wizard to add an event handler for the menu. Good luck
|
|
|
|
|
Thanks for responding. I found the error it was because i wasn't inheriting from the CDialog class like i should.
|
|
|
|
|
almost every one has used following line
#include < iostream > //or others
i don't know why don't use dot h, so
#include < iostream.h >
if say, file name < iostream.h > has been used, but it can be another name (i.e. iosteam_0_1_2.h)
my question is,
why don't use .h for the head file? is there any advantages?
thx
includeh10
|
|
|
|
|
<iostream> and <iostream.h> are different versions of the file; <iostream> is preferred and conforms closely with the current ANSI/ISO standard. <iostream.h> is older and provided for backwards compatibility. Use <iostream> for all new code.
This posting is provided “AS IS” with no warranties, and confers no rights. You assume all risk for your use. © 2001 Microsoft Corporation. All rights reserved.
|
|
|
|
|
Adding to what Nick said, the new headers were part of the first C++ standard ( and therefore the .h headers are non-standard C++ ), and they wrap everything in namespace std, so if for example you wanted to use cout, you'd need to use iostream AND put using std::cout; in your code, or reference cout through std:: every time you use it.
There is also the option of using the entire std namespace, but that's not something that real programmers do.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
sometimes i am blocked there for hours just for a stupid error, i think it comes again.
i need to access a char buffer with high speed, now it uses almost 37 ms, i want to reduce it. to do so, i do several tests to find the points of time consumer.
one test is very strange as following.
const char*pszBuf points to a null-based string, size is 354,737 bytes (from opening a file) and created by new, out of scope of following function:
function code:
char*pszFirst=(char*)pszBuf;
char*pszLast=(char*)&pszFirst[strlen(pszFirst)];
UINT uTime=::GetTickCount();
for(int i=0;i<1000;i++) //loop for getting right time
{
//line 0
pszLast=(char*)&pszFirst[strlen(pszFirst)];
char*psz=pszFirst;
//line 1
while (psz < pszLast) psz++;
}
uTime=::GetTickCount()-uTime; //check time here
run the code
a). keep both line 0 and line 1, uTime is 8,570 ms
b). delete line 0, keep line 1, uTime is almost 0
c). delete line 1, keep line 0, uTime is almost 0
that is: 0 + 0 = 8570
what is wrong? can u beleave that?
thx
includeh10
|
|
|
|
|
strlen() is slowing your code. Try calculating the string length outside the loop.
This posting is provided “AS IS” with no warranties, and confers no rights. You assume all risk for your use. © 2001 Microsoft Corporation. All rights reserved.
|
|
|
|
|
it is a test, that is why inside loop.
i can put strlen out of loop, but can't put it out of my program.
includeh10
|
|
|
|
|
includeh10 wrote:
i can put strlen out of loop, but can't put it out of my program.
That's what Nick said. It's being called over and over when you only need to call it once. It is the bottleneck in this code because you call it over and over needlessly.
Christian
We're just observing the seasonal migration from VB to VC. Most of these birds will be killed by predators or will die of hunger. Only the best will survive - Tomasz Sowinski 29-07-2002 ( on the number of newbie posters in the VC forum )
Cats, and most other animals apart from mad cows can write fully functional vb code. - Simon Walton - 6-Aug-2002
|
|
|
|
|
Although I agree with Nick and Christian that the strlen should be out of the loop I also think it's really besides the point.
You're wondering how 0 + 0 gets to be 8570, right? And putting strlen inside a loop here is just for testing purposes, right? You would never put strlen inside a loop in your final program, right? Promise?;P
Anyway, I can't see anything "wrong" with the code (except that you didn't put it into pre-tags which greatly improves readability ). I put it into my VC++6.0, and got pp. 4200 ms for both lines and app. half for each of the lines alone - all in debug builds. In release builds all timings were 0 msecs.
My best shot would be that optimization is playing you a trick. Are you sure all optimizations are turned off? Or perhaps some of your other code only forces the optimizer to keep the code when both lines are present.
I'm probably wrong, but hey, that's the story of my life.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
I think that Visual C++ does some trivial optimisation even in debug builds.
When line 0 is deleted, it is trivial for the compiler to know that line 1 does nothing and the the whole loop is useless.
For the other case (line 1 deleted), I don't see how it can be "optimized" except if intrinsic inline functions are enabled.
The best thing to do is to take a look at the assembler code while debugging. You will see what the compiler has generate.
At first, I would think that the compiler has detected that the loop is useless when timing is really near 0ms.
Probaly when you have both lines, the complexity is higher than what VC will try to optimize...
Philippe Mori
|
|
|
|
|
Hi.
I am becoming more familiar with Win32 API especially for winsock and core Windows including threads, processes, and DLL. I began learning programming about a year ago and my first and currently more proficient language is C++. I have no prior programming experience and not knowledge of C. Nonetheless, Win32 API and other Windows programming tools as well and good DOS and linux programs all make use of C run-time library.
I would like to know ways to allocate and deallocate a chunk of memory space. In C++, I am familiar with the new and delete operators. However, you have to define the data type you before allocating memory. I C, I believe you can allocate a chunk of memory (BYTE data type?) and store anything there. Furthermore, you can use function, I believe free(), to free the memory.
What are some ways to allocate/deallocate memory using C/C++ other than new/delete?
Thanks,
Kuphryn
|
|
|
|
|
void * ptr = malloc(NumberofBytes);
There is also calloc, and GlobalAlloc
Look 'em up to see the usage.
|
|
|
|