Click here to Skip to main content
15,898,984 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Encryption Pin
Joaquín M López Muñoz30-Jul-01 11:46
Joaquín M López Muñoz30-Jul-01 11:46 
GeneralRe: Encryption Pin
Frank Deo30-Jul-01 12:31
Frank Deo30-Jul-01 12:31 
QuestionHow can I create read-only file ??? Pin
30-Jul-01 9:45
suss30-Jul-01 9:45 
AnswerRe: How can I create read-only file ??? Pin
Carlos Antollini30-Jul-01 10:09
Carlos Antollini30-Jul-01 10:09 
AnswerRe: How can I create read-only file ??? Pin
Hadi Rezaee30-Jul-01 19:28
Hadi Rezaee30-Jul-01 19:28 
QuestionCan a CRuntimeClass be Serialized? Pin
Joel Holdsworth30-Jul-01 9:22
Joel Holdsworth30-Jul-01 9:22 
AnswerRe: Can a CRuntimeClass be Serialized? Pin
Tomasz Sowinski30-Jul-01 9:27
Tomasz Sowinski30-Jul-01 9:27 
GeneralScaling Fonts, Zooming. Pin
Mike Doner30-Jul-01 8:53
Mike Doner30-Jul-01 8:53 
Mad | :mad:

Hey folks,

I've been working on some code for some time which simply draws interconnecting boxes with text on the screen using the basic window calls to illustrate some kind of network connectivity. (Box represents a server, lines represent some kind of cabling between that server, and another).

For fun, I thought it would be great if I could implement some kind of "ZOOM" function which would change the sizes of the boxes dynamically, then choose a font which would fit in the new boxes.

I created a pull-down from the window I created, and added a resource for "10%", "25%", "50%", 100%", "200%", where 100% is the NORMAL view when you launch this window, 50% being half of the original etc, you get the idea.

When a user clicks on one of my "Zoom" items, I initialize a global variable called ZoomFactor which contains the ratio of how the diagram is to change. (ie. ZoomFactor == 1, denotes 100%, or normal view, ZoomFactor == 0.5, denotes half the original).

When the time comes to "build" the diagram again, I dynamically determine the new cell size by using the code below:

// Set our cellsize to be our zoomed cell size.

GetTextExtentPoint32 ( hdc, "A", 1, &szorgFontSize );

szZoomCellSize.cx = (LONG)(szorgFontSize.cx * ZoomFactor );
szZoomCellSize.cy = (LONG)(szorgFontSize.cy * ZoomFactor );

// Set the size of my server box width, by multiplying
// the new cell X size, by the maximum number of chars/server box.
ServerBoxWidth = szZoomCellSize.cx * MaxServerChars;


NO Problems, everything is great, my szZoomCellSize is scaled properly, my box sizes change as they should, Problem comes when I want to create an appropriate font for the new cellsize.

Basically, I want to create a font which will fit in the szZoomCellSize rectangle, I make this call in hopes that the font it creates will fit insize of the ZoomCell.

// Setup our new font
hfont = CreateFont ( szZoomCellSize.cy, 0, GM_COMPATIBLE, GM_COMPATIBLE, FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_DEVICE_PRECIS, CLIP_LH_ANGLES,
PROOF_QUALITY, FF_MODERN, lfnt.lfFaceName );

After I made this call, I noticed that in many cases, the font that it choose had a proportionate height and width (the font didn't look stretched), but was often TOO big for the box I've created. I added a "GetTextExtentPoint32" call after the create font and found that the font it picked was in most cases, LARGER than the "szZoomCellSize.cy" I specified. I understand that most fonts are NOT fixed width, so I even change the character in both "GetText" calls to "M", because M is usually one of the bigger characters, no go, same results.

I've spent some time looking through "CreateFont" and found it to be a little out of my league... By no means am I an expert graphics guy, just need a basic explanation! Wink | ;-) Anyone? Ive heard I can also create a bitmap of sorts, and just StrechBlt it, but I'm leaning NOT to do that...

Anybody see what I'm doing wrong here?

Much appreciated,
Mike.

GeneralRe: Scaling Fonts, Zooming. Pin
Tomasz Sowinski30-Jul-01 9:55
Tomasz Sowinski30-Jul-01 9:55 
GeneralRe: Scaling Fonts, Zooming. Pin
Mike Doner31-Jul-01 5:02
Mike Doner31-Jul-01 5:02 
GeneralRe: Scaling Fonts, Zooming. Pin
Tomasz Sowinski31-Jul-01 6:32
Tomasz Sowinski31-Jul-01 6:32 
GeneralRe: Scaling Fonts, Zooming. Pin
AndyC30-Jul-01 12:51
AndyC30-Jul-01 12:51 
GeneralRe: Scaling Fonts, Zooming. Pin
Mike Doner31-Jul-01 5:06
Mike Doner31-Jul-01 5:06 
Generalkeeping my selections in listbox Pin
Ananya Sen Gupta30-Jul-01 8:14
Ananya Sen Gupta30-Jul-01 8:14 
GeneralRe: keeping my selections in listbox Pin
Tomasz Sowinski30-Jul-01 10:03
Tomasz Sowinski30-Jul-01 10:03 
GeneralMFC modal "wait" dialog Pin
flurinator30-Jul-01 8:02
flurinator30-Jul-01 8:02 
GeneralRe: MFC modal Pin
Tomasz Sowinski30-Jul-01 9:36
Tomasz Sowinski30-Jul-01 9:36 
GeneralRe: MFC modal Pin
Matt Gullett30-Jul-01 18:01
Matt Gullett30-Jul-01 18:01 
GeneralI need some help with some errors... Pin
30-Jul-01 7:54
suss30-Jul-01 7:54 
GeneralRe: I need some help with some errors... Pin
Tomasz Sowinski30-Jul-01 9:38
Tomasz Sowinski30-Jul-01 9:38 
GeneralRe: I need some help with some errors... Pin
30-Jul-01 16:15
suss30-Jul-01 16:15 
GeneralRe: I need some help with some errors... Pin
Christian Graus30-Jul-01 16:31
protectorChristian Graus30-Jul-01 16:31 
GeneralRe: I need some help with some errors... Pin
Matt Gullett30-Jul-01 17:52
Matt Gullett30-Jul-01 17:52 
GeneralRe: I need some help with some errors... Pin
31-Jul-01 10:50
suss31-Jul-01 10:50 
GeneralRe: I need some help with some errors... Pin
Matt Gullett31-Jul-01 13:31
Matt Gullett31-Jul-01 13:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.