Click here to Skip to main content
15,910,981 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Disabling Keys Pin
31-Jul-01 4:52
suss31-Jul-01 4:52 
Generalpalmap32.dll <-pretty impossible !?! Pin
30-Jul-01 11:42
suss30-Jul-01 11:42 
GeneralSynchronizing a global function Pin
PJ Arends30-Jul-01 11:37
professionalPJ Arends30-Jul-01 11:37 
GeneralRe: Synchronizing a global function Pin
Tomasz Sowinski30-Jul-01 11:42
Tomasz Sowinski30-Jul-01 11:42 
GeneralRe: Synchronizing a global function Pin
PJ Arends30-Jul-01 11:44
professionalPJ Arends30-Jul-01 11:44 
GeneralDegree to pixel Pin
Not Active30-Jul-01 11:26
mentorNot Active30-Jul-01 11:26 
GeneralRe: Degree to pixel Pin
Tomasz Sowinski30-Jul-01 11:47
Tomasz Sowinski30-Jul-01 11:47 
GeneralRe: Degree to pixel Pin
Wolfram Steinke30-Jul-01 11:49
Wolfram Steinke30-Jul-01 11:49 
GeneralUDP Socket Pin
orcun colak30-Jul-01 10:37
orcun colak30-Jul-01 10:37 
GeneralRe: UDP Socket Pin
EiSl2-Aug-01 1:52
EiSl2-Aug-01 1:52 
Generalmultirow buttons in CToolBar Pin
gaylen30-Jul-01 9:55
gaylen30-Jul-01 9:55 
GeneralRe: multirow buttons in CToolBar Pin
EiSl2-Aug-01 1:55
EiSl2-Aug-01 1:55 
GeneralEncryption Pin
Frank Deo30-Jul-01 9:48
Frank Deo30-Jul-01 9:48 
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 

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.