Click here to Skip to main content
16,006,768 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralGetDeviceCaps problems... Pin
Braulio Dez28-Dec-01 6:05
Braulio Dez28-Dec-01 6:05 
GeneralLoading a string from a binary file Pin
James Bird28-Dec-01 5:34
James Bird28-Dec-01 5:34 
GeneralRe: Loading a string from a binary file Pin
Nemanja Trifunovic28-Dec-01 5:44
Nemanja Trifunovic28-Dec-01 5:44 
GeneralRe: Loading a string from a binary file Pin
Daniel Lohmann28-Dec-01 5:53
Daniel Lohmann28-Dec-01 5:53 
GeneralRe: Loading a string from a binary file Pin
James R. Twine28-Dec-01 7:06
James R. Twine28-Dec-01 7:06 
GeneralTrying to get the size of A3... Pin
Braulio Dez28-Dec-01 4:35
Braulio Dez28-Dec-01 4:35 
GeneralRotating shapes Pin
bhat_adarsh28-Dec-01 4:24
bhat_adarsh28-Dec-01 4:24 
GeneralRe: Rotating shapes Pin
567890123430-Dec-01 1:08
567890123430-Dec-01 1:08 
First I will try to solve the simple problem ("am able to rotate the rectangle by the required degrees
although a part of the rectangle is hidden"). I think every object should be rotated around it's top-left vertex. In this case I use two functions which prepare DC state to draw the object:

// Set device context to new state:
// every object drawn after call to this function will be rotated
// to nAngle degrees around (x, y) point.
// Rotation direction: positive - clockwise
//
void CWorldTransform2View::SetRotation(CDC* pDC,
int x,
int y,
int nAngle) // degrees
{
double dAngle = nAngle * PI_X_2 / 360.0; // PI_X_2 is pi*2

XFORM xForm;

xForm.eM11 = (FLOAT) cos(dAngle);
xForm.eM12 = (FLOAT) sin(dAngle);
xForm.eM21 = (FLOAT) (-sin(dAngle));
xForm.eM22 = (FLOAT) cos(dAngle);
xForm.eDx = (FLOAT) 0.0;
xForm.eDy = (FLOAT) 0.0;


int x1, y1;
x1 = (int) ( (x * cos(dAngle)) - (y * sin(dAngle)) );
y1 = (int) ( (x * sin(dAngle)) + (y * cos(dAngle)) );

GetViewportOrgEx(pDC->m_hDC, &m_PointOrigin);
SetViewportOrgEx(pDC->m_hDC, -x1 + x, -y1 + y, NULL);

m_nGraphicsMode = GetGraphicsMode(pDC->m_hDC);
SetGraphicsMode(pDC->m_hDC, GM_ADVANCED);

GetWorldTransform(pDC->m_hDC, &m_xForm);
SetWorldTransform(pDC->m_hDC, &xForm);

}

// Restore device context to the state is was before call to SetRotation
void CWorldTransform2View::RestoreDC(CDC* pDC)
{
SetWorldTransform(pDC->m_hDC, &m_xForm);

SetGraphicsMode(pDC->m_hDC, m_nGraphicsMode);

SetViewportOrgEx(pDC->m_hDC, m_PointOrigin.x, m_PointOrigin.y, NULL);
}

I hope this will help you to draw (if you have such problem).

To solve the second problem you need derive new class from drawing object you need to rotate (for example, CDrawRect) and add to it member m_nRotationAngle. After this rewrite all class functions using this angle. For example, function CDrawRect::GetHandle returns point. In your class you should rotate this point around rectangle's top-left vertex (some math...) and after this return it. Function Draw should draw the object with rotation angle (this is the problem you always solved, I beleive). Function MoveHandleTo should first rotate point (parameter) to -m_nRotationAngle degrees and after this work as usual (at least, such it seems to me now...). Function Intersects should work with region rather than rectangle etc.

So, you have some work for a couple of days or more, good luck.
GeneralMigrating from Win9x to Linux - PLEASE HELP! Pin
Sergei Yevseyev28-Dec-01 4:16
Sergei Yevseyev28-Dec-01 4:16 
GeneralRe: Migrating from Win9x to Linux - PLEASE HELP! Pin
Matt Newman28-Dec-01 4:31
Matt Newman28-Dec-01 4:31 
GeneralRe: Migrating from Win9x to Linux - PLEASE HELP! Pin
Nemanja Trifunovic28-Dec-01 5:25
Nemanja Trifunovic28-Dec-01 5:25 
GeneralRe: Migrating from Win9x to Linux - PLEASE HELP! Pin
Fazlul Kabir28-Dec-01 5:30
Fazlul Kabir28-Dec-01 5:30 
GeneralRe: Migrating from Win9x to Linux - PLEASE HELP! Pin
Ravi Bhavnani28-Dec-01 5:31
professionalRavi Bhavnani28-Dec-01 5:31 
GeneralRe: Migrating from Win9x to Linux - PLEASE HELP! Pin
Tomasso7-Jan-02 7:10
Tomasso7-Jan-02 7:10 
Generalaccess CRecordSet from another class Pin
jafrazee28-Dec-01 2:43
jafrazee28-Dec-01 2:43 
GeneralRe: access CRecordSet from another class Pin
Carlos Antollini28-Dec-01 3:05
Carlos Antollini28-Dec-01 3:05 
GeneralRe: access CRecordSet from another class Pin
jafrazee28-Dec-01 3:46
jafrazee28-Dec-01 3:46 
GeneralRe: access CRecordSet from another class Pin
Carlos Antollini28-Dec-01 5:07
Carlos Antollini28-Dec-01 5:07 
Questionhow can i DRAW in CVIEW:OnInitialUpdate() function? Pin
AnonymousBabe@usa.net28-Dec-01 2:08
AnonymousBabe@usa.net28-Dec-01 2:08 
AnswerRe: how can i DRAW in CVIEW:OnInitialUpdate() function? Pin
AnonymousBabe@usa.net28-Dec-01 6:07
AnonymousBabe@usa.net28-Dec-01 6:07 
AnswerRe: how can i DRAW in CVIEW:OnInitialUpdate() function? Pin
Shog928-Dec-01 8:58
sitebuilderShog928-Dec-01 8:58 
GeneralRe: how can i DRAW in CVIEW:OnInitialUpdate() function? Pin
AnonymousBabe@usa.net28-Dec-01 14:23
AnonymousBabe@usa.net28-Dec-01 14:23 
GeneralRe: how can i DRAW in CVIEW:OnInitialUpdate() function? Pin
Shog929-Dec-01 13:14
sitebuilderShog929-Dec-01 13:14 
Generalcsv file Pin
Sonu Kapoor28-Dec-01 2:06
Sonu Kapoor28-Dec-01 2:06 
Generalerror message Pin
28-Dec-01 0:42
suss28-Dec-01 0:42 

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.