Solved

void CCalendar::SetDayFont(LPDISPATCH newValue)

Posted on 2000-04-18
16
748 Views
Last Modified: 2013-11-20
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
0
Comment
Question by:Malek103197
  • 7
  • 7
  • 2
16 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 2728839
COleFont is derived from COleDispatchDriver, which has a member variable m_lpDispatch.

m_calCtrl.SetDayFont(m_font.m_lpDispatch);
0
 

Author Comment

by:Malek103197
ID: 2729371
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
 
LVL 1

Expert Comment

by:MT_MU
ID: 2729448
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
 
LVL 23

Expert Comment

by:chensu
ID: 2729461
I think you need to create the font instead of calling SetItalic only. What MT_MU suggests is one of the methods.
0
 
LVL 1

Expert Comment

by:MT_MU
ID: 2729472
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
 

Author Comment

by:Malek103197
ID: 2732783
Adjusted points from 100 to 300
0
 

Author Comment

by:Malek103197
ID: 2732784
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
 
LVL 1

Expert Comment

by:MT_MU
ID: 2732822
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Expert Comment

by:MT_MU
ID: 2732831
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
 

Author Comment

by:Malek103197
ID: 2732978
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
 

Author Comment

by:Malek103197
ID: 2732982
Oh yes, just a remenider, that I am working with the TreeView ActiveX control, and not the CTreeCtrl class.
0
 
LVL 1

Expert Comment

by:MT_MU
ID: 2732983
Post the question - and I'm sure you will get lots of good answers.
0
 
LVL 1

Accepted Solution

by:
MT_MU earned 300 total points
ID: 2733083
For Malek to accept
0
 

Author Comment

by:Malek103197
ID: 2733112
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
 
LVL 1

Expert Comment

by:MT_MU
ID: 2733118
I'll give it my best shot.  FWIW, you can accept comments as an answer.
0
 

Author Comment

by:Malek103197
ID: 2734783
OK, looking forward to your assistance.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now