|
|
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.
|
|
|
|
|
Thanks, markkuk, my old friend!
Your reply has resolved all my doubts!
Cheers,
George
|
|
|
|
|
I want to install hook to detect Win32 function called, eg. ::TextOut(). What type of hook I should use?
|
|
|
|
|
|
This one on Codeguru rocks,
And I swallow a small raisin.
|
|
|
|
|
Hello everyone!
My problem is as follows...
I've created a RichEditCtrl which contains text with various font sizes,
formatting and the total number of lines exceedes the visible window.
I want to calculate the number of visible lines that are in it.
I'd appriciate any suggestions....
Thanks
|
|
|
|
|
Issue a resize message to the control like this:
DWORD dwEventMask=m_richedit_ayuda.GetEventMask();
dwEventMask|=ENM_REQUESTRESIZE;
m_richedit.SetEventMask(dwEventMask);
m_richedit.RequestResize(); Then, have EM_REQUESTRESIZE handled: there you are provided with the new size. It is up to you to do the actual resizing or not:
void CYourDlg::OnRichEditRequestResize(NMHDR* pNMHDR, LRESULT* pResult)
{
REQRESIZE *pReqResize = reinterpret_cast<REQRESIZE *>(pNMHDR);
CRect rect(pReqResize->rc);
m_richedit_ayuda.SetWindowPos(NULL,0,0,rect.Width(),rect.Height(),SWP_NOMOVE|SWP_NOZORDER);
*pResult = 0;
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks that was helpful!!
Ioannis Sarris
|
|
|
|
|
Hello,
I'm already programming my parallel port in c++ with inp and outp to control and external device but I would like to programm it in MFC and I'm realy lost...
I need to write data to port 0x378, read and write on port 0x379 and 0x37a (command register)
Anny help will be very apreciate.
Thank's
Yan
Here my email address: yanwxt@hotmail.com
|
|
|
|
|
hi yannick
as per my knowledge
inp and outp routines only work on windows95
anju
|
|
|
|
|
Tool : Vc++ OS : xp
Bios Information - i'm want source code . please
I need Bios Information ( make date )
Go~~
|
|
|
|
|
If you only need general information about the BIOS you can simply read out the following 3 keys of the registry:
The name of the BIOS:
HKEY_LOCAL_MACHINE\\Enum\\Root\\*PNP0C01\\0000\\ "BIOSName"
Version of the BIOS:
HKEY_LOCAL_MACHINE\\Enum\\Root\\*PNP0C01\\0000\\ "BIOSVersion"
Date of the BIOS:
HKEY_LOCAL_MACHINE\\Enum\\Root\\*PNP0C01\\0000\\ "BIOSDate"
Happy coding!
-Dominik
|
|
|
|