|
You could make a temp copy of the file for your own program, then delete the temp file when finished. That wouldn't require direct access to the target file.
u6ik
|
|
|
|
|
Yes, I am currently making a temp copy however I am dealing with multiple files of 9,500KB many times reaching to gigabytes of data... so I would like to avoid this extra copy!
|
|
|
|
|
Hello...
I want to get the Font width from a font handle and the ::GetObject(...) function to retrieve the font data (in a LOGFONT structure)... But often the lfWidth member is zero or very small...
How to get the correct font width ???
|
|
|
|
|
//You can get it like this:
double width;
RECT Rect;
width=Rect.right;//This is the width of your window.
|
|
|
|
|
which has to do with fonts how, exactly ?
Steve S
Developer for hire!
|
|
|
|
|
That will give you the average width (if available) of a character (in logical units). That may not be what you want, unless it's a fixed pitch font. Better (but slower) is to select the font into a device context, and use the GetTextExtentPoint32 functions for specific strings. Alternatively, if you really want the average width, you can do this using GetCharABCWidths and a bit of math.
Steve S
Developer for hire!
|
|
|
|
|
I believe what you want is something like GetTextMetrics(), which will return an average width in units based on the DC your using. A LOGFONT's lfWidth returns an average width in logical units. Also you can use DrawText() with DT_CALCRECT to get accurate dimensions on a given peice of text on a given DC.
|
|
|
|
|
Thanx for your very fast reply...
I hoped that i mustn't select it to dc and can calculate the max font width or better max letter width from the LOGFONT structure or other else...
But also big thanx...
|
|
|
|
|
Yes and No...
TEXTMETRIC struct defines the right member that i need (tmAveCharWidth), but i need always a dc to get them... So i hoped it exists any other way to calculate them from LOGFONT structure or other else...
But always big THX for your reply...
|
|
|
|
|
Without a DC a real width doesn't exist until it's associated with a DC. If your printing it to a high dpi printer your width will be different then on a low dpi monitor. If you want something more "logical" use the font size which is calculated from LOGFONT's height.
|
|
|
|
|
Hello...
Mhhh...
Mark Petrik Sosa wrote:
Without a DC a real width doesn't exist until it's associated with a DC.
I don't understand ?
I think the LOGFONT height it's the height of the font. The size is fixed and independent from the dc...
What's the different about the width...
When i create a font with a height of 20 pixels then is height from the font on a screen dc different as from the printer dc, but i think it's difference about the resolution and the count of pixel per inch...
Can you explain your idea?
Best regards...
|
|
|
|
|
Good question.
From the MSDN on LOGFONT:
If lfWidth is zero, the aspect ratio of the device is matched against the digitization aspect ratio of the available fonts to find the closest match, determined by the absolute value of the difference.
The height of a font is in logical units. Which is why a font at size 8 can look huge on a computer with large fonts set.
The Windows GDI was designed to make as little assumptions as possible about what it's drawing on. On a printer 20 pixels is very tiny because it's DPI is so high. There are even monitors that aren't at the normal 96 dpi, so these would not look right if it was embedded with a nonlogical number. Some devices don't even use pixels but other measurements, like twips, so until the DC is set with this information you can't get the width on some fonts.
Why can't you get the font's average width logical units? I'm not sure, perhaps it has to do mostly with the font, whether an accurate font to that size has been selected or not, or whether a font author must set this information in the header. Maybe windows is just reluctant to provide such an inaccurate approximation, I don't know.
In my opinion it doesn't seem like a big deal (apart from being interesting) since it's a logical value anyways. If you were to use it, you'd have to make all the calculations that GetTextMetrics makes for it to work across all DCs. I can't see where you'd use it without a DC.
I hope this makes things somewhat clearer.
|
|
|
|
|
Hello Mark...
Thx for your comments... It helps me a lot to understand the difference about logical untits and the real size on dc'S...
Mark Petrik Sosa wrote:
I can't see where you'd use it without a DC
I need the width of the font in some calculations of my new app...
But before the window is drawing...
At this point the explicit creation of a dc handle to retrieve only the width of the font looks very involved...
Best regards...
|
|
|
|
|
I've used DrawText() with DT_CALCRECT, when the string is long enough, then the speed will
be very slow.
|
|
|
|
|
Hi All
Got a weird problem. I am using VC++ SDK v6.0 and placing a Progbar active component in the dialog window for obvious progress status reasons... however, it causes the window to disappear from the program. Not just the dialog window, the whole program vanishes from the screen. I know it's running due to the program icon in the taskbar, though nothing is shown onscreen. Also, when removed from the resource dialog all is fine and the window reappears.
I'm not sure what's going on as I've used PBs before with no trouble. comctl32.lib is in place and the correct headers... all very weird.
Any thoughts?
u6ik (The Confused)
|
|
|
|
|
Try calling InitCommonControlsEx() with ICC_PROGRESS_CLASS before you start your main winproc.
|
|
|
|
|
Don't know how I missed that, my idiot moment for the day.
Many thanks
u6ik
|
|
|
|
|
an opc simple : I can run opc server and client in one pc. But when Opc running in another pc , the opc client can't connect to server. Why? How can I config opc server ,server pc and client pc ,thank you!
|
|
|
|
|
I made an graphic mfc ocx . But I want to see it in IE at remote client. And I use this ocx in server mode in asp.net. How Can I convert it. I want't to program it repeatly.
|
|
|
|
|
Hi guy..
im a newbies in c++ and workin on a sch. pro. which i need to connect a plc to a network and check his data status using tcp/ip.
I decided to worry abt that later.. but just setup a simple sort of server n client pro. that i can sent a msg using tcp/ip to another com.
But i been like lookin though book n sites.. and i very confuse abt what to do..
So can anyone give me a hint on how to start doind this..
like what i must include in my header.. then what to initialize.
i have no idea..
sorry abt that. cos i suck in programmin
|
|
|
|
|
I blieve thats not right (first ???) project for you... Firstly learning C++ and some basics about socket programming...
It exists many articels with examples on codeproject which make the first steps much easier...
|
|
|
|
|
I find this site a great resource and the forum help on tricky projects extremely good but...
There's no shortcut to learning C++. I suggest buying a few books and get reading
u6ik
|
|
|
|
|
Ok... My comment was in front of Socket Programming and not at learning c++...
There are many other pages on www which do this... But, In my opinion it's always a better choice to buy some books (in the mother language) to learn the basics...
|
|
|
|
|
I had a question about the two programming + I am some what new to the subject so bear with me... I have read multiple tutorials on programming in C++ and in Python, but I was always notice that something is different...
My first question is for Python... Whenever I look at different tutorials I notice this:
#! /usr/local/bin/python or this #! /usr/bin/python before your program starts... I was wondering though why some tutorials do not incorperate that in their tutorial/programs... I was actually wondering why you would, because I can run things just fine without putting that before my code in Python. I don't get any errors also. Is that only if you are running a linux system and you have to do that?
My second question is about C++... I have also noticed that in different tutorials they show all types of different ways to start out their programs. For example one way is
-----------------------------------------------------------------------------------------
#include<br />
<br />
int main ()<br />
<br />
<br />
or<br />
<br />
#include<br />
#include<br />
int main(int nNumberofArgs, char* pszArgs[])<br />
{
----------------------------------------------------------------------------------------
The list goes on and on... I am just so confused. Is there a right way to right a C++ program? Are they all right ways? What does it all mean?
Thanks for any help,
Raistlin
|
|
|
|
|
You are definitely new to the language. As such I'm sure this is not your only set of questions and as you've said the list goes on. This is a really good book to get started:http://www.amazon.com/exec/obidos/tg/detail/-/0201485184/002-4765200-8896040?v=glance[^]
It gives a very compact overview of C++ and it does so in a pretty short text. It might work for you and maybe not.
As far as your questions go:
Google for overloading functions in C++ and the other is just the path in a *nix (Linux/Unix/Etc) environment to where python is installed. In most cases it will be in either /usr/local/bin/python or /usr/bin/python you can also set your system path to contain the absolute path to it as well. In windows it's working because you most likely have the path in your environment variables and the python installer probably did this for you.
What environment are you coding in?
At this point are you just trying to learn the language or is there a problem you are trying to solve using C++?
Do you have other programming experience that members here can use to explain things to as a comparison? If you've worked in Java or VB 6 then some things can be explained like, "In VB you did this to ..." and "In C++ you can do the same thing by ..."
- Rex
My name is Maximus Decimus Meridius, commander of the Armies of the North, General of the Felix Legions, loyal servant to the true emperor, Marcus Aurelius. Father to a murdered son, husband to a murdered wife. And I will finish this project, in this life or the next. Slightly modified " from Gladiator.
Code-frog System Architects, Inc.
|
|
|
|