|
Hello...
I am trying to make a WYSIWYG editor and for that I am using the MSHTML control (in a win32 application).
Well it works fine you can set properties of the text with the build in functions...
Than I get a text range (with IHTMLTxtRange) (i can get the text range with no problem) and modify it using pasteHTML (i am doing that to apply font properties...) (i can do what I want but maybe there is some problem here).
Well after that I cannot change anything with the built in functions... But my functions continue working...
I am thinking about the selection range... Do I have to select the whole document and out it in a range in order to edit it with the built in functions?
What may be the problem?
Thank you very much in advance for your answers...
Well... I am a beginner ...
|
|
|
|
|
Problem solved...
Well... I am a beginner ...
|
|
|
|
|
My question is related to client/server programming;
Can we communicate between client and server which have benn developed using different technologies, e.g. client using a Winsock control and server using CSocket class, or say raw winsock apis, MFC etc.
What about different plateforms
|
|
|
|
|
Normal winsock and raw winsock can work together...
CSocket should work also...
Well... I am a beginner ...
|
|
|
|
|
Hello
I have few questions related to MFC.
1. I have added a tree control and a rich edit control in Dialog based application. My aim is that when i click an item in tree control, text is displayed in rich edit control. I have modified the code of NM_CLICK event handler for a tree control. So that when i click an item in tree control, an operation is perfomed. But i have to click that item two or three times to display text in rich edit control where as text should be displayed in rich edit control by clicking item just one time. Can anyone please tell me where i am doing mistake? I have given my code below
void CTreeDlg::OnClickTree(NMHDR* pNMHDR, LRESULT* pResult)
{
CTreeCtrl* pCtrl = (CTreeCtrl*) GetDlgItem(IDC_TREE);
HTREEITEM hCurSel = pCtrl->GetSelectedItem();
if (pCtrl->GetItemText(hCurSel) == "Aqueel") // if i clicked on Aqueel in tree control
{
// displaying contents of a file in rich edit
CFile cFile(TEXT("myfile.rtf"), CFile::modeRead);
EDITSTREAM strm;
strm.dwCookie = (DWORD) &cFile;
strm.pfnCallback = WriteEditData;
m_Info.StreamIn(SF_RTF, strm);
}
*pResult = 0;
}
2. How can i clear the contents of a rich edit control.
3. After i have included a .rtf file as a resourse in my project, how can i display it in rich edit control.
Please help me
Thank you.
Aqueel A. Mirza
We Believe in Excellence
|
|
|
|
|
1) Don't handle NM_CLICK. This only works if you select a tree item
with the mouse. If you use the cursor keys to navigate around the tree,
NM_CLICK does not happen. Use
ON_NOTIFY_REFLECT( TVN_SELCHANGING, OnSelectionChanging)
ON_NOTIFY_REFLECT( TVN_SELCHANGED, OnSelectionChanged)
//this routine is called if tree item is selected.
//Set *pResult to 1 to PREVENT this item from being selected
//Set *pResult to 0 to ALLOW this item from being selected
void CMyTreeView::OnSelectionChanging(NMHDR* pNMHDR, LRESULT* pResult){
NM_TREEVIEW* pTreeView = (NM_TREEVIEW*)pNMHDR;
if(OkayToSelectThisTreeItem(pTreeView)){ //insert your own check
*pResult=0; //item will be selected
}
else{
*pResult=1; //item will not be selected
}
}
//This function is called after a tree item is successfully selected.
//It is also called numerous times when tree branch is
//expanded, collapsed, added or deleted,
//which is why deleting a branch is usually so slow.
//Note: unlike OnSelectionChanging, *pResult is NOT used here
void CMyTreeView::OnSelectionChanged(NMHDR* pNMHDR, LRESULT* pResult){
NM_TREEVIEW* pTV = (NM_TREEVIEW*)pNMHDR;
//figure out which RTF to load
//load the RTF into the window
}
To load the RTF from a file, this is easy.
You can make the RTF a new type of resource.
See http://www.codeproject.com/winhelp/myhelpdialog.asp
|
|
|
|
|
Thanks. It works perfectly
|
|
|
|
|
hi,guys,
How to set the initial position of Dialog?
Thanks.
Best Regards,
KHLin
|
|
|
|
|
Hi khlins,
In dialog proc use MoveWindow(...) on "WM_INITDIALOG" message.
This would position the dialog box where you wanted.
Have fun !
Cheers,
Vishal
|
|
|
|
|
Hi, Vishal
I got it.
Thank you very much.
Best Regards,
KHLin
|
|
|
|
|
khlins wrote:
How to set the initial position of Dialog?
In Continuation With Mr. Vishal ,
SetWindowPos(...) api will also help in this case
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Compiling...
MP3PLAYER.cpp
c:\documents and settings\administrator\desktop\sebin\mp3player\mp3playerdlg.h(14) : error C2084: function 'long __stdcall DllGetClassObject(const struct _GUID &,const struct _GUID &,void ** )' already has a body
MP3PLAYERDlg.cpp
c:\documents and settings\administrator\desktop\sebin\mp3player\mp3playerdlg.h(14) : error C2084: function 'long __stdcall DllGetClassObject(const struct _GUID &,const struct _GUID &,void ** )' already has a body
Generating Code...
Error executing cl.exe.
MP3PLAYER.exe - 2 error(s), 0 warning(s)
these are the errors i got when i compiled my project..i am doing a project to create an mp3 player which reads data bit by bit...
for playing i followed the code in the memfile in directx8..then i got some linker errors...
then i write this code at the start of my mfc project...
// DllGetClassObject
extern "C"
STDAPI DllGetClassObject (REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
AFX_MANAGE_STATE (AfxGetStaticModuleState());
return AfxDllGetClassObject (rclsid, riid, ppv);
}
when compiled i got the above said errors...
please help me...i am a beginer in mfc...and vc....
sebin
|
|
|
|
|
please someone answer me...
sebin
|
|
|
|
|
The compiler is saying that it found the definition of DllGetClassObject in both MP3PLAYER.CPP and MP3PLAYERDlg.cpp. You have included mp3playerdlg.h file in both those files and provided the implementation of DllGetClassObject in mp3playerdlg.h.
You need to have just the declaration in the header file and move the implementation to a cpp file.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hello All,
I'm using the Speech SDK inside a COM module thus:
HRESULT hr;<br />
ISpVoice * pVoice = NULL;<br />
......<br />
hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);<br />
if(! SUCCEEDED(hr)) MessageBox (NULL, "Cant load Voice",NULL,NULL);<br />
else hr = pVoice->Speak(L"Hello World", SPF_DEFAULT, NULL);<br />
......<br />
pVoice->Release();<br />
pVoice = NULL;
It compiles and - amazingly enough - works ok.
Now, if I change the 2nd parameter in Speak() to SPF_ASYNC or SPF_ASYNC | SPF_PURGEBEFORESPEAK, to call it asynchronously, thre is no sound at all.
Thanks
alex
'Architecture is music frozen in space.'
|
|
|
|
|
Maybe because you dn't appear to specifically wait for the speech to start or finish, if you go asynchronous you are calling pVoice->Release(); too soon and it never has a chance to get started.
|
|
|
|
|
That's it, thanks.
OTH, I'm trying to 'launch and forget' the TTS, but I have to call Release()before returning from the func, otherwise the speech object will never get destroyed.
All this occurs inside a shell interface, called by Explorer.
Can the speech object be global? (created at _Module.Init() and destroyed at _Module.Term()? I did try it but it caused a GPF.
Ideas anyone?
Thanks.
alex
'Architecture is music frozen in space.'
|
|
|
|
|
How about you launch a separate EXE and pass it information on what speech to say? Then when the EXE is done, it can exit, or else stay resident and you communicate with it next time.
That would allow your shell interface to 'exit' fairly quickly, and the speech will still be playing in the background.
|
|
|
|
|
Well, it is meant as a shell add-in, so i wouldn't want to complicate things.
Otherwise, i'm not fluent enough in ATL COM but it looks to me like launching a new thread might do the trick ?
The COM module could launch it, and the next time around (when it's called again by Explorer), it could check if the thread is still alive and either kill (Release) it before launching a new one (with a different message) or just wait for it to finish speaking and then..
How do we identify the 'speak' thread from one call to another?
Does it make any sense?
alex
'Architecture is music frozen in space.'
|
|
|
|
|
The problem with this is that you might have created the instance of the speech object on one thread and tried to delete it on another. COM is not happy about that.
What you might need to do is try to create a new thread when your COM object's DLL is loaded and retain that thread for the lifetime of the DLL load.
Then you can send information to that thread from the various COM objects instantiated to speak. Maybe that is worth a try. However, based on what your criteria were - asynchronous speech - I am already thinking a separate EXE is the better way to go.
|
|
|
|
|
Thank you, I will try that.
alex
'Architecture is music frozen in space.'
|
|
|
|
|
Hi.
I have not been writing socket programs long but I encountered the following:
1. How do I know if a network is available on the computer? If there is no cable in the port etc? This leads to the second problem.
2. I am using CAsyncSocket, when there is no cable connected to my computer and I try to connect, it will just sit there and never come back saying that it can not connect. IN non blocking mode, the Connect function come back with WSAEWOULDBLOCK so I know that it is trying to connect. Is there a notification that comes back when it can not connect after so much time?
3. What would happen if I was connected and then I pull out the cable, is there a notification mechanism that the connect is lost and closed? Or is there anything I can check?
4. For a server socket, what exactly does the backlog do? I thought that I can set a certain number of maximum sockets I can accept and spin off at one time? Is this correct? If I set it to 1, then once I accept this one, then the listen will stop listening until I call listen again with a new setting for backlog, right? I want to limit the number of sockets open and running for each port I listen to.
I know it is quite a mouth full up there, thanks in advance for any help.
|
|
|
|
|
Hi,
so I'll try to write something
1. Depends, I think you can try to query using WMI if the cable is plugged in (if the ethernet card is connected). Or you can try to ping to the nearest computer - usually default gateway. I think there are few articles here around that covers that. You can check the InternetCheckConnection function.
2. It should return with error value WSAETIMEDOUT . Problem is, that the timeout is quite long, so you have to wait quite long time. I think is in a range of minutes. But it can vary. You can check on telnet. Simply connect to some nonexistent site and you'll see the timeout size.
3. No. It's based on a nature of the TCP protocol (I assume you use). It's in fact connection protocol based on IP - this is packets. This means, that you can reliable only detect transfer timeouts. It's mainly not a problem that someone disconnects cable on your computer. Mostly this can happen one hop later - someone disconnects cable between switch and internet gateway, or between two switches. This is not reported to your computer. Only if you send data time to time in your connection, then you can detect the send timeout. Or you can set some timeouts on read. There's also possibility to set-up socket to do it for you by setting the alive monitoring heart-beat. But this must be supported by both sides socket provider - on client and server.
4. backlog - hm, I would say, that it's simply a size of waiting queue - after the queue is built, on one side new incomming connections are put into the queue, on other sude you get the incomming connection requests from the queue by using Accept function. If the size of the queue reaches the backlog limit, the susequent incomming connections are refused. And I'm really not sure, if you can change this limit once is set.
So enough for today, sorry for my english, it's not my native language and I don't have much opportunity to improve it at the moment.
If something is unclear, don't worry to ask for more
Hope this helps.
|
|
|
|
|
Here's what I'm trying to accomplish (and I admit right up front that I am a hobby coder and some of this stuff is over my head, but I learn best by trying something new)...
What I would like to be able to do is have an editable HTML document, except have areas that are "off limits." For example, having the top portion of the page, with logos and header stuff NOT editable, but everything below that editable.
I have read Rob Manderson's article on Using IHTMLEditDesigner[^]. I think I have a fair understanding of how it works. I posted essentially this message on the article's page, but no one has responded, so I figured I'd try here.
So what I was thinking is to set up separate sections (several sections) and set perhaps the background color of the off-limits areas to a light gray (so that the user can see what is off-limits). Then if the user clicks in or moves the cursor to an area of the document that is in the off-limits area, the editor would simply jump the cursor back out of the off-limits area -- perhaps to the first position below the off-limits area (or perhaps simply cancel the mouse-click or cursor move). I would also need to disable the ability to click and drag to highlight an area within the off-limits section.
So, the first question is: is it doable?
The second question is: how do I do it? And I don't expect you guys the write this for me, but point me in the direction of being able to track where the cursor is in the document and programmatically move it elsewhere, how to detect the background color of the element at the cursor location (or selected text in case the user clicks in an editable section and then drags into an off-limits section), etc.
I think I have a basic understanding of Rob's article, but I'm stuck as to where to go from here. I have tried just a simple modification of his demo program where I try to cancel the click in a DIV (or keydown or keypress or mousedown) instead of the ondrag, but so far to no avail. I guess my very first question is how do I cancel the user's ability to click or keypress within a DIV?
Thanks for any ideas/suggestions.
|
|
|
|
|
Well, either no one could answer this, or no one noticed the question, or no one wanted to answer it. Regardless, I did some checking and finally found one solution (although not necessarily the best nor necessarily the solution I want to use -- I'll know once I play with it more).
Anyway, one way to restrict where the user can edit, is to simply put the areas of the HTML document you want to protect into a DIV and within that tag include "contentEditable=false". E.g. "<DIV contentEditable=false>"
When you do that, what you will find is that keyboard input is cancelled within that section, even though you can highlight things. I kept the drag-cancel implemented in this article to prevent the user from dragging this DIV around. It all seems to work, except that I did notice that when you click within the protected DIV, the editor puts handles around the DIV area that allow you to resize that DIV area. I have not experimented yet to see what effect this has on the HTML document once you save it.
Anyway, just in case someone else was looking for an answer to this question, this is at least one partial answer.
|
|
|
|
|