|
try making new CFont object using CFont* ListBoxFont = new CFont;
that might work... just an idea
r -€
|
|
|
|
|
Your CFont object needs to be moved to the header file of your dialog class.
What's happening is that the CFont object is being created on the stack within your function and when the function exits the CFont object goes out of scope and it's destructor is being called.
shultas wrote:
Also: I am wondering if there is a way to set the default font for the dialog buttons or set the font / size for the button text with the resource editor (instead of having to have code to "change" the font of the button) ?
This would be a nice feature. Microsoft, are you listening?
Kelly Herald
Software Developer
MPC
|
|
|
|
|
LOGFONT logFont;
logFont.lfHeight = 12;
logFont.lfWidth = 0;
logFont.lfWeight = FW_BOLD;
logFont.lfItalic = FALSE;
logFont.lfUnderline = FALSE;
logFont.lfStrikeOut = FALSE;
logFont.lfEscapement = 0;
logFont.lfOrientation = 0;
lstrcpy(logFont.lfFaceName, _T("Arial"));
m_font.CreateFontIndirect(&logFont); // Create the font.
GetDlgItem(IDC_BUTTON)->SetFont(&m_font);
Declare CFont in .h file
|
|
|
|
|
When I put the declaration of Cfont on the .h file, it whined saying that multiple definitions were found (probably because that .h file is included in several places). (I did not put it in the class declaration, but after the class declaration).
But, what I did is right up top in my .c file where the <include> statements were, I put Cfont ListBoxFont; in there and it worked perfectly
Thanks for the tips!
|
|
|
|
|
shultas wrote:
When I put the declaration of Cfont on the .h file, it whined saying that multiple definitions were found (probably because that .h file is included in several places). (I did not put it in the class declaration, but after the class declaration).
Try to put the CFont declaration in the class scope, as a class member.
shultas wrote:
But, what I did is right up top in my .c file where the statements were, I put Cfont ListBoxFont; in there and it worked perfectly
That has essentially the same effect I believe. Since here it's been declared as a global variable, the CFont still exists after exiting OnInitDialog()
|
|
|
|
|
Is there a way to intercept mouse clicks when the current window is minimized or inactive?
Thanks
~Mike
|
|
|
|
|
When ou click on a window, it will become active and you'll recieve your mouse messages.
when you window is minimized, you want to capture mouse clicks inside another window?
Probably best to look into hooks
HTH
Cheers
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
Yes, actually I want to intercept every mouse click once the "Start" button of my program is clicked... can you help me?
|
|
|
|
|
Hello everyone,
I have been working on an MFC SDI program whose Document actually has lists of lists (and possibly a list of a list of a list). I would like to get into a good habit and be consistent with the way I maintain collections (mostly lists, occasionally arrays and maps). Almost all my objects are derived from CObject (for serializing, etc.).
I guess it comes down to picking between CList<type, type>, CList<type, type&>, CList<type*, type*> and whatever other combinations. To keep sane, I think I always want to use CList<type*, type*>. That way, I just use the new operator at the point where an object needs to be instantiated and call delete on it (while traversing the list or sublist) at the 'outer' list's destructor.
I would like comments about this. Is it safe? Is it a decent practice to keep? How can I prevent double deleting the same objects (if that could even happen)? Does this choice affect how I code the required copy constructor and assignment operator (which always seem to involve references)?
Thanks in advance for any advice and comments!
Happy New Year,
Eric
|
|
|
|
|
Is this the proper forum to ask this question, or should I move it elsewhere?
Thanks,
Eric
|
|
|
|
|
Using NMAKE (the VC++6 version) and a makefile, I can easily write implcit rules to compile *.c *.cpp and *.asm files.
However, if I write an implicit rule to compile an *.a39 file, I always get an error;
NMAKE : fatal error U1073: don't know how to make 'D:\v400\bld\obj\testprg.o'
It seems that if it is not a "normal" filetype then NMAKE will not find it.
Is there any way around this (apart from renaming my files)?
Thanks,
Bryan.
|
|
|
|
|
Hi
When closing access database file objects in c++ I keep getting this error:- Debug Assertion Failed.
It happens as I close the CDaoDatabase object but I have noticed that when it is debugged and stepped over there are no errors.
Why doesn't this work?
CDaoDatabase db;<br />
db.Open( _T("c:\\database.mdb") );<br />
db.Close();
Also are there any good examples of using the MS Jet Engine including V4 if pos.
Many thanks
Jason
|
|
|
|
|
Hello,
I think this article helps to you.
http://funducode.com/freevc/database/database2.htm
With Regards,
R.Selvam
|
|
|
|
|
Hi,
How can we compare sign of numbers in C++ ?
Bye,
Claude
|
|
|
|
|
int i = -5;
BOOL bNegativeNumber = i >> 31;
ASSERT(bNegativeNumber == TRUE);
...
short sh = 4;
BOOL bNegative16 = sh >> 15;
ASSERT(sh == FALSE);
Hope you meant that
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
I hope you are joking... the size of integers are only specified in realtive form (i.e. sizeof(char) <= sizeof(int) and so on).
Bitshifting based on static numbers are bound to fail.
Use comparisons instead (as in the post below).
And if the paths that I have followed/have tread against the flow/there is no need for sorrow
I am coming home
Return, Crüxshadows
|
|
|
|
|
int a = 145;
int b = -51;
bool fIsDifferent = (a >= 0) ^ (b >= 0);
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Hi !!
My app is being developed in MFC, VC++7. How can I make my controls resizable ?? I mean, when an user clicks on the corner to make the window bigger or smaller... please if the piece of code could be provided it would be great!!
Thank you very much !!
Written by: Rafael Fernández López.
void life ( bool me, bool her )
{
if ( her )
{
me = true ;
}
else
{
me = false ;
} }
|
|
|
|
|
|
Hello everyone.
I have built a program with a listbox on the main dialog. I desire to use this listbox for multiple purposes, sometimes allowing the user to select an item out of it, othertimes not allowing them to select anything. What I am wondering, is it possible to have code within the program that changes the "selection" property of the listbox from "Single" to "None"?
Thanks!
|
|
|
|
|
One solution is to derive a class from CListCtrl and do custom selection. Otherwise, one possible solution is to intercept the mouse click.
Kuphryn
|
|
|
|
|
|
(I'm new at VC++). I've been looking for an hour on how to do this. I am wondering could you give me an example of how I would do this? (I tried looking for things such as m_ListBox.SetStyle() but could not find anything?)
Thanks for the reply I do appreciate it!
|
|
|
|
|
See CWnd::GetStyle() and ::SetWindowLong() to dynamically change a control's style.
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Close, CWnd::ModifyStyle() is the function to use (assuming you're using MFC which it looks like you are)
m_ListBox.ModifyStyle ( LBS_MULTIPLESEL | LBS_NOSEL, LBS_NOSEL );
m_ListBox.ModifyStyle ( LBS_MULTIPLESEL | LBS_NOSEL, LBS_MULTIPLESEL );
m_ListBox.ModifyStyle ( LBS_MULTIPLESEL | LBS_NOSEL, 0 );
--Mike--
Ericahist | CP SearchBar v2.0.2 | Homepage | 1ClickPicGrabber New v2.0! | RightClick-Encrypt
Pinky, are you pondering what I'm pondering?
I think so Brain, but if we shaved our heads, we'd look like weasels!
|
|
|
|