|
Hi,
MSDN is your friend and you will be a much better software engineer if you learn to use it. The LCIDToLocaleName function[^] is available for Vista+ operating systems. The DownlevelLCIDToLocaleName function[^] is available for XP and below but unfortunately users will need to install the National Language Support (NLS) package.
You can avoid all of this by using the code I gave you here[^] which works on all operating systems >= WinXP. I've never tested it on Win2k.
Best Wishes,
-David Delaune
[Updated incorrect MSDN links]
modified 12-Oct-11 6:22am.
|
|
|
|
|
Hi there, I have an edit box control in a dialog and a button which opens another dialog... I need to learn how can I use main dialog's aditbox text in opened one's editbox (Data transfer)... Please I need urgent help...
|
|
|
|
|
|
Howdy, you'll need the HWND of each dialog and the INT identifier of each control, or you'll need the HWND of each edit control.I'll assume the first.
HWND editSrc, editDst;
char *szBuffer;
int stringLength;
editSrc = GetDlgItem(dlg1, IDC_EDITBOX1);
editDst = GetDlgItem(dlg2, IDC_EDITBOX2);
stringLength = GetWindowTextLength(editSrc);
szBuffer = new char[stringLength+1];
ZeroMemory(szBuffer, stringLength+1);
GetWindowText(editSrc, szBuffer, stringLength);
SetWindowText(editDst, szBuffer);
delete szBuffer;
|
|
|
|
|
See my response for simpler functions.
|
|
|
|
|
:facepalm:
Of course!
Cheers Richard.
|
|
|
|
|
Keep a public CString member variable in Child dialog class, set the member variable before calling the DoModal() or Create function of child dialog. Call SetWindowText of edit control in InitDialog.
for. eg
If CMainDlg is your Main dialog class and CChildDialog be the child.
in header of CChildDialog you declare a public member variable to hold the string
class CChildDialog : public CDialog
{
public :
CString m_strText;
}
and in your button click function of CMainDlg do this
void CMainDlg::OnClick_Button()
{
CChildDialog oChildDlg;
oChildDlg.m_strText = strText; oChildDlg.DoModal();
}
Set the variable value in CChildDialog's OnInitDialog as
CChildDialog::OnInitDialog()
{
SetDlgItemText(ID_OF_YOUR_EDIT, m_strText);
}
You can also set the text by modifying your constructor of CChildDialog, such as
CChildDialog::CChildDialog(CString strText)
|
|
|
|
|
From class wizard, maindialog's member variables I added a member variable to the editbox which gets the editbox's value and then as you said, I equalize each variables but than it returns nothing from main dialog ???
|
|
|
|
|
|
I did it as Mahdu replied and by your hint... like
void mainform::OnBnClickedButton2()
{
GetDlgItemText(IDC_EDIT1,newform.strtext);
}
BOOL newform::OnInitDialog()
{
SetDlgItemText(IDC_EDIT1, strtext);
}
THANKS TO YOU ALL FOR REPLIES PEOPLE!!! YOU ARE GREAT... )
|
|
|
|
|
How about something like:
CMainDlg::OnButtonClick()
{
CString strText;
m_edit.GetWindowText(strText);
CSecondDlg dlg;
dlg.setData(strText);
dlg.DoModal();
}
CSecondDlg::setData( LPCTSTR lpszText )
{
m_strText = lpszText;
}
CSecondDlg:OnInitDialog()
{
m_edit.SetWindowText(m_strText);
} I'm a big fan of weak coupling, so tying these two dialogs together like this would not be my first choice. I would opt for a "data transfer" or "liaison" class instead. This is a one-instance class where you would put all of your shared data.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
Thanks for your reply David... I would like to criticise your post if I was more skilled... But seems to me for now... Maybe not, in the future?? Just joking, thanks again...
|
|
|
|
|
By the way, you can just explain this :
CFileDialog *pOpenDlg=new CFileDialog(FALSE,".txt",NULL,OFN_OVERWRITEPROMPT,"Text Files (*.txt)|*.txt|All Files(*.*)|*.*||");
if you want some more charity from our heavenly father?? PLEASE!
|
|
|
|
|
Try and put this code in a button click and see what happens. then you will understand why is this code required.
Every new day is another chance to change your life.
|
|
|
|
|
hi,
how do i get a list of LANGID in array?
i want initialize an array with LANGIDs (for example i do this in a loop).
int count;
WORD* arr = new WORD[count];
please help me
Zo.Naderi-Iran
|
|
|
|
|
The current list should be in file WinNT.h; search for keyword LANG_NEUTRAL . See also second response.
modified 12-Oct-11 5:18am.
|
|
|
|
|
Further research suggests you should use one of the locale support functions such as EnumSystemLocalesEx()[^].
|
|
|
|
|
zon_cpp wrote: how do i get a list of LANGID in array?
Hi,
I believe Microsoft discourages using the MLANG interface. At least that's what it use to say on MSDN. However I looked just now and could not find the do-not-use disclaimer. With that being said... A few years ago I managed to figure out how to use some of the vaguely documented interfaces. Here is what I use to enumerate available locales:
HRESULT hr = CoInitialize(NULL);
if(SUCCEEDED(hr))
{
IMultiLanguage * pml;
hr = CoCreateInstance(CLSID_CMultiLanguage,NULL,CLSCTX_ALL,IID_IMultiLanguage,(void**)&pml);
if(SUCCEEDED(hr))
{
RFC1766INFO info;
ULONG num;
IEnumRfc1766 *rfc1766;
hr = pml->EnumRfc1766(&rfc1766);
if(SUCCEEDED(hr))
{
while(S_OK == rfc1766->Next(1,&info,&num))
{
WORD wLangID = LANGIDFROMLCID(info.lcid);
}
}
}
pml->Release();
}
CoUninitialize();
Best Wishes,
-David Delaune
|
|
|
|
|
Hi,
How to bold a specific listcontrol row?
|
|
|
|
|
in OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult) event of CListCtrl
void CMyList::OnNMCustomdraw(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLVCUSTOMDRAW pLVCD reinterpret_cast<LPNMLVCUSTOMDRAW>(pNMHDR);
switch(pLVCD->nmcd.dwDrawStage)
{
case CDDS_ITEMPREPAINT:
if(pLVCD->nmcd.dwItemSpec == 1)
{
pLVCD->clrTextBk = RGB(235,235,235);
}
break;
}
}
Zo.Naderi-Iran
|
|
|
|
|
It will chage the color of text, I need to make it BOLD
|
|
|
|
|
Hi,
Modify the code zon_cpp gave you and use something like this in the CDDS_ITEMPREPAINT case:
HFONT hOldFont = (HFONT)SelectObject(pLVCD>hdc, m_Font);
SelectObject(pLVCD>hdc, hOldFont);
In your header add:
CFont m_Font;
In your dialog constructor add something like:
m_Font.CreateFont(13,0,0,0,FW_NORMAL,0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY,DEFAULT_PITCH | FF_DONTCARE,_T("MS Shell Dlg 2"));
Best Wishes,
-David Delaune
|
|
|
|
|
|
I'm trying to read text from a text file. I look for in msdn how to read and write in text file, and I found this:
http://msdn.microsoft.com/es-es/library/6337eske.aspx[^]
I made this funtion to read from my text file:
void CDlgResultados::loadFromFile(void)
{
CString path= GetUserHomeDir() + _T("\\Documents\\file.txt");
TCHAR szBuffer[256];
UINT nActual = 0;
CFile myFile;
if ( myFile.Open(path, CFile::modeCreate |
CFile::modeRead ) )
{
myFile.Write( szBuffer, sizeof( szBuffer ) );
myFile.Flush();
myFile.Seek( 0, CFile::begin );
nActual = myFile.Read( szBuffer, sizeof( szBuffer ) );
}
m_Edit.SetWindowTextW(szBuffer);
}
But when I run the app and I press the button to read the file, I get a error that it said:
You dont have acces to this file.
|
|
|
|
|
What is the actual value of the string in your path variable, at the time you try to create the file?
|
|
|
|