|
I think I need to determine if the focus is going to a window outside my app. How do I do that?
Here is the code.
void DataImportDlg2::OnKillfocusProtocolNameCb()
{
CString protoName;
m_protocolNameCB.GetWindowText(protoName);
if (protoName.GetLength() > 0)
{
int index = m_protocolNameCB.FindStringExact(0, protoName);
if (index == CB_ERR)
{
MessageBox (_T ("Protocol does not exist, to create it, use the Create Protocol button"),
_T ("Data Import"),
MB_ICONERROR | MB_OK | MB_APPLMODAL | MB_TOPMOST);
m_protocolNameCB.SetFocus();
}
Thanks,
Bob
|
|
|
|
|
I am trying to determine if the control that focus is going to next is on my app's window. Here is how I am attempting to do this
void DataImportDlg2::OnKillfocusProtocolNameCb(CWnd* pNewWnd )
{
CString protoName;
CWnd *pMainWnd = (CWnd *) AfxGetMainWnd();
BOOL child = pMainWnd->IsChild(pNewWnd);
When I click on a control on my apps window, the IsChild returns FALSE. I would expect it to return TRUE.
What am I doing wrong?
Thanks in advance,
Bob
|
|
|
|
|
Well, this won't work because the control is the child of your View class; not the CMainFrame class.
I have two suggestions: The first one is the easier way: Don't try to validate the data everytime you loose focus. Instead, validate it when the user clicks on OK button.
If you want to do it whenever the window looses focus do it this way: Create a bool variable as a member of your view. Lets say m_bChildHasFocus
Now, whenever the control gets the focus set the variable to true and whenever it looses set it false. Here is the code:
void DataImportDlg2::OnKillfocusProtocolNameCb()
{
if (!m_bChildHasFocus)
return CView::OnKillFocus();
m_bChildHasFocus = false;
CString protoName;
m_protocolNameCB.GetWindowText(protoName);
if (protoName.GetLength() > 0)
{
int index = m_protocolNameCB.FindStringExact(0, protoName);
if (index == CB_ERR)
{
MessageBox (_T ("Protocol does not exist, to create it, use the Create Protocol button"),
_T ("Data Import"),
MB_ICONERROR | MB_OK | MB_APPLMODAL | MB_TOPMOST);
m_protocolNameCB.SetFocus();
m_bChildHasFocus = true;
}
Also, don't forget to add the OnGetFocus function. In OnGetFocus functions, just set m_bChildHasFocus = true .
Mustafa Demirhan
http://www.macroangel.com
Sonork ID 100.9935:zoltrix
<nobr>They say I'm lazy but it takes all my time
|
|
|
|
|
Hi
I would need your help, I need to add text in my multiline EditBox when a user clicks on the appropriate link on the menu.
I use a Dialog-based Application.
Thanks for helping me!
|
|
|
|
|
CEdit* pEdit = (CEdit *) GetDlgItem (IDC_MyEdit);
ASSERT (pEdit != NULL);
CString strText;
pEdit->GetWindowText (strText);
strText += "Added text";
pEdit->SetWindowText (strText);
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
CString szContent = "...";
myeditbox.SetSel(0,-1); // Ctrl-A
myeditbox.ReplaceSel( szContent.GetBuffer(0) ); // Paste
And I swallow a small raisin.
|
|
|
|
|
Sorry but I'm working on a HTML Editor and your both methods works, but not for the type of project I'm working on.
I want to add text at my cursor's position in my edit box, and someone told me I had to use ReplaceSel.
Anyways, please tell me what I have to do.
Thanks a lot!
|
|
|
|
|
This is what MSDN says on recv
If the socket is connection oriented and the remote side has shut down the connection gracefully, and all data has been received, a recv will complete immediately with zero bytes received. If the connection has been reset, a recv will fail with the error WSAECONNRESET.
and then
If no error occurs, recv returns the number of bytes received. If the connection has been gracefully closed, the return value is zero. Otherwise, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling WSAGetLastError.
The first paragraphs says if all data has been received. Is there ever a case where recv returns 0 for a few cycles but then continues receiving data or does 0 mean dead?
Todd Smith
|
|
|
|
|
If recv returns 0, it means that the peer has close the connection on its side. In fact, recv will block if the connection is still open but there is no data to be read. All data has been received means that previous call(s) to recv returned data and there is no more to be read and the connection is closed by the peer.
Michel
It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
- TreeBeard
|
|
|
|
|
If you're using blocking sockets then recv will block if there's no data to return.
If you're using non-blocking sockets then recv will return SOCKET_ERROR and WSAGetLastError will return WSAEWOULDBLOCK .
If the call to recv returns 0 then it means that the connection has been shutdown cleanly and there's no more data to come through.
Len Holgate
www.jetbyte.com
The right code, right now.
|
|
|
|
|
Does anyone know the basics for merging 2 mediafiles together, one after eachother, using direct show?
I can copy a sourcefile to a destfile, mix 2 sourcefiles OVER eachother, but I can not merge them one AFTER another.
I'm using DShow 8.1
Which filter should I use?
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
the vidclip sample from the DirectX SDK should be used as the starting point. it translates any format to any format, and that should be easy to do an append instead,
And I swallow a small raisin.
|
|
|
|
|
Could you tell me the dx-version number that contains the vidclip sample (probably 6)? Cause dx8 doesn't have such a sample.
And if you know the place to download that sample (or sdk), it'll be welcome.
btw. I've tried several things, also a simple append, but then it writes again from the start. So, stopping your graph equals a rewind to the start (I guess, msdn docs are not too detailed about that, but what are they huh .
tnx
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
I work on a dialog box. I want that when you press VK_RETURN or VK_TAB or VK_DOWN, you will go to the next control. I use accelerator. When one of this key is pressed a relating command arrived and then I launch NextDlgCtrl to go the next. It works well. Normally when a button has the focus, a dotted rectangle appears on it, but in this case with W2k it never appear (with NT it works well). More strange, if you press ALT+TAB go to another application and come back, it begins to work. I do not understand. Is Somebody have an explanation.
|
|
|
|
|
what is the difference between those two functions?
|
|
|
|
|
Is there anyway to make an window that shows the content while moving(dragging), the toolbars don't have this also if i disable that option on the main window setting i won't see the content, so i want to make something to this, could anybody help me?
|
|
|
|
|
Yaw.
Does anybody familiar with some API that can calculate bounding rect of a windows text (Considering the font) ???
Appreciated...
--BlackSmith--
"With the help of all mighty", 2001, Me.
|
|
|
|
|
You need a DC and the font to correctly do this:
CDC *pDC = GetDC(NULL) ;
pDC->SaveDC() ;
CFont *pFont = GetDlgItem(IDC_CONTROL)->GetFont() ;
if (pFont != NULL)
pDC->SelectObject(pFont) ;
CSize size = pDC->GetTextExtent("Some text") ;
pDC->RestoreDC(-1) ;
pDC->ReleaseDC() ;
Roger Allen
Sonork 100.10016
I think I need a new quote, I am on the prowl, so look out for a soft cute furry looking animal, which is really a Hippo in disguise. Its probably me.
|
|
|
|
|
You can also use DrawText() with the DT_CALCRECT flag.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
named, message-oriented, blocked pipe
Server: one thread, ReadFile, then processes it, then WriteFile.
Client: two threads:
ThreadSend: WriteFile, the content is from console.
ThreadRecv: blocked ReadFile, then processes what is read;
It is found that when ThreadRecv is blocked reading (nothing read), the write operation in ThreadRecv will also be blocked, nothing is written to the pipe and the server gets nothing from it.
When I put the WriteFile and ReadFile into one thread on the client side, everything works well (one thread, ReadFile, then processes it, then WriteFile). It seems that the blocked ReadFile blocks the WriteFile. Is there anyone who knows why this happens and how it can be solved?
Thanks a lot.
Tiny Flying Elephant loves flying...
|
|
|
|
|
Use PeekNamedPipe() to see if there is anything in the pipe to be read and call ReadFile() only if there is.
CPUA 0x5041
Sonork 100.11743 Chicken Little
"So it can now be written in stone as a testament to humanities achievments "PJ did Pi at CP"." Colin Davies
Within you lies the power for good - Use it!
|
|
|
|
|
also watch out with console apps - they are blocking calls
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
hi i have a function called
<br />
writetofile(const char* filename)<br />
{<br />
FILE *stream;<br />
stream = fopen(filename,"a+");<br />
fprintf( stream,"%s",strptr);
fprintf(stream," ");<br />
fclose(stream);<br />
}<br />
when I call the function first time, i got no proglem.. but when i calll next time, I got run time error.... why is that?
|
|
|
|
|
The code makes sense to me, the only reason for failure I can make out is the strptr variable. fprintf may fail horribly if strptr is NULL or pointing to some weird memory location...
Look! They have the Internet on computers now! (Homer J. Simpson)
|
|
|
|
|
strptr is not NULL..
strptr get set to some string... right before that function got called.. strptr was fine... even i put some string fori know, that is like "hello" i
oh.. would it be because the function is in different program???
I have two dos-based applications.. but the both have the same function...writefile()....
so please also so tell me...
|
|
|
|