|
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.
|
|
|
|
|
You are not including the header file that defines that macro, or have some macros set that excludes the definition of it.
Compiler flag /P is your friend.
|
|
|
|
|
|
I already tried that but it had the same effect
I will check my compiler options now.
|
|
|
|
|
How do i get the size of a button or a static text.
Assuming i have a class that is a subclass or a button/static text.
I can get the size of this control by GetWindowRect let's say in OnPaint();
But the position returned by the GetWindowRect in OnPaint gives the position and size
according to the actual whole screen.
How can i get the position and size relative to the dialog box?
void CMyButton::OnPaint()
{
CPaintDC dc(this); // device context for painting
CRect rect;
GetWindowRect(&rect);
// Do not call CButton::OnPaint() for painting messages
}
CMyButton is a subclass of CButton.
The purpose of this is to create a control that has a size determined by metric like mm rather than pixel. Thus making the control look the same size on all resolution.
Anyone? being looking around for the proper command.
Thanxs a billion in advance
|
|
|
|
|
I must use the GetClientRect() instead GetWindowRect()
Best regards,
Eugene Pustovoyt
|
|
|
|
|
How can i get the position and size relative to the dialog box?
Just offset the rect with the parent windows window rect.
But, if you just want to draw your "window", what's wrong with the client rect???
|
|
|
|