|
I'm losing all my hair on this one.
In my app, I create a CPrintDialog like this:
CPrintDialog dlg(FALSE);<br />
dlg.DoModal();
which is very basic stuff. Running this, the dialog appears. When I select the printer properties, the app closes itself without a message! So I created a new app with the MFC wizard. In this app, I've put the same code. And guess what: no problems at all. The printer properties are shown without a problem.
To make things worse, I only have this problem in NT SP6. No problem in W2K. Haven't tested this on other windows versions...
In debugging, I get an assertion.
Pressing retry on the assertion:
call stack:
AfxWndProc(HWND__ * 0x0012e870, unsigned int 1240072, unsigned int 1239180, long 1239124) line 365 + 25 bytes<br />
AfxWndProcBase(HWND__ * 0x0012e870, unsigned int 1240072, unsigned int 1239180, long 1239124) line 220 + 21 bytes
function:
<br />
LRESULT CALLBACK<br />
AfxWndProc(HWND hWnd, UINT nMsg, WPARAM wParam, LPARAM lParam)<br />
{<br />
if (nMsg == WM_QUERYAFXWNDPROC)<br />
return 1;<br />
<br />
CWnd* pWnd = CWnd::FromHandlePermanent(hWnd);<br />
ASSERT(pWnd != NULL);
return AfxCallWndProc(pWnd, hWnd, nMsg, wParam, lParam);<br />
}
Any ideas? I'm thinking of some conflicting resources...
New and improved: kwakkelflap.com
|
|
|
|
|
Hi Everyone,
I'm currently embarking on the most exciting, but complex project I've ever attempted. The program is an advanced parametric image generator. In the last version of the program I had a wonderful engine in place, but in the end it got rather tripped by its own complexity, and the overhead involved. So now in this second generation of the program I want to implement a dynamic recompilation engine.
Atm my plugins spit out a whole load of C++ code into a buffer which is then saved, and I'm using the MSVC compiler to compile the code into a dll, which I can then call to perform my image making work. The problem is that any possible speed increases are kind of lost in the time taken to build the dll, and in the wasted cycles from C++'s inherant slowness problems. Also the microsoft license specifically states that bundling their compiler with your product is illegal - I'm not so worried about this because its only a homebrew thing. (Btw I'm only using C++ because I need to comunicate with my C++ objects, I would prefer C in this case of coarse). But the whole system is a little messy.
I would prefer a lighter language such, but it must capable of interfacing with a MSC++ DLL, be reasonably easy to learn, compiling quickly, produce reasonably quick code, and preferably be open source (so I can mod it so that it spits out function ptrs rather than files). I know this is a tall order, and I'm asking if any of you know at all. Am I going about it the right way? would you suggest that I make my own scripting language which cuts and pastes blocks of asembler together? Maybe if anyone has experience in this type of thing...
Any help is much appreciated...
With time we live, with money we spend!
Joel Holdsworth.
|
|
|
|
|
Joel Holdsworth wrote:
in the wasted cycles from C++'s inherant slowness problems
LOL
Are you programming in assembler or just entering binary codes?
You can consider GCC - I think that C++ objects could be made compatible, as long as you don't use multiple inheritance.
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
Isn't GCC only for UNIX? Or is there some way of getting it run well with windows? Does it work with XP?
With time we live, with money we spend!
Joel Holdsworth.
|
|
|
|
|
|
hi
I'm new to C++ and would like to know how to load a file into a buffer. Is it something like
char *buf1 = fopen(??);
though that does not seem to work
thanks
|
|
|
|
|
FILE * pf;
pf = fopen("C:\\File\\Path\\File.extension" , "R" );
if (pf) { // File well opened
// in order to read work on the fread function
}
if u want to use MFC see the CStdioFile or CFile class
Papa
Murex Co.
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
tx for the reply.
pf (file in my case) unfortunately does change, but to 0, so the if function isn't entered. The file does exist, cuase I'm using the following code:
FILE *file;
CFileDialog cf(TRUE);
//Get Filename
if (cf.DoModal() == IDOK)
{
CString m_pathname1 = cf.GetPathName();
file=fopen(m_pathname1,"R");
}
if (file)
{
//does not enter here!!
}
what am I doing wrong?
|
|
|
|
|
tx for the reply
pf (file in my case) unfortunately does change, but to 0, so the if function isn't entered. The file does exist, cuase I'm using the following code:
FILE *file;
CFileDialog cf(TRUE);
//Get Filename
if (cf.DoModal() == IDOK)
{
CString m_pathname1 = cf.GetPathName();
file=fopen(m_pathname1,"R");
}
if (file)
{
//does not enter here!!
}
what am I doing wrong?
|
|
|
|
|
file=fopen(m_pathname1,"r");
with a lowercase 'r'
"640K ought to be enough for anybody."
Bill Gates
|
|
|
|
|
I like to right align tree control. If you know any idea then please tell me. Actually i want to print tree items in Arabic and for this purpose i needed to change the alignment of tree control items. If you know any such sample application or method then please tell me.
|
|
|
|
|
|
Hi,
I want to access member functions of my derived CPropertyPage
Classes from the PropertySheet in a for loop. The problem is that I don't how to get a pointer to the correct PropertyPage Class
I can do it like this
<br />
CParameterList parList;<br />
CMainPage* mainPage = GetPage(0);<br />
parList = mainPage->GetList();<br />
DoStuff();<br />
<br />
CDrivePage* drivePage = GetPage(1);<br />
parList = drivePage->GetList();<br />
DoStuff();<br />
<br />
and more<br />
But it would make more sence if I could do it in a loop
<br />
for (int i = 0 ; i < GetPageCount(); i++)<br />
{<br />
CParameterList parList;<br />
CPropertyPage* page = GetPage(i);
parList = page->GetList();
DoStuff();<br />
}<br />
van Padoea
|
|
|
|
|
1) You can use IsKindOf:
CPropertyPage* page = GetPage(i); <br />
if(page.IsKindOf(RUNTIME_CLASS(CMainPage))) ((CMainPage*)page)->GetList();
2) If you have GetList() methods in all your pages, you can derive your pages from a intermediate class which defines the GetList() method as virtual:
class CListPage:CPropertyPage<br />
{<br />
virtual CParameterList GetList()=0;<br />
...<br />
}<br />
<br />
class CMainPage:CListPage<br />
{<br />
virtual CParameterList GetList(){...}<br />
...<br />
}
Sonork 100.15206;PavelK
|
|
|
|
|
Thank you,
Will try option 2 first.
van Padoea.
If every fool wore a crown, we would all be king - Lard
|
|
|
|
|
Hi, everyone!
Take a look at the following source codes,
--------
#ifdef __cplusplus
extern "C" {
#endif
--------
In my experience, we can use function and variable after
the key word "extern", but what means "C" {
here?
Cheers,
George
|
|
|
|
|
This means that all following exported functions are in C style (and not C++, even if you are coding in C++).
If you declare something as C, you cannot use polymorphy (two functions with same name but different parameters). Every function has a unique name.
Using this declaration, you can use the DLL in Visual Basic or Pascal for example.
Dominik
|
|
|
|
|
Dominik Reichl wrote:
If you declare something as C, you cannot use polymorphy (two functions with same name but different parameters).
Actually, this C++ feature is called 'overloading', not 'polymorphism'
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
Tomasz Sowinski wrote:
Actually, this C++ feature is called 'overloading', not 'polymorphism'
Yeah, but very curiously I have heard quite a few people refer to overloading as a kind of static polymorphism whereas the actual polymorphism is referred to as dynamic polymorphism. I thought it was some kinda Trivandrum thing Anyway since I wasn't sure I decided not to correct them
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Nishant S wrote:
I have heard quite a few people refer to overloading as a kind of static polymorphism
Strange - I don't know where they get this. Can you ask them for reference?
I believe there's a distinction between compile-time polymorphism (templates) and run-time polymorphism (inheritance/virtual functions).
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
Alexandrescu says something of the sort somewhere in his book "Modern C++ Desisgn", if my memory serves me well.
If you think it over, the mechanism by which one or other overload of a given function is selected mimics polymorhpism in which it is the type of the objects involved that drives the selection of the right implementation:
class A{...};
class B:public A{...};
void f(A& a);
A a;
B b;
f(a);
f(b); If now we define an additional overload things change:
class A{...};
class B:public A{...};
void f(A& a);
void f(B& b);
A a;
B b;
f(a);
f(b); IMHO this is a very close compile-time equivalent to virtualness.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
PS: Anyway, I totally agree with you polymorphism is commonly used to refer to the run-time kind.
|
|
|
|
|
You're right. Alexandrescu, "Modern C++ Design", page 264
Tomasz Sowinski -- http://www.shooltz.com
Free your mind and your ass will follow.
|
|
|
|
|
|
Thanks, Dominik pal!
Your reply has resolved all my doubts!
Cheers,
George
|
|
|
|
|
This is used in header files that must be compatible with both C and C++. extern "C" tells the C++ compiler that anything inside the curly braces { } must be treated as C language declarations.
|
|
|
|