|
Huh?
"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
|
|
|
|
|
Hi, I want to know what compiler does WDK 7 use to compile files when we try to build any WDK sample?
Regards
msr
|
|
|
|
|
|
Hi,
I am using a modal dialog box to gather some inforamtion one the peices of info I need is
a filename so in myokhandler I invoke CFileDialog I get an exception when I do the the domdal
My question is can invoke a modal whtin a modal and if so what is the parent window
Thanks
|
|
|
|
|
of-course yes. You can invoke a modal dialog from another modal dialog. Coming to your problem there is something wrong with the usage of CFileDialog. can you paste the complete exception stack/message so that we can able find what went wrong.
I took this sample from here[^] hope you are doing the same. if not give a try.
CFileDialog dlgFile(...);
...
CString fileName;
dlgFile.GetOFN().lpstrFile = fileName.GetBuffer(<very large number&>);
dlgFile.GetOFN().nMaxFile = <very large number >;
INT_PTR nResult = dlgFile.DoModal();
fileName.ReleaseBuffer();
Read these lines carefully
The destruction of CFileDialog objects is handled automatically. It is not necessary to call CDialog::EndDialog.
To allow the user to select multiple files, set the OFN_ALLOWMULTISELECT flag before calling DoModal. You need to supply your own filename buffer to accommodate the returned list of multiple filenames. Do this by replacing m_ofn.lpstrFile with a pointer to a buffer you have allocated, after constructing the CFileDialog, but before calling DoModal.
When the user allocates their own buffer to accommodate OFN_ALLOWMULTISELECT, the buffer can't be larger than 2048 or else everything gets corrupted (2048 is the maximum size).
Additionally, you must set m_ofn.nMaxFile with the number of characters in the buffer pointed to by m_ofn.lpstrFile. If you set the maximum number of files to be selected to n, the necessary buffer size is n*(_MAX_PATH + 1) + 1.
|
|
|
|
|
Thanks for the suggestion however I am still getting an exception on the CFileDialog.Domodal
Here is the the code from the main window when a user selects Debug Program the following
ON_COMMAND handler is invoked
Cprogdialog progdlg(this);
nRet = progdlg.DoModal();
return;
}
Then the follwing code is the on okay handler to this modal dialog box
void Cprogdialog::Process()
{
UpdateData(TRUE); CFileDialog dlg(TRUE, _T("asm"), _T("*.asm"), NULL);
dlg.m_ofn.lStructSize = sizeof(OPENFILENAME);
dlg.m_ofn.lpstrFilter = (LPCTSTR)"*.asm,*.cbl,*.c";
dlg.m_ofn.lpstrInitialDir = (LPCTSTR)"F:\\";
dlg.m_ofn.lpstrTitle = (LPCTSTR)"Program Source Code";
dlg.m_ofn.lpstrFile = new char[50];
dlg.SetParent(this);
if (dlg.DoModal() == IDOK)
AfxMessageBox((LPCTSTR)"Waiting for program " || (LPCTSTR)progname || (LPCTSTR)" In JobName " || (LPCTSTR)jobname,MB_OK);
The exception occurs at dlg.DoModal
Thanks again
|
|
|
|
|
There are many problems in your code.
The main problem that I see is the typecast to LPCTSTR .
I've said it before and I will say it again - Typecasting is evil.
Here is a sample code that you can use to correct your mistakes -
CFileDialog fOpenDlg(TRUE, L"txt", L"",
OFN_FILEMUSTEXIST|OFN_EXPLORER|OFN_HIDEREADONLY ,
L"All Image Files (*.jpg;*.jpeg;*.bmp;*.png)|*.jpg; *.jpeg; *.bmp ; *.png|Bitmap Files (*.bmp)|*.bmp|PNG Files (*.png)|*.png|JPEG Files (*.jpg;*.jpeg)|*.jpg; *.jpeg||", this);
fOpenDlg.DoModal();
|
|
|
|
|
You are using the _T() macro in some places to ensure your strings are correctly created as ASCII or Unicode. However, further down you are using the (LPCTSTR) cast. This means that your code should not even compile in Unicode mode. You also failed to tell us what the exception is that you are seeing.
|
|
|
|
|
Right after I try to step over the CFIleDialog.DOModal
a break is hit "int 3" the Call Stack points to somewhere in KerenelBase.dll
then doing a go PF5 results in a access exception
I red-did the code with L" instead of T("")
Thr CfileDailogBox I somewhat familar with its look appears not fully just the frame
right before "int 3" is hit
Thanks
|
|
|
|
|
ForNow wrote: I red-did the code with L" instead of T("") So you think that randomly changing some strings to Unicode will fix the problem? My comment was made in the hope that you would actually think about what you are trying to do and whether your various parameters are correct. Read the documentation[^] and look more closely at the requirements for the different parameters on the CFIleDialog class.
You should also learn the difference between the _T() macro and the L prefix on strings. And finally you need to understand exactly what a cast, such as (LPCTSTR) , does and how it affects the way your program runs.
|
|
|
|
|
ForNow wrote: Then the follwing code is the on okay handler to this modal dialog box
void Cprogdialog::Process() So Process() is being called from OnOK() ? Why are you wanting to browse for a file when the "main" dialog is being dismissed?
ForNow wrote: dlg.m_ofn.lpstrFile = new char[50]; I do not see how this is going to work.
ForNow wrote: dlg.m_ofn.lpstrFilter = (LPCTSTR)"*.asm,*.cbl,*.c"; Have you read the docs for this member? It must be double null terminated.
"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
|
|
|
|
|
Okay i'll re-read the docs
I have a modal dialog box open to gather info
1 of the pieces of info is a file name so......
as soon as the user hits "OK"
I look for the last piece of info which a file thus the need to invoke CFileDiaog from the OKHANLDER of the first dialog box
you right I'll re-read the doc
|
|
|
|
|
ForNow wrote: I have a modal dialog box open to gather info 1 of the pieces of info is a file name so...... as soon as the user hits "OK" When the user clicks the OK button, they are expecting to be done, not be presented with yet another dialog box. The OK button should not be available to click until all required information has been collected. It sounds like what you need is a Browse button to allow browsing for the file name.
"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
|
|
|
|
|
I applogize
I have ON_COMMAND(IDC_PUSH,process)
In the message map
in the resource file I have DEFPUSHBUTTON IDC_PUSH
I haven't overriden CDialog::OnOk
I haven't defined a button with a ID of IDOK
maybe I should re-do the modal dialogbox as a modaal with DEFBUTTON of IDOK
since one the pieces of info i need is a file is omay in my OnOk overrride to invoke CFileDialog
to prompt the user for the file name?
Thanks
|
|
|
|
|
ForNow wrote: since one the pieces of info i need is a file is omay it okay in my OnOk overrride to invoke CFileDialog to prompt the user for the file name? I would disable the OK button until all required information has been provided.
"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
|
|
|
|
|
|
For what? What does Hans' article have to do with the title of this thread?
"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
|
|
|
|
|
Instead of opening a second modal dialog box I'll add my controls to CFileDialog
|
|
|
|
|
Creating a proper main dialog with a "browse" button that opened a CFileDialog would be way simpler.
"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
|
|
|
|
|
What's the exception (specifics)?
"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
|
|
|
|
|
Hi,
I just got to work now but just before I left I re-built the code with only
CFileDialog dlg(TRUE);
one paramter as everybody was telling me I have problems wih my parms
as soon as I try stepping over dlg.Domodal();
I get a break point "int 3" some system DLL then entering PF5 "GO" again I get an access exception
I have a related question since I am creating the modal dialog box inside a modal dialog OKHANDLER what is the parent window the first modal or the MainWindow
Thanks
|
|
|
|
|
ForNow wrote: one paramter as everybody was telling me I have problems wih my parms So why not take my advice, read the documentation, and fix the incorrect parameters? Unless and until you properly address the things that are obviously incorrect you are not going to make any progress finding the problem.
|
|
|
|
|
ForNow wrote: CFileDialog dlg(TRUE); one paramter as everybody was telling me I have problems wih my parms as soon as I try stepping over dlg.Domodal(); What about the OPENFILENAME structure?
ForNow wrote: as soon as I try stepping over dlg.Domodal(); Does the Open dialog display, or is the exception thrown first?
ForNow wrote: I have a related question since I am creating the modal dialog box inside a modal dialog OKHANDLER what is the parent window the first modal or the MainWindow What exactly are you talking about here?
"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
|
|
|
|
|
The program takes the input of an initial key and an initial
vector, reads the plaintext or ciphertext from a file, conducts the encryption or
decryption, and writes the resulting ciphertext or plaintext into a second file.
test case is as follows: using a binary initialization vector of 10101010, a binary plaintext
of 00000001 00100011 encrypted with a binary key of 0111111101 should give a binary
ciphertext of 11110100 00001011. Decryption should work correspondingly.
|
|
|
|
|
Please do not post your homework questions here; no one is going to do your work for you.
|
|
|
|