|
MoveWindow() ???
Ninety-eight percent of the thrill comes from knowing that the thing you designed works, and works almost the way you expected it would. If that happens, part of you is in that machine.
|
|
|
|
|
I don't want to use firewall to reject SYN connection.
Can I use SPI(service provider interface )to achieve reject connection ?
If could make it,please tell me how to do it.
Thanks a lot.
|
|
|
|
|
I am not quite sure what your question is -- are you just trying to reject incoming tcp connects?
Take a look at the WSAAccept() function. It let's you filter incoming connection attempts -- either accepting or rejecting.
This all assumes I interpreted your question correctly.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
Thanks for your help.
My problem is solved.
|
|
|
|
|
I am trying to present data that its maximum length is 2000 characters using a CListCtrl.
I am using the LVN_GETDISPINFO event, so I can change the cchTextMax to 2000 and point pszText to a buffer that contains the 2000 characters to be presented.
Even though I am permitted to change, when presenting it the data is always truncated in 260 characters.
How to change it for being able to present the complete text?
Thank you for your help,
magda.
|
|
|
|
|
Your data should be fine, this is only an inability by CListCtrl to *display* more than 260 characters. Interestingly MAX_PATH is 260, ListView was designed for Explorer so it seems like a hardcoded limitation.
You can get around this by doing custom drawing. If your using WTL I'm going to have to vouch for my article on the subject. http://www.codeproject.com/wtl/ListView_OwnerDraw.asp[^]
|
|
|
|
|
Thank you for your reply!!
I will look at your link and I will bother you, if I need more help!!
Thank you again!
magda.
|
|
|
|
|
Good afternoon dear CPians,
i'm facing a problem with a popup menu (MFC programming, VS7.1). here is what i'm trying to do :
i have a vector that's been filled with several Phone numbers of a particuliar person.
what i need is creating a popup menu that is displayed next to the button clicked to display it.
the popup menu is supposed to contain all the entries of the vector...
<font color=blue>void</font> CFactEditorDlg::OnSClickShowNumbers() {
<font color=blue>using namespace</font> std;
vector<CString> vPersonNumbers;
<font color=green>
<font color=blue>if</font> (vPersonNumbers.size() != 0) {
CMenu PhonesMenu;
<font color=blue>if</font> (PhonesMenu.<font color=red>CreatePopupMenu()</font>) {
vector<CString>::const_iterator itvPhoneNumbers;
<font color=blue>int</font> iCpt = 1;
<font color=blue>for</font> (itvPhoneNumbers = vPersonNumbers.begin();
itvPhoneNumbers != vPersonNumbers.end();
itvPhoneNumbers++, iCpt++) {
PhonesMenu.AppendMenu(MF_STRING, iCpt, *itvPhoneNumbers);
}
CRect rect;
m_pbShowNumbers->GetWindowRect(&rect); <font color=green>
PhonesMenu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, rect.right, rect.top, AfxGetMainWnd());
}
}
}
the CMenu::AppendMenu() i call give me an Unhandled exception , but no more description.
i'm certainly using CMenu the wrong way, but i cannot find any good tutorial to just create a popup menu dynamically (dynamic content) and display the place i want (by the side of the button that calls it)...
did anyone ever encounter such a problem, or know how to solve this ?
now, i would like to recover the item the user click on to put it into an EditBox...
anyone ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
You need to call PhonesMenu.CreateMenu() before you can AppendMenu()
|
|
|
|
|
i did it (see the previous post to see the updates in the code), but i still have an Unhandled/Undescribed exception
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Try:
for (itvPhoneNumbers = vPersonNumbers.begin();<br />
itvPhoneNumbers != vPersonNumbers.end();<br />
itvPhoneNumbers++, iCpt++) {<br />
PhonesMenu.AppendMenu(MF_STRING, iCpt, *itvPhoneNumbers);<br />
}
|
|
|
|
|
thank you very much for that help... that point work quite fine now.
i say quite because the popup is drawn, but so thin that i can't read if there are items on (it is about 2 or 3 pixels wide) ; but high enough though.
moreover, when i click on the last item of the menu, it ends the program returning an
Run-Time Check Failure #2 - Stack around the variable 'dlg' was corrupted.
into InitInstance() (it is a dialog based application).
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I don't know what happen to your stack, however the thin menu is because your popping up the menu, you want to popup a popup of the menu. Try this:
CMenu popup_menu = PhonesMenu.GetSubMenu(0);
popup_menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, rect.right, rect.top, AfxGetMainWnd());
|
|
|
|
|
no more luck
i added this to my code
CMenu* popup_menu = PhonesMenu.GetSubMenu(0);
popup_menu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, rect.right, rect.top, AfxGetMainWnd());
but popup_menu is handling NULL pointer, and so, calling TrackPopupMenu() is crashing...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Sorry, remember when I told you to use CreateMenu()? Try calling CreatePopupMenu(). Also remember when I told you to call GetSubMenu(), that doesn't matter anymore with CreatePopupMenu(). Yeah I know, sorry, I never made it out of highschool.
CMenu popup_menu;<br />
popup_menu.CreatePopupMenu();<br />
<br />
popup_menu.AppendMenu(MF_STRING, 2, _T("I know they're stolen"));<br />
popup_menu.AppendMenu(MF_STRING, 3, _T("But I don't feel bad"));<br />
<br />
CRect rect;<br />
<br />
popup_menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, rect.right, rect.top, AfxGetMainWnd());
|
|
|
|
|
hello again mark,
ok, that's ok now. here is what i did during the last hour (when the server of my school was off ). actually, you were right with CreatePopupMenu() but i found it by myself, as you aswered at 15' ...
see the first post on that thread for the working function...
now, the popup displays correctly, and its content is perfectly and fully dynamic : i select someone in a combobox and all his phone numbers are listed on the popup menu. What i would like so is to be able to copy the number the user click on into its related EditBox...
I however don't know how to dynamically assign such a behavior to the menu and its items...
anyway, thanks for your help.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Handle WM_COMMAND, the ID will be the ID you passed to AppendMenu(), if the CMenu is global you can query it for it's text, or use the ID to look up the string vector directly.
|
|
|
|
|
hello Mark,
i ended the taff on that menu... it works now.
however, i think there might be a better to do it, but as i could find out how, here is what i did :
FactEditor.h :
<font color=blue>class</font> CFactEditorDlg : <font color=blue>public</font> CDialog {
<font color=green>
<font color=blue>protected</font>:
<font color=green>
std::vector<CString> m_vPersonPhoneNumbers;
<font color=blue>bool</font> m_bPhonesMenuCalled;
<font color=green>
};
FactEditor.cpp :
<font color=blue>void</font> CFactEditorDlg::OnSClickShowNumbers() {
<font color=blue>using namespace</font> std;
m_vPersonPhoneNumbers.clear();
map<CString, TOperatorPersonPair>::const_iterator itmPersonNumbers;
<font color=green>
<font color=blue>for</font> (itmPersonNumbers = m_mapPhoneWithOpPersPair.begin();
itmPersonNumbers != m_mapPhoneWithOpPersPair.end();
itmPersonNumbers++) {
<font color=blue>if</font> (itmPersonNumbers->second.m_strPerson == m_strCalledPerson) {
m_vPersonPhoneNumbers.push_back(itmPersonNumbers->first);
}
}
sort(m_vPersonPhoneNumbers.begin(), m_vPersonPhoneNumbers.end());
<font color=green>
<font color=blue>if</font> (m_vPersonPhoneNumbers.size() != 0) {
CMenu PhonesMenu;
<font color=blue>if</font> (PhonesMenu.CreatePopupMenu()) {
vector<CString>::const_iterator itvPhoneNumbers;
CString strRes, strMenuTitle;
strRes.LoadString(IDS_FACTEDITORDLGTITLE);
strMenuTitle.Format(strRes, m_strEditorVersion);
PhonesMenu.AppendMenu(MF_STRING, 1, strMenuTitle);
PhonesMenu.AppendMenu(MF_SEPARATOR);
<font color=blue>int</font> iCpt = 3;
<font color=blue>for</font> (itvPhoneNumbers = m_vPersonPhoneNumbers.begin();
itvPhoneNumbers != m_vPersonPhoneNumbers.end();
itvPhoneNumbers++, iCpt++) {
PhonesMenu.AppendMenu(MF_STRING, iCpt, *itvPhoneNumbers);
}
CRect rect;
m_pbShowNumbers->GetWindowRect(&rect);
PhonesMenu.EnableMenuItem(1, MF_GRAYED);
m_bPhonesMenuCalled = <font color=blue>true</font>;
PhonesMenu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, rect.right+1, rect.top-1, AfxGetMainWnd());
}
}
}
BOOL CFactEditorDlg::OnCommand(WPARAM wParam, LPARAM lParam) {
<font color=blue>if</font> (HIWORD(wParam) == (UINT)0) { <font color=green>
<font color=blue>if</font> (m_bPhonesMenuCalled) { <font color=green>
m_peCalledNumber->SetWindowText(m_vPersonPhoneNumbers[LOWORD(wParam)-3]);
m_bPhonesMenuCalled = <font color=blue>false</font>;
}
}
<font color=blue>return</font> CDialog::OnCommand(wParam, lParam);
}
as you see, i use a boolean flag to test is the WM_COMMAND is sent by my popup or another menu because i couldn't find other way to test it.
i also wanted to put the menu as a member of the class, but here again, no way to turn the new incoming exceptions off... i think i had to do with DestroyMenu() and/or Attach() /Detach() , but where to put them, and how to use them ???
well, i'd like to thank you very much for you help, it was very good, and quite fast too !!
thanks
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Usually what I do with a dynamic menu like that is have a begining ID range and an ending ID range, I define this in the resource header like
#define ID_DYNAMIC_MENU_BEGIN 3000
#define ID_DYNAMIC_MENU_END (ID_DYNAMIC_MENU_BEGIN + 100)
I then call AppendMenu with ID_DYNAMIC_MENU_BEGIN + index;
That would get rid of your m_bPhonesMenuCalled flag because you can just check the wParam to see if it's the range. To get an index use wParam - ID_DYNAMIC_MENU_BEGIN.
Attach()/Detach() are unwanted since they are for menus that already exist. You do however have a resource leak in that you never destroy the menu. After your TrackPopupMenu() you should call DestroyMenu(), with that in place I see no reason for you to Assert by using a CMenu as a member. You were probably ASSERTing by calling CreatePopupMenu() twice without a DestroyMenu().
You ask good questions.
|
|
|
|
|
Mark Petrik Sosa wrote:
Usually what I do with a dynamic menu like that is have a begging ID range and an ending ID range, I define this in the resource header
i cannot do that as i don't know how many items will be placed into the menu when i populate it (it depends on what person is selected to show its phne numbers)...
Mark Petrik Sosa wrote:
That would get rid of your m_bPhonesMenuCalled flag because you can just check the wParam
i don't agree, it could exist several menus in a bigger application than mine that have ID defined twice... i should better have a menu handle.
Mark Petrik Sosa wrote:
You were probably ASSERTing by calling CreatePopupMenu() twice without a DestroyMenu().
yes, that's it, but were to place DestroyMenu() so ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
TrackPopupMenu() blocks until they select something or it loses focus and goes away so you can call DestroyMenu() right after TrackPopupMenu().
|
|
|
|
|
here is my code:
<br />
void CChildView::SortData(LPCTSTR pszData)<br />
<br />
ofstream testFile ("test.txt", ios::app);<br />
testFile << pszData;<br />
The Problem is that it saves the pointer address, 0x00421DA8
and what I want it to do is save the character that is recieved by pszData.
How do I do that?
Thanks,
|
|
|
|
|
pszData is a pointer, you must dereference it to use it's contents.
testFile << *pszData;
|
|
|
|
|
I have tried using *pszData. But when I use that, it gives me numbers, a being 97, b 98, c 99, and so on...
pszData is Unicode, I believe. I don't realy understand the string converstions.
|
|
|
|
|
Looks like you have a Unicode string coming in which is trying to be treated as an Ansi string. Do you have UNICODE defined?
|
|
|
|
|