|
What would you say is the best way to set a idle timeout on a socket connection?
Artificial Intelligence is no match for Natural Stupidity
No one can understand the truth until he drinks of coffee's frothy goodness. ~Sheik Abd-al-Kadir
I can't always be wrong ... or can I?
|
|
|
|
|
|
The SetTimer() approach given will work. Also depending on your application the TimerQueue[^] library might be more appropriate.
led mike
|
|
|
|
|
hi,
I have Doc/view application I want to get invalidate rectangle value in my ondraw() function.
can any one help me?
Thanks in advance.
Regards,
Rushiraj
|
|
|
|
|
Use m_ps(PAINTSTRUCT) member of CPaintDC class.
void CMyView::OnDraw(CDC* pDC)
{
CPaintDC* dcPain = dynamic_cast<CPaintDC*>(pDC) ;
RECT rcInvalid= dcPain->m_ps.rcPaint ;
}
|
|
|
|
|
|
Hello all,
I have a Rich edit control in my win 32 App.
I am passing one word to rich edit control and I want to change the color of that word in all the places where it occurs in the Rich control.
I am trying with this code
void ColorWords(char* word,HWND hwnd)<br />
{<br />
CHARFORMAT2 cf;<br />
memset(&cf, 0, sizeof(CHARFORMAT2));<br />
cf.cbSize = sizeof(CHARFORMAT2);<br />
cf.dwMask = CFM_BOLD;<br />
cf.dwEffects = CFE_BOLD;<br />
COLORREF clr =RGB(255, 10, 15) ;<br />
cf.dwMask =CFM_COLOR;<br />
cf.crTextColor = clr;<br />
<br />
<br />
FINDTEXTEX findText;<br />
int foundCount = 0;<br />
int foundPos = 0;<br />
int wordLen = lstrlen(word);<br />
<br />
findText.chrg.cpMin = 0;<br />
findText.chrg.cpMax = -1;<br />
findText.lpstrText = word;<br />
<br />
HWND hwndRichEdit = GetDlgItem(hwnd, IDC_FILECONT);<br />
foundPos=SendMessage(hwndRichEdit,EM_FINDTEXT,FR_WHOLEWORD,(LPARAM)&findText);<br />
<br />
while (foundPos != -1)<br />
{<br />
SendMessage(hwndRichEdit,EM_EXSETSEL,0,(LPARAM)foundPos + wordLen);<br />
SendMessage(hwndRichEdit,EM_GETCHARFORMAT,SCF_SELECTION,(LPARAM)cf);<br />
findText.chrg.cpMin = foundPos + wordLen; <br />
foundPos =SendMessage(hwndRichEdit,EM_FINDTEXT,FR_WHOLEWORD,(LPARAM)&findText);<br />
}<br />
}
I am getting the below error can u please tell me what is error ??
Error :-
error C2440: 'type cast' : cannot convert from 'struct CHARFORMAT2A' to 'long'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Error executing cl.exe.
|
|
|
|
|
Hi Prasad,
Thanks for the response. I did that changes and its working.
Now no compile time errors,and also I am not getting any out put . I just traced the code using debug .
Till this line no error while (foundPos != -1)
after this statement I am getting
unhanded exception in a.exe (RICHED20.DLL):0XC000005 : Access violation
can u please tell me what is the error ?? is there any problem with send messages ??
|
|
|
|
|
Hi Prasad,
I made the changes
<br />
while (foundPos != -1)<br />
{<br />
CHARRANGE chrRange;<br />
chrRange.cpMin = foundPos-1;<br />
chrRange.cpMax = chrRange.cpMin + wordLen;<br />
SendMessage(hwndRichEdit,EM_EXSETSEL,0,(LPARAM)(&chrRange));<br />
SendMessage(hwndRichEdit,EM_GETCHARFORMAT,SCF_SELECTION,(LPARAM)(&cf));<br />
findText.chrg.cpMin = foundPos + wordLen; <br />
foundPos=SendMessage(hwndRichEdit,EM_FINDTEXT,FR_WHOLEWORD,(LPARAM)&findText);<br />
}<br />
Now i am not getting any debug error or the words are getting colored ??
word color is not getting updated why ?? is there any error in this format statment ??
SendMessage(hwndRichEdit,EM_GETCHARFORMAT,SCF_SELECTION,(LPARAM)(&cf));
|
|
|
|
|
Ho at last ……its working … thanks prasad ……now words are getting colored …
To the color function I am passing the word like if I am passing the word Africa only that particular word will be highlighted. And in the dialog I have one more option like we can give fuzziness ranging from 1 to 5 if we give fuzziness as 1 and search word as Africa , it should high light the words like Africa1 African 0Africa etc and so on …
I want to know is there any possibilities of doing this ???? if yes then which send methods I have use ???
|
|
|
|
|
|
Thanks white sky for the link ….
But its MFC rich edit box application …. I think there is a lot of changes in the MFC and Win 32 way of handling structure and send messages.
If u have any link for win 32 Api Application examples for rich edit box please send it, it will be very use full for me.
|
|
|
|
|
Hi,
Can you please tell me how to capture keyboard button down . i want especially for delete button.
This is required for me because i should be able to delete selected item by pressing "Delete" or(And) "Del" button of keyboard.
Harsha
|
|
|
|
|
Can you use of WM_KEYDOWN/WM_KEYUP
|
|
|
|
|
Hello,
can be "PretranslateMessage(MSG* pMsg)" solution for this question?
Something like this:
BOOL CMyDialog::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message == WM_KEYDOWN)
{
if(pMsg->wParam == VK_DELETE)
{
}
}
return CDialog::PreTranslateMessage(pMsg);
}
regards
break;
|
|
|
|
|
Your answer is Yes;),but you must know one thing about WM_KEY*.if you have a control on your forum then you dont get any WM_KEY* because focus send to it control.Test this sibject with a dialog that first it has controls on itself again it doesnt have any control and see retuslt.
|
|
|
|
|
ok,
what is the right way to do this?
do you know some example for this?
tanks
break;
|
|
|
|
|
I found this function here:
ON_WM_KEYDOWN()
to use with:
OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
is that maybe te current way to catch key input?
|
|
|
|
|
Hi,
i used the below function on WM_KEYDOWN() message, but donno why it is not working.
It is not even detecting if i press any key. i dont know if ishould add something else.
Note:in the function "dummy" i have a messagebox to see if its working.
void CKeyboard1Dlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
//char lsChar;
//lsChar=char(nChar);
switch(nChar)
{
case VK_DELETE:
dummy();
break;
default:
CString d1;
d1="ur code not worki";
MessageBox(d1);
}
CDialog::OnKeyDown(nChar, nRepCnt, nFlags);
}
and function prototype i used is in ".h"file is
"afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);"
Harsha
|
|
|
|
|
Hi,
have you add
ON_WM_KEYDOWN()
to your message map!
break;
|
|
|
|
|
Ya .. i have added on_wm_keydown().. its not worki even then.
Harsha
|
|
|
|
|
Do you have any controls on the forum?
|
|
|
|
|
this code is working.. thanks a lot
Harsha
|
|
|
|
|
Hi,
Right now i am able to delete single selected row from the listcontrol. Can you please tell me how to delete all those selected rows if i select more than one row from list control.(selection of rows can be done either by mouse click along with "Ctrl" button on keyboard or with the help of arrow buttons on keyboard along with Shift button)
Harsha
|
|
|
|
|
Use of GetFirstSelectedItemPosition/GetNextSelectedItem
|
|
|
|