|
Try
RecalcLayout();
to redraw the Framewnd which in your case a mainframe.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Hello,
here is my problem; using the GDI+ i draw a string using DrawString() and i draw a rectangle around this string.
But when i scale the view (to simulate a zoom in or zoom out) the string can becomes larger than the rectangle !
It seems that the true type fonts are not truly scalable.
However i read that the GDI+ subtly manipulates the character and word spacing...
Can you help me ?
Thanks a lot.
|
|
|
|
|
Hi !
Did you try to modify the unit parameter in the Font class constructor ?
|
|
|
|
|
Yes, no effects... sorry...
|
|
|
|
|
How are you using the scale ? Are you using an API method ?
|
|
|
|
|
here is the code used;
void CChildView::OnPaint()
{
CPaintDC dc(this); // device context for painting
Matrix myMatrix;
myMatrix.Translate(m_cx / 2.0f + m_fOffsetX, m_cy / 2.0f + m_fOffsetY);
myMatrix.Scale(m_fZoom, m_fZoom) ;
graphics.SetTransform(&myMatrix);
// Create a string.
WCHAR string[256];
wcscpy(string, L"These days, products with VIA's new PT880 and the SiS 655FX are becoming available");
// Initialize arguments.
FontFamily fontFamily(L"Arial");
Font myFont(&fontFamily, 14, FontStyleRegular, UnitPoint);
// the hardcoded coords come from MeasureString();
PointF origin(-753 / 2.0f, 0.0f);
SolidBrush blackBrush(Color(255, 0, 0, 0));
Status status = graphics.DrawString(string, (INT)wcslen(string), &myFont, origin, &blackBrush);
RectF boundingBox;
graphics.MeasureString(string, (INT)wcslen(string), &myFont, origin, &boundingBox);
// Get the height of myFont.
REAL height = myFont.GetHeight(&graphics);
wcscpy(string, L"et blablabla...");
origin.Y += height;
status = graphics.DrawString(string, (INT)wcslen(string), &myFont, origin, &blackBrush);
// here we draw a rectangle around the text, the values come from the initial MeasureString()
// Create a Pen object.
Pen blackPen(Color(255, 0, 0, 0), 1);
// Draw the rectangle.
// the hardcoded coords come from MeasureString();
graphics.DrawRectangle(&blackPen, -753 / 2, 0, 753, 23);
}
|
|
|
|
|
How exactly are you doing the scaling? If you use the ScaleTransform (or whatever it's called) it should work without incident.
Joel Lucsy - You can have it done cheaply.
- You can have it done well.
- You can have it done fast.
Pick any two.
|
|
|
|
|
I'm trying to build a utility that runs a few console commands and directs the output to an edit control.
i.e. Click a button, it copies some files, and the output of the xcopy command shows up in an edit control.
Another desired result (for an entirely different project down the road) - is to be able to interact with the console application. (end user can give input as needed to the application)
It seems like a fairly easy thing to accomplish (fingers crossed), but I'm having a hard time finding sample source code to work from.
Can you point me in the right direction?
===
The workflow that I'm trying to implement is as follows:
1. Copy files from e:\tiff to c:\clients\$customer name$\tiff
2. Convert images from tiff to jpg (I can do this via command line, requires command line parameters - meaning c:\convert.exe /s:conversiontemplate.txt )
3. Create thumbnail size images (also via command line)
4. Create html for web photo album
5. Copy other files to directory for CD-ROM (autorun.inf, drive.ico, etc.)
6. Upload html docs, images to web server. (using dundas tcp-ip)
I want to put these commands in an MFC app so that my receptionist can just click a button and have all the magic happen. I want the output in an edit control so that if there is a problem, the receptionist can copy/paste the output into an email and have me troubleshoot the process.
(Maybe even have a send-to-steve button that handles that part)
===
|
|
|
|
|
skallestad wrote:
...and the output of the xcopy command shows up in an edit control.
Take a look at the MSDN article Q190351, and the one titled "Creating a Child Process with Redirected Input and Output."
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Thank you. That is the perfect starting point for me!
|
|
|
|
|
hi,
i want to disable the possibility to change the label of an item of a CTreeCtrl. SetReadOnly() namely makes it possible that the user can't edit the item's label, but the edit control box is still displayed and that shouldn't happen.
Any ideas ?
Thanks in advance!
|
|
|
|
|
I got it. Maybe someone is interested in how i did it, so here is the solution. If the message TVN_BEGINLABELEDIT is send, i dispatch the follwoing notification: SendMessage(TVM_ENDEDITLABELNOW, (WPARAM) (BOOL) TRUE, 0);
Looks simple, isn't it?!
|
|
|
|
|
Handle TVN_BEGINLABELEDIT , returning TRUE to prevent editing.
|
|
|
|
|
|
What is the simplest way to kill an MFC dialog based application?
|
|
|
|
|
alt+F4 works pretty well.
*.*
cin >> knowledge;
|
|
|
|
|
Find the handle of the window (FindWindow or EnumWindows work well), then send it a WM_CLOSE message.
If this causes it to ask to save data, and you don't want that, use DestroyWindow instead, although this is very brutal.
|
|
|
|
|
|
I am having a problem using the CEdit class and the CRgn class. I am using the CRgn to make a roundedrect and then setting the region to the CEdit control during PreSubClassWindow ( I am actually trying to make a class that is derived from CEdit that is a rounded edit control ). However it seems that the region is only having an effect on the border of the CEdit. The white part ( the part you type in ) is still a rectangle. Any Ideas why this is happening?
|
|
|
|
|
Friends,
I have a vector of pointers:
vector< PhoneRecord*> phonerecs(MAX);
I want to pass this vector to a function so I can add things to it outside of main().
The function declartion is:
void addPhoneRecord(PhoneRecord* records[]);
and call it from main() using something like:
addPhoneRecord(phonerecs);
The error I'm getting is:
error C2664: 'addPhoneRecord' : cannot convert parameter 1 from 'class std::vector<class PhoneRecord *,class std::allocator<class PhoneRecord *> >' to 'class PhoneRecord *[]'
I understand I'm not passing this correctly...
I'm sure this is a somewhat easy solution, but I can't seem to pinpoint it.
Thanks in advance!
|
|
|
|
|
|
Dave, thanks again for your quick and informative reply.
Allow me to include better code representation:
My function definition is:
void addPhoneRecord(string& name, string& address, string& phone, PhoneRecord* records[])<br />
{<br />
Name* nameEntry = new Name();<br />
nameEntry->set_name(name);<br />
Address* addressEntry = new Address();<br />
addressEntry->set_address(address);<br />
PhoneRecord* phoneEntry = new PhoneRecord(nameEntry, addressEntry);<br />
phoneEntry->set_phoneNumber(phone);<br />
<br />
records.push_back(phoneEntry);<br />
}
When I call it from main I'm using:
addPhoneRecord(name, address, phone, &phonerecs.back());
All of the setting functions and the like work like they should, and properly.
The error I'm getting is:
error C2228: left of '.push_back' must have class/struct/union type
If I comment out the records.push_back(phoneEntry); it compiles fine, but I get the standard WinXP error report problem.
Any suggestions?
Thanks again.
|
|
|
|
|
Since you are actually trying to use the vector as a vector (instead of just an array as you indicated in your previous message), you should pass a reference to the vector into the function. The last parameter should be: vector< PhoneRecord*>& records - then you will be able to use the push_back member.
Dave
http://www.cloudsofheaven.org
|
|
|
|
|
Dave,
Thank you again. You're a master.
|
|
|
|
|
My program uses API calls and now that I have converted my program from a simple console app to a windows service, I cannot use all of the same API calls. If anybody is familiar with this type of problem, please fill me in with possible fixes. Thanks!
|
|
|
|