Click here to Skip to main content
15,900,724 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: table like structure(multiple collumns) Pin
lisoft12-Dec-04 13:55
lisoft12-Dec-04 13:55 
GeneralRe: table like structure(multiple collumns) Pin
bmzhao12-Dec-04 14:11
bmzhao12-Dec-04 14:11 
GeneralCEdit select text highlight Pin
Anonymous12-Dec-04 8:26
Anonymous12-Dec-04 8:26 
GeneralRe: CEdit select text highlight Pin
PJ Arends12-Dec-04 9:14
professionalPJ Arends12-Dec-04 9:14 
QuestionCannot ever open fstream object in DLL? Pin
registering12-Dec-04 8:23
registering12-Dec-04 8:23 
AnswerRe: Cannot ever open fstream object in DLL? Pin
bmzhao12-Dec-04 14:04
bmzhao12-Dec-04 14:04 
GeneralRe: Cannot ever open fstream object in DLL? Pin
registering12-Dec-04 14:31
registering12-Dec-04 14:31 
GeneralConfused by the "Mapping Mode" Pin
LiYS12-Dec-04 4:41
LiYS12-Dec-04 4:41 
Hi all:
Recently I've been reading Charles Petzold's Programming Windows, but in the The GDI Mapping Mode chapter I encounter a few sentences for which I think they're contradict with each other. I'm sure It just because I'm just don't fully understand the priciple in it. But, for now it really confused me. So I  hope if someone had readed this book or have a understanding about Mapping Mode can show me the way! The following is the excerpt for the book that confused me!
*********************************************************
Here's how the functions work: If you change the viewport origin to (xViewOrg, yViewOrg), the logical point (0, 0) will be mapped to the device point (xViewOrg, yViewOrg). If you change the window origin to (xWinOrg, yWinOrg), the logical point (xWinOrg, yWinOrg) will be mapped to the device point (0, 0), which is the upper left corner. Regardless of any changes you make to the window and viewport origins, the device point (0, 0) is always the upper left corner of the client area.
For instance, suppose your client area is cxClient pixels wide and cyClient pixels high. If you want to define the logical point (0, 0) to be the center of the client area, you can do so by calling


SetViewportOrgEx (hdc, cxClient / 2, cyClient / 2, NULL) ;

The arguments to SetViewportOrgEx are always in terms of device units. The logical point (0, 0) will now be mapped to the device point (cxClient / 2, cyClient / 2). Now you can use your client area as if it had the coordinate system shown below.

00-y0|
00000|
0-----|----+x
00-x0|
00000|+y
(the origin shifted to the center, sorry for the zero because without them the coordinate will not be look like coordinate)


The logical x-axis ranges from -cxClient/2 to +cxClient/2, and the logical y-axis ranges from -cyClient/2 to +cyClient/2. The lower right corner of the client area is the logical point (cxClient/2, cyClient/2). If you want to display text starting at the upper left corner of the client area, which is the device point (0, 0), you need to use negative coordinates:


TextOut (hdc, -cxClient / 2, -cyClient / 2, "Hello", 5) ;

You can achieve the same result with SetWindowOrgEx as you did when you used SetViewportOrgEx:


SetWindowOrgEx (hdc, -cxClient / 2, -cyClient / 2, NULL) ;//ok know problem, the (-cxClient / 2, -cyClient / 2) is changed to the device point (0,0), I understand that

The arguments to SetWindowOrgEx are always in terms of logical units. After this call, the logical point (-cxClient / 2, -cyClient / 2) is mapped to the device point (0, 0), the upper left corner of the client area.

What you probably don't want to do (unless you know what's going to happen) is to use both function calls together:


SetViewportOrgEx (hdc, cxClient / 2, cyClient / 2, NULL) ;
SetWindowOrgEx (hdc, -cxClient / 2, -cyClient / 2, NULL) ;
//from what I'm understanding, after the logical point (0,0) mapped to veiwport center the SetWindowOrgEx (...) will make the point already in the upper left corner mapped to the device point (0,0) which is also at left corner (0,0)

This means that the logical point (-cxClient/2, -cyClient/2) is mapped to the device point (cxClient/2, cyClient/2), giving you a coordinate system that looks like this:




00000000000000-y|
0000000000000000|
00000000000-x-----|
(the origin shifted to the lower right corner, but I think it should be at the upper left corner, why why why?)

I don't know how's the origin shifted to lower right corner. given that If you change the window origin to (xWinOrg, yWinOrg), the logical point (xWinOrg, yWinOrg) will be mapped to the device point (0, 0)
I think the origin will shifted to the upper left corner.
Beside if you change the window origin to (xWinOrg, yWinOrg), the logical point (xWinOrg, yWinOrg) will be mapped to the device point (0, 0), then I think It will be no matters regarding how you specify you window origin because It always be shifted to device point (0,0) which is upper left corner and it contradict with the second picture.
GeneralRe: Confused by the "Mapping Mode" Pin
PJ Arends12-Dec-04 9:55
professionalPJ Arends12-Dec-04 9:55 
GeneralPrinting Output Pin
BRIMID12-Dec-04 4:14
BRIMID12-Dec-04 4:14 
GeneralRe: Printing Output Pin
PJ Arends12-Dec-04 9:31
professionalPJ Arends12-Dec-04 9:31 
GeneralRe: Printing Output Pin
BRIMID12-Dec-04 14:01
BRIMID12-Dec-04 14:01 
Questionis this kind icon in an exe file possible? Pin
includeh1012-Dec-04 4:05
includeh1012-Dec-04 4:05 
AnswerRe: is this kind icon in an exe file possible? Pin
PJ Arends12-Dec-04 9:20
professionalPJ Arends12-Dec-04 9:20 
Generalras "error 632" Pin
mohsen nourian12-Dec-04 3:52
mohsen nourian12-Dec-04 3:52 
GeneralYahoo Messenger Pin
Member 141138912-Dec-04 3:08
Member 141138912-Dec-04 3:08 
GeneralBUG: ScrollWindowEx smoothscrolling, Child windows are drawn displaced Pin
Nalik12-Dec-04 2:03
Nalik12-Dec-04 2:03 
GeneralUpdateResource() ------ 2 Pin
includeh1012-Dec-04 0:49
includeh1012-Dec-04 0:49 
GeneralUpdateResource function Pin
includeh1012-Dec-04 0:29
includeh1012-Dec-04 0:29 
QuestionHow can I change focus between child windows within an MDI application Pin
wicked_guy12-Dec-04 0:16
wicked_guy12-Dec-04 0:16 
QuestionDid I miss something? Pin
jw8111-Dec-04 23:18
jw8111-Dec-04 23:18 
AnswerRe: Did I miss something? Pin
*Dreamz12-Dec-04 19:01
*Dreamz12-Dec-04 19:01 
GeneralRe: Did I miss something? Pin
jw8112-Dec-04 19:05
jw8112-Dec-04 19:05 
GeneralRe: Did I miss something? Pin
*Dreamz12-Dec-04 19:14
*Dreamz12-Dec-04 19:14 
GeneralRe: Did I miss something? Pin
jw8113-Dec-04 4:45
jw8113-Dec-04 4:45 

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.