|
Good old PostMessage, it helped me out a few times too. Maybe we should send flowers as a thank, or better, post flowers.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
|
|
|
|
|
I seem to have encountered a Debug Assertion failure in AFXWIN2.inl, line 572
The error happens in the following Code:
void CBitmapEdit::PutUpImage()
{
HBITMAP PreEditImage = LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1));
m_EdittingImage.SetBitmap(PreEditImage)
DoModal();
}
.
.
.
.
.
.
void CEditAndCapture::OnEditbmp()
{
CBitmapEdit* EditImage = new CBitmapEdit;
EditImage->PutUpImage();
}
m_EdittingImage is a CStatic object that will contain the Bitmap to display a dialog
CBitmapEdit is a class derived from CDialog that will create a popup modal dialog box
CEditAndCapture is the class that handles the main window and the call to CBitmapEdit is as above.
I kinda suspect is the way I'm calling CBitmapEdit 's methods, am I right?
BTW, Line 572 is :
_AFXWIN_INLINE HBITMAP CStatic::SetBitmap(HBITMAP hBitmap)
{ ASSERT(::IsWindow(m_hWnd)); return (HBITMAP)::SendMessage(m_hWnd, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)hBitmap); }
Can anyone help? Thanks.
Jeffrey
|
|
|
|
|
It looks like you never created the window associated with the CStatic control.
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]
|
|
|
|
|
Ah... I see. Cart before the horse issue...
All because I was doing it in modules and didn't set up everything else yet before testing..
I'll try again...
Thanks
|
|
|
|
|
JJeffrey wrote: All because I was doing it in modules and didn't set up everything else yet before testing..
At least you're doing test. That's a good practice.
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]
|
|
|
|
|
|
Do you mean something like this [^]?
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,
I have template class with the following declaration
template<typename T>
class PrintUserData
{
public:
template<typename T1, typename T2>
bool PrintData (T1 const& t1, T2 const& t2);
};
How do I specialize this class and it's overload members for the following
1. Specialize for class MyClass / class UserClass etc
2. Overload PrintData template member for class TextFormater i.e. T1 = T2 = TextFormater
3. Overload PrintData template member for class RtfFormater/class TextFormater i.e. T1 = RtfFormatter/TextFormatter, T2 can be anything
4. Overload PrintData template member for class RtfFormater/class TextFormater i.e. T2 = RtfFormatter/TextFormatter, T1 can be anything
I find Full Specialization for specific class is easy
e.g.
template<>
class PrintUserData<MyClass>
{
// other member
};
but I am kind of stuck when I tried to oveload the member method
I am trying to get comfortable with C++ Templates so please assist me in obtaining the desired result. If someone feels that the template class declartion needs to be changed to achieve the desired result please let me know. I will change it accordingly
Thanks and Regards
|
|
|
|
|
#include <iostream>
template<typename T>
class PrintUserData
{
public:
template<typename T1, typename T2>
bool PrintData (T1 const& t1, T2 const& t2)
{
std::cout << "Template" << std::endl;
return true;
}
template<class T2>
bool PrintData<int, int>(int const& t1, T2 const& t2)
{
std::cout << "Partially specialised Template" << std::endl;
return true;
}
bool PrintData(float const& t1, float const& t2)
{
std::cout << "Function Overload" << std::endl;
return true;
}
};
struct MyClass {};
template<>
class PrintUserData<MyClass>
{
public:
template<typename T1, typename T2>
bool PrintData (T1 const& t1, T2 const& t2)
{
std::cout << "MyClass specialisation" << std::endl;
return true;
}
};
int main(int, char**)
{
PrintUserData<int> pudInt;
pudInt.PrintData('a', 'a');
const int a = 10;
pudInt.PrintData(a, a);
const float b = 10;
pudInt.PrintData(b, b);
PrintUserData<MyClass> pudMy;
pudMy.PrintData('a', 'a');
}
HTH?
|
|
|
|
|
Hi Stuart,
Thanks for the help. I tried compiling your code with Visual C++ 2005 Professional SP1 compiler and the compiler gave me the following error :- "error C2768: 'PrintUserData<T>::PrintData' : illegal use of explicit template arguments". "See reference to class template instantiation 'PrintUserData<T>'
While the code at (2) compliles properly, the reason could be that the compiler sees t the second
declaration/(definition) as a full specialization of member template function for any class. Please correct me if I am wrong
template<class T2>
bool PrintData<int, int>(int const& t1, T2 const& t2)--------------- (1)
{
std::cout << "Partially specialised Template" << std::endl;
return true;
}
bool PrintData(float const& t1, float const& t2)-------------------- (2)
{
std::cout << "Function Overload" << std::endl;
return true;
}
On the second thoughts I think there could be an issue with the Visaul C++ 2005 SP1 compiler regarding the template specification implementation
Regards
|
|
|
|
|
I compiled it with the VS2008SP1 compiler (that's version 15.00.30729.01 of cl ) - compiled and ran OK But it doesn't compile with gcc 3.4.5
(2) isn't a full specialisation - it's an overload, which is slightly different - it probably alters the relative priority of the overload in partial function ordering.
|
|
|
|
|
Hi Stuart,
Thanks for letting me know that the real issue is with VS2005 SP1 compiler. I will try to get hold of VS 2008 SP1 compiler and try on it.
In last two days I went crazy trying to figure out what is wrong with the declaration/definition, now I know the reason.
Do you think VS2008 SP1 compiler is the most complete one when it comes to templates specification implementation?
And does it supports export keyword for templates?
Thanks and Regards
|
|
|
|
|
psychedelic_fur wrote: Do you think VS2008 SP1 compiler is the most complete one when it comes to templates specification implementation?
It's not far off the top.
psychedelic_fur wrote: And does it supports export keyword for templates?
No - but then, which C++ compiler does
That's a trick question, 'cause here's the answers:
- Comeau C++[^]
- Intel C++ for Linux..but don't know about Windows.
- Possibly Borland C++
|
|
|
|
|
Hi all,
i have created a dialog similar to messagebox can somebody tell me what font should i use to display the message,so that look and feel is same for both .
vikas da
|
|
|
|
|
Simply set "Use System Font" in the dialog editor and the dialog will automatically use the default system font.
|
|
|
|
|
this to be done while creating font object...
vikas da
|
|
|
|
|
Then you should use SystemParametersInfo to retrieve information about the message box font and create a font object based on that. Something like this:
NONCLIENTMETRICS ncm;
ncm.cbSize = sizeof(ncm);
SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0);
HFONT hSystemFont = CreateFontIndirect(&ncm.lfMessageFont);
|
|
|
|
|
Thank you very much for all the help .. but really not using such code to create the fond..
CreateFont(
16,
0,
0,
0,
FW_BOLD,
FALSE,
FALSE,
0,
ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH | FF_SWISS,
"Tahoma"));
and after creating the font am just using this to set for particular dlg item..
please let me know how can i use this ..
vikas da
|
|
|
|
|
You have to make your mind up... do you want to use the system's message font, or Tahoma?
As previously shown to you, get the NONCLIENTMETRICS structure, contaming lfMessageFont .
Then create a font with it.
CMyDialog dlg (blah);
dlg.m_MyFont.CreateFontIndirect (&ncm.lfMessageFont);
and use it to set your control's font...
BOOL CMyDialog::OnInitDialog ()
{
...
GetDlgItem (IDC_MYCONTROL)->SetFont (dlg.m_MyFont);
...
}
Tada!
Iain.
|
|
|
|
|
Dear all
I have two programs:
1. the source code of a dll suppose that a.dll
2. the source code of program which uses a.dll suppose b.exe.
both of them were written in vc6 IDE, and both are operational
now I compile the a.dll in visual C++ 2005.
but when I want to use a.dll with b.exe , when I call GetProcAddress to retrieve the address of functions , Null value is returned.
I dont know how to overcome this problem.
If u have any idea please let me know.
I must say that a.dll should be backward compatible , thus it is not possible to change b.exe program.
Regards
Mahdi
|
|
|
|
|
Gut Mikh Tappe wrote: when I call GetProcAddress to retrieve the address of functions , Null value is returned
Check the below two things.
1) Debug the application and when the GetProcAddress returns NULL, put err,hr in the watch window to find the last error occured.
2)Take the dependecy walker and open the dll. In the export section of the dll, check whether the function is exported or not.
|
|
|
|
|
thank you mr Nave
I found that I didnt export functions of dll.
But i dont know what dependency walker is.
whould you please let me know about it.
I download a tiny software to see the export list of the dll.
Regards
Mahdi
|
|
|
|
|
|
Thank you mr nave
you are my abroad friend.
Hope you to be successfull.
Regards
Mahdi
|
|
|
|
|
Always keep in mind there's nothing to do with which version of the VC compiler was used to make the dll. Always check for the dependency & exported functions ,that's it.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|