|
CRect rect;
GetDlgItem(IDC_CONTROLNAME)->GetWindowRect(&rect);
ScreenToClient(&rect);
You should then be able to take the values of rect.
"You know "that look" women get when they want sex? Me neither."
--Steve Martin
|
|
|
|
|
I got it working using GetWindowRect of the control and ScreenToClient of the dialog. Is this the best way to do it?
[EDIT]
Guess I should have refreshed before I posted Thanks for the help though
[/EDIT]
- Aaron
|
|
|
|
|
Off the top of my head.
GetClientRect(): is the rectangular area that represents the area where drawing is to occur, with (0,0) representing the upper left courner of the client area within the window.
GetWindowRect(): is the rectangular area that represents the area where the window is draw in screen coordinates and must be converted to client coordinates to be useful.
Therefore, you need to get the screen coordinates via GetWindowRect() and then convert them to the dialog coordinates via ScreenToClient().
Now is there a better way or a function that does the needed conversion for you? I am not sure, there is one function whose usage is a bit confusing so I keep forgetting its' name and all I remeber (at the moment) is that it converts from one coordinate system to anoghter (a.k.a. client to screen or screen to client). Basicaly, it is less confusing to do it your self (with two simple function calls), than to call some function that (based on the arguments) makes the same function calls.
INTP
|
|
|
|
|
I need to find out the Domain name in which my computer is at the moment not using GetComputerNameEx if possible. How?
|
|
|
|
|
You can use LookupAccountName
<br />
DWORD dwDomain = DNLEN + 1;<br />
char szDomain[DNLEN + 1];<br />
<br />
memset(&szDomain, 0, DNLEN + 1);<br />
<br />
PSID pSid = NULL;<br />
DWORD cbSid = SID_SIZE;<br />
SID_NAME_USE peUse;<br />
<br />
pSid = (PSID)HeapAlloc(GetProcessHeap(), 0, cbSid);<br />
ASSERT(pSid != NULL);<br />
<br />
if (LookupAccountName(NULL, szUserName, pSid, &cbSid, szDomain, &dwDomain, &peUse)) <br />
{<br />
}<br />
<br />
if (pSid != NULL)<br />
HeapFree(GetProcessHeap(), 0, pSid);
This may help you, note that if the computer is not joined to a domain it returns the computer name!
Ant.
|
|
|
|
|
Wait a minute!
what is szUserName as the second parameter?
It look like it wants full domain\user path, but if I knew that I wouldn't need to call this on the first place.
So at the moment I get only computer name as when it's not joined to a domain, but it is.
|
|
|
|
|
Um fair points. However you do not need the full qualifying 'domain\username' you can pass just 'username'.
The reason you get the local machine is probably because the szUserName is a local account name also. You could set the szUserName to a domain account name and this should then find the domain that that account resides.
I wish I'd thought a bit longer before posting this as it is not ideal
Ant.
|
|
|
|
|
Ok. For now I'll use GetComputerNameEx and/or NetGetJoinInformation.
But those are just on 2000, XP and 2003.
<dreaming>
Still would be nice to figure out the domain name on like NT and 98.
</dreaming>
|
|
|
|
|
I need to dump data to my SDI window as I read it from a socket. What's the easiest way to do that ?
Thanks !!
|
|
|
|
|
Stick a RichEdit control in the middle of your window and dump all the input into it?
It's dirty, but it works.
|
|
|
|
|
Can you give me an example of how to add it and how to dump to it ?
Thanks !
|
|
|
|
|
Depends on what framework you are using. Since you referred to "SDI", I assume you're doing MFC or WTL. There are a ton of articles on this site which can should you how to add a RichEdit control to either of those windows. Just look around a bit. (Or check out msdn.)
|
|
|
|
|
How about TextOut() ?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
David
Any example of using TextOut() ?
Thanks !
|
|
|
|
|
The documentation is pretty self-explanatory. Here's another example.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
|
You don't. It's passed as a parameter to the OnDraw() method.
void CMyView::OnDraw( CDC *pDC )
{
pDC->TextOut(...);
}
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Thanks for the info but I'm getting confused.
I have a have a ClientSocket::OnReceive() method that reads a CString from a socket(). I want to print this CString directly to my SDI (CView) window. Do I call OnDraw() from this method ??
Thanks again !
|
|
|
|
|
You never call OnDraw() manually. It is called by the framework when drawing needs to take place. At this point, the framework is basically asking, "What do you want to draw?".
It might be wise to read up on the relationship between the document and the view. In a nutshell, the document holds the data that the view renders, or to put it another way, the view renders the data that the document holds.
So, when you receive data via a socket, the document needs to be updated with the received data. The document, in turn, tells the view that something has changed and that a redraw is needed.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Derive your view from CEditView . Then, each time you want to append a line of text to the view, do this:
CString strTextReadBySocket = ...;
CString strText;
myEditView.GetEditCtrl().GetWindowText (strText);
strText += _T("\r\n") + strTextReadBySocket;
myEditView.GetEditCtrl().SetWindowText (strText);
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Ravi
Thanks, this works but after a while of printing text to the window I get an Out of memory errors. Is there a limit to how much data can be written to the window ??
Thanks
Gary
|
|
|
|
|
I increased by buffer size to 4096 when receiving data and the memory errors are gone.
How can I get the cursor to stay at the bottom of the window ??
Thanks
Gary
|
|
|
|
|
|
myEditView.LineScroll (myEditView.GetLineCount(), 0);
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I am trying to subclass a CEditView in an sdi app and am having a few problems.
Basically I have the above SetWindowText statment in a class which extends from CEdit.
Now If I create a CEdit control at resource time and put it on a dialog and then call
SubclassDlgItem everything is ok. However I would would really like to mimic the Visual Studio Output Window. What I did was to try and call SubClassWindow in my CEditView derived SDI view in the OnCreate Handler.
However this fails and I read I need to Call SubClassDlgItem for the CEdit Dialog obtained by GetEditCtrl() which is defined in the CView.
However how do I work out the resource id of the CEdit which is created in the CEditView?
I guess if I Create a CEdit control dynamically on a CFormView I would know the resource ID. Basically I am trying to get a general debugging routine which I can attach to any
CEdit or CEditView (Which is dynamically created). I would prefer this than a log window which is a separate window from my application.
Regards,
Axe,
|
|
|
|