|
you will need to setup a handler for a message that is reflected from the tree view back to the parent. Check this message, NM_RCLICK. Then you need to use the tree controls hittest functions to determine if the mouse position is on one of the nodes in question. Once you have that you can display your context menu. Hope that helps. For more info search msdn for the NM_RCLICK message and also lookup message reflection for a broader overview of the topic. Good luck.
Joseph Dempsey
joseph_r_dempsey@yahoo.com
"Software Engineering is a race between the programmers, trying to make bigger and better fool-proof software, and the universe trying to make bigger fools. So far the Universe in winning."
--anonymous
|
|
|
|
|
I've got a program that uses mail slots. My problem is that when I send a mail message to the local machine the message is recieved twice. I have narrowed this down to my sending code by changing it to send to the microsoft messenger service. The messeneger service recieves the message twice too. However, it I use net send to send the message it is only recieved once. I think net send uses the NetMessageBufferSend function, but I should still only recieve once. If I send to a remote machine with the same code, it is only recieved once. I have tested it on two machines and both have the problem. My code to send is as follows:
{
int nResult;
HANDLE pHandle;
DWORD dwBytesSent;
CString strMailslotName;
strMailslotName = _T("\\\\");
strMailslotName += m_sComputerName;
strMailslotName += _T("\\mailslot\\messngr");
pHandle = CreateFile( strMailslotName, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
if( pHandle == INVALID_HANDLE_VALUE )
{
AfxMessageBox("Error accessing mail slot \"" + strMailslotName + "\"");
CloseHandle( pHandle );
return;
}
else
{
nResult = WriteFile( pHandle, strMsgText, ( DWORD )strMsgText.GetLength(), &dwBytesSent, NULL );
if( nResult == 0 || ( DWORD )strMsgText.GetLength() != dwBytesSent )
{
CString Error;
LPVOID lpMsgBuf;
if (!::FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0,
NULL ))
{
AfxMessageBox("An unknown error occured.");
}
else
{
Error = "Error writing to mailslot: ";
Error += (LPCTSTR)lpMsgBuf;
AfxMessageBox(Error);
}
LocalFree( lpMsgBuf );
}
}
CloseHandle( pHandle );
}
Any ideas whats wrong with this? I don't see how it could be sending two messages. m_sComputerName is the local computer's name.
Thanks for you help!
|
|
|
|
|
This is actually by design. Sending on a mailslot goes across all the available protocals installed on the machine. This means if you have both TCP/IP and IPX installed, you'd get two messages. If you peruse the documentaion more carefully you'll see that this is documented. You need to include some kind of ID with the message to you can throw out duplicates. Also note that this protocal does not ensure order of deliverly. Just because msg 1 went out before msg 2 doesn't mean you'll get msg 1 before msg 2. In testing i've found that 99% of the time you'll get them in order, but the documentation say's it this isn't guaranteed. If you need further help, let me know.
Joel Lucsy (jjlucsy@concentric.net)
|
|
|
|
|
How do I specify the Rect tangle for my new CViews?
I have tried this ...
<br />
void CMyView::OnDraw(CDC* pDC)<br />
{<br />
COragomy_IIDoc* pDoc = GetDocument();<br />
ASSERT_VALID(pDoc);<br />
<br />
CRect rect = new CRect( 0, 0, 320, 200 );<br />
pDoc->m_clientRect = rect;<br />
... but it doesn't work.
|
|
|
|
|
Actually the code looks like this ...
<br />
void CMyView::OnDraw(CDC* pDC)<br />
{<br />
COragomy_IIDoc* pDoc = GetDocument();<br />
ASSERT_VALID(pDoc);<br />
<br />
CRect rect = new CRect( 0, 0, 320, 200 );<br />
pDoc->m_clientRect = rect;<br />
<br />
|
|
|
|
|
i want to start a local process that should be started by loading the executable located on the remote computer into local memory.
i am sharing the folder on the remote machine.but it could not be started.
can any body tell the sample code of running a process at network path?
i will be very thank full to you.
r00d0034@yahoo.com
|
|
|
|
|
Try to see what exact error you've got. I used ShellExecute and it worked fine wherever the file is located
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
|
Hello,
I am trying to create an email application in which users send HTML emails to one another. I am debating at present how to create the GUI for when a user composes the email. The problem is that I have to convert the email when it is sent, into HTML.
I first thought of CRichEditView, but that can't convert a formatted message into HTML. I looked at CHTMLView, but I think that all this does is provide a read-only browsing service with the Web Browser control.
Is there any way I can use CHTMLView to convert a text message into HTML? Or does anyone know of a library/DLL which can parse formatted text into HTML?
I would be very grateful for guidance here.
Thanks,
Trimtrom
|
|
|
|
|
Formatted text can easily be converted into HTML depending
on exactly what you want. For example,
CString convertToHTML(CString s)
{
return CString("<PRE>") + s + "</PRE>";
}
will do it. However, that doesn't allow the browser to reformat
line breaks. to do that simply search your string for any
blank lines (use the Find function in CString) and replace them
with "<p>".
Oh, and one other thing, you might have to hack grough the
string replacing special characters with their equivelents
in HTML. Specifically "<" with < ">" with > and " with
" (?? not sure of the exact spelling of this.)
Note that you don't need to put all the <HTML>, <HEAD> or
<BODY> tags as they are all optional. Though theoretically,
but not in practice, you are supposed to start all HTML with
the following tag:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
(assuming you are using English.)
If you need more complex formatting, you need to pull together
some sort of GUI to manipulate the text (i.e., have a bold button
insert <b></b>) If that is the case you need to look at
CHTMLEditCtrl.
HTH
|
|
|
|
|
Thanks for the reply.
I am using Visual C++ 6.0, and I have had a look all over the Help, and I can't find anything on CHTMLEditCtrl. Did this come in with version 7.0?? It sounds like something I would want.
I think basically I am looking for some control to turn text into HTML the same way the RichEditCtrl writes RTF files.
Any comments appreciated,
trimtrom
|
|
|
|
|
Check MSDN, it'll give you the info you need.
|
|
|
|
|
umm how do i convert c++ to hex?
or does anyone have a program that will do it for me?
|
|
|
|
|
what does "convert c++ to hex" mean?
-c
There's one easy way to prove the effectiveness of 'letting the market decide' when it comes to environmental protection. It's spelt 'S-U-V'.
--Holgate, from Plastic
|
|
|
|
|
I think he can't find a "Build" button in his VC
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
|
LOL
Cheers
Kannan
|
|
|
|
|
Yeah, the program called Visual Studio. Just press F7 in it
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
|
|
|
|
|
LOL, that's exactly what I thought
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
[edit]N/m, DEFAULT_GUI_FONT works, although SYSTEM_FONT doesn't for some reason. [/edit]
I'm baffled.
I have a scenario like this:
I have a splitter window. One pane contains a window, written by me, which itself hosts two windows - one list control and one window written by me. It's in this last window my problems occur.
In the WM_PAINT handler I do the usual CPaintDC dc(*this) and then I get on with the actual drawing. I want to draw some text (using DrawText ) using the default gui font. So i HFONT hOldFont = dc.SelectObject((HFONT)GetStockObject(DEFAULT_GUI_FONT)) . But guess what? It's not the default gui font (Tahoma)! It's that damn fixed font. I also tried with SYSTEM_FONT to no avail. I did try OEM_FIXED_FONT which gave me Courier which seems ok according to the MSDN docs. GetStockObject() does not return NULL. I'm stumped! Have I missed some initialization, window style, window class style, or something?
--
Only in a world this sh*tty could you even try to say these were innocent people and keep a straight face.
|
|
|
|
|
It seems as if I posted this in the wrong forum, but I think it's in the right forum. I think the error is related to windows in general, not the toolkit.
--
Only in a world this sh*tty could you even try to say these were innocent people and keep a straight face.
|
|
|
|
|
I get weird results from this code:
void CGDlg::OnButton1()
{
WIN32_FIND_DATA wfd;
HANDLE hRes = FindFirstFile("C:\\Documents and Settings\\dator19\\Skrivbord\\MUMMEL\\*.txt", &wfd);
BOOL bOk = (hRes != INVALID_HANDLE_VALUE);
while(bOk)
{
bOk = FindNextFile(hRes, &wfd);
m_ListBox1.AddString(wfd.cFileName);
}
}
I have 4 files (1.txt, 2.txt, 3.txt and 4.txt) in the directory but when I show the filnames in a listbox (m_ListBox1) the output is:
2.txt
3.txt
4.txt
4.txt
Hmm... what is wrong!
It should be:
1.txt
2.txt
3.txt
4.txt
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
FindFirstFile actually gives you a file - you need to add that to your list, too.
There's one easy way to prove the effectiveness of 'letting the market decide' when it comes to environmental protection. It's spelt 'S-U-V'.
--Holgate, from Plastic
|
|
|
|
|
That fixed one bug... but it still print out the last file two times;
1.txt
2.txt
3.txt
4.txt
<code>4.txt <-- Damn %¤#"¤#¤&!!!</code>
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Try reversing the code in the while block
while(bOk)
{
m_ListBox1.AddString(wfd.cFileName);
bOk = FindNextFile(hRes, &wfd);
}
------- signature starts
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Please review the Legal Disclaimer in my bio.
------- signature ends
|
|
|
|
|
John Simmons / outlaw programmer wrote:
Try reversing the code in the while block
YES!!
Thanks!
void CGDlg::OnButton1()
{
WIN32_FIND_DATA wfd;
HANDLE hRes = FindFirstFile("C:\\Documents and Settings\\dator19\\Skrivbord\\MUMMEL\\*.txt", &wfd);
BOOL bOk = (hRes != INVALID_HANDLE_VALUE);
while(bOk)
{
m_ListBox1.AddString(wfd.cFileName);
bOk = FindNextFile(hRes, &wfd);
}
}
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
May I ask one more question: If I change to *.* instead of *.txt it adds .. and ... into the listbox. What's that?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|