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(LPDISPATCH 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
Malek103197Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
MT_MUConnect With a Mentor Commented:
For Malek to accept
0
 
chensuCommented:
COleFont is derived from COleDispatchDriver, which has a member variable m_lpDispatch.

m_calCtrl.SetDayFont(m_font.m_lpDispatch);
0
 
Malek103197Author Commented:
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_font.m_lpDispatch);

I also tried a m_calCtrl.Refresh();
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
MT_MUCommented:
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(olefont);
0
 
chensuCommented:
I think you need to create the font instead of calling SetItalic only. What MT_MU suggests is one of the methods.
0
 
MT_MUCommented:
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(olefont);
0
 
Malek103197Author Commented:
Adjusted points from 100 to 300
0
 
Malek103197Author Commented:
Thanks, the following works:

COleFont olefont = m_calCtrl.GetDayFont();
olefont.SetItalic(TRUE);
m_calCtrl.SetDayFont(olefont);

The following also works:

COleFont olefont(m_calCtrl.GetDayFont());
olefont.SetItalic(TRUE);
m_calCtrl.SetDayFont(olefont);

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(LPDISPATCH 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_ICON1);
pic.CreateFromIcon(IDI_ICON2);
CPicture picture(pic.GetPictureDispatch());

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.

0
 
MT_MUCommented:
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.
0
 
MT_MUCommented:
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->CreateFontIndirect(&logfont); // 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.




0
 
Malek103197Author Commented:
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.
0
 
Malek103197Author Commented:
Oh yes, just a remenider, that I am working with the TreeView ActiveX control, and not the CTreeCtrl class.
0
 
MT_MUCommented:
Post the question - and I'm sure you will get lots of good answers.
0
 
Malek103197Author Commented:
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.
0
 
MT_MUCommented:
I'll give it my best shot.  FWIW, you can accept comments as an answer.
0
 
Malek103197Author Commented:
OK, looking forward to your assistance.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.