Click here to Skip to main content
15,908,444 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Justifying text Pin
AparnaBollapalli31-Oct-09 23:47
AparnaBollapalli31-Oct-09 23:47 
Generalsize of integer and pointer on a machine Pin
Omar Alvi9-Jun-03 4:51
Omar Alvi9-Jun-03 4:51 
GeneralRe: size of integer and pointer on a machine Pin
valikac9-Jun-03 6:33
valikac9-Jun-03 6:33 
GeneralRe: size of integer and pointer on a machine Pin
Omar Alvi9-Jun-03 18:40
Omar Alvi9-Jun-03 18:40 
GeneralRe: size of integer and pointer on a machine Pin
valikac9-Jun-03 18:51
valikac9-Jun-03 18:51 
GeneralRe: size of integer and pointer on a machine Pin
Omar Alvi9-Jun-03 19:18
Omar Alvi9-Jun-03 19:18 
GeneralRe: size of integer and pointer on a machine Pin
Ryan Binns9-Jun-03 23:15
Ryan Binns9-Jun-03 23:15 
GeneralPanning -Zooming-Centering 2d shapes Pin
ninpo9-Jun-03 4:50
ninpo9-Jun-03 4:50 
I have been working on this for about 3 weeks and have not got any where. Perhaps someone out there can send me in the right direction. The Big picture I'm after is, given a length and width (of a 2d shape)Draw the shape to the screen centered and given a little margin, and be able to drag the mouse across the screen and it will display the XY in the status menu (have the code for this done but numbers are wrong....just need the formulas to calculate it), and finally to be able to Zoom or Pan.

Thats the total direction I'm heading, but I believe the panning and zooming in MFC is real easy by just setting the SetViewExtents and by moving the view origin around (again that is what I believe)

What I've been banging my head against the wall with is this centering aspects of the shape. (AS A SIDE NOTE: I want the units to be real ie if I have a rectangle that is 5.25x1.25 in or mm then use those such that when I do my magic calculations then the cursor gives you those positions as you move the cursor over it)

Anyway, back to the orignal, This is the code I have been playing with in my Ondraw functin:

(CPoint apt is the length and width of the rectangle) if I change these I want the shape to be drawn centered

CTestHelpDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
m_pDC=NULL;

CPoint apt;
apt.x=5250; //5.25*1000
apt.y=1250;//1.25*1000 units scaled by 1000

CRect arect;
GetClientRect(&arect);
pDC->SetMapMode(MM_ISOTROPIC);//MM_HIENGLISH
int m_iView=(int)(viewextents);

pDC->SetWindowExt(m_iView,m_iView);

int m_iSize=0;
if(arect.right>arect.bottom)
m_iSize=int(arect.right*scalefac);
else
m_iSize=int(arect.bottom*scalefac);

double testX=apt.x/viewextents;
double testY=apt.y/viewextents;

double m_RatioX= testX * m_iSize;
double m_RatioY= testY * m_iSize;

int Rx,Ry;
// Rx=(m_iSize-m_RatioX)/2;
// Ry=arect.bottom-(arect.bottom-m_RatioY)/2;
Rx=(((double)apt.x*((double)arect.right/viewextents))+arect.right)/4;
Ry=m_RatioY/2;

pDC->SetViewportExt(m_iSize,-m_iSize);
// pDC->SetViewportExt(viewextents/2,-viewextents/2);
// pDC->SetViewportExt(testX,-testY);
// pDC->SetViewportExt(arect.right,-arect.bottom);

// pDC->SetViewportOrg(m_iSize/2,m_iSize/2);
pDC->SetViewportOrg(arect.right/2,arect.bottom/2);

// pDC->SetViewportOrg(Rx,Ry);
// pDC->SetViewportOrg(m_RatioX,m_RatioY);
// pDC->SetViewportOrg(m_RatioX,m_RatioY);
// pDC->SetViewportOrg(testX/8,testY/1.4);

// pDC->OffsetViewportOrg(-apt.x,-apt.y);
pDC->OffsetViewportOrg(-Rx,Ry);
// pDC->OffsetViewportOrg(-m_RatioX*1.3,m_RatioY*2.0);

pDC->Rectangle(0,0,apt.x,apt.y);

//Orgin
pDC->MoveTo(0,0);
pDC->LineTo(0,50);
pDC->MoveTo(0,0);
pDC->LineTo(50,0);


I need to set this up correct so when I go after the mousemove to update the status pains with the locatin in real units that they work correctly as well as have it ready for zooming and panning.

Thanks in advance!

-Eric
QuestionHow to import the addressbook of the Cuteftp to my program? Pin
kindows9-Jun-03 4:38
kindows9-Jun-03 4:38 
QuestionWhich API can set a image file as wallpaper? Pin
white jungle9-Jun-03 4:35
white jungle9-Jun-03 4:35 
AnswerRe: Which API can set a image file as wallpaper? Pin
Ryan Binns9-Jun-03 4:43
Ryan Binns9-Jun-03 4:43 
AnswerRe: Which API can set a image file as wallpaper? Pin
kindows9-Jun-03 4:44
kindows9-Jun-03 4:44 
AnswerRe: Which API can set a image file as wallpaper? Pin
Sardaukar9-Jun-03 22:02
Sardaukar9-Jun-03 22:02 
GeneralBasic understanding question... Pin
CherezZaboro9-Jun-03 4:32
CherezZaboro9-Jun-03 4:32 
GeneralRe: Basic understanding question... Pin
valikac9-Jun-03 6:35
valikac9-Jun-03 6:35 
GeneralRe: Basic understanding question... Pin
CherezZaboro9-Jun-03 7:02
CherezZaboro9-Jun-03 7:02 
GeneralRe: Basic understanding question... Pin
valikac9-Jun-03 7:22
valikac9-Jun-03 7:22 
GeneralRe: Basic understanding question... Pin
CherezZaboro9-Jun-03 7:36
CherezZaboro9-Jun-03 7:36 
GeneralRe: Basic understanding question... Pin
valikac9-Jun-03 7:39
valikac9-Jun-03 7:39 
GeneralLayered window problem Pin
Bedas9-Jun-03 4:21
Bedas9-Jun-03 4:21 
GeneralRe: Layered window problem Pin
Ryan Binns9-Jun-03 4:37
Ryan Binns9-Jun-03 4:37 
GeneralRe: Layered window problem Pin
Bedas10-Jun-03 0:31
Bedas10-Jun-03 0:31 
GeneralRe: Layered window problem Pin
Ryan Binns10-Jun-03 0:51
Ryan Binns10-Jun-03 0:51 
GeneralList Control Pin
User 98859-Jun-03 3:49
User 98859-Jun-03 3:49 
GeneralRe: List Control Pin
valikac9-Jun-03 6:37
valikac9-Jun-03 6:37 

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.