|
thanks for helpin me out yesterday guys.
guys can uyou help me with this.
How can the following fuction can happen:
on Buttin click Save, the text file present in the Dialog box's-Edit box should be saved.I am getting junk when savoin the file.what are the required changes needed to make in the code given below.
void CReadDlg::OnSave()
{
char szFilters[]="MyType Files (*.txt)|*.txt|All Files (*.*)|*.*||";
CFileDialog fileDlg (false,"txt", "*.txt",OFN_FILEMUSTEXIST| OFN_HIDEREADONLY, szFilters, this);
fileDlg.DoModal();
// TODO: Add your control notification handler code here
UpdateData(true);
HANDLE hFile = NULL;
DWORD dwBufSize=BUFSIZE;
BOOL bRet;
DWORD dwBytesWritten;
char buffer[BUFSIZE];
hFile = CreateFile(fileDlg.GetPathName(),
GENERIC_WRITE |GENERIC_READ,
FILE_SHARE_READ,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
//m_ed = fileDlg.GetPathName();
//m_text_ctrl=buffer[BUFSIZE];
m_text_str = buffer;
bRet = WriteFile(hFile,
buffer,
BUFSIZE,
&dwBytesWritten,
NULL);
m_text_ctrl.SetWindowText(buffer);
if( hFile!=NULL )
{
CloseHandle(hFile);
hFile = NULL;
}
}
shashank
|
|
|
|
|
guys can uyou help me with this.
Yes. But first please fix your display name so we know who we're talking to.
/ravi
|
|
|
|
|
Ravi Bhavnani wrote: fix your display name so we know who we're talking to
|
|
|
|
|
can u guys give tell me the solution ,now that i have updated my name.
guys can you help me with this.
How can the following fuction can happen:
on Buttin click Save, the text file present in the Dialog box's-Edit box should be saved.I am getting junk when savr the file.what are the required changes needed to make in the code given below.
void CReadDlg::OnSave()
{
char szFilters[]="MyType Files (*.txt)|*.txt|All Files (*.*)|*.*||";
CFileDialog fileDlg (false,"txt", "*.txt",OFN_FILEMUSTEXIST| OFN_HIDEREADONLY, szFilters, this);
fileDlg.DoModal();
// TODO: Add your control notification handler code here
UpdateData(true);
HANDLE hFile = NULL;
DWORD dwBufSize=BUFSIZE;
BOOL bRet;
DWORD dwBytesWritten;
char buffer[BUFSIZE];
hFile = CreateFile(fileDlg.GetPathName(),
GENERIC_WRITE |GENERIC_READ,
FILE_SHARE_READ,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
//m_ed = fileDlg.GetPathName();
//m_text_ctrl=buffer[BUFSIZE];
m_text_str = buffer;
bRet = WriteFile(hFile,
buffer,
BUFSIZE,
&dwBytesWritten,
NULL);
m_text_ctrl.SetWindowText(buffer);
if( hFile!=NULL )
{
CloseHandle(hFile);
hFile = NULL;
}
}
sagar
|
|
|
|
|
Siddam wrote: char buffer[BUFSIZE];
hFile = CreateFile(fileDlg.GetPathName(),
GENERIC_WRITE |GENERIC_READ,
FILE_SHARE_READ,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
//m_ed = fileDlg.GetPathName();
//m_text_ctrl=buffer[BUFSIZE];
m_text_str = buffer;
bRet = WriteFile(hFile,
buffer,
BUFSIZE,
&dwBytesWritten,
NULL);
m_text_ctrl.SetWindowText(buffer);
I cannot see buffer is initialized by something. Obviously, its going to have junk.
|
|
|
|
|
value of buffer is ? and also I think m_text_ctrl(editbox) is null
|
|
|
|
|
Could you find problem(buffer) ?
|
|
|
|
|
hi! All
I need to update the child dialog window from some other window how can i do I have did the folllowing for that.
//the following dialog having the listview control on event(NM_CLICK) of that listitem the other
window show.
i have did the following way.
LRESULT CALLBACK GlobaListProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
.
.
.
.
.
.
case WM_NOTIFY:
{
switch(LOWORD(wParam))
{
case IDC_LIST4:
LPNMLISTVIEW pnm = (LPNMLISTVIEW)lParam;
if(pnm->hdr.hwndFrom == hList &&pnm->hdr.code == NM_CUSTOMDRAW)
{
return TRUE;
}
if(((LPNMHDR)lParam)->code == LVN_KEYDOWN)
{
LV_KEYDOWN* pLVKeyDow = (LV_KEYDOWN*)lParam;
if( pLVKeyDow->wVKey == VK_DELETE )
{
int iSlected=0;
iSlected=SendMessage(hList,LVM_GETNEXTITEM,-1,LVNI_FOCUSED);
if(iSlected==-1)
{
MessageBox(hList,_T("No Items in ListView"),_T("Error"),MB_OK|MB_ICONINFORMATION);
break;
}
ListView_DeleteItem(hList,iSlected);
}
}
if(((LPNMHDR)lParam)->code == NM_RCLICK)
{
HMENU hMenu = LoadMenu (NULL, MAKEINTRESOURCE (IDR_MENU1));
HMENU hPopupMenu = GetSubMenu (hMenu, 0);
POINT pt;
SetMenuDefaultItem (hPopupMenu, -1, TRUE);
GetCursorPos (&pt);
TrackPopupMenu (hPopupMenu,TPM_LEFTALIGN, pt.x, pt.y, 0, hDlg, NULL);
DestroyMenu (hPopupMenu);
DestroyMenu (hMenu);
}
<code>
if(((LPNMHDR)lParam)->code == NM_CLICK)
{
iSelect=SendMessage(hList,LVM_GETNEXTITEM,-1,LVNI_FOCUSED);
if(iSelect==-1)
{
break;
}
index=iSelect;
ShowWindow(hWndinoutfiledir,SW_HIDE);
ShowWindow(hwndEncrypt,SW_HIDE);
ShowWindow(hwndSplit,SW_HIDE);
ShowWindow(hwndUpload,SW_HIDE);
<big>ShowWindow(hwndTagEditorDlg ,SW_SHOW);</big> UpdateWindow(hwndTagEditorDlg);
} </code>
break;
}
}
break;
}
LRESULT CALLBACK TagEditorProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
Utility util;
switch(message)
{
case WM_INITDIALOG:
if(_ProtectSet[index].listviewIndex==index)
{
SetDlgItemText(hDlg,IDC_EDIT_ARTIST,util.ConvertStringToWCHAR(_ProtectSet[index].artist));
SetDlgItemText(hDlg,IDC_EDIT_ALBUM,util.ConvertStringToWCHAR(_ProtectSet[index].album));
SetDlgItemText(hDlg,IDC_EDIT_COPYRIGHT,util.ConvertStringToWCHAR(_ProtectSet[index].copyright));
SetDlgItemText(hDlg,IDC_EDIT_AUTHOR,util.ConvertStringToWCHAR(_ProtectSet[index].author));
SetDlgItemText(hDlg,IDC_EDIT_GENRE,util.ConvertStringToWCHAR(_ProtectSet[index].genre));
SetDlgItemText(hDlg,IDC_EDIT_DESCRIPTION,util.ConvertStringToWCHAR(_ProtectSet[index].desc));
}
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDC_SAVE_TAG:
_ResideId3TagForSelectedFile(hDlg);
break;
}
break;
}
return FALSE;
}
void _ResideId3TagForSelectedFile(HWND hDlg)
{
static int i=0;
Utility util;
TCHAR buff[MAX_PATH];
ListView_GetItemText(hList,index,0,(LPWSTR)&buff,MAX_PATH);
std::wstring buff_input(buff);
std::string compare(buff_input.begin(),buff_input.end());
WCHAR w_Artist[MAX_PATH],w_Title[MAX_PATH],w_Album[MAX_PATH],w_Year[MAX_PATH],w_Copyright[MAX_PATH],w_Author[MAX_PATH];
WCHAR w_Gener[MAX_PATH],w_Desc[MAX_PATH];
string str_Artist,str_Title,str_Album,str_Year,str_Copyright,str_Authour,str_Gener,str_Desc;
GetDlgItemText(hDlg,IDC_EDIT_ARTIST,w_Artist,MAX_PATH);
GetDlgItemText(hDlg,IDC_EDIT_TITLE,w_Title,MAX_PATH);
GetDlgItemText(hDlg,IDC_EDIT_ALBUM,w_Album,MAX_PATH);
GetDlgItemText(hDlg,IDC_EDIT_YEAR,w_Year,MAX_PATH);
GetDlgItemText(hDlg,IDC_EDIT_COPYRIGHT,w_Copyright,MAX_PATH);
GetDlgItemText(hDlg,IDC_EDIT_AUTHOR,w_Author,MAX_PATH);
GetDlgItemText(hDlg,IDC_EDIT_GENRE,w_Gener,MAX_PATH);
GetDlgItemText(hDlg,IDC_EDIT_DESCRIPTION,w_Desc,MAX_PATH);
str_Artist=util.ConvertWCHARToString(w_Artist);
str_Title=util.ConvertWCHARToString(w_Title);
str_Album=util.ConvertWCHARToString(w_Album);
str_Year=util.ConvertWCHARToString(w_Year);
str_Copyright=util.ConvertWCHARToString(w_Copyright);
str_Authour=util.ConvertWCHARToString(w_Author);
str_Gener=util.ConvertWCHARToString(w_Gener);
str_Desc=util.ConvertWCHARToString(w_Desc);
int int_Year=atoi(str_Year.c_str());
_ProtectSet[i++].Exchangedata(index,compare,str_Artist,str_Title,int_Year,str_Album,str_Copyright,str_Authour,str_Gener,str_Desc);
}
detail
so once i click on the lisitem view it will call/display other window. for that i saved all that tag in the object respectively filename and index of listview. i have taken static int i for object stored. then when i finished each item with corrsponding itemlist for all tags.
when i context switch in the listview from one lits item to other it couldnt display the respective tags for the particular file. is there any missed thing?
Amit
|
|
|
|
|
amitmistry_petlad wrote: I need to update the child dialog window from some other window how can i do
In the interest of clean design, the updating dialog shouldn't know anything about the internals of the updated dialog. I recommend posting a command message to the dialog that needs updating, which in turn should handle the message (as a WM_COMMAND ) and update itself accordingly.
/ravi
|
|
|
|
|
can you please elborate how can i do ,means how can i sent commnad .through function?
i didnt get .please specify any code if possible,
Amit
|
|
|
|
|
Here's an easy way:- Add a hidden button to your child dialog.
- Add a handler for the button, which contains code for updating the dialog in the desired manner.
- In the "parent" dialog, post the child dialog a command that simulates clicking the button by doing:
pChildDialog->PostMessage (WM_COMMAND, ID_OF_HIDDEN_BUTTON);
/ravi
|
|
|
|
|
Dear,
will it work in win32 ?
Amit
|
|
|
|
|
Yes. Use the global ::PostMessage() function.
/ravi
|
|
|
|
|
take a sample & quantify image
|
|
|
|
|
|
WhiteSky wrote: Can you be more specific
Yeap! .. Many new people on this forum suffer from this problem only
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
|
because they are new to forums
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
|
|
Dear all..
How can I use GetDC() in a dialog from an MDI CView?
I mean, I have image data in CMyMDIView, and I want to show it in a dialog (CMyDialog).
I've tried this:
CMyDialog *pMyDialog = (CMyDialog*) AfxGetMainWnd();<br />
CDC *pDC = pMyDialog->m_StaticImage.GetDC();
but the second line doesn't work...
I also tried to call the function in CMyDialog that calls CDC from CMyMDIView, like this:
void MyMDIView::OnDraw(CDC* pDC)<br />
{<br />
CMyDialog *pMyDialog = (CMyDialog*) AfxGetMainWnd();<br />
pMyDialog->DoLoadImage();<br />
...<br />
}
where DoLoadImage() contains CDC *pDC = m_StaticImage.GetDC();
but it also doesn't work..
I really bad at these pointer things ..
Thank you in advance..
-Houari
|
|
|
|
|
There are (at least) three things worth pointing out here.
CMyDialog *pMyDialog = (CMyDialog*) AfxGetMainWnd();
This won't work because (I assume) your application's window is a mainframe window, not a dialog. Forcing the cast just tells the compiler to assume your main window is indeed a CMyDialog (which is why it compiles), but any attempt to treat the cast object as such will only cause you a lot of pain (because you've made an incorrect assumption about the structure of the dereferenced object).
CDC *pDC = pMyDialog->m_StaticImage.GetDC();
pMyDialog is really a pointer to your application's mainframe window, so trying to reference its m_StaticImage member's DC is going to hurt. A lot.
- You're better off defining a method in your view class that exposes pertinent data required by any class who wishes to display the image. The displaying class (i.e. an instance of
CMyDialog ) can be passed a pointer to the view class - or can be so bold as to cast its GetParent() to your view class (assuming the dialog is and will always be only displayed by that view class) - in order to get at the image data, which it can then display in a suitable control. /ravi
|
|
|
|
|
thank you mr ravi...
I just get your point about referencing from view class. so instead, I just use OnPaint() function in the CMyDialog to call the function to display the image, and it works fine..
thanks a lot...
-Houari
|
|
|
|
|
Excellent - good work!
/ravi
|
|
|
|
|
Can someone tell me how can I get registry keys values in C++(just to read it from the registry
not write it) and if possible to explain the steps because I've tried to search for this on the Internet and can't make sense of the information/source code provided there because no one explains it (ex:why is this instead of that).
|
|
|
|
|