|
Can any one tell me how to get to the selected text in an edit/richedit control (or any control having text that could be highlighted) of a foreground window from my own application? What about accessing a selected text in IE browser? One can see such use in Microsoft Boolshelf -- highlight any word in any window and then click on the QuickShelf icon in the system tray to get the meaning of the word! Tomasz Sowinski in the VC++ message board mentioned earlier using a combination of (1) calling the WIN32 API GETFOREGROUNDWINDOW to get a handle to the window and (2) sending the EM_GETSEL window message to get a pointer to the selected text. But I am not sure if this limits only to the case when the foreground window is itself a edit/richedit control.
Would appreciate very much any answers to these questions!
Gene Yu - gene4yu@yahoo.com
|
|
|
|
|
hello, I wants attach an application that I board create with a Word document or pdf,in way:whene I click on the document my application start in first.
|
|
|
|
|
:-Oi guess you will have to write something into ergistry so that your application runs whenever the word is opened or cleicked to open any document.
i don't have a clue how to do it? just in case maybe you are smart enuf to proceed if there is an idea i am writing this here. I am not sure whether this will work or not. but i guess it should.
cheers..
Himanshu
|
|
|
|
|
I tracked it down to:
BOOL CWnd::GetWindowPlacement(WINDOWPLACEMENT* lpwndpl) const
{
ASSERT(::IsWindow(m_hWnd));
lpwndpl->length = sizeof(WINDOWPLACEMENT);
return ::GetWindowPlacement(m_hWnd, lpwndpl);
}
and its at the assert that its unhappy.
I did get a non-null pointer imageDisplay that I used:
CImageDisplay* imageDisplay =m_imageDisplayVector[0];
imageDisplay->GetWindowPlacement(&wp);
Thanks
Appreciate your help,
ns
|
|
|
|
|
What is m_imageDisplayVector[0] ?? is it a valid ptr?
Where do you initialize it and what is it's value?
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
My GetActiveView is returniung a null pointer. Maybe thius is because I dont have an active view? When I run the app, it pops up with one CFormView in it which I was assuming is the so called active view> Am I right? Or do I have to do something to make a view active?
Appreciate your help,
ns
|
|
|
|
|
I had a way of getting the pView pointer but its not working anymore. I posted on anotehr thread. What I would like is to get a fresh sample or pointer on how to get to the view class members from the mainframe. Its a CFormView based MDI project with only 1 doc and only 1 view at this stage.....
Appreciate your help,
ns
|
|
|
|
|
hi,
i am poking aroung at a tabcntl, and i was wondering if theres a way to attach an individual dialog resource to each tabcntl tab?
seems like the easiest way for me to edit my tabs would be this way.
can it be done?
todo....
:: insert inpirational text here ::
|
|
|
|
|
You may want to check this[^] out.
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
I would like to draw some text then outline it with a black border. How does one do something like this?
Christian Graus are you reading this? You seem to be a graphics wizard
Cheers,
Clint
|
|
|
|
|
use GetTextExtent or DrawTextEx with the DT_CALCRECT flag to find the size of the text. then draw a rect of the appropriate size at the appropriate place. that's a rectangular border.
if you actually want an outline around the individual characters (like you might find in a graphics package), then you're in for some work. one way is to draw it slightly larger in black, then draw normal size on top - one character at a time. or, you could draw the text, use some kind of filter to detect the border, overlay the images, etc..
-c
I'm not the droid you're looking for.
|
|
|
|
|
Could I draw the whole string slightly larger than one I overlay or do I have to do the characters one at a time?
Cheers,
Clint
|
|
|
|
|
if you draw the whole string, you could run into alignment problems, since the spacing between characters may be different between the two font sizes. but, it might be worth a shot.
-c
I'm not the droid you're looking for.
|
|
|
|
|
One fairly easy solution is just to draw your text 4 times in black, offset by one pixel in each direction, then once in your desired colour in the middle
i.e.
Text( x-1,y, "Hello", BLACK )
Text( x+1,y, "Hello", BLACK )
Text( x,y-1, "Hello", BLACK )
Text( x,y+1, "Hello", BLACK )
Text( x,y, "Hello", WHITE )
or you could just use a for loop if you want a thicker border
Obviously this all relies on your text rendering code being nice and fast, but if you're using anything modern then it should be
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
I'm working in C and would like to be able to use the SHBrowseForFolder to have a folder browser. I used the following code:
void FolderDialog(HWND hDlg, int msgField)
{
IMalloc * pMalloc;
if ( SHGetMalloc(&pMalloc) == NOERROR )
{
BROWSEINFO bi;
char pszBuffer[MAX_PATH];
LPITEMIDLIST pidl;
bi.hwndOwner = hDlg;
bi.pidlRoot = NULL;
bi.pszDisplayName = pszBuffer;
bi.lpszTitle = "Select Directory";
bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
bi.lpfn = NULL;
bi.lParam = 0;
if ((pidl = SHBrowseForFolder(&bi)) != NULL)
{
if (SHGetPathFromIDList(pidl, pszBuffer))
{
SetDlgItemText(hDlg, msgField, pszBuffer);
}
pMalloc->Free(pidl);
}
pMalloc->Release();
}
}
I get the following two errors:
error C2039: 'Free' : is not a member of 'IMalloc'
(846) : see declaration of 'IMalloc'
error C2039: 'Release' : is not a member of 'IMalloc'
(846) : see declaration of 'IMalloc'
If I remove the Free and Release statements the program execute fine but I would rather not have that kinda leakage going on. Any suggestions would be much appreciated.
Thanks
|
|
|
|
|
Use the vtable explicitly.
pMalloc->lpVtbl->Free()
The price you will pay for skipping ++
"You can stand all night at a redlight anywhere in town, hailing Marys left and right but none of them slow down. I've seen the best of men go past. I don't wanna be the last..."
|
|
|
|
|
Stefan,
I did something similar earlier but now I get the following errors:
error C2198: 'function through pointer' : too few actual parameters
error C2198: 'function through pointer' : too few actual parameters
Believe me I would have much rather done this in civilized code but its not my call.
Thanks
|
|
|
|
|
Ok Stefan,
You were right, sorry about the hassle. I found the explanation to my question here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/intro/program/com/usingc.asp
Should have researched more before I opened my mouth.
Basically using COM with C requires an extra level of indirection + an additional parameter which points to the interface...
so in my case, this works:
pMalloc->lpVtbl->Free(pMalloc,pidl);
}
pMalloc->lpVtbl->Release(pMalloc);
Thank you much
Nadim
|
|
|
|
|
THis is an MFC MDI app. I get the msgBox for :
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame->GetActiveFrame();
CResizeSonarViewBoxView *pView = (CResizeSonarViewBoxView *) pChild->GetActiveView();
if(pView == NULL)<code>AfxMessageBox("Null pView")</code>;
I only have the one view so far. Whats is wrong and how do I fix it?
ACtually how do I go about tracking down this problem?
Thanks
Appreciate your help,
ns
|
|
|
|
|
Hello,
For MDI you have to do it another way....
<br />
CView * SomeClass::GetActiveView(void)<br />
{<br />
POSITION pos;<br />
CMDIChildWnd *pChild;<br />
CDocument *pDoc;<br />
CView* pView;<br />
CMainFrame *pFrame;<br />
<br />
pFrame = (CMainFrame *) AfxGetMainWnd();<br />
ASSERT(pFrame!=NULL);<br />
pChild = pFrame->MDIGetActive();<br />
ASSERT(pChild != NULL);<br />
pDoc = pChild->GetActiveDocument();<br />
ASSERT(pDoc != NULL);<br />
pos = pDoc->GetFirstViewPosition();<br />
ASSERT(pos != NULL);<br />
pView = pDoc->GetNextView(pos); <br />
return pView;<br />
}<br />
Hope that helps,
Paul...
|
|
|
|
|
I see what you are doing. But the sample I have trouble withis actually from a working program that I put together last year..............it works great there! I wonder why.
I'll do your method in this project though I am very very puzzled!
Appreciate your help,
ns
|
|
|
|
|
The one thing that might be the problem is that my old project where the code I posted, has two views. In this curent code I only have 1 view.....Could that be the problem?
Appreciate your help,
ns
|
|
|
|
|
Crashed at the assert:
POSITION pos;
CMDIChildWnd *pChild;
CDocument *pDoc;
CResizeSonarViewBoxView* pView;
CMainFrame *pFrame;
pFrame = (CMainFrame *) AfxGetMainWnd();
ASSERT(pFrame!=NULL);
pChild = pFrame->MDIGetActive();
<code>ASSERT</code>(pChild != NULL);
Thanks
Appreciate your help,
ns
|
|
|
|
|
Hi,
What happened to the..
pDoc->GetFirstViewPosition();<br />
part of the code???
|
|
|
|
|
Crashed before it got there! Thtas why Ididnt paste that part....
Appreciate your help,
ns
|
|
|
|