|
Please tell me how can do this.
Please tell me with example.
Thanks.
IN A DAY, WHEN YOU DON'T COME ACROSS ANY PROBLEMS - YOU CAN BE SURE THAT YOU ARE TRAVELLING IN A WRONG PATH
|
|
|
|
|
Pseudo code:-
1. FileDialogObject.GetFileName() return you the file path, where you save you file.
2. check for existence of your extension, if it there, leave it otherwise add it to the filename.
3. write code for saving of file.
remember cfiledialog doesn't save file for you, you have to write code for it.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|
|
Try changing your second parameter:
CFileDialog avi(FALSE,_T("bkp"),NULL,OFN_CREATEPROMPT|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,_T("Backup File|*.BKP|"), this,0);
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Hi,
How to write a BYTE array into a file and reading it back from. I used fwrite and fread but it is not working.
Regards,
|
|
|
|
|
subramanyeswari wrote: I used fwrite and fread but it is not working.
It should.
Please, when you have a problem like describe exactly what you did so that we can check it. Post some code how you open the file and read/write in it.
|
|
|
|
|
Here is the code
char strPasswd[8] = "test123";
DWORD dlen = 8;
size_t t ;
long lSize;
size_t result;
BYTE* Newpasswd;
FILE *fp = fopen("c:\\test.bin", "wb+");
BYTE* encodedpasswd = EncodeString(strPasswd,&dlen);
t = fwrite((unsigned char*)encodedpasswd,1,sizeof((unsigned char*)encodedpasswd),fp);
fclose(fp);
fp = fopen("c:\\test.bin", "rb+");
fseek (fp , 0 , SEEK_END);
lSize = ftell (fp);
rewind (fp);
Newpasswd= (unsigned char*) malloc (sizeof(unsigned char)*lSize);
int i = fread(Newpasswd,1,sizeof(Newpasswd),fp);
char* tempPassword = DecodeString(testpasswd,&dlen);
Is writing is not done properly?
Regards,
|
|
|
|
|
I guess the problem is because you are using sizeof to calculate the lenght of your string. Sizeof will return the size (in bytes) of the pointer, not what it contains. So replace the first sizeof by a strlen (if the string is NULL terminated).
The others sizeof (in the malloc and in the fread) should be replaced by the size of the data that is retrieved from the file.
|
|
|
|
|
subramanyeswari wrote: I used fwrite and fread but it is not working.
(Un)fortunately It doesn't depend on fwrite and fread , my friend.
The following works for me (error checking left as exercise)
int main()
{
{
BYTE bValue[]={2,4,8};
int iLen = sizeof(bValue)/sizeof(bValue[0]);
FILE * fpo = fopen("foo.bin", "wb");
fwrite(&iLen, sizeof(iLen), 1,fpo);
fwrite(bValue, sizeof(bValue), 1, fpo);
fclose(fpo);
}
{
BYTE * bValue;
FILE * fpi = fopen("foo.bin", "rb");
int iLen;
fread(&iLen, sizeof(iLen), 1,fpi);
bValue = new BYTE[iLen];
fread(bValue, sizeof(BYTE), iLen, fpi);
fclose(fpi);
delete [] bValue;
}
return 0;
}
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi all,
I am working on a dialog box application...
i want to disable the cross button on top right corner on a particular condition and at other situations it may work.....
How can i do this?
thanks in advance
|
|
|
|
|
You can disable the button using the code shown below
BOOL bEnable = FALSE;
UINT menuf = bEnable ? (MF_BYCOMMAND) : (MF_BYCOMMAND | MF_GRAYED | MF_DISABLED);
CMenu* pSM = GetSystemMenu(FALSE);
if(pSM)
{
pSM->EnableMenuItem(SC_CLOSE, menuf);
}
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Hello,
I have an application which works fine .
I have now made DLL of the classes which I use.In one of the classes
it has a statement which calls the ParentFrame and sets the menu.
GetParentFrame()->SetMenu(&FrameMenu);
But when I use DLL in my application I get an unhandled error where it seems that the Parent Frame is not found
What must be the problem?
When I debug he application with DLL the debug cursor does not enter inside the DLL's .cpp file .I want to enter the DLL code .What should be
done for that?
Pritha
|
|
|
|
|
Why did you repost your question 1 hour after the previous one ? Did is a forum, not a chat. People can still see your question and this won't make any difference to ask it again except for spamming the forum.
|
|
|
|
|
Hello,
Sorry to repost my question.
But I did that because of my network connection.I posted my first question and could not see it on the screen after refreshing the page.When I tried to post it again,it said The question was posted and I thought the question subject must have collided with my earlier question which I posted 15 days back.so I changed the subject and reposted.
This will not happen again.
Regards.
Pritha
|
|
|
|
|
No problem, I thought you did that on purpose because you didn't replies fast enough
|
|
|
|
|
Hi all
i am new in vc++ and i am going to develop a USB project.My project is first monitor the USB port then i set permission.Permission like read and wright,enable and disble like that.Any one give me tips..
Thx's in Advance..
|
|
|
|
|
|
|
error C2352: 'CWnd::UpdateData' : illegal call of non-static member function
I am calling void SearchDialog::OnSearchBtn() from a thread.Please advice
class SeachDialog
{
....
....
protected:
// Generated message map functions
//{{AFX_MSG(AssetSearchDialog)
static afx_msg void OnSearchBtn();
....
static UINT StartWorkingThread (LPVOID param);
....
typedef struct THREADSTRUCT //structure for passing to the controlling function
{
SearchDialog* _this;
} THREADSTRUCT;
.....
....
}
UINT SearchDialog::StartWorkingThread (LPVOID param)
{
THREADSTRUCT* ts = (THREADSTRUCT*)param;
ts->_this->OnSearchBtn();
...
...
}
void SearchDialog::OnSearchBtn()
{
UpdateData(TRUE); // updates selection attributes
...
..
}
|
|
|
|
|
Hello,
I have an application which works fine .
I have now made DLL of the classes which I use.In one of the classes
it has a statement which calls the ParentFrame and sets the menu.
GetParentFrame()->SetMenu(&FrameMenu);
But when I use DLL in my application I get an unhandled error where it seems that the Parent Frame is not found
What must be the problem?
When I debug he application with DLL the debug cursor does not enter inside the DLL's .cpp file .I want to enter the DLL code .What should be
done for that?
Pritha
|
|
|
|
|
To debug your DLL, Set DLL project as active and under Project->Settings->Executable for Debug session browse the exe which is using your DLL.
|
|
|
|
|
Hello,
Thanks
But I aam using 2 DLLs and How should I debug starting from my client project?
Pritha
|
|
|
|
|
prithaa wrote: But I aam using 2 DLLs and How should I debug starting from my client project?
Set your dll project as the startup/active project. So when you press F5 you get a dialog prompting you to enter an exe name which will be hosting or using this dll, here browse and select the main exe which runs using this dll.
Nibu babu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http://nibuthomas.wordpress.com
|
|
|
|
|
MFC has issues with multiple threads and possibly also with dlls. In this case GetParentFrame() is the culprit as it makes an internal call to CWnd::FromHandle which looks like this:
CWnd* PASCAL CWnd::FromHandle(HWND hWnd)
{
CHandleMap* pMap = afxMapHWND(TRUE);
ASSERT(pMap != NULL);
CWnd* pWnd = (CWnd*)pMap->FromHandle(hWnd);
#ifndef _AFX_NO_OCC_SUPPORT
pWnd->AttachControlSite(pMap);
#endif
ASSERT(pWnd == NULL || pWnd->m_hWnd == hWnd);
return pWnd;
}
The afxMapHWND func is probably trying to use global structures that aren't visible from the dll.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
hello,
thanks for the reply.
So I should not use the GetParentFrame() function.And what care should be taken regarding functions that go into the DLLs
Pritha
|
|
|
|
|
Can you avoid using MFC functions from the dll? Here you could use ::GetParent(m_hWnd) instead of GetParentFrame(), but it would give you a HWND, not CFrameWnd. If you can use only raw winapi calls it should be OK.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|