|
Try searching through this message board. I think you will find this has been answered many times.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
|
<br />
CString st;<br />
int k=10;<br />
st.Format("%d", k);<br />
Now st become "10".
Is that your needed?
|
|
|
|
|
|
Hi,
I need to do the following:
- A process (outside my control completely) generates a file.
- I need to read the file from some offset (near the end) and once I reach the end, wait at the end for more data
I don't want to keep polling for more data (as I don't want to waste CPU cycles). Is there some API I can use?
Cheers.
|
|
|
|
|
|
Thanks, I definitely will.
|
|
|
|
|
Good. Please register here at CP instead of posting Anonymously. I tend to ignore anonymous posts as do others.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Hi,
I have a CDialog which contains several CEdit fields. I would like to be able to set one of those CEdit fields to have initial input focus.
I'm trying to use the following code but it does nothing. I've made sure editField1 is valid at that point.
<br />
BOOL MyDialog::OnInitDialog() <br />
{<br />
CDialog::OnInitDialog();<br />
editField1.SetFocus();<br />
<br />
return true;<br />
}<br />
Thoughts/hints?
Thanks
Hua-Ying
|
|
|
|
|
Calling SetFocus() in a dialog (or anywhere else) can be problematic. You could try editField1.PostMessage( WM_SETFOCUS ... ) which will have a far better chance of working. You need to test stuff like this on all patforms your app will run on.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
When I tried what you suggested, the CEdit field stops accepting user input(just beeps when you type)? It does put the caret in the edit box when the dialog starts up though.
editField1.PostMessage(WM_SETFOCUS);
Hua-Ying
|
|
|
|
|
hyling wrote:
When I tried what you suggested, the CEdit field to stop accepting input at all? It does put the caret in the edit box when the dialog starts up though.
Have you specified the correct vaues for the PostMessage() wParam and lParam params. Look at WM_SETFOCUS in the Help for details.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Would you explain why you said this: Calling SetFocus() in a dialog (or anywhere else) can be problematic. I couldn't find anything discussions about this with google.
Also, I could never get PostMessage to work right.
I tried this:
<br />
mIDField.PostMessage(WM_SETFOCUS, (WPARAM)m_hWnd, 0);<br />
According to the docs:
Parameters
-wParam
Handle to the window that has lost the keyboard focus. This parameter can be NULL.
-lParam
This parameter is not used.
Thanks
Hua-Ying
|
|
|
|
|
hyling wrote:
Would you explain why you said this: Calling SetFocus() in a dialog (or anywhere else) can be problematic. I couldn't find anything discussions about this with google.
You can and do get into race conditions where your code is trying to SetFocus and Windows is also trying to SetFocus(). A common mistake people make where this is evident is validating a control in its OnKillFocus() handler and calling SetFocus() when it is invalid to set the focus back to the control loosing focus. This won't work because upon return from OnKillFocus() windows will set the focus to the next control etc. PostMessage() is a way to handle this scenario.
David has pointed out the correct answer however.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
When posting code snippets, it's beneficial to post them verbatim rather than typing them in manually. This is evident in the fact that you are returning a bool from a BOOL method.
Since OnInitDialog() is created by AppWizard or ClassWizard, you've no doubt noticed the comment that gets placed near the bottom of the OnInitDialog() method:
return TRUE;
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
AppWizard didn't create a OnInitDialog function for this class, I had to add it in by hand and didn't see the comment before.
You're right, I should have been returning false for this function.
The following code works for me:
<br />
BOOL MyDialog::OnInitDialog() <br />
{<br />
CDialog::OnInitDialog();<br />
editField1.SetFocus();<br />
<br />
return FALSE;<br />
}<br />
Thanks!
Hua-Ying
|
|
|
|
|
|
Hi,
I Want to disable move menuitem in a window's system menu, please help.
Thanks
Bose
|
|
|
|
|
Congratulations!!! Good question. I wasted two hours of my life today doing this s..t for you.
Below is a solution of the problem:
BOOL CYourDlg::PreTranslateMessage(MSG* pMsg)
{
if((pMsg->message==WM_NCLBUTTONDOWN && SendMessage(WM_NCHITTEST,0,pMsg->lParam)==HTSYSMENU) ||
(pMsg->message==WM_NCRBUTTONDOWN && SendMessage(WM_NCHITTEST,0,pMsg->lParam)==HTCAPTION))
{
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
if(GetStyle()&WS_THICKFRAME)
pSysMenu->EnableMenuItem(SC_SIZE,MF_BYCOMMAND|MF_ENABLED);
else
pSysMenu->EnableMenuItem(SC_SIZE,MF_BYCOMMAND|MF_GRAYED);
if(GetStyle()&WS_MINIMIZEBOX||GetStyle()&WS_MAXIMIZEBOX)
{
if(GetStyle()&WS_MINIMIZEBOX)
{
if(IsIconic())
{
pSysMenu->EnableMenuItem(SC_MINIMIZE,MF_BYCOMMAND|MF_GRAYED);
pSysMenu->EnableMenuItem(SC_RESTORE,MF_BYCOMMAND|MF_ENABLED);
}
else
{
pSysMenu->EnableMenuItem(SC_MINIMIZE,MF_BYCOMMAND|MF_ENABLED);
pSysMenu->EnableMenuItem(SC_RESTORE,MF_BYCOMMAND|MF_GRAYED);
}
}
else
pSysMenu->EnableMenuItem(SC_MINIMIZE,MF_BYCOMMAND|MF_GRAYED);
if(GetStyle()&WS_MAXIMIZEBOX)
{
if(IsZoomed())
{
pSysMenu->EnableMenuItem(SC_MAXIMIZE,MF_BYCOMMAND|MF_GRAYED);
pSysMenu->EnableMenuItem(SC_RESTORE,MF_BYCOMMAND|MF_ENABLED);
}
else
{
pSysMenu->EnableMenuItem(SC_MAXIMIZE,MF_BYCOMMAND|MF_ENABLED);
pSysMenu->EnableMenuItem(SC_RESTORE,MF_BYCOMMAND|MF_GRAYED);
}
}
else
pSysMenu->EnableMenuItem(SC_MAXIMIZE,MF_BYCOMMAND|MF_GRAYED);
}
<BR>pSysMenu->EnableMenuItem(SC_MOVE,MF_BYCOMMAND|MF_GRAYED);
int nRet = pSysMenu->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON|TPM_RETURNCMD, LOWORD(pMsg->lParam), HIWORD(pMsg->lParam), this);
PostMessage(WM_SYSCOMMAND,nRet,pMsg->lParam);
return 1;
}
}
return CDialog::PreTranslateMessage(pMsg);
}
Regards,
Andrzej Markowski
|
|
|
|
|
I have an application that is compiled for Unicode (MSVC 7.0). I need to call functions in a DLL that is MBCS only. I need suggestions on how to convert the function args that are passed between the Unicode and non-unicode layers.
Jim S
|
|
|
|
|
I have an angry baby sitting on my lap so I'm going to be quick about it:
MultiByteToWideChar
WideCharToMultiByte
look'em up
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
|
I knew about converting strings to/from Unicode and the ATL macros. I didn't know if anything special had to be done to make function calls work correctly between a Unicode and a non-Unicode DLL. I think that the answer is that you only have to worry about keeping the strings straight.
|
|
|
|
|
I have 5 CString and i want to write it to a txt file on 5 different lines at the end of the file help please.
|
|
|
|
|
insert "\r\n" between each CString then call CFile::Write()
[insert witty comment here]
bdiamond
|
|
|
|