|
thank you stephen,
but can you narrate an example, where this sort of convention can be used.
|
|
|
|
|
There's sample code at the bottom of the link. printf and sprintf use this construct: both functions take a variable number of arguments.
Steve
|
|
|
|
|
so nice of you for the example.
i will try to implement it in my applications and post back if any more doubts are there.
thank you.
|
|
|
|
|
Microsoft has forgotten to include the standard va_copy() function/macro. See http://www.codeproject.com/script/comments/forums.asp?forumid=1647&mpp=50&select=2255221&df=100&fr=51[^]
va_copy() is required in a function like vprintf (which is probably how printf is actually implemented on most systems:
int printf( const char* format, ... )
{
int ret;
va_list args;
va_start( args, format );
ret = vprintf( format, args );
va_end( args );
return ret;
}
)
but unlike vprintf, you need to traverse the va_list more than once. There is no portable way to restart the argument traversal process without the va_copy() macro.
In my program, I went ahead and wrote:
#include <stdarg.h>
#ifndef va_copy
# define va_copy(dest,src) ((dest)=(src))
#endif
This may be confusing to a newbie to the subject, but if you program long enough, and you try to factor your code correctly, you're going to run into this situation.
David
|
|
|
|
|
Hi,
How long is the maximum popup time that can be set to a tooltip?
Thanks in advance.
- NS -
|
|
|
|
|
NS17 wrote: maximum popup time
I think that there isn't any limit
Russell
|
|
|
|
|
From my experiments I understood that it cant be set more than 0x7fff (signed short int max)
- NS -
|
|
|
|
|
|
TTM_SETDELAYTIME with TTDT_AUTOPOP flag
- NS -
|
|
|
|
|
Oh yes, got it.
Exactly, I found 7FFF milliseconds too.
If you need more I think that you need a custom tolltip that use a timer.
Russell
|
|
|
|
|
Less the code, lesser the bugs...
- NS -
|
|
|
|
|
|
You send the ToolTip control a TTM_SETDELAYTIME message with a WPARAM argument of TTDT_AUTOPOP and an LPARAM argument of the number of milliseconds
|
|
|
|
|
I have a button with text and an icon drawn on it.
If the user changes some entry, I want to be able
to change the text and the icon. I can do this, however,
everything just jumbles on top of the button. How can
I erase the background of the button so that when I
put the new text and icon, it looks clean?
Please, any response any one can give me will be
greatly appreciated.
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
|
DanYELL wrote: How can
I erase the background of the button so that when I
put the new text and icon, it looks clean?
How are you changing the icon and the text?
How are the icon and text drawn?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
It looks like this:
<br />
void ColorYes(CXPStyleButtonST *m_button)<br />
{<br />
CFont *SimpleFont = new CFont;<br />
SimpleFont->CreatePointFont(90, "Arial");<br />
<br />
m_button->SetFont(SimpleFont);<br />
<br />
m_button->SetBitmaps(IDB_GREEN_CHECK, WHITE, IDB_GREEN_CHECK, WHITE);<br />
m_button->SetFlat(FALSE);<br />
m_button->SetColor(CButtonST::BTNST_COLOR_FG_IN, WHITE);<br />
m_button->DrawTransparent();<br />
<br />
m_button->SetWindowText("Yes");<br />
}<br />
<br />
void ColorNo(CXPStyleButtonST *m_button)<br />
{<br />
CFont *SimpleFont = new CFont;<br />
SimpleFont->CreatePointFont(90, "Arial");<br />
<br />
m_button->SetFont(SimpleFont);<br />
m_button->SetBitmaps(IDB_RED_NO, WHITE, IDB_RED_NO, WHITE);<br />
m_button->SetFlat(FALSE);<br />
m_button->SetColor(CButtonST::BTNST_COLOR_FG_IN, WHITE);<br />
m_button->DrawTransparent();<br />
<br />
m_button->SetWindowText("No");<br />
<br />
}<br />
I call ColorYes and it puts the bitmap and text on the button. I call
ColorNo and it puts the new bitmap and text on top of the button with
the old image and button.
I need to call something that clears the button before I add new
stuff. I just dont know what function to call.
??
|
|
|
|
|
I'm not familiar with the CXPStyleButtonST class.
Maybe someone familiar with it will read here, but you may want to
post the question to the author on the article page[^] too.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Since I don't know the code, I'm not sure if this will work...
I would pull common code out of these functions and just do them once
during initialization (when the button is created:
CFont *SimpleFont = new CFont;<br />
SimpleFont->CreatePointFont(90, "Arial");<br />
m_button->SetFont(SimpleFont);<br />
m_button->SetFlat(FALSE);<br />
m_button->SetColor(CButtonST::BTNST_COLOR_FG_IN, WHITE);<br />
m_button->DrawTransparent();<br />
Then maybe try forcing a redraw:
void ColorYes(CXPStyleButtonST *m_button)<br />
{<br />
m_button->SetBitmaps(IDB_GREEN_CHECK, WHITE, IDB_GREEN_CHECK, WHITE);<br />
m_button->SetWindowText("Yes");<br />
<br /> m_button->Invalidate();
m_button->UpdateWindow();
}<br />
<br />
void ColorNo(CXPStyleButtonST *m_button)<br />
{<br />
m_button->SetBitmaps(IDB_RED_NO, WHITE, IDB_RED_NO, WHITE);<br />
m_button->SetWindowText("No");<br />
<br /> m_button->Invalidate();
m_button->UpdateWindow();
}<br />
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I'm not familiar with the CXPStyleButtonST class either, but the call to DrawTransparent() to redraw the button immediately raises my suspicions that it may not be erasing the background.
Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."
|
|
|
|
|
with reference to the previous post clickety[^]
Cedric helped me in getting the function pointer definition correct as such:
typedef bool (WorkerClass::*pf)(std::string &, std::string &);
for Method signature:
bool fncSame( std::string &x , std::string &y );
I now have two questions.
1) Why does the following fail?
<br />
std::string a("a");<br />
WorkerClass::pf pfn = &WorkerClass::fncSame;<br />
pfn(&a,&a);<br />
giving me the error: "error C2064: term does not evaluate to a function taking 2 arguments"
2) Where would I use function pointers? (other than academically as I'm currently doing)
Many Thanks
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
"There is no wealth like knowledge, no poverty like ignorance." Ali ibn Abi Talib
|
|
|
|
|
is fncSame a static member function ? (it should be. if you're going to use it with fn pointers)
Mustafa Ismail Mustafa wrote: Where would I use function pointers?
you use them all the time when interacting with C-style interfaces (ex. qsort, EnumChildWindows, EnumFonts, WndProcs, etc). you find them often in C-interfaced libraries, where library authors add hooks to let you override library functionality without having to change any of the library's source code - just set the "errorOutput" function pointer (or whatever) to your own function instead of the built-in function.
C++ reduces their importance, though. since a lot of what they were used for in C is handled by the ability to override functions in base classes, you don't need to use function pointers - just derive from the base class and override a virtual function.
|
|
|
|
|
Chris Losinger wrote: is fncSame a static member function ?
Its not. I thought that both static and instance members could be used, but not interchangeably.
Anyways, I changed the method to static and now it gives me this error:
error C2440: 'initializing' : cannot convert from 'bool (__cdecl *)(std::string &,std::string &)' to 'WorkerClass::pf'
In addition to the previous error:
error C2064: term does not evaluate to a function taking 2 arguments
I'm using VS2005 if that means anything in this case.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
"There is no wealth like knowledge, no poverty like ignorance." Ali ibn Abi Talib
|
|
|
|
|
Chris Losinger wrote: is fncSame a static member function ? (it should be. if you're going to use it with fn pointers)
The pointer type is as follows (I added the underline):
typedef bool (WorkerClass::*pf)(std::string &, std::string &)
The function must be a non-static member function of WorkerClass .
Steve
|
|
|
|
|
Mustafa Ismail Mustafa wrote: I now have two questions.
1) Why does the following fail?
std::string a("a");
WorkerClass::pf pfn = &WorkerClass::fncSame;
pfn(&a,&a);
Because it doesn’t make sense: what instance of the class would the member function be called on? You need something like this:
WorkerClass wc;
std::string a("a");
WorkerClass::pf pfn = &WorkerClass::fncSame;
(wc.*pfn)(&a,&a a, a);
-- modified at 3:39 Wednesday 3rd October, 2007
Steve
|
|
|
|
|
Another you have to take care of (Stephen already answered the main question):
bool fncSame( std::string &x , std::string &y );
This is your function signature: it requires two string parameters that are passed by reference. When you use it, you do that:
pfn(&a,&a);
Which is wrong, because you pass the addresses of the strings (pointers). You should do this instead (and take in account the answer of Stephen of course ):
pfn(a,a);
|
|
|
|