|
This code is for convert of points to logical device coordinates.
|
|
|
|
|
O_o
Aha...
So how do I say that I want the font size to be 20, for example?
Time to come clean...
Vive y deja vivir / Live and let live
Javier
|
|
|
|
|
garfield185 wrote: So how do I say that I want the font size to be 20, for example?
you have to set nHeight as follows:
nHeight = -MulDiv(20, GetDeviceCaps(hDC, LOGPIXELSY), 72);
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
garfield185 wrote: I guess it is all about that line that I do not understand
You also have to be aware that the system matches your request again available fonts.
garfield185 wrote: nHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
Can you explain me what it means?
OK.
It simply states that nHeight isn't the pixel height of the font, but it is related with it by the factor
GetDeviceCaps(hDC, LOGPIXELSY)/72 that is system-dependant.
On my Laptop the factor is 1.33 meaning that I have to specify nHeight=27 (let's forget for the minus sign) to obtain a 20-point sized font (and nHeight=21 to obtain the 16-point one).
On your system maybe the difference between the requested font heights it's so small that the same font is choosen.
Hope that helps.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Excuse my no-knowledge...
No it says that "hDC" is not declared...
What data does the function GetDeviceCaps need? Moreover, I guess LOGPIXELSY is a constant that I must define...
Time to come clean...
Vive y deja vivir / Live and let live
Javier
|
|
|
|
|
hDC must be a valid handle of a device context (HDC).
Using MFC you can pass the HDC of the current window (provided the code belongs to a window class)
nHeight = -MulDiv(20, GetDeviceCaps(GetDC()->m_hDC, LOGPIXELSY), 72);
you can also use the screen HDC for the pourpose:
nHeight = -MulDiv(20, GetDeviceCaps(::GetDC(NULL), LOGPIXELSY), 72);
garfield185 wrote: I guess LOGPIXELSY is a constant that I must define
No you must NOT define it, since it is already defined inside windows.h header file.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Fine. No errors.
Anyway the size does no change. Am I missing something?
Here is all the written code.
************************
CFont m_fuente;
LOGFONT lf;
m_fuente.CreateStockObject(DEFAULT_GUI_FONT);
m_fuente.GetLogFont(&lf);
strcpy(lf.lfFaceName,"MS Sans Serif");
lf.lfHeight = -MulDiv(50, GetDeviceCaps(GetDC()->m_hDC, LOGPIXELSY), 72);
lf.lfWeight =700;
m_fuente.DeleteObject();
m_fuente.CreateFontIndirect(&lf);
m_label.SetFont(&m_fuente);
******************************
Should it be like this?
Time to come clean...
Vive y deja vivir / Live and let live
Javier
|
|
|
|
|
The only problem I saw in your code was the declaration of
CFont m_fuente;
since m_fuente has to be a member of the Window class (otherwise it will be destroyed...)
I declared CFont as a member of my CDialog class and your code is working fine (I see a label with very, very big characters ).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
YEAH!!!! You are the best!!!!
Thanks a lot!! I was creatin m_fuente on each function. I didn´t know it had to be a member of the class... Thank you very much!!
Time to come clean...
Vive y deja vivir / Live and let live
Javier
|
|
|
|
|
garfield185 wrote: What data does the function GetDeviceCaps need?
See here.
garfield185 wrote: Moreover, I guess LOGPIXELSY is a constant that I must define...
No.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Pallini told me about that. I get no errors. What I say is that the code I wrote on the post before does not change the size of the text...
Time to come clean...
Vive y deja vivir / Live and let live
Javier
|
|
|
|
|
Hi,
I have some results calculated in MATLAB. Actually the result is in two arrays namely Bias and Scale Factor. I want the results to be in Coefficients.h. So that I could use it anywhere. Can anyone plaese help me out?
Please
Regards,
Puru
|
|
|
|
|
What does this file contain ? Just plain data (without being C++ specific) ? If yes, why don't you simply read the file in your program ?
I don't see what you are trying to do. Why do you want to convert that to a header file ? Everytime you recompute your results you will need to recompile your application, that seems a crazy solution.
|
|
|
|
|
Cedric Moonen wrote: Everytime you recompute your results you will need to recompile your application, that seems a crazy solution.
Some guy has to tell it to Microsoft, about their string tables!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hi
I have a problem with msvcrt.dll from WinNT/System32 on windows 2000 (this dll doesn't have _resetstkoflw entry).
My software use this function and it works correctly on Win XP. I use Visual Studio and MFC.
Is it possible to forced my software to load other msvcrt.dll?
Please Help
thanks
|
|
|
|
|
You could try static linking to the C Runtime rather than linking dynamically to the installed msvcrt.dll at runtime.
However if you do this you should use a #define to set the WINNT Version to 0x500, see MSDN for the exact macros to use, to make your entire build Windows 2000 compatible. If _resetstkoflw relies on WinXP only APIs then it will be cut from your code by the #define anyway and you may still have a problem. If setting the WINNT Version to 0x500 does not remove the _resetstkoflw declaration but it doesn't work on Windows 2000 at runtime then you've found a bug in C Runtime Good luck
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
According to this, it should be available on Windows 2000.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
If you need to use this function it seems to me than 99 times out of 100 it would be better to just increase the stack size and not use it!
Steve
|
|
|
|
|
I'm developing a dialog based application.Due to some issue i need to insert the
dialog inside SDI.So can you pls tell me how to do that job....
Thanks a lot.
bu
|
|
|
|
|
I assume this is about how to add the dialog and its resources to the SDI project.
- Copy the source files for the dialog to the SDI project folder.
- Open the resource files (*.rc) for both projects and copy the dialog resource from your dialog project to your SDI project.
- Add resource IDs for all the resources in your dialog in resource.h for the SDI project, don't forget the resource ID for the dialog itself. You can view all the required resources in the .rc file, they usually start with
IDC_ . Make sure the values don't collide with existing values in the SDI project.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hi,
I assume you need dialog to be displayed as SDI View.
You can use CFormView Derived class for your old dialog.
on the resource view using class wizard you can add class
for dialog to CFormView derived class. Then set the
CFormView derived view as SDI view.
Best Regards
|
|
|
|
|
I think you want to insert CFormView class to your project,right?
|
|
|
|
|
Hi,
I need to hide some vales in one combobox depending on the changes in values of another combobox.
Please any one help me to solve this
Thanks
Tony
|
|
|
|
|
AFAIK you cannot hide combobox itemes, you have to remove them.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
aby Skaria wrote: I need to hide some vales in one combobox
See this[^] thread.
|
|
|
|