|
Hello,
I have stumbled across one odd (in the very least) situation.
According to what MSDN makes reference to, almost all pos/size changing methods understand left/top as the topmost coordinates and right/bottom as the width/height. But that doesn't work in my programs, for some reason, as right/bottom are understood as screen coordinates and not as width/height.
Should I be doing any coordinate mapping of some sort? What am I missing out here?
David
Example:
In MSDN:
CWnd::MoveWindow
void MoveWindow( int x, int y, int nWidth, int nHeight, BOOL bRepaint = TRUE );
void MoveWindow( LPCRECT lpRect, BOOL bRepaint = TRUE );
Parameters
x Specifies the new position of the left side of the CWnd.
y Specifies the new position of the top of the CWnd.
nWidth Specifies the new width of the CWnd.
nHeight Specifies the new height of the CWnd.
bRepaint Specifies whether CWnd is to be repainted. If TRUE, CWnd
receives aWM_PAINT message in its OnPaint message handler as usual. If this
parameter is FALSE, no repainting of any kind occurs. This applies to the
client area, to the nonclient area (including the title and scroll bars),
and to any part of the parent window uncovered as a result of Cwnd’s move.
When this parameter is FALSE, the application must explicitly invalidate or
redraw any parts of CWnd and parent window that must be redrawn.
lpRect The CRect object or RECT structure that specifies the new size and position.
|
|
|
|
|
Technicaly, if you want to move your windows inside another window then you should perform some mapping. However, why don't you post some code so everyone can see what you mean?
// Afterall, I realized that even my comment lines have bugs
If the sun were to blow up, it would take us 7-8 minutes to realize it.
|
|
|
|
|
If you are working with CRect s, use the Width and Height members respectively. Otherwise, deduct the left coord from the right and the top from the bottom, and you'll get the height and width. You might also want to check SetWindowPos , where you can select SWP_NOSIZE to just move the control.
There is otherwise no need for any coordinate manipulations.
|
|
|
|
|
Johan Rosengren wrote:
If you are working with CRects, use the Width and Height members respectively.
So you mean, width/height only apply to CRect objects?
Johan Rosengren wrote:
Otherwise, deduct the left coord from the right and the top from the bottom, and you'll get the height and width.
That's exactly what I have been doing...
I was just confused with the information you can find in MSDN -- they make no mention (or actually little) to CRect objects, but instead to (LP)RECT structures; they mention width/heights of rects and NOT coordinates; ...
This is why I thought you didn't really need to use screen coordinates -- after all you do. (isn't it?)
Thanks for the replies, everyone.
David
|
|
|
|
|
dNimrod#X wrote:
Johan Rosengren wrote:
If you are working with CRects, use the Width and Height members respectively
Width and Height of CRect are calculated by subtracting the coordinates and they do not represent the actual coordinates of the rectangle. So you shouldn't use them directly as coordinates in your MoveWindow function.
Width and Height in CWnd::MoveWindow() are coordinates, not sizes. CRect is similar to RECT struct. You initialize these two with coordinates, not sizes. MoveWindow API takes coordinates (not sizes) as parameters and CWnd::MoveWindow encapsulates this function. I hope this is not confusing you because as I am reading it now I am starting to have second thoughts about my explanations.
// Afterall, I realized that even my comment lines have bugs
If the sun were to blow up, it would take us 7-8 minutes to realize it.
|
|
|
|
|
Toni78 wrote:
I hope this is not confusing you because as I am reading it now I am starting to have second thoughts about my explanations.
You should From MSDN, on MoveWindow :
nWidth
Specifies the new width of the <code>CWnd</code>.
nHeight
Specifies the new height of the <code>CWnd</code>.
It is the height and width, not the coordinates.
|
|
|
|
|
Johan Rosengren wrote:
It is the height and width, not the coordinates.
Yes, you are so right. Sorry, for the confusion that I created.
// Afterall, I realized that even my comment lines have bugs
If the sun were to blow up, it would take us 7-8 minutes to realize it.
|
|
|
|
|
dNimrod#X wrote:
So you mean, width/height only apply to CRect objects?
Yes, RECT is a simple structure
Here you have an example of moving a control using MFC:
CRect rect;
m_ctrl.GetWindowRect( rect );
ScreenToClient( rect );
m_ctrl.MoveWindow( rect.left - 10, rect.top - 10, rect.Width(), rect.Height() );
|
|
|
|
|
How do i find whether a file is present in a directory or not?
|
|
|
|
|
/* Check for existence */
if( (_access( "filename, with full path", 0 )) != -1 )
{
//file exists
}
This will do the trick for you
|
|
|
|
|
will the same trick work to find the existence of a directory
|
|
|
|
|
Why people never take a look at the msdn before asking something? In 90% of the time, you will have the answer in less than 1 min. Like in this case...
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt__access.2c_._waccess.asp
Mangez des gnous!
|
|
|
|
|
use api PathFileExist() this will help you above cause
-----------------------------
"I Think It will Work"
Formerly Known As "Alok The Programmer" at CP
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
I'm working on an MDI application. Now, I have this side bar which displays certain information about a document. Each time I switch to a different document I handle the view change message in the corresponding view and from there I update the sidebar.
This worked great. But some new feature in the program demands I put in an extra view for each document/frame (a CListView to be exact). In the toolbar the user can switch between these views.
Now the problem arises, that once the view changes, I get a new message in the sidebar saying the document has switched, whereas in real, the document hasn't switched at all. I was wondering whether there would be a different way to detect if the user went to a different document
|
|
|
|
|
hi,
how i include status bar in model or moduless dialog box(Child Window).plz help me.
Thank you.
nevis
|
|
|
|
|
Can't you do it like this?
Make a CStatusBar member in your dialog
In OnInitDialog() call m_wndStatusBar.Create( this)
|
|
|
|
|
Hi,
I have a MSHFlexGrid-like control that often needs to be redrawn. Sometimes the redraw flickers and sometimes it doesn't.
It seems to flicker when rows OR cols are out of the direct view, thus enabling the scrollbar.
Why does this problem occur and what can I do about it?
I didn't know there was significant diffence between redrawing with and without a scrollbar?
tnx for your help!
"If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix
|
|
|
|
|
I did work with MSHFlexGrid a lot last year, but unfortunately I don't have any source code with me right here and right now. However, I remember that there was an option where you could let the control draw itself automatically. Now I don't know if you have enabled that option and at the same time you are redrawing the grid manually as well. But that would be my first and only guess, because I never had a flickering problem.
// Afterall, I realized that even my comment lines have bugs
If the sun were to blow up, it would take us 7-8 minutes to realize it.
|
|
|
|
|
hello,
I've got a simple question, some time ago I've wrote an application that creates a binary search tree and now I need it to be used into my win32 appliaction, since importing dll function is not difficult, how do I import structures? I've included in my project the bst.h file that contanins all the definition but at link compiler I get errors... as no bst_node struct is found...... my question is : How I tell the compiler to import a structure from a dll?
for all the funcions that needs to be exported I inserted
__declspec( dllexport )
but it doesn't work with str.
Thanks!
|
|
|
|
|
I have better idea for you,
Create A class instead of Structure and and made it variable public accesible.
and now export/import class using the AFX_EXT_MACRO.
note:for this you have to craete the MFC extention Dll
-----------------------------
"I Think It will Work"
Formerly Known As "Alok The Programmer" at CP
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
thanks, but I'm not familiar with MFC, I've never done anything with it...thanks for the advice btw!
|
|
|
|
|
I produce a document in MS word.
I added tables and I would like to add Rows to those tables by using
Rows.Add(VARIANT* BeforeRow) command
as fallowed but I could not do it.
How can I do it?
Thank you in advance.
m_Tables=Document.GetTables();
m_Selection=m_Table.Cell(2,6);
m_Selection.Select();
m_lpcstr="somestring";
m_Selection.SetText(m_lpcstr);
VariantInit(m_Var);
m_Var->vt=VT_VARIANT;
m_Var->pvarVal=(VARIANT*)2;
// or
m_Var->vt=VT_I4;
m_Var->lVal=2;
m_Table=m_Tables.Item(4);
m_Rows=m_Table.GetRows();
cnt=m_Rows.GetCount();
m_Row=m_Rows.Item(2);
m_Row.Select();
m_Rows.Add(m_Var);
|
|
|
|
|
Ive a CListCtrl
I would like to do the opposite of an InvalidateRect on a section.
i.e. I want to redraw the entire control EXCEPT a certain region (rectangle)
how does one go about this?
cheers
bryce
---
Publitor, making Pubmed easy.
http://www.sohocode.com/publitor
|
|
|
|
|
ValidateRect()
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|