Malek103197
asked on
void CCalendar::SetDayFont(LPDISPATCH newValue)
Hi again,
In order for me to understand the use of LPDISPATCH, let's look at the Calendar control.
I've declared:
CCalendar m_calCtrl;
COleFont m_font;
I've got a dialog application and I've inserted the Calendar control. I want the user to change the "Day Font" at run time, let's say setting the font to "italic" (m_font.SetItalic(TRUE)). For this I need to set the properties of the m_font, and then call the function
void CCalendar::SetDayFont(LPDI SPATCH newValue)
{
static BYTE parms[] =
VTS_DISPATCH;
InvokeHelper(0x1, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
newValue);
}
My problem is that I do not know how to pass in for the newValue.
I've tried many things, but still with no luck. Thanks
In order for me to understand the use of LPDISPATCH, let's look at the Calendar control.
I've declared:
CCalendar m_calCtrl;
COleFont m_font;
I've got a dialog application and I've inserted the Calendar control. I want the user to change the "Day Font" at run time, let's say setting the font to "italic" (m_font.SetItalic(TRUE)). For this I need to set the properties of the m_font, and then call the function
void CCalendar::SetDayFont(LPDI
{
static BYTE parms[] =
VTS_DISPATCH;
InvokeHelper(0x1, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms,
newValue);
}
My problem is that I do not know how to pass in for the newValue.
I've tried many things, but still with no luck. Thanks
ASKER
I've tried this already and I get a small message box popping up with a red circle, whitX and an OK button. I press the OK button and the program continues without error.
My code is:
m_font.SetItalic(TRUE);
m_calCtrl.SetDayFont(m_fon t.m_lpDisp atch);
I also tried a m_calCtrl.Refresh();
My code is:
m_font.SetItalic(TRUE);
m_calCtrl.SetDayFont(m_fon
I also tried a m_calCtrl.Refresh();
This should do it for you....
COleFont olefont = m_Calendar.GetDayFont(); // Retrieve the original info...
CString old_name = olefont.GetName();
olefont.SetName("Courier") ;
m_Calendar.SetDayFont(olef ont);
COleFont olefont = m_Calendar.GetDayFont(); // Retrieve the original info...
CString old_name = olefont.GetName();
olefont.SetName("Courier")
m_Calendar.SetDayFont(olef
I think you need to create the font instead of calling SetItalic only. What MT_MU suggests is one of the methods.
It should be very similiar for the Italic (sorry I overlooked that)...
COleFont olefont = m_Calendar.GetDayFont(); // Retrieve the original info...
olefont.SetItalic(TRUE);
m_Calendar.SetDayFont(olef ont);
COleFont olefont = m_Calendar.GetDayFont(); // Retrieve the original info...
olefont.SetItalic(TRUE);
m_Calendar.SetDayFont(olef
ASKER
Adjusted points from 100 to 300
ASKER
Thanks, the following works:
COleFont olefont = m_calCtrl.GetDayFont();
olefont.SetItalic(TRUE);
m_calCtrl.SetDayFont(olefo nt);
The following also works:
COleFont olefont(m_calCtrl.GetDayFo nt());
olefont.SetItalic(TRUE);
m_calCtrl.SetDayFont(olefo nt);
The trick is to find another ActiveX property function that returns a COleFont class. Now I wish to extend this to get the TreeView ActiveX control working, which from my observation, is not that easy. I realize that it would be much simpler to use the CTreeCtrl class, but my reason for pursuing this is in order to use a commercial "GIS Mapping" ActiveX control in my application.
So far, on the TreeView control I've determined that the CTreeView1 has a property which sets the ImageList:
m_treeCtrl.SetImageList(LP DISPATCH newvalue);
So now I have to find a property function that returns an ImageList. But, the only other COleDispatchDriver that comes with the CTreeView1 control is the CPicture. So, I think I must use the CPicture class to load some icons or bitmaps, and then some how add these to an image list, and then set the image list of the m_treeCtrl. I've added the ImageList ActiveX control in order to assist, but now I'm confused on how to proceed.
I beleive this is related:
CPictureHolder pic;
pic.CreateFromIcon(IDI_ICO N1);
pic.CreateFromIcon(IDI_ICO N2);
CPicture picture(pic.GetPictureDisp atch());
I also beleive it is related to CListImage1, CImage & CImages, and also the CPicture.
Since I've found people that have experience using ActiveX controls wiht VC++, I'd like to continue since I've been unable to find much documentation on this subject. Please help, thanks.
COleFont olefont = m_calCtrl.GetDayFont();
olefont.SetItalic(TRUE);
m_calCtrl.SetDayFont(olefo
The following also works:
COleFont olefont(m_calCtrl.GetDayFo
olefont.SetItalic(TRUE);
m_calCtrl.SetDayFont(olefo
The trick is to find another ActiveX property function that returns a COleFont class. Now I wish to extend this to get the TreeView ActiveX control working, which from my observation, is not that easy. I realize that it would be much simpler to use the CTreeCtrl class, but my reason for pursuing this is in order to use a commercial "GIS Mapping" ActiveX control in my application.
So far, on the TreeView control I've determined that the CTreeView1 has a property which sets the ImageList:
m_treeCtrl.SetImageList(LP
So now I have to find a property function that returns an ImageList. But, the only other COleDispatchDriver that comes with the CTreeView1 control is the CPicture. So, I think I must use the CPicture class to load some icons or bitmaps, and then some how add these to an image list, and then set the image list of the m_treeCtrl. I've added the ImageList ActiveX control in order to assist, but now I'm confused on how to proceed.
I beleive this is related:
CPictureHolder pic;
pic.CreateFromIcon(IDI_ICO
pic.CreateFromIcon(IDI_ICO
CPicture picture(pic.GetPictureDisp
I also beleive it is related to CListImage1, CImage & CImages, and also the CPicture.
Since I've found people that have experience using ActiveX controls wiht VC++, I'd like to continue since I've been unable to find much documentation on this subject. Please help, thanks.
Okay - but since this question has been answered - you need to go ahead and award the points. Ask the next question, and I'm sure you will find as much help for it.
Actually the next question is almost trival.
With a TreeView - you simply need to add the following code...
CFont* pFont = m_Tree.GetFont(); // get the current font
LOGFONT logfont;
pFont->GetLogFont(&logfont ); // and it's characteristics - for me this returns lfHeight = -11;
logfont.lfHeight = -14; // set a new height
m_NewFont = new CFont; // create a new font
m_NewFont->CreateFontIndir ect(&logfo nt); // with the appro characteristics
m_Tree.SetFont(m_NewFont); // and tell the list control to use it
I'm naturally assuming that m_Tree is a variable holding the CTreeCtrl, and that the above code will be in OnInitDialog()
One warning - m_NewFont needs to be a member variable - and needs to be deleted when the dialog exits.
With a TreeView - you simply need to add the following code...
CFont* pFont = m_Tree.GetFont(); // get the current font
LOGFONT logfont;
pFont->GetLogFont(&logfont
logfont.lfHeight = -14; // set a new height
m_NewFont = new CFont; // create a new font
m_NewFont->CreateFontIndir
m_Tree.SetFont(m_NewFont);
I'm naturally assuming that m_Tree is a variable holding the CTreeCtrl, and that the above code will be in OnInitDialog()
One warning - m_NewFont needs to be a member variable - and needs to be deleted when the dialog exits.
ASKER
For MT_MU:
OK, I've rejected Chensu's answer and will accept yours.
I'm not interested in setting the Font properties of the TreeView; I agree, it is a straight forward process. My question is about setting the Iamgelist for the TreeView.
OK, I've rejected Chensu's answer and will accept yours.
I'm not interested in setting the Font properties of the TreeView; I agree, it is a straight forward process. My question is about setting the Iamgelist for the TreeView.
ASKER
Oh yes, just a remenider, that I am working with the TreeView ActiveX control, and not the CTreeCtrl class.
Post the question - and I'm sure you will get lots of good answers.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi MT_MU,
Can you assist me on the TreeView ActiveX, I really need to get this stuff in order to work with my GIS Mapping ActiveX. Thanks.
Can you assist me on the TreeView ActiveX, I really need to get this stuff in order to work with my GIS Mapping ActiveX. Thanks.
I'll give it my best shot. FWIW, you can accept comments as an answer.
ASKER
OK, looking forward to your assistance.
m_calCtrl.SetDayFont(m_fon