|
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
|
|
|
|
|
I want to develop a FTP client like Cuteftp,and want to share my addressbook with the cuteftp, so I need to know the structure of the addressbook of the cuteftp. Who knows it or where can I find the explanation of the structure of the addressbook?
Thank you very much!
|
|
|
|
|
I do have MSDN.But I don't know which keyword I can use to look for it!
|
|
|
|
|
SystemParametersInfo() with the SPI_SETDESK_WALLPAPER option. However, this is a temporary change (it disappears after a reboot). To make it permanent, you'll also have to change the registry. The key to look at is "HKEY_CURRENT_USER\Control Panel\Desktop\Wallpaper".
Remember that this only works if web-view is disabled for the desktop, and Windows can only show BMP images when web-view is disabled.
Hope this helps
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
|
[MSDN October 2001]
IActiveDesktop::SetWallpaper
Sets the wallpaper for the Active Desktop.
HRESULT SetWallpaper(
LPCWSTR pwszWallpaper,
DWORD dwReserved
);
Parameters
pwszWallpaper
String value containing the file name of the wallpaper to be set.
dwReserved
Reserved. Must be set to zero.
Return Values
Returns S_OK if successful, or an OLE error code otherwise.
See Also
IActiveDesktop
Requirements
Version 4.71 and later of Shell32.dll
Windows NT/2000: Requires Windows 2000 (or Windows NT 4.0 with Internet Explorer 4.0 or later).
Windows 95/98/Me: Requires Windows 98 (or Windows 95 with Internet Explorer 4.0 or later).
Header: Declared in Shlobj.h.
So it should work from IE 4.0+. Hope it helps.
For a lower version, try SystemParametersInfo:
BOOL SystemParametersInfo(
UINT uiAction, // system parameter to retrieve or set
UINT uiParam, // depends on action to be taken
PVOID pvParam, // depends on action to be taken
UINT fWinIni // user profile update option
);
SPI_SETDESKWALLPAPER
Sets the desktop wallpaper.
The value of the pvParam parameter determines the new wallpaper.
To specify a wallpaper bitmap, set pvParam to point to a null-terminated string containing the name of a bitmap file.
Setting pvParam to "" removes the wallpaper.
Setting pvParam to SETWALLPAPER_DEFAULT or NULL reverts to the default wallpaper.
|
|
|
|
|
Using WSAEvents winsock notifications... Under what circumstances would a client get FD_WRITE and FD_CONNECT at the same time? I mean WSAEnumNetworkEvents gives me 0x12(18) in WSANETWORKEVENTS::lNetworkEvents which to me looks like FD_CONNECT|FD_WRITE .
That throws me off pretty bad.
|
|
|
|
|
Upon an initial connection, the server will trigger both FD_CONNECT and FD_WRITE events.
Kuphryn
|
|
|
|
|
Thanks! OK I get it. Now is there any chance or a situation when I will NOT recv the FD_CONNECT notification. May be when ::connect returns success right away - without WSAWOULDBLOCK?
MSDN help is vague on this.
|
|
|
|
|
connect() is a blocking winsock API. If it returns immediately, then yes there is a possibility the process will not receive FD_CONNECT.
Kuphryn
|
|
|
|
|
That's strange..
My MSDN in connect() article says:
<br />
For connection-oriented, nonblocking sockets, it is often not possible to complete the connection immediately. In such a case, this function returns the error WSAEWOULDBLOCK. However, the operation proceeds.<br />
<br />
When the success or failure outcome becomes known, it may be reported in one of two ways, depending on how the client registers for notification.<br />
<br />
If the client uses the select function, success is reported in the writefds set and failure is reported in the exceptfds set.<br />
If the client uses the functions WSAAsyncSelect or WSAEventSelect, the notification is announced with FD_CONNECT and the error code associated with the FD_CONNECT indicates either success or a specific reason for failure.<br />
It actualy feels just like WSAConnect and I get notification most of the time but not always.
Should I switch to WSAConnect or what?
|
|
|
|
|
Yes, I highly recommend WSAConnect(). I am not familiar with connect() because I always use WSAConnect() under non-blocking I/O model.
Kuphryn
|
|
|
|
|
Hello,
I'm using the SetLayeredWindowAttributes() function for
setting transparency of a frame window. It works fine but
all window childs (edit boxes, combo boxes ...) are
transparent too. Is it possible to make childs opaque but
with preserving parent transparency ?
Thank you.
Bedas
|
|
|
|
|
You could try calling SetLayeredWindowAttributes() for each child window, but I don't think it would work. I may be wrong though.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Thank you, but unfortunately it doesn't work.
|
|
|
|
|
I didn't think it would. I think you're attempting something that Windows does not support. You might have to implement the transparency yourself if you really need this feature. It's not standard and may very well confuse some users.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
|
How does the program determine which items are selected? One solution is to determine the selected items in the on item change handler. Thus, item insertion will cause windows to send an item change message.
Kuphryn
|
|
|
|
|
I use
int index = GetNextItem(previous_index, LVNI_SELECTED);
to get the selected item.
With the OWNERDATA style, I don't have to insert items into the list view control using InsertItem. Rather, I just add items in the underlying container and call SetItemCount() on the control with the number of items.
Say, I was at index 0, and a new item was added at the top of the container. Now the selected index is still 0, but the item that is at that index is the new item. The same problem occurs when the container is sorted.
The only option I can think of now, is to get the object that is in the container at the index before changing it, and then find the index of same object in the modified container, and selecting that item from the code, and then make sure that the item is visible.
I was looking for an easier solution to this
My article on a reference-counted smart pointer that supports polymorphic objects and raw pointers
modified 29-Aug-18 21:01pm.
|
|
|
|
|
One solution is to update the index database that holds the selected items. Here is one example.
Selected indices:
2
3
5
8
10
13
15
- insert new item at index 0
Now using STL, one solution is to determine where the item was inserted and update the index database.
Updated selected indices:
3
4
6
9
11
12
16
Kuphryn
|
|
|
|
|
I am trying to get RTF text into an MS Word document, using automation. I have a method which works fine, whereby I write the rtf to the file, then call the Range object's InsertFile() method. However, this is a little slow, to say the least.
Any ideas on how I could transfer my text quicker?
Thanks in advance!
|
|
|
|
|
Word's automation is extremely slow for anything You can get a bit of a speedup by preventing the changes to be shown by setting Application.ScreenUpdating to false while you insert the file, but this only really works when you're performing more than one operation. Other than this, there's not much you can do.
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late - John Nichol "Point Of Impact"
|
|
|
|
|
Hi All
i have a CListView project, i would like to capture whats in my list
view and output if for printing, i know i need some kind of pointer to
my list view but im a bit stuck, on what to put in my OnDraw(CDC* pDC)
function to capture whats there
please help
thakns in advance
si
void CCallParentsView::OnDraw(CDC* pDC)
{
}
|
|
|
|
|
Your OnDraw(0 procedure is part of the window which contains the control, so yuo shoul dbe able to do either of the following:
CListCtrl *pCOntrol = static_cast < CListCtrl* > (GetDlgItem(ID_OF_CONTROL));
or just use the control that was mapped with DDX_Control() call.
You can then loop round using the item count etc. Take a look at some of my printing articles for some tips on printing.
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
hello bies
I heard lot more about static functions that it access only static variable
it count the number of objects created... and so on
But still i a am unable to known in which condn it shpild be used can any one give me details with small code would apprecitaed
|
|
|
|