|
|
lf.lfFaceName giving the right font name that I select but lf.lfHeight giving the arbitrary wrong negative values. how can I solve it
Trioum
|
|
|
|
|
trioum wrote: lf.lfHeight giving the arbitrary wrong negative values
As MSDN tells you, you can use the following formula to specify a height for a font with a specified point size:
lfHeight = -MulDiv(PointSize, GetDeviceCaps(hDC, LOGPIXELSY), 72);
So you can use a simple function like the following to get the (positive) point size (which is what the font dialog displays) from the LOGFONT height:
int GetFontPointSize(int nHeight)
{
HDC hdc = ::CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
ASSERT(hdc);
int cyPixelsPerInch = ::GetDeviceCaps(hdc, LOGPIXELSY);
::DeleteDC(hdc);
int nPointSize = MulDiv(nHeight, 72, cyPixelsPerInch);
if (nPointSize < 0)
nPointSize = -nPointSize;
return nPointSize;
}
Note that you must use logical units for the lfHeight parameter in the LOGFONT struct. To get logical units from point size, you can use following function:
int GetFontHeight(int nPointSize)
{
HDC hdc = ::CreateDC(_T("DISPLAY"), NULL, NULL, NULL);
ASSERT(hdc);
int cyPixelsPerInch = ::GetDeviceCaps(hdc, LOGPIXELSY);
::DeleteDC(hdc);
int nHeight = -MulDiv(nPointSize, cyPixelsPerInch, 72);
return nHeight;
}
|
|
|
|
|
Hi. Why my progress bar ctrl doesn't apply smooth style although I set it's 'Smooth' property to TRUE???
I'm working in VS2008.
Thanks.
|
|
|
|
|
Load the resource file in a text editor, and look for the progress control there - make sure the styles are as you expect.
You can also use Spy++ to find the control, and look at its styles.
This is assuming the control is part of a dialog, and created automatically. If you use CreateWindow(Ex) yourself, then look at your code.
Also, many control styles are only valid at creation - using SetWindowLong (xxx_STYLE, blah)[*] won;t affect them.
Iain.
[*] too lazy to look it up, but I hope it makes the point.
|
|
|
|
|
Thanks Iain.
I've looked up using Spy++ and PBS_SMOOTH is present!?
The control is part of dialog, added on from toolbox on the dialog.
I don't use any code like 'CreateWindow...' or setting any style with 'SetWindowLong...'
Strange?
Also, forget to mention I'm on XP.
|
|
|
|
|
josip cagalj wrote: Also, forget to mention I'm on HP.
I saw your original post! I'm more of a fan of Heinz myself...
Not sure what to recommend really. I'd suggest starting an empty project with a dialog and progress bar.
Build up from there - see what you're doing differently.
Iain.
|
|
|
|
|
Once again thanks.
I'll do that, relay nothing else to try.
|
|
|
|
|
OK.
I've tried opening new project (dialog based) and put progress ctrl on dialog with smooth property and still nothing. I've did some surfing on net and found similar questions, they suggested (over at MSDN) to change windows theme to classic. After doing so, my progress ctrl did work with smooth style applied but come on that can't be solution!?
I don't wont to do that!
|
|
|
|
|
hello all. I am reading some data from xml file. I memcpy it to a BITMAP structure variable. Now I need to convert this to HBITMAP. how do I do this?
|
|
|
|
|
By using CreateBitmapIndirect...
|
|
|
|
|
|
Welcome... Don't forget to call DeleteObject to delete it when it is no longer needed.
|
|
|
|
|
Hi,
I have an UI developed using VC++. This UI identifies the com port in the system, upon selecting the com port and clicking OK button, the main application opens where commands is sent using com for communication with target. A usb to serial RS232 convertor for COM is being used. This UI is woking fine in some XP system.
When this UI executed in newly installed XP machine, it identified the com port but on cliking OK the application is getting closed.Before clicking OK button the com port would be opened and connected using another button. Is any dll is missing?
Thanks
|
|
|
|
|
Did you get an error message? If yes, please give details.
BTW try also to insert some debugging info (for instance logs) in your application.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
No i didn't get any error message.
|
|
|
|
|
Since you cannot possibly use the debugger on the failing machine, provide some trace info in you application.
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.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi All,
I am creating a client server project .
My server is multithreaded, One thread is created for each request
from client.
Now my problem is:
As i send the 10 reuests at a time to the server Some of the receive
gets fail even after successful accepting, and give the 10038 error
number.
I have set the 15 sec time out for rece on client and server side.
But my server returns the error with in a second.
kindly help
|
|
|
|
|
Would help if you were to show some of your code too.
10038 is. btw, WSAENOTSOCK, so you specified something that's not a socket to a call which takes a valid socket. At the first run, without knowing much of what your code does, i'd say this is a thread synch problem.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
Anyone know if it's possible to create a shell extension that will change the text shown in the file type column in the same way as the IExtractIcon shell extension allows you to display a custom icon according to file content?
|
|
|
|
|
Does anybody know any tool that can be used to identify data types used in files?
I need to search and list out all the data types (primitive, MFC, STL data types) used as class members, function parameters, etc., in a large volume of c++ files (need to consider the header files only).
modified on Friday, December 12, 2008 4:47 AM
|
|
|
|
|
my initial thought would be along the lines of find a parser & grammar for c++, generate a parse-tree and walk that looking for the declarations you need ...
[edit] its not an easy thing you ask .. this is one way http://www.devincook.com/goldparser/[^]
alternatively, I guess you can do a brute force match against an array of key-words representing what you'd like to identify, eg {"map","vector","int","string"...} there was an article about this on cp somewhere
It depends on context/what/how you will use the info
'g'
|
|
|
|
|
Thank you... I have some time constraint too...
|
|
|
|
|
I have a global variable defined as "char toAscii[255]" in some MyFile.c
I declared another variable as "extern char *toAscii" in some other file YourFile.c of same console application.
In YourFile.c, I accessed toAscii as "toAscii[0] = 1;"
No linking error. Linker generate mangaled name same for both as "int * toAscii" (?toAscii@@3PAHA)
but at runtime "toAscii[0] = 1" is causing crash because it point to a NULL while debugger showing a valid address.
If I change "extern char *toAscii" to ""extern char *toAscii[]", every thing works fine.
I just want to know why in first case it toAscii points to NULL at runtime while we have same mangaled name for both. I am using VC2005.
Manish Agarwal
manish.k.agarwal @ gmail DOT com
|
|
|
|
|
There are difference in the code generated for "toAscii[0] = 1;" when toAscii is declared as "extern char *toAscii" and "extern char toAscii[]".
1. When toAscii is defined as "extern char *toAscii"
toAscii[0] = 1;
00401DED mov eax,[toAscii (004167c0)]
00401DF2 mov byte ptr [eax],1
2. When toAscii is defined as "extern char toAscii[]"
toAscii[0] = 1;
00401DED mov byte ptr [toAscii (004167c0)],1
I hope you understood.
|
|
|
|