|
how do i place a image next a menu
Clint
|
|
|
|
|
What about this[^]
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
thank you for your reply but, these examples are all part of the toolbar not nex to the toolbar.
Clint
|
|
|
|
|
huh ?
what exactly do you want ? a popup/drop down menu in a toolbar ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
something that looks like a standard menu ie File,edit,options but can have a large picture, on the left which may, or may not overlap the toolbar.
Clint
|
|
|
|
|
I have a quick question regarding saving font settings in a drawing type package.
For example, an application like Corel Draw who has a TextBox on the canvas who uses Arial font, how would that information be saved?
Obviously, we'd store the text in some kind of string/char object, but for the font, would you just store the szFontName, nPointSize and some style bits (bold/italics/underline)?
We're working on an issue with our product where somebody has chose to save the LOGFONT structure, but we're finding that the logfont.height guy is based on the DC because of the call:
logfont.lfHeight = -MulDiv ( PointSize, GetDeviceCaps(hdc, LOGPIXELSY), 72 );
Bottom line, Whats the common way to save this stuff?
Any info you could send would be greatly appreciated.
Mike.
|
|
|
|
|
I would save the font height in typographical points - that is, PointSize rather than logfont.lfHeight above.
You might want to consider using CreatePointFontIndirect for font creation, then you can save/load the LOGFONT directly.
|
|
|
|
|
excerpted from MSN" The user scrolls the content of a window by clicking one of the arrow buttons, by clicking the area in the shaded shaft, or by dragging the scroll box. When the user clicks an arrow button, the application scrolls the content by one unit (typically a single line or column). "
Question: how to retrieve the size (by pixel) of a unit?
ZZH1234567@HOTMAIL.COM
|
|
|
|
|
have a look at CScrollBar::GetScrollInfo and the SCROLLINFO struct.
also, depending on the application, it can be user/programmer defined, for example, if you need to scroll a bitmap, you can set the "unit" to 1 pixel, or if it's text, you can compute it to scroll the height of the next/previous line.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hello
I'm writing a class derived from MFC's CTime with additional methods for my
app but have a problem.
Time variable in base class is declared as follows:
private:
time_t m_time;
Is there any 'magical c++' trick to access it in derived class?
(without changing base class of course)
For now i see only two options (not deriving):
Rewrite entire class
or put CTime in new class as a member and do some tricks with all required methods.
But maybe someone hava a better idea?
thanks
Chris
|
|
|
|
|
no trick needed ....
use the GetTime method from CTime to get m_time.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
well, i didn't say i cannot get this value. i want my class to derive all
methods, operators from CTime and work well with CTimeSpan also.
I have written a method like this:
bool CTimeEx::SetYear(int nYear)
{
time_t c_time;
struct tm *atm;
c_time = GetTime();
...
...
...
return TRUE;
}
but GetTime() don't work here. When i debug there is an error like this:
code:
_AFX_INLINE time_t CTime::GetTime() const
{ return m_time; }
m_time | CXX0069 Error: variable needs stack frame
it's because of inline i think
any more help?
thx
|
|
|
|
|
No tricks are advisable.
Consider COleDateTime though
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
kzyczynski wrote:
Is there any 'magical c++' trick to access it in derived class?
There is an unorthodox trick: time_t *pointer_to__m_time=(time_t *)this; .
Anyway, not recommended
rechi
|
|
|
|
|
is it possible to increase the print preview area with out zoom out
|
|
|
|
|
#include <iostream.h>
template<class t=""> T max(T a, T b)
{
if (a > b)
return(a);
else
return(b);
}
float max(float, float);
int max(int, int);
void main(void)
{
cout << "The maximum of 100 and 200 is " <<
max(100, 200) << endl;
cout << "The maximum of 5.4321 and 1.2345 is " <<
max(5.4321, 1.2345) << endl;
}
--------------------Configuration: Max_Temp - Win32 Debug--------------------
Linking...
Max_Temp.obj : error LNK2001: unresolved external symbol "int __cdecl max(int,int)" (?max@@YAHHH@Z)
Debug/Max_Temp.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
The problem seems with 'int max(int, int);'; after comment this line, no linking error
DJ
|
|
|
|
|
Like you said the problem is the redefinition of the max macro as a function
When you redefine the max macro as function and you dont supply a code for it the linker would nag about unresolved external(s).
either code the max function, or just use the macro (defined in stdlib.h and windef.h)as it expands to
#define max(a,b) (((a) > (b)) ? (a) : (b))
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
sure
when u declare:
int max(int,int);
it looks for a function other than the template function when u use it.
when there exists the template function definition, there's no need to explicitly define prototypes.
u should remove both prototypes. if u need to use not exactly the same types in max, eg. max(int,float), max(float,int), etc. u may define inline functions like these:
float max(int i,float f) { return max(float(i),f); }
float max(float f,int i) { return max(f,float(i)); }
etc.
|
|
|
|
|
The purpose of this test code is to make use of function template, instead of max funtion, which happened to be here.
HOwever, if comment out [int max(int, int);], leave [float max(float, float);
], the code works well.
Seems something wrong to the int type?
DJ
|
|
|
|
|
there's no difference between int and float. if u use float too, it nags about it too. the default for numbers including decimal points is double, not float. this is why it didn't error.
to test is cast the floating point numbers to float.
as i said, u don't need to prototype the existing max template function.
|
|
|
|
|
but if I just comment out int maxf(int, int); , the code works.
Moreover, if I comment out float maxf(float, float); , the code works too.
DJ
|
|
|
|
|
so comment out both
if u like i'm online (invis always) now with id ilostmyid2 at yahoo messenger
|
|
|
|
|
thanks. my concern is why int max(int, int) not working but float max(float, float) working. What I had tested was funtion templates, not max/min funtion. So I renamed the function name to confuse less.
The following codes work:
#include <iostream>
template<class T> T TFun(T a, T b)
{
if (a > b)
return(a);
else
return(b);
}
float TFun(float, float);
void main(void)
{
std::cout << "The TFunimum of 100 and 200 is " <<
TFun(100, 200) << '\n';
std::cout << "The TFunimum of 5.4321 and 1.2345 is " <<
TFun(5.4321, 1.2345) << '\n';
}
DJ
|
|
|
|
|
i answered ur question before
as i said TFun(5.4321, 1.2345) maps to double TFun(double,double), not float TFun(float,float). ie. u didn't use float. this is why it's ok.
if u declare a prototype as:
double TFun(double,double);
it errors
|
|
|
|
|
There isn't per se anything wrong with the template function, rather with some other parts of the code.
- You are using
iostream.h , this is a pre-standard header and should not be used. Instead use iostream , without a postfixed .h - You defined two functions manually,
float max(float, float); and int max(int, int); . These two functions do not refer to the templated function and will be used before the match to the template function. Hence, you should remove these and the error will go away. - Lastly, have you considered what happens if you do something like this:
short s = 37; int a = 2839; int b = max(s, a); ? This will fail with an error message, because the compiler isn't able to deduce the type of T (your template parameter). Thus, you need to implement a more solid min/max function, as explained by Andrei Alexandrescu in his Generic< Programming >: Min and Max Redividus[^] article at http://www.cuj.com[^] - Also, this is just a small detail, but you might want to consider using '\n' rather than std::endl, because std::endl also explicitly flushes the stream - can slow down performance unnecessarily (albeit not a lot in most cases).
- Lastly, the main signature is according to the standard either
int main() or int main(int argc, char* argv[]) . void main() is a Microsoft-specific extension, and unless necessary (I haven't yet seen any reason why) it should be avoided for the sake of portability.
All in all, the code will look like this:
#include <iostream>
<br />
template<typename T>
T max(T a, T b) {
return a > b ? a : b;
}
<br />
int main() {
std::cout << "The maximum of 100 and 200 is "
<< max(100, 200) << '\n';
std::cout << "The maximum of 5.4321 and 1.2345 is "
<< max(5.4321, 1.2345) << '\n';
return 0;
}
I hope this helps.
--
Henrik Stuart (http://www.unprompted.com/hstuart/[^])
|
|
|
|
|