|
There is one more way to do it. Make a dialog box with desired message. Create a thread, call DoModal() in this thread to display that dialog box. When u need to kill dialog, kill the thread. How's that??
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
what do this two programs do if anyone can write the commens next to them tnx again
CODE #1
#include <iostream>
using namespace std;
void branje(double *polje, int velikost);
void zamenjava(double *polje, int velikost);
void pomikvdesno(double *polje, int velikost);
void sort(double *polje, int velikost);
void izpisi(double *polje, int velikost);
int main()
{
int velikost = 10;
double polje[velikost];
branje(&polje[0],velikost);
izpisi(&polje[0],velikost);
sort(&polje[0],velikost);
izpisi(&polje[0],velikost);
zamenjava(&polje[0],velikost);
izpisi(&polje[0],velikost);
pomikvdesno(&polje[0],velikost);
izpisi(&polje[0],velikost);
return 0;
}
void izpisi(double *polje, int velikost)
{
static int a=1;
cout<<"Klic st:"<< a <<endl;
for(int="" i="0;" i<velikost;="" i++)
="" {
="" cout<<"stevilo="" je:="" "<<polje[i]<<endl;
="" }
="" a++;
}
void="" branje(double="" *polje,="" int="" velikost)
{
="" cout<<"vpisi="" stevila."<<endl;
="" stevilo:="" ";
="" cin="">>polje[i];
}
}
void zamenjava(double *polje, int velikost)
{
for(int i=0; i<velikost; i++)
="" {
="" if(i="" %="" 2="=" 0)
="" !="velikost-1)
" double="" z;
=""
="" z="polje[i];
" polje[i]="polje[i+1];
" polje[i+1]="z;
" }
="" }
}
void="" zamenjaj(double="" &a,="" &b)
{
="" a="b;
" b="z;
}
void" pomikvdesno(double="" *polje,="" int="" velikost)
{
="" for(int="" i="velikost-2;" i--)
="" polje[0]="z;
}
void" sort(double="" j="0;" j<velikost="" -1;="" j++)
="" i<velikost-1;="" if(polje[i]="" <="" polje[i+1])
="" zamenjaj(polje[i],polje[i+1]);
="" }
}
code="" #2
#include="" <iostream="">
#include <stdio.h>
using namespace std;
struct NIZ
{
char niz[100];
int length;
};
void branje(NIZ *nizi);
void uredi(NIZ *nizi);
void izpis(NIZ *nizi);
int main()
{
NIZ nizi[6];
branje(nizi);
uredi(nizi);
izpis(nizi);
return 0;
}
void branje(NIZ nizi[])
{
for(int i=0; i<6 ; i++)
{
cout<<"Vpisi besedo: ";
cin>>nizi[i].niz;
nizi[i].length=strlen(nizi[i].niz);
}
}
void izpis(NIZ nizi[])
{
for(int i=0; i<6; i++)
{
cout<<nizi[i].niz<<endl;
}
}
void="" zamenjaj(niz="" &niz1,="" niz="" &niz2)
{
="" niz3;
=""
="" niz3="niz1;
" niz1="niz2;
" niz2="niz3;
}
void" uredi(niz="" nizi[])
{
="" for(int="" j="0" ;="" <="" 5="" j++)
="" {
="" i="0;" i<5;="" i++)
="" if(nizi[i].length="" nizi[i+1].length)
="" zamenjaj(nizi[i],nizi[i+1]);
="" }
="" }
}
=""
<div="" class="ForumSig">I'm The Stig
|
|
|
|
|
do the function and variable names have any real meaning in a language other than english ?
except for sort I have absolutly no clue.
|
|
|
|
|
yea i can try to write it in english
CODE #1
#include <iostream>
#include <stdio.h>
using namespace std;
struct NIZ
{
char niz[100];
int length;
};
void read(NIZ *nizi);
void u(NIZ *nizi);
void write(NIZ *nizi);
int main()
{
NIZ nizi[6];
read(nizi);
u(nizi);
write(nizi);
return 0;
}
void read(NIZ nizi[])
{
for(int i=0; i<6 ; i++)
{
cout<<"Write a word: ";
cin>>nizi[i].niz;
nizi[i].length=strlen(nizi[i].niz);
}
}
void write(NIZ nizi[])
{
for(int i=0; i<6; i++)
{
cout<<nizi[i].niz<<endl;
}
}
void="" switc_h(niz="" &niz1,="" niz="" &niz2)
{
="" niz3;
=""
="" niz3="niz1;
" niz1="niz2;
" niz2="niz3;
}
void" u(niz="" nizi[])
{
="" for(int="" j="0" ;="" <="" 5="" j++)
="" {
="" i="0;" i<5;="" i++)
="" if(nizi[i].length="" nizi[i+1].length)
="" switc_h(nizi[i],nizi[i+1]);
="" }
="" }
}
code="" #2
#include="" <iostream="">
using namespace std;
void r(double *po, int v);
void z(double *po, int v);
void p(double *po, int v);
void s(double *po, int v);
void iz(double *po, int v);
int main()
{
int v = 10;
double po[v];
r(&polje[0],v);
iz(&polje[0],v);
s(&polje[0],v);
iz(&polje[0],v);
z(&polje[0],v);
iz(&polje[0],v);
p(&polje[0],v);
iz(&polje[0],v);
return 0;
}
void i(double *po, int v)
{
static int a=1;
cout<<"Call st:"<< a <<endl;
for(int="" i="0;" i<v;="" i++)
="" {
="" cout<<"number="" is:="" "<<po[i]<<endl;
="" }
="" a++;
}
void="" r(double="" *po,="" int="" v)
{
="" cout<<"write="" numbers."<<endl;
="" numbers:="" ";
="" cin="">>po[i];
}
}
void z(double *po, int v)
{
for(int i=0; i<v; i++)
="" {
="" if(i="" %="" 2="=" 0)
="" !="v-1)
" double="" x;
=""
="" x="po[i];
" po[i]="po[i+1];
" po[i+1]="x;
" }
="" }
}
void="" z(double="" &a,="" &b)
{
="" a="b;
" b="x;
}
void" p(double="" *po,="" int="" v)
{
="" for(int="" i="v-2;" i--)
="" po[0]="x;
}
void" sort(double="" j="0;" j<v="" -1;="" j++)
="" i<v-1;="" if(po[i]="" <="" po[i+1])
="" z(po[i],po[i+1]);
="" }
}
=""
<div="" class="ForumSig">I'm The Stig
|
|
|
|
|
Hi all ,
Please help me out to programmaticaly find whether we have
Rights to "CREATE & MODIFY IN a specified folder" in vc++.
INPUT :
NAME OF THE Folder
OUTPUT : Whether it is possible for logged user to create a file in folder
for thendral
|
|
|
|
|
The easiest way is just to try and create a (temporary) file. If it fails with a specific error, you know that current permissions are inadequate.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
My application uses CFileDialog to select a file to work with.
It seems to work well (the file is selected and returned) but when I execute other part of the application, an exception occurs (always in the same instruction: a query execution)
No problems arise if CFileDialog DoModal is not called or even if it is called but no file is selected (cancel button)
First I've tried to understand the problem, compiling with the SDK and using even "#define _WIN32_WINNT 0x500" and using CFileDialog either on stack and heap, but with no results.
At the end I've used the GetOpenFileName() API but it doesn't solve.
const char *szFilter = "JPG images (*.jpg)|*.jpg||";
CFileDialog dlg( TRUE, "jpg", NULL, OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST, szFilter, this );
if( dlg.DoModal() != IDOK )
{
return;
}
I use VC++ 6.0 SP6 with PDSK Feb 2003 on XP Professional SP2
Some tips ?
|
|
|
|
|
Hmm....
Are you check the return values for any possible error messages?
How is the file passed to the part of the application that is throwing the exception? What state is the file in and what is the open type (i.e. binary, input, output, etc...)?
Just some thoughts,
BP
|
|
|
|
|
I store the file path returned by CFileDialog into a database table and neither opened or modified.
The exception, however, is thrown when a query is executed in another table and in another CDialog, with no relations with the CDialog where CFileDialog has been executed.
I've even tried to compile with #define _WIN32_WINNT 0x500 and CFileDialog allocated on heap and when "delete dlg" is called, an exception is thrown immediatly.
It seems CFileDialog/GetOpenFileName has some weird behaviours. Searching around the web no solution i've applied has worked.
|
|
|
|
|
make the definition like that:
#define _WIN32_WINNT 0x0400
In CommDlg.h you can view this:
#if (_WIN32_WINNT >= 0x0500)
void * pvReserved;
DWORD dwReserved;
DWORD FlagsEx;
#endif // (_WIN32_WINNT >= 0x0500)
CFileDialog doesnt expect an OPENFILENAME this big.
|
|
|
|
|
so
Nyarlatotep wrote: CFileDialog dlg( TRUE, "jpg", NULL, OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST, szFilter, this );
if( dlg.DoModal() != IDOK )
{
return;
}
does not cause a problem if cancel is pressed but does cause a problem if you press ok right? I suspect that the problem lies in the code beyond this call. Pressing cancel will cause a 'return' to execute, pressing ok will cause what ever code is after this to execute...
<br />
CFileDialog dlg( TRUE, "jpg", NULL, OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST, szFilter, this );<br />
if( dlg.DoModal() != IDOK )<br />
{<br />
return;<br />
}<br />
<br />
...WHAT CODE IS HERE?<br />
cje
|
|
|
|
|
Oh i've commented out the code which is executed when the OK button is pressed. It doesn't solve ...
|
|
|
|
|
Have you tried catching the exception and outputting the error message?
Mark
|
|
|
|
|
The instruction which throws the exception (in another CDialog, different from those where CFileDialog is invoked) is a execution of a SQLite query. The exception catched doesn't explain very much: only a error code of 1, which in SQLite is generic.
|
|
|
|
|
Nyarlatotep wrote: The exception catched doesn't explain very much: only a error code of 1, which in SQLite is generic.
Well, that's helpful
I would first make sure that no string operations have overruns.
I've never used SQLite, but maybe a previous query is still open that needs to be closed?
|
|
|
|
|
Neither of those events would occur.
1) User clickx on button A
2) Dialog A is opened and the database is opened in the OnInitDialog and a query is executed (and closed)
3) A browse button is pressed in Dialog A and CFileDialog (or GetOpenFileName API) is invoked to browse for a file
4) When Dialog A is closed data is saved into the db with an update (but the problems occurs even if no update is done)
5) User now clicks on button B
6) Dialog B is opened and the database is opened in the OnInitDialog and a query is executed ==> Exception
if point 3) is not executed (and file is not selected) no problems arise ...
I'm getting crazy ...
|
|
|
|
|
hmm...It's hard to tell what's happening - if it's a after-effect of a previous problem or an actual problem at the query.
All I can think of based on what I've read so far...
Divide and conquer! Comment out dynamically-created queries and test with static queries you
know should work. Use a static sring instead of the returned string from CFileDialog.
You should be able to narrow it down
|
|
|
|
|
Now i'm tring directly with the GetOpenFileName() and a static buffer (char strPath[MAX_PATH]) for the OPENFILENAME. No MFC, therefore.
But it doesn't solve ...
Tried to use the OPENFILENAME_NT4 structure and the OPENFILENAME_SIZE_VERSION_400 structure size (in MSDN they say MFC42 application compiled with _WIN32_WINNT set to 0x0500 should use this structure to avoid avoid heap corruption).
Nothing ...
|
|
|
|
|
I meant ignore whatever the fileopen dialog returns. Call the dialog (DoModal(), etc) but instead
of using the result just pass a const string to the query ("C:\\test.jpg" or whatever).
If it works then you know the problem is something fileopen dialog related. If it still
doesn't work then the problem is elsewhere, maybe query related, maybe related to some memory
corruption that occured somewhere else, etc...
|
|
|
|
|
yes I've tried to ignore the GetOpenFileName() result and using a static string but it doesn't solve.
Perhaps I have to follow another way but to me it seems the problem resides in the GetOpenFileName() API, whichever it is ...
|
|
|
|
|
If you do JUST this...
const char *szFilter = "JPG images (*.jpg)|*.jpg||";
CFileDialog dlg( TRUE, "jpg", NULL, OFN_FILEMUSTEXIST| OFN_HIDEREADONLY, szFilter, this );
if( dlg.DoModal() != IDOK )
{
return;
}
static char szTest = "C:\\test.jpg";
...do the query using szTest
...and it still doesn't work then the problem has nothing to do with the openfile dialog.
The common dialog (and its associated MFC wrapper class) has been around quite a while with no
"weirdness". It really sounds like the problem is elsewhere...
|
|
|
|
|
It could be. (even if, searching around, some 'weirdness' for the MFC CFileDialog wrapper class has been found).
However, I've used this functions thousand of times with no problems, in the past.
May be some system DLL has been replaced by some software ?
|
|
|
|
|
Nyarlatotep wrote: May be some system DLL has been replaced by some software ?
I'm sure that's it. Couldn't possibly be a problem elsewhere in your code
|
|
|
|
|
const char *szFilter = "Excel Worksheet Files (*.xls)|*.xls||";
CFileDialog dlg( TRUE, "xls", NULL, OFN_FILEMUSTEXIST|OFN_HIDEREADONLY|OFN_PATHMUSTEXIST, szFilter, this );
if( dlg.DoModal() != IDOK )
{
return;
}
Tried this code (compiling with /D_WIN32_WINNT=0x500) and when CFileDialog destructor is invoked an exception occurs.
|
|
|
|