|
clipped from MSDN:
Title: Edit Controls
Kyle Marsh
Microsoft Developer Network Technology Group
Created: January 31, 1992
after a seach on "GetCaretPos"
[ clip follows ]
Finding the Caret Position
An application can perform the following steps to determine the current position of the caret:
{
WORD wLineNumber;
WORD wLineIndex;
WORD dwGetSel;
WORD wStart;
WORD wEnd;
WORD wColNumber;
char szBuffer[128];
wLineNumber = (WORD)SendMessage(GetDlgItem(hWndDlg,IDEDIT),
EM_LINEFROMCHAR, -1, 0L);
// Send the EM_GETSEL message to the edit control.
// The low-order word of the return value is the character
// position of the caret relative to the first character in the
// edit control.
dwGetSel = (WORD)SendMessage(GetDlgItem(hWndDlg,101), EM_GETSEL,
0, 0L);
wStart = LOWORD(dwGetSel);
// Send the EM_LINEINDEX message with the value of -1 in wParam.
// The return value is the absolute number of characters
// that precede the first character in the line containing
// the caret.
wLineIndex = (WORD)SendMessage(GetDlgItem(hWndDlg,101),
EM_LINEINDEX, -1, 0L);
// Subtract the LineIndex from the start of the selection,
// and then add 1 (since the column is zero-based).
// This result is the column number of the caret position.
wColNumber = wStart - wLineIndex;
sprintf(szBuffer,"Caret at Line:%d Column:%d", wLineNumber+1,
wColNumber+1);
MessageBox(hWndDlg, szBuffer, "Current Caret Position",
MB_APPLMODAL);
}
hope that helps
Just trying to keep the forces of entropy at bay
|
|
|
|
|
Hi
I'm new to VC from a Delphi background, and would like to know how to call new modals (dialogs) and work on them, as you would in Delphi:
NewModal.ShowModal;
thanks
D
|
|
|
|
|
It is a two-step procedure in VC++:
CYourDlg dlg;
dlg.DoModal();
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
o ok, that's almost the same!
thanks
|
|
|
|
|
hello again
I'm trying to use the MS WebBrowser control in a dialog based application I'm making and I'm having the problem that I need to get access to the HTML code so I can work with it inside the program. The interface and most of the supporting stuff is looking good but I can't grast this final problem. It doesn't help that I'm no COM wizard but I'm always willing to learn
Thanks guys
|
|
|
|
|
You've probably dropped the IE ocx onto your dialog.
To get the Html from the current web page, you just need to call this method :
HRESULT IWebBrowser2::get_Document(IDispatch** ppDisp);<br />
It returns a IDispatch interface which actually you can cast to IHTMLDocument2. This one is the DOM, ie provides access to the html tags hierarchy.
sometimes it helps to look at the IL generated code
a MS guy on develop.com "answering" .NET issues
|
|
|
|
|
Fantastic stephane, can't thank you enough Thats just the sort of answer I was looking for.
Thanks again.
|
|
|
|
|
Note a lot of folk have trouble trying to use it, because they don't wait for the DocComplete to fire before altering the page.
Try searching the old MSJ for articles by Scott Roberts also, might help.
Regardz
Colin J Davies
Sonork ID 100.9197:Colin
You are the intrepid one, always willing to leap into the fray! A serious character flaw, I might add, but entertaining.
Said by Roger Wright about me.
|
|
|
|
|
hehe, a sneaky bit of info hidden in the periodicals, thanks for pointing it out Colin, I'm sure its going to come in handy
Thanks guys, you're stars
|
|
|
|
|
Hello,
I want to use drag and drop using VC++. But I don't know how/What to use namespeace. Please help me.
thanks
|
|
|
|
|
Check out some of the code/samples under "Clipboard" on the left-hand side section in "MFC" -- there's a lot of drag-n-drop stuff in there to help you get started. MSDN also has some good samples also, depending on what you want to do.
Also, check out this link: Drag -n- Drop between controls . This is a class I use, and is simple to understand and modify...
Good luck!
"If at any time I announce that a nation or kingdom is to be uprooted, torn down and destroyed, and if that nation I warned repents of its evil, then I will relent and not inflict on it the disaster I had planned. And if at another time I announce that a nation or kingdom is to be built up and planted, and if it does evil in my sight and does not obey me, then I will reconsider the good I had intended to do for it." -- Jeremiah 18:7-10 (God, commenting on the value of the United Nations)
|
|
|
|
|
I have a vector vec of structures. The structure has two members: a long nSize, and a CString fileName.
Now I get these two values on the fly and want to push them onto the vector. Had it been a vector of a single variable, I'd just do vec.push_back(myVAr) . But how do I push_back two elements of my structure into a single vector element?
Appreciate your help,
ns
|
|
|
|
|
Make sure your structure has a constructor which inits the members, like foo(long sz, CString name):nSize(sz), fileName(name).
Then, do something like:
vec.push_back(foo(sz, name));
"If at any time I announce that a nation or kingdom is to be uprooted, torn down and destroyed, and if that nation I warned repents of its evil, then I will relent and not inflict on it the disaster I had planned. And if at another time I announce that a nation or kingdom is to be built up and planted, and if it does evil in my sight and does not obey me, then I will reconsider the good I had intended to do for it." -- Jeremiah 18:7-10 (God, commenting on the value of the United Nations)
|
|
|
|
|
....some thing like:
#include <string>
#include <vector>
using namespace std;
// defined types
//
typedef struct _tagMyThing
{
// make this whatever you want.....for ex:
long lValue;
string oValue;
}
MY_THING, *P_MY_THING;
typedef vector< P_MY_THING > MY_VECTOR;
typedef MY_VECTOR::iterator MY_VECTOR_ITER;
// declare variable of type MY_VECTOR
//
MY_VECTOR m_oVector;
// fill it....
//
P_MY_THING pxThing = new MY_THING;
...
...
m_oVector.push_back( pxThing );
// looping...
MY_VECTOR_ITER oIter;
for( oIter = m_oVector.begin();
oIter != m_oVector.end();
oIter++ )
{
P_MY_THING = (*oIter);
...
...
}
Just trying to keep the forces of entropy at bay
|
|
|
|
|
I guess you are showing how to 'read' it back out...
MY_VECTOR_ITER oIter;
for( oIter = m_oVector.begin();
oIter != m_oVector.end();
oIter++ )
{
P_MY_THING = (*oIter);
...
...
}
This line is puzzling me:
P_MY_THING = (*oIter);
Its assigning to a type? MAybe you meant P_MY_THING abc = (*oIter);
??
A big thank you for the loading part!
Appreciate your help,
ns
|
|
|
|
|
yeah...that was a typo on my part...saw it after i pushed the 'submit button' .... good though that you got what i *meant* there
Just trying to keep the forces of entropy at bay
|
|
|
|
|
What I need to do is create a form view SDI app that has two different forms seperated by a splitter control. Well maybe I do. What I need is a top window that is stationary and a lower window that the user can scroll. What it is is a form that I want the header to always stay on top and in view. Just like some excel sheets do. Is this possible? What is the easiest way of implimenting this? I already have an SDI form view with a splitter control but the 2 panes are of the same window. I have already done a few searches but I think I am looking for the wrong thing. Thanks for your help.
Darroll
Not one person lives in the present. Only the past. I can prove it.
|
|
|
|
|
Check out: Reusable base class for SplitterWnd here in CodeProject. What you can do is not allow the top form to be resized in the class by handling WM_SIZE appropriately, and just swap out the bottom pane.
"If at any time I announce that a nation or kingdom is to be uprooted, torn down and destroyed, and if that nation I warned repents of its evil, then I will relent and not inflict on it the disaster I had planned. And if at another time I announce that a nation or kingdom is to be built up and planted, and if it does evil in my sight and does not obey me, then I will reconsider the good I had intended to do for it." -- Jeremiah 18:7-10 (God, commenting on the value of the United Nations)
|
|
|
|
|
Thank you. I was so new at SDI FormView apps, too many Dialog apps, I missed that whole section. Thank you.
Darroll
Not one person lives in the present. Only the past. I can prove it.
|
|
|
|
|
The map is (long, char*). I get a char* buffer tempB from a CFile read, of size nSize .
CAn I do aMap[nSize] = tempB ? i.e. assign it with the = sign?
or do I have to allocate memory for the maps second element or something and do a strcpy?
I would have avoided char* and used CStrings but it looks like the Write for CFile needs a pointer to a buffer....
In case my question isnt clear...we cant assign char* with the = sign, it has to be strcpy. SO in the case of my map, do I allocate ,memory to *it.second() and strcpy?
Appreciate your help,
ns
|
|
|
|
|
You can still use CString.
<br />
CString csWrite(_T("Hello World"));<br />
CFile cFile;<br />
<br />
cFile.Open(...);<br />
cFile.Write((void*)(LPCTSTR)csWrite, csWrite.GetLength());
|
|
|
|
|
Thanks so much for telling me CString works! I was going through hoops wqith strcpy and all that mess. Thank you very very much!
Appreciate your help,
ns
|
|
|
|
|
Can I use the same trick with Read?
CString abc;
cFile.Read((void*)(LPCTSTR)abc, abc.GetLength());
Appreciate your help,
ns
|
|
|
|
|
int n=S.GetLength(); // this is icky
S.ReleaseBuffer(File.Read(S.GetBuffer(n),n));
|
|
|
|
|
Oh. So I dont need the LPTCTSR thing for read because GetBuffer returns the pointer to the string? Thanks for the compact coding.
Appreciate your help,
ns
|
|
|
|