|
I am using MFC dialog application and want to use something other than messageBox to instruct the user what to do. I was thinking something like a note pad that someone can't modify. Can someone help me?
www.nucleus.com/~grant.cooper
|
|
|
|
|
Create a dialog with a read-only editbox....maybe?
/Magnus
|
|
|
|
|
|
I'm a bit lost here
If you want to create a modal dialog, you just write this:
CMyDialog dlg;<br />
dlg.DoModal();
But if you want to create a modeless dialog, you have to make the calls to the template yourself. I've searched the internet (also this site) and I've found several methods to do this, but I didn't find a working one.
So, what you have is a CMyDialog created using the vc dialog resource editor and an id=IDD_LOAD_DIALOG.
What are the steps to create this dialog?
I know it has something to do with those templates, but I just can't figure out what to do first.
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
This is all documented. There's even a (Microsoft MSDN or MSVC) sample called MODELESS that displays how you do it.
|
|
|
|
|
Sorry
dlg.Create(IDD_LOAD_DIALOG)
Didn't know it's as simple as that. All I found here was that CreateIndirect()-method, with handlers and pointers to pointers to pointers to ....
[VISUAL STUDIO 6.0] [MFC] [WIN98/2]
Bluute tette!
|
|
|
|
|
You must write anything following for creation and displays of dialog:
CMyModelessDlg * pDialog = new MyModelessDlg();
pDialog->Create(IDD_LOAD_DIALOG);
and certainly following to delete the modeless dialog
delete pDialog;
Best regards,
Eugene Pustovoyt
|
|
|
|
|
You must write anything following for creation and displays of dialog:
CMyModelessDlg * pDialog = new CMyModelessDlg();
pDialog->Create(IDD_LOAD_DIALOG);
and certainly following to delete the modeless dialog
delete pDialog;
Best regards,
Eugene Pustovoyt
|
|
|
|
|
Hi,
In a dialog-based application, I have create a number of *.dat files (binary file) in the project directory. I want to delete these files when the application is closed. Which VC command should be used for doing this?
Thanks in advance!
chen
|
|
|
|
|
It seems you are not interested in a "VC command" but an API function. Look up DeleteFile.
|
|
|
|
|
For VC6
In Project/Settings, Post-Build step, you can enter the DOS
commands which are to be executed after build is done.
This batch is executed before the program starts.
|
|
|
|
|
it means:
if anybody modified my EXE file.
EXE file may be refuse to run....
|
|
|
|
|
Some kind of signing. Either by implementing your own cryptography stuff or reusing something existing. Have a look at Google for e.g. "Diffie Hellman".
|
|
|
|
|
I think the easy way is to use MS Authenticode (http://msdn.microsoft.com/workshop/security/authcode/signing.asp). And then use function WinVerifyTrust (http://msdn.microsoft.com/library/en-us/security/Security/winverifytrust.asp?frame=true) to verify integrity of your exe.
M
|
|
|
|
|
I've an OLE automated project to convert MS Excel document to PDf file. I use the
void _Workbook::PrintOut(const VARIANT& From,
const VARIANT& To,
const VARIANT& Copies,
const VARIANT& Preview,
const VARIANT& ActivePrinter,
const VARIANT& PrintToFile,
const VARIANT& Collate,
const VARIANT& PrToFileName)
for printing into Acrobat PDFWriter. It runs, but the problem is that Acrobat appears. How can i do to avoid this, please ?
Thanks.
Aziz Rajim.
Aziz Rajim
|
|
|
|
|
May should should make the acrobat reader object invisible or minimized after creating it.;)
|
|
|
|
|
Hi, everyone!
I have define the below template function:
template <class t=""> void MyFuction(T* Para)
{
if(sizeof(T) == sizeof(MyClassA))
Para->Method_Of_MyClassA();
else
Para->Method_Of_MyClassB();
...
}
To use this template class, I will pass pointer of MyClassA and MyClassB
as a parameter to it;
eg.
MyFuction<myclassa>(pMyClassA);
MyFuction<myclassb>(pMyClassB);
But I got compiler error saying Method_Of_MyClassA() not a member MyClassB
and Method_Of_MyClassB() not a member MyClassA.
Does anyone know how to overcome this problem?
Best Regards,
Wayne King
|
|
|
|
|
Don't do this.
Perhaps you could tell us what you really want to?
|
|
|
|
|
You should use a template specialization as follows
template <T> void MyFuction(T* Para)
{
...
}
is still the unspecialized
Specialization for MyClassA
template<> void MyFuction(MyClassA* Para)
{
if(sizeof(T) == sizeof(MyClassA))
Para->Method_Of_MyClassA();
...
}
Specialization for class B
template<> void MyFuction(MyClassB* Para)
{
Para->Method_Of_MyClassB();
...
}
It's impossible as you want it to be handled because the compiler will try to evaluate the terms. Also you are using a run time check that is not needed if you use specialization because the compiler will check it for you (that's why you are getting errors, so it's even faster
If you have a lot of code in your function you could also create a helper template function that is specialized to call the proper method_of_myclass. and thus keeping your original function unspecialized (hey you could make a template class of it with some specialized functions and some not specialized)
Good luck
Rutger
Wayne King wrote:
I have define the below template function:
template void MyFuction(T* Para)
{
if(sizeof(T) == sizeof(MyClassA))
Para->Method_Of_MyClassA();
else
Para->Method_Of_MyClassB();
...
}
To use this template class, I will pass pointer of MyClassA and MyClassB
as a parameter to it;
eg.
MyFuction(pMyClassA);
MyFuction(pMyClassB);
But I got compiler error saying Method_Of_MyClassA() not a member MyClassB
and Method_Of_MyClassB() not a member MyClassA.
Does anyone know how to overcome this problem?
Best Regards,
Wayne King
|
|
|
|
|
Dont know what you are trying to do, but it looks like you be better of using virtual functions.
/Magnus
|
|
|
|
|
Thanks for all the reply!
The purpose of my question is try to combine the below 1-3 functions(in fact there are 8 similar functions) into 1 template function(4).
1.
static void ImgProjectEx(EImageBW8* pSrcImage, LPCRECT lpRect,
EBW32Vector* pProjection, BOOL bIsOnARow=TRUE, BOOL bMaxI=TRUE);
2.
static void ImgProjectEx(EImageBW8* pSrcImage, LPCRECT lpRect, vector<ebw32>* pProjection, BOOL bIsOnARow=TRUE, BOOL bMaxI=TRUE);
3.
static void ImgProjectEx(EImageBW8* pSrcImage, LPCRECT lpRect,
vector<ebw8>* pProjection, BOOL bIsOnARow=TRUE, BOOL bMaxI=TRUE);
4.
template <class type1,="" class="" type2,="" typename="" type3=""> static void ImgProjectEx(Type1* pSrcImage, LPCRECT lpRect, Type2* pProjection, BOOL bIsOnARow=TRUE, BOOL bMaxI=TRUE, BOOL bAverage=TRUE);
The vector<ebw32> and EBW32Vector are similar, but only few of the methods are different.
Attach the real fuction below for your Ref.
Maybe there is other solution. Any comments are greatly appreciated!
Best Regards,
Wayne King
template <class type1,="" class="" type2,="" typename="" type3=""> static void ImgProjectEx(Type1* pSrcImage, LPCRECT lpRect, Type2* pProjection, BOOL bIsOnARow, BOOL bMaxI, BOOL bAverage)
{
INT32 nWidth0 = pSrcImage->GetWidth();
INT32 nHeight0 = pSrcImage->GetHeight();
INT32 nOrgX = lpRect->left;
INT32 nOrgY = lpRect->top;
INT32 nWidth = lpRect->right - lpRect->left;
INT32 nHeight = lpRect->bottom - lpRect->top;
UINT32 uNum;
Type3* pPix;
Type3 color;
int i, j;
EBW32 uMax;
pPix = (Type3*)pSrcImage->GetGenericImagePtr(0, 0);
if(bIsOnARow)
{
uNum = nWidth;
if(Type3 is kindof(vector<ebw32>)
pProjection->resize(uNum);
else
pProjection->SetNumElements(uNum);
for(j=0; j<nwidth; j++)
="" {
="" umax="0;
" for(i="0;" i<nheight;="" i++)
="" color="pPix[nOrgX+(nOrgY+i)*nWidth0+j];
" if(bmaxi)
="" if(color=""> uMax)
uMax = color;
}
else
uMax += color;
}
if(bAverage)
(*pProjection)[j]=(Type3)(uMax/nHeight);
else
(*pProjection)[j]=uMax;
}
}
else
{
uNum = nHeight;
if(Type3 is kindof(vector<ebw32>)
pProjection->resize(uNum);
else
pProjection->SetNumElements(uNum);
for(i=0; i<nheight; i++)
="" {
="" umax="0;
" for(j="0;" j<nwidth;="" j++)
="" color="pPix[nOrgX+(nOrgY+i)*nWidth0+j];
" if(bmaxi)
="" if(color=""> uMax)
uMax = color;
}
else
uMax += color;
}
if(bAverage)
(*pProjection)[i]=(Type3)(uMax/nHeight);
else
(*pProjection)[j]=uMax;
}
}
}
|
|
|
|
|
So at compile time you 'know' when what item is being passed to the function? If so it's possible to do it with templates.
Keep all your code (except for the pseudocode ofcourse) and make a few extra template functions that call the proper method.
Using templates will *not* work if your objecttype has to be determined at runtime!
You could make a template function as follows
template <Type2> static HelperFunc(Type2* pProjection,UINT32 uNum)
{
pProjection->SetNumElements(uNum);
}
the above being the generic type.
template <> static HelperFunc(vector* pProjection,UINT32 uNum)
{
pProjection->->resize(uNum);
}
This is the specialization for vectors. Now make a function wrapper for each of the properties that are different and it should work.
|
|
|
|
|
Dear Rutger,
Try your suggestion, got the same error. Seems it's not easy to cheat the compiler.
---------------------------| Error Info |---------------------------
c:\MyClass\MyEx.h(614) : error C2039: 'SetNumElements' : is not a member of 'vector<unsigned int,class std::allocator<unsigned int> >'
c:\MyClass\MyEx.h(649) : see reference to function template instantiation 'int __cdecl HelperFunc(class std::vector<unsigned int,class std::allocator<unsigned int> > *,unsigned int)' being compiled
--------------------------------------------------------------------
Below is the code I used, Maybe you can't point out my errors.
template <class T> static HelperFunc(T* pProjection,UINT32 uNum)
{
pProjection->SetNumElements(uNum);
}
template <class T>static HelperFunc(vector<int>* pProjection, UINT32 uNum)
{
pProjection->->resize(uNum);
}
Inside my template class:
template<class Type1, class Type2, typename Type3> MyFunction(......)
{
...
HelperFunc<Type2>(pProjection, uNum);
...
}
|
|
|
|
|
What's wrong with this?
PostMessage(WM_COMMAND, MAKEWPARAM(IDC_LIST1, LBN_SELCHANGE), (LPARAM) m_hWnd);
error C2064: term does not evaluate to a function
MAKEWPARAM is causing this but I can't see something wrong with it.
Thanks,
Arjan.
|
|
|
|
|
Still don't know why MAKEWPARAM is not working but fixed it
with
WPARAM wParam = (LBN_SELCHANGE << 16) + IDC_LIST1;
PostMessage(WM_COMMAND, wParam, (LPARAM) m_hWnd);
Arjan.
|
|
|
|