|
|
How do you set a window's font using Win32 (NOT MFC!!!)?
I have been trying to use the WM_SETFONT message but it doesn't seem to work...
Thanks,
James Bird - birdjames@bigfoot.com
|
|
|
|
|
by window's font do you mean the font on the title bar? or do you mean the font of all the controls on that window? I am not sure you can use WM_SETFONT to change the font of the title bar unless you do some painting on your own...
for the individual controls you can use WM_SETFONT
Nish
|
|
|
|
|
Could you post an example, I've been unable to get it to work.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
I tried it out and it worked fine
medit is a global HWND
medit=CreateWindow("EDIT","",WS_VISIBLE|WS_CHILD|WS_BORDER,10,10,300,30,hWnd,NULL,
hInstance,NULL);
HFONT hfont;
hfont=CreateFont(25,12,0,0,700,TRUE,0,0,DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH,
"Times New Roman");
SendMessage(medit,WM_SETFONT,(WPARAM)hfont,0);
|
|
|
|
|
Are you sure that lifetime of HFONT is long enough? You can't just pass a HFONT to a Window with WM_SETFONT and destroy the font - the window doesn't copy the font.
The second thing is that not all Windows support this message. Standard controls do, but your own Window classes do not unless you explicitly handle this message.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
the HFONT is only a handle to the font
the HFONT variable need not last the life time of the control
once you send the WM_SETFONT message to the font then you can forget your HFONT variable
even if the HFONT variable is destroyed the font is not destroyed
for that, you may use DeleteObject
Nish
|
|
|
|
|
Sorry, you're wrong. HFONT needs to last as long as the window which uses it. If you destroy the HFONT with DeleteObject, the window painting will fail (SelectObject somewhere inside WM_PAINT handler will not work and subsequent calls to TextOut or DrawText will use default font).
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hello tomasz
I wasnt wrong
I clearly said that if the HFONT variable gets destroyed there is no problem as the CreateFont created front is still alive. I clearly said that for the font to be destroyed you need to call DeleteObject. But if you dont call DeleteObject your font is alive and well and you can forget about the HFONT variable
Nish
|
|
|
|
|
Let's clear things: by 'lifetime of a HFONT' I mean the time between CreateFont[Indirect] and DeleteObject. I'm not talking about local variable of type HFONT.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
oh!
sorry tomasz....
got you wrong
my fault
Nish
|
|
|
|
|
This is my fault as well - instead of technobabble like 'lifetime of a HFONT' I should just write 'you can't immediately delete a font you've set with WM_SETFONT'.
Cheers,
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
maybe...
Nish
|
|
|
|
|
Nish is talking about a deliberate memory leak.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
Hello folks,
I know that a service process (under NT/Win2k) should not communicate with GUI, since no user has to be logged in so no shell is available.
But...
When my service is crashing (unhandled exception), I want my general exception handler sends a messagebox to the user in case there's a user logged in.
So...
How can I detect if a shell exist (aka: a user is logged in), so I can safely shoot a messagebox.
Thanks,
EiSl
|
|
|
|
|
hi
this might be a dumb technique but I think you can use GetDesktopWindow() and if that returns NULL, that probably means there is no user logged in
nish
|
|
|
|
|
I think you should rather write this info to the Windows Event Log.
Anyway, if you need to interact with the desktop, first read 'Interactive Services' in your VC++ help. It should be under Platform SDK/DLLs, Processes, and Threads.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I am still trying to choose the language of the standard dialog boxes...
I succeed for all common dialog boxes (printer setup, save as...): Just for try, I put the right comdlg32.dll version (the english one, I am on a french OS)in the working directory of my app and what was my surprise to see that it is working!!! I run my app, clic the "open file" item and the english box was display. I let it open on the desktop and run notepad to clic the same item: the box has been open in french!!!
But I steel searching for the monthes and days names of the calendar. The call of the calendar APIs seems to be in the comctl32.dll but I can't load another version of this DLL as I do for comdlg32.
elisabeth.sever@europlacer.fr
|
|
|
|
|
If you have a DLL that exports a number of classes, many of which a template classes, and you find that there is a common templated type that is being used over and over again, is there something special you're supposed to do for this ? I realize I may not be explaining this very clearly so here's an example:
so I have this:
template <class t=""> class A {
///whatever
};
and I find I am using A<int> all over the place in the library. Should there be some special instantiation of the template type ? Is this more efficient ? Does it even matter ?
|
|
|
|
|
I find I am using A<int> all over the place in the library.
A simple typedef A<int> AINT will save you a bit of typing. Since this is only a compile-time thing, there is no difference in the resulting binary.
--Mike--
http://home.inreach.com/mdunn/
This posting is provided "as was" with no warranties, guarantees, lotteries, or any of those little bags of peanuts you get on planes. You assume all risk for crossing the street without holding mommy's hand. © 2001 Mike's Classy Software. Member FDIC. If rash develops, discontinue use.
your with and
|
|
|
|
|
Guys,
Is there any way to cancel WaitCommEvent for non-overlapped IO ?
Thanx..
|
|
|
|
|
You can't...
Only one thing at a time can be done to a non-overlapped serial port.
See Q105302
Col
|
|
|
|
|
how can i get a responce to a click on a capture window. i tried ONLBUTTONDOWN but no responce
|
|
|
|
|
I found the only way to make this work was to keep firing a timer that called SetCapture over and over, and doing this in OnMouseMove:
CPoint pt;
GetCursorPos(&pt);
CRect rc;
GetWindowRect(&rc);
if (rc.PtInRect(pt))
ReleaseCapture();
Here's the timer function:
if(nIDEvent == ID_TIMER_SETCAPTURE)
{
CPoint pt;
GetCursorPos(&pt);
CRect rc;
GetWindowRect(&rc);
if (!rc.PtInRect(pt))
SetCapture();
}
I did not find another solution that captured the mouse AND got the click messages inside the dialog class. If you find one, please LMK because I thought this very ugly indeed.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
Dear friends,
i've created one dialog box, which shows the downloading status of a file from the internet. but, the speed is a bit slower than the actual windows downloading dialog box. can any1 suggest how to make my dialog box downloads more faster than the windows one. thanx in advance...gopi
|
|
|
|