 |
|
 |
Good job well done.
I'd like to use it on Activex control (OCX).
My idea was to do final user can move the control at runtime
as the same way as I do on Visual basic at design time.
I make a function:
void CMyClassCtrl::Tracker(BOOL bTracker)
{
if (bTracker){
if (m_tracker){
delete m_tracker;
m_tracker = NULL;
}
CDC* pDC=(CDC*)GetDC();
LPRECT rect = new RECT;
CRect rect;
GetRectInContainer(&rect) ;
m_tracker = new CRectTracker(rect,CRectTracker::dottedLine | CRectTracker::resizeOutside | CRectTracker::hatchedBorder );
m_tracker->Draw(pDC) ;
delete rect;
rect = NULL;
SetModifiedFlag();
}
else {
if (m_tracker){
delete m_tracker;
m_tracker = NULL;
Invalidate(TRUE);
}
}
}
This code fail because at run time when I call this
funcion only a part of rect is showed, not all around the
control as I wanted.
The function GetRectInContainer(&rect) does't seem to retun
right rect of client area. Do I have to transform it on other coordinate?
What is wrong, can you help me ? thank you
|
|
|
|
 |
|
|
 |
|
 |
I have been researching how to resize controls at runtime from a C# application and there is no easy way. C# does not have the equivalent of the CRectTracker class. It appears that my best option is to call your routine from a C# application. Any suggestions on the best way to link the events. Is there the equivalent of the OnSetCursor event in C#? Any help would be appreciated.
|
|
|
|
 |
|
 |
It's slightly off topic but:
How can you save the new dialog layout back to a resource file?
Any help would be very welcome...
|
|
|
|
 |
|
 |
That's actually pretty complicated. It would be another article, or maybe a book. It can certainly be done though.
|
|
|
|
 |
|
 |
I am having a problem with CRectTracker. When I link with Shared DLL it works fine, when I link with Static Library the cursors (resize and move) do not show up when the mouse is over the tracking rect. I was going crazy thinking I was doing something wrong, but this code has exactly the same problem.
Anybody know why the cursors do not show up when statically linked?
Thanks!
Craig Smith
|
|
|
|
 |
|
 |
Add _AFXDLL in Project's configuration Properties/ "C/C++" / Preprocessor / Preprocessor Definitions.
In Code Generation / RunTime Library use "Multi-Threaded Dll" (/MD)
|
|
|
|
 |
|
 |
If you can use dynamically linked MFC dll, just follow up Mr. lesnikowski's suggestion.
Otherwise, initialize cursor resource by your hand. For example, simple initialization would be
extern HCURSOR _afxCursors[10];
BOOL _InitCursor()
{
HINSTANCE hInst=NULL;
if (!_afxCursors[0])
_afxCursors[0] = ::LoadCursor(hInst, MAKEINTRESOURCE(IDC_SIZENWSE));
if (!_afxCursors[1])
_afxCursors[1] = ::LoadCursor(hInst, MAKEINTRESOURCE(IDC_SIZENESW));
if (!_afxCursors[2])
_afxCursors[2] = _afxCursors[0];
if (!_afxCursors[3])
_afxCursors[3] = _afxCursors[1];
if (!_afxCursors[4])
_afxCursors[4] = ::LoadCursor(hInst, MAKEINTRESOURCE(IDC_SIZENS));
if (!_afxCursors[5])
_afxCursors[5] = ::LoadCursor(hInst, MAKEINTRESOURCE(IDC_SIZEWE));
if (!_afxCursors[6])
_afxCursors[6] = _afxCursors[4];
if (!_afxCursors[7])
_afxCursors[7] = _afxCursors[5];
if (!_afxCursors[8])
_afxCursors[8] = ::LoadCursor(hInst, MAKEINTRESOURCE(IDC_SIZEALL));
if (!_afxCursors[9])
_afxCursors[9] = ::LoadCursor(hInst, MAKEINTRESOURCE(IDC_SIZEALL));
return TRUE;
}
BOOL CAdjustWBoxDialog::OnInitDialog()
{
...
m_tracker=new CRectTracker(rect, CRectTracker::solidLine|CRectTracker::resizeOutside);
_InitCursor();
...
}
Please note that _InitCursor() should be called after instantiation of m_tracker(see the MFC source trckrect.cpp).
|
|
|
|
 |
|
 |
See this article http://support.microsoft.com/kb/208856[^]
CAUSE
When an application is linked to MFC by using the static library, the MFC resources are compiled into the executable of an application. The executable of the application will include the Afxres.rc file. To check this, click Resource Includes on the View menu. The Afxres.rc file has the resources that CRectTracker uses in the MFC source code.
These resources are only included when _AFX_NO_TRACKER_RESOURCES is not defined. The BLOCKS32 project has _AFX_NO_TRACKER_RESOURCES defined. Therefore, it does not put the resources that CRectTracker requires in the executable image of the application. Therefore, none of the cursors that are used by CRectTracker will show up when you build the sample by using MFC statically.
RESOLUTION
1. On the View menu, click Resource Includes.
2. Delete the following line:
#define _AFX_NO_TRACKER_RESOURCES
|
|
|
|
 |
|
 |
On VS2008, I found that the "Resource Includes" item is under the Edit menu.
The line in the .rc was as follows:
#define _AFX_NO_SPLITTER_RESOURCES
When I deleted this in my application (which is statically linked to MFC), the splitter cursors returned.
|
|
|
|
 |
|
 |
i have try to use this code in an other application
but when i start rezice at run and i go over the elment i see no mouse that isn't ver good becuase you can't see if you are over the rezice rect or ocer the rest
soooo please help me
|
|
|
|
 |
|
 |
Well I for one would like to compliment you. This is a great idea and the demo project works perfectly.
I am going to try using the code you've included when I get home.
As for the comlaints below, the one about deleting a NULL crect is valid however that is probably just a cut-n-paste error that slipped through. As for the overlapping tracker problem I'd just suggest to resize one control at a time.
Again good job and I'll try it tonight.
--
FireBox @ Synetech
|
|
|
|
 |
|
 |
U GOT A FOOONE? N WHERES DAT ARTICLE WHERE DA MUSLIM GEEZA WAS GETIN GUNED?
-------------
Oi BlAd U GoT a fOnE oN U?
|
|
|
|
 |
|
 |
When 2 controls overlap each other and if they are selected
( in other words they are showing the tracker) then the
crecttracker is hidden in the overlapping place.
Please can please tell me the solution on how to overcome this.
John 3:16
For God so loved the world,
that he gave his only begotten Son ( Jesus Christ ) ,
that whosoever believeth in him should not perish, but have everlasting life.
|
|
|
|
 |
|
 |
Probably not a good idea, in CResizeDlg::OnLButtonDown:
rect = NULL;
delete rect;
rect = NULL;
|
|
|
|
 |
|
 |
.. although the code is perfectly legal, it indicates this guy obviously doesn't know what he's doing.
|
|
|
|
 |
|
 |
Sigh!
Ground Zero Tech-Works
http://www.ayanova.com
|
|
|
|
 |